Java 类com.intellij.util.text.DateFormatUtil 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:HybrisProjectManagerListener.java   
private void showDiscountOffer(final Project project) {
    final PropertiesComponent properties = PropertiesComponent.getInstance();
    final long lastNotificationTime = properties.getOrInitLong(LAST_DISCOUNT_OFFER_TIME_PROPERTY, 0);
    final long currentTime = System.currentTimeMillis();

    if (currentTime - lastNotificationTime >= DateFormatUtil.MONTH) {
        properties.setValue(LAST_DISCOUNT_OFFER_TIME_PROPERTY, String.valueOf(currentTime));

        final Notification notification = notificationGroup.createNotification(
            HybrisI18NBundleUtils.message("evaluation.license.discount.offer.bubble.title"),
            HybrisI18NBundleUtils.message("evaluation.license.discount.offer.bubble.text"),
            NotificationType.INFORMATION,
            (myNotification, myHyperlinkEvent) -> goToDiscountOffer(myHyperlinkEvent)
        );
        notification.setImportant(true);
        Notifications.Bus.notify(notification, project);

        ApplicationManager.getApplication().invokeLater(() -> {
            if (!notificationClosingAlarm.isDisposed()) {
                notificationClosingAlarm.addRequest(notification::hideBalloon, 3000);
            }
        });

    }
}
项目:intellij-ce-playground    文件:VcsLogGraphTable.java   
private void setColumnPreferredSize() {
  for (int i = 0; i < getColumnCount(); i++) {
    TableColumn column = getColumnModel().getColumn(i);
    if (i == GraphTableModel.ROOT_COLUMN) { // thin stripe, or root name, or nothing
      setRootColumnSize(column);
    }
    else if (i == GraphTableModel.COMMIT_COLUMN) { // let commit message occupy as much as possible
      column.setPreferredWidth(Short.MAX_VALUE);
    }
    else if (i == GraphTableModel.AUTHOR_COLUMN) { // detect author with the longest name
      // to avoid querying the last row (it would lead to full graph loading)
      int maxRowsToCheck = Math.min(MAX_ROWS_TO_CALC_WIDTH, getRowCount() - MAX_ROWS_TO_CALC_OFFSET);
      if (maxRowsToCheck < 0) { // but if the log is small, check all of them
        maxRowsToCheck = getRowCount();
      }
      int contentWidth = calcMaxContentColumnWidth(i, maxRowsToCheck);
      column.setMinWidth(Math.min(contentWidth, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH));
      column.setWidth(column.getMinWidth());
    }
    else if (i == GraphTableModel.DATE_COLUMN) { // all dates have nearly equal sizes
      Font tableFont = UIManager.getFont("Table.font");
      column.setMinWidth(getFontMetrics(tableFont).stringWidth("mm" + DateFormatUtil.formatDateTime(new Date())));
      column.setWidth(column.getMinWidth());
    }
  }
}
项目:intellij-ce-playground    文件:DateFilterPopupComponent.java   
@NotNull
@Override
protected String getText(@NotNull VcsLogDateFilter filter) {
  Date after = filter.getAfter();
  Date before = filter.getBefore();
  if (after != null && before != null) {
    return DateFormatUtil.formatDate(after) + "-" + DateFormatUtil.formatDate(before);
  }
  else if (after != null) {
    return "Since " + DateFormatUtil.formatDate(after);
  }
  else if (before != null) {
    return "Until " + DateFormatUtil.formatDate(before);
  }
  else {
    return ALL;
  }
}
项目:intellij-ce-playground    文件:DateFilterPopupComponent.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final DateFilterComponent dateComponent = new DateFilterComponent(false, DateFormatUtil.getDateFormat().getDelegate());
  VcsLogDateFilter currentFilter = myFilterModel.getFilter();
  if (currentFilter != null) {
    if (currentFilter.getBefore() != null) {
      dateComponent.setBefore(currentFilter.getBefore().getTime());
    }
    if (currentFilter.getAfter() != null) {
      dateComponent.setAfter(currentFilter.getAfter().getTime());
    }
  }

  DialogBuilder db = new DialogBuilder(DateFilterPopupComponent.this);
  db.addOkAction();
  db.setCenterPanel(dateComponent.getPanel());
  db.setPreferredFocusComponent(dateComponent.getPanel());
  db.setTitle("Select Period");
  if (DialogWrapper.OK_EXIT_CODE == db.show()) {
    long after = dateComponent.getAfter();
    long before = dateComponent.getBefore();
    VcsLogDateFilter filter = new VcsLogDateFilterImpl(after > 0 ? new Date(after) : null, before > 0 ? new Date(before) : null);
    myFilterModel.setFilter(filter);
  }
}
项目:intellij-ce-playground    文件:SMTestRunnerResultsForm.java   
/**
 * Returns root node, fake parent suite for all tests and suites
 *
 * @param testsRoot
 * @return
 */
public void onTestingStarted(@NotNull SMTestProxy.SMRootTestProxy testsRoot) {
  myAnimator.setCurrentTestCase(myTestsRootNode);
  myTreeBuilder.updateFromRoot();

  // Status line
  myStatusLine.setStatusColor(ColorProgressBar.GREEN);

  // Tests tree
  selectAndNotify(myTestsRootNode);

  myStartTime = System.currentTimeMillis();
  boolean printTestingStartedTime = true;
  if (myProperties instanceof SMTRunnerConsoleProperties) {
    printTestingStartedTime = ((SMTRunnerConsoleProperties)myProperties).isPrintTestingStartedTime();
  }
  if (printTestingStartedTime) {
    myTestsRootNode.addSystemOutput("Testing started at " + DateFormatUtil.formatTime(myStartTime) + " ...\n");
  }

  updateStatusLabel(false);

  // TODO : show info - "Loading..." msg

  fireOnTestingStarted();
}
项目:intellij-ce-playground    文件:FileHistoryDialogTest.java   
public void testTitles() throws IOException {
  long leftTime = new Date(2001 - 1900, 1, 3, 12, 0).getTime();
  long rightTime = new Date(2002 - 1900, 2, 4, 14, 0).getTime();

  VirtualFile f = myRoot.createChildData(null, "old.txt");
  f.setBinaryContent("old".getBytes(), -1, leftTime);

  f.rename(null, "new.txt");
  f.setBinaryContent("new".getBytes(), -1, rightTime);

  f.setBinaryContent(new byte[0]); // to create current content to skip.

  FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 2);
  assertEquals(FileUtil.toSystemDependentName(f.getPath()), m.getDifferenceModel().getTitle());

  assertEquals(DateFormatUtil.formatPrettyDateTime(leftTime) + " - old.txt",
               m.getDifferenceModel().getLeftTitle(new NullRevisionsProgress()));
  assertEquals(DateFormatUtil.formatPrettyDateTime(rightTime) + " - new.txt",
               m.getDifferenceModel().getRightTitle(new NullRevisionsProgress()));
}
项目:intellij-ce-playground    文件:ExistingTemplatesComponent.java   
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean focus) {
  if (!(value instanceof Configuration)) {
    return;
  }
  final Configuration configuration = (Configuration)value;
  final Color background = (selected && !focus) ?
                           UIUtil.getListUnfocusedSelectionBackground() : UIUtil.getListBackground(selected);
  final Color foreground = UIUtil.getListForeground(selected);
  setPaintFocusBorder(false);
  SearchUtil.appendFragments(mySpeedSearch.getEnteredPrefix(), configuration.getName(), SimpleTextAttributes.STYLE_PLAIN,
                             foreground, background, this);
  final long created = configuration.getCreated();
  if (created > 0) {
    final String createdString = DateFormatUtil.formatPrettyDateTime(created);
    append(" (" + createdString + ')',
           selected ? new SimpleTextAttributes(Font.PLAIN, foreground) : SimpleTextAttributes.GRAYED_ATTRIBUTES);
  }
}
项目:intellij-ce-playground    文件:CurrentDateMacro.java   
static String formatUserDefined(Expression[] params, ExpressionContext context, boolean date) {
  long time = Clock.getTime();
  if (params.length == 1) {
    Result format = params[0].calculateResult(context);
    if (format != null) {
      String pattern = format.toString();
      try {
        return new SimpleDateFormat(pattern).format(new Date(time));
      }
      catch (Exception e) {
        return "Problem when formatting date/time for pattern \"" + pattern + "\": " + e.getMessage();
      }
    }
  }
  return date ? DateFormatUtil.formatDate(time) : DateFormatUtil.formatTime(time);
}
项目:intellij-ce-playground    文件:GithubComment.java   
public void appendTo(StringBuilder builder) {
  builder.append("<hr>");
  builder.append("<table>");
  builder.append("<tr><td>");
  if (myAvatarUrl != null) {
    builder.append("<img src=\"").append(myAvatarUrl).append("\" height=\"40\" width=\"40\"/><br>");
  }
  builder.append("</td><td>");
  if (getAuthor() != null) {
    builder.append("<b>Author:</b> <a href=\"").append(myUserHtmlUrl).append("\">").append(getAuthor()).append("</a><br>");
  }
  if (getDate() != null) {
    builder.append("<b>Date:</b> ").append(DateFormatUtil.formatDateTime(getDate())).append("<br>");
  }
  builder.append("</td></tr></table>");

  builder.append(getText()).append("<br>");
}
项目:intellij-ce-playground    文件:MavenRepositoriesConfigurable.java   
public Object getValueAt(int rowIndex, int columnIndex) {
  MavenIndex i = getIndex(rowIndex);
  switch (columnIndex) {
    case 0:
      return i.getRepositoryPathOrUrl();
    case 1:
      if (i.getKind() == MavenIndex.Kind.LOCAL) return "Local";
      return "Remote";
    case 2:
      if (i.getFailureMessage() != null) {
        return IndicesBundle.message("maven.index.updated.error");
      }
      long timestamp = i.getUpdateTimestamp();
      if (timestamp == -1) return IndicesBundle.message("maven.index.updated.never");
      return DateFormatUtil.formatDate(timestamp);
    case 3:
      return myManager.getUpdatingState(i);
  }
  throw new RuntimeException();
}
项目:intellij-ce-playground    文件:AntBuildMessageView.java   
private String getFinishStatusText(boolean isAborted, long buildTimeInMilliseconds) {
  final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime());
  final String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000);
  if (isAborted) {
    return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString);
  }
  final int errors = getErrorCount();
  final int warnings = getWarningCount();
  if (errors == 0 && warnings == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString);
  }
  if (errors == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString);
  }
  return AntBundle.message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString);
}
项目:intellij-ce-playground    文件:GitPreservingProcess.java   
public GitPreservingProcess(@NotNull Project project,
                            @NotNull GitPlatformFacade facade,
                            @NotNull Git git,
                            @NotNull Collection<VirtualFile> rootsToSave,
                            @NotNull String operationTitle,
                            @NotNull String destinationName,
                            @NotNull GitVcsSettings.UpdateChangesPolicy saveMethod,
                            @NotNull ProgressIndicator indicator,
                            @NotNull Runnable operation) {
  myProject = project;
  myFacade = facade;
  myGit = git;
  myRootsToSave = rootsToSave;
  myOperationTitle = operationTitle;
  myDestinationName = destinationName;
  myProgressIndicator = indicator;
  myOperation = operation;
  myStashMessage = String.format("Uncommitted changes before %s at %s", StringUtil.capitalize(myOperationTitle),
                                 DateFormatUtil.formatDateTime(Clock.getTime()));
  mySaver = configureSaver(saveMethod);
}
项目:intellij-ce-playground    文件:HgAnnotateCommand.java   
private static List<HgAnnotationLine> parse(List<String> outputLines) {
  List<HgAnnotationLine> annotations = new ArrayList<HgAnnotationLine>(outputLines.size());
  for (String line : outputLines) {
    Matcher matcher = LINE_PATTERN.matcher(line);
    if (matcher.matches()) {
      String user = matcher.group(USER_GROUP).trim();
      HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP));
      String dateGroup = matcher.group(DATE_GROUP).trim();
      SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
      String date = "";
      try {
        date = DateFormatUtil.formatPrettyDate(dateFormat.parse(dateGroup));
      }
      catch (ParseException e) {
        LOG.error("Couldn't parse annotation date ", e);
      }
      Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP));
      String content = matcher.group(CONTENT_GROUP);
      HgAnnotationLine annotationLine = new HgAnnotationLine(
        user, rev, date, lineNumber, content
      );
      annotations.add(annotationLine);
    }
  }
  return annotations;
}
项目:intellij-ce-playground    文件:SelectBranchPopup.java   
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  if (isSelected || cellHasFocus) {
    setBackground(UIUtil.getListSelectionBackground());
    final Color selectedForegroundColor = UIUtil.getListSelectionForeground();
    myUrlLabel.setForeground(selectedForegroundColor);
    myDateLabel.setForeground(selectedForegroundColor);
    setForeground(selectedForegroundColor);
  }
  else {
    setBackground(UIUtil.getListBackground());
    final Color foregroundColor = UIUtil.getListForeground();
    myUrlLabel.setForeground(foregroundColor);
    myDateLabel.setForeground(UIUtil.getInactiveTextColor());
    setForeground(foregroundColor);
  }
  if (value instanceof String) {
    myUrlLabel.setText((String) value);
    myDateLabel.setText("");
  } else {
    SvnBranchItem item = (SvnBranchItem) value;
    myUrlLabel.setText(SVNPathUtil.tail(item.getUrl()));
    final long creationMillis = item.getCreationDateMillis();
    myDateLabel.setText((creationMillis > 0) ? DateFormatUtil.formatDate(creationMillis) : "");
  }
  return this;
}
项目:tools-idea    文件:SMTestRunnerResultsForm.java   
/**
 * Returns root node, fake parent suite for all tests and suites
 *
 * @param testsRoot
 * @return
 */
public void onTestingStarted(@NotNull SMTestProxy.SMRootTestProxy testsRoot) {
  myAnimator.setCurrentTestCase(myTestsRootNode);

  // Status line
  myStatusLine.setStatusColor(ColorProgressBar.GREEN);

  // Tests tree
  selectAndNotify(myTestsRootNode);

  myStartTime = System.currentTimeMillis();
  myTestsRootNode.addSystemOutput("Testing started at "
                                  + DateFormatUtil.formatTime(myStartTime)
                                  + " ...\n");

  updateStatusLabel(false);

  // TODO : show info - "Loading..." msg

  fireOnTestingStarted();
}
项目:tools-idea    文件:FileHistoryDialogTest.java   
public void testTitles() throws IOException {
  long leftTime = new Date(2001 - 1900, 1, 3, 12, 0).getTime();
  long rightTime = new Date(2002 - 1900, 2, 4, 14, 0).getTime();

  VirtualFile f = myRoot.createChildData(null, "old.txt");
  f.setBinaryContent("old".getBytes(), -1, leftTime);

  f.rename(null, "new.txt");
  f.setBinaryContent("new".getBytes(), -1, rightTime);

  f.setBinaryContent(new byte[0]); // to create current content to skip.

  FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 2);
  assertEquals(FileUtil.toSystemDependentName(f.getPath()), m.getDifferenceModel().getTitle());

  assertEquals(DateFormatUtil.formatPrettyDateTime(leftTime) + " - old.txt",
               m.getDifferenceModel().getLeftTitle(new NullRevisionsProgress()));
  assertEquals(DateFormatUtil.formatPrettyDateTime(rightTime) + " - new.txt",
               m.getDifferenceModel().getRightTitle(new NullRevisionsProgress()));
}
项目:tools-idea    文件:CurrentDateMacro.java   
static String formatUserDefined(Expression[] params, ExpressionContext context, boolean date) {
  long time = Clock.getTime();
  if (params.length == 1) {
    Result format = params[0].calculateResult(context);
    if (format != null) {
      String pattern = format.toString();
      try {
        return new SimpleDateFormat(pattern).format(new Date(time));
      }
      catch (Exception e) {
        return "Problem when formatting date/time for pattern \"" + pattern + "\": " + e.getMessage();
      }
    }
  }
  return date ? DateFormatUtil.formatDate(time) : DateFormatUtil.formatTime(time);
}
项目:tools-idea    文件:GithubComment.java   
public void appendTo(StringBuilder builder) {
  builder.append("<hr>");
  builder.append("<table>");
  builder.append("<tr><td>");
  if (myGravatarId != null) {
      builder.append("<img src=\"").append("http://www.gravatar.com/avatar/").append(myGravatarId).append("?s=40\"/><br>");
    }
  builder.append("</td><td>");
  if (getAuthor() != null) {
    builder.append("<b>Author:</b> <a href=\"").append(myUserHtmlUrl).append("\">").append(getAuthor()).append("</a><br>");
  }
  if (getDate() != null) {
    builder.append("<b>Date:</b> ").append(DateFormatUtil.formatDateTime(getDate())).append("<br>");
  }
  builder.append("</td></tr></table>");

  builder.append(getText()).append("<br>");
}
项目:tools-idea    文件:MavenRepositoriesConfigurable.java   
public Object getValueAt(int rowIndex, int columnIndex) {
  MavenIndex i = getIndex(rowIndex);
  switch (columnIndex) {
    case 0:
      return i.getRepositoryPathOrUrl();
    case 1:
      if (i.getKind() == MavenIndex.Kind.LOCAL) return "Local";
      return "Remote";
    case 2:
      if (i.getFailureMessage() != null) {
        return IndicesBundle.message("maven.index.updated.error");
      }
      long timestamp = i.getUpdateTimestamp();
      if (timestamp == -1) return IndicesBundle.message("maven.index.updated.never");
      return DateFormatUtil.formatDate(timestamp);
    case 3:
      return myManager.getUpdatingState(i);
  }
  throw new RuntimeException();
}
项目:tools-idea    文件:AntBuildMessageView.java   
public String getFinishStatusText(boolean isAborted, long buildTimeInMilliseconds) {
  int errors = getErrorCount();
  int warnings = getWarningCount();
  final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime());

  String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000);

  if (isAborted) {
    return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString);
  }
  else if (errors == 0 && warnings == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString);
  }
  else if (errors == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString);
  }
  else {
    return AntBundle
      .message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString);
  }
}
项目:tools-idea    文件:HgAnnotateCommand.java   
private static List<HgAnnotationLine> parse(List<String> outputLines) {
  List<HgAnnotationLine> annotations = new ArrayList<HgAnnotationLine>(outputLines.size());
  for (String line : outputLines) {
    Matcher matcher = LINE_PATTERN.matcher(line);
    if (matcher.matches()) {
      String user = matcher.group(USER_GROUP);
      HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP));
      String dateGroup = matcher.group(DATE_GROUP).trim();
      SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
      String date = "";
      try {
        date = DateFormatUtil.formatPrettyDate(dateFormat.parse(dateGroup));
      }
      catch (ParseException e) {
        LOG.error("Couldn't parse annotation date ", e);
      }
      Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP));
      String content = matcher.group(CONTENT_GROUP);
      HgAnnotationLine annotationLine = new HgAnnotationLine(
        user, rev, date, lineNumber, content
      );
      annotations.add(annotationLine);
    }
  }
  return annotations;
}
项目:tools-idea    文件:SelectBranchPopup.java   
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  if (isSelected || cellHasFocus) {
    setBackground(UIUtil.getListSelectionBackground());
    final Color selectedForegroundColor = UIUtil.getListSelectionForeground();
    myUrlLabel.setForeground(selectedForegroundColor);
    myDateLabel.setForeground(selectedForegroundColor);
    setForeground(selectedForegroundColor);
  }
  else {
    setBackground(UIUtil.getListBackground());
    final Color foregroundColor = UIUtil.getListForeground();
    myUrlLabel.setForeground(foregroundColor);
    myDateLabel.setForeground(UIUtil.getInactiveTextColor());
    setForeground(foregroundColor);
  }
  if (value instanceof String) {
    myUrlLabel.setText((String) value);
    myDateLabel.setText("");
  } else {
    SvnBranchItem item = (SvnBranchItem) value;
    myUrlLabel.setText(SVNPathUtil.tail(item.getUrl()));
    final long creationMillis = item.getCreationDateMillis();
    myDateLabel.setText((creationMillis > 0) ? DateFormatUtil.formatDate(creationMillis) : "");
  }
  return this;
}
项目:consulo-apache-ant    文件:AntBuildMessageView.java   
public String getFinishStatusText(boolean isAborted, long buildTimeInMilliseconds) {
  int errors = getErrorCount();
  int warnings = getWarningCount();
  final String theDateAsString = DateFormatUtil.formatDateTime(Clock.getTime());

  String formattedBuildTime = formatBuildTime(buildTimeInMilliseconds / 1000);

  if (isAborted) {
    return AntBundle.message("build.finished.status.ant.build.aborted", formattedBuildTime, theDateAsString);
  }
  else if (errors == 0 && warnings == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.successfully", formattedBuildTime, theDateAsString);
  }
  else if (errors == 0) {
    return AntBundle.message("build.finished.status.ant.build.completed.with.warnings", warnings, formattedBuildTime, theDateAsString);
  }
  else {
    return AntBundle
      .message("build.finished.status.ant.build.completed.with.errors.warnings", errors, warnings, formattedBuildTime, theDateAsString);
  }
}
项目:consulo    文件:DateFilterPopupComponent.java   
@Nonnull
@Override
protected String getText(@Nonnull VcsLogDateFilter filter) {
  Date after = filter.getAfter();
  Date before = filter.getBefore();
  if (after != null && before != null) {
    return DateFormatUtil.formatDate(after) + "-" + DateFormatUtil.formatDate(before);
  }
  else if (after != null) {
    return "Since " + DateFormatUtil.formatDate(after);
  }
  else if (before != null) {
    return "Until " + DateFormatUtil.formatDate(before);
  }
  else {
    return ALL;
  }
}
项目:consulo    文件:DateFilterPopupComponent.java   
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final DateFilterComponent dateComponent = new DateFilterComponent(false, DateFormatUtil.getDateFormat().getDelegate());
  VcsLogDateFilter currentFilter = myFilterModel.getFilter();
  if (currentFilter != null) {
    if (currentFilter.getBefore() != null) {
      dateComponent.setBefore(currentFilter.getBefore().getTime());
    }
    if (currentFilter.getAfter() != null) {
      dateComponent.setAfter(currentFilter.getAfter().getTime());
    }
  }

  DialogBuilder db = new DialogBuilder(DateFilterPopupComponent.this);
  db.addOkAction();
  db.setCenterPanel(dateComponent.getPanel());
  db.setPreferredFocusComponent(dateComponent.getPanel());
  db.setTitle("Select Period");
  if (DialogWrapper.OK_EXIT_CODE == db.show()) {
    long after = dateComponent.getAfter();
    long before = dateComponent.getBefore();
    VcsLogDateFilter filter = new VcsLogDateFilterImpl(after > 0 ? new Date(after) : null, before > 0 ? new Date(before) : null);
    myFilterModel.setFilter(filter);
  }
}
项目:consulo    文件:FileHistoryDialogTest.java   
public void testTitles() throws IOException {
  long leftTime = new Date(2001 - 1900, 1, 3, 12, 0).getTime();
  long rightTime = new Date(2002 - 1900, 2, 4, 14, 0).getTime();

  VirtualFile f = myRoot.createChildData(null, "old.txt");
  f.setBinaryContent("old".getBytes(), -1, leftTime);

  f.rename(null, "new.txt");
  f.setBinaryContent("new".getBytes(), -1, rightTime);

  f.setBinaryContent(new byte[0]); // to create current content to skip.

  FileHistoryDialogModel m = createFileModelAndSelectRevisions(f, 0, 2);
  assertEquals(FileUtil.toSystemDependentName(f.getPath()), m.getDifferenceModel().getTitle());

  assertEquals(DateFormatUtil.formatPrettyDateTime(leftTime) + " - old.txt",
               m.getDifferenceModel().getLeftTitle(new NullRevisionsProgress()));
  assertEquals(DateFormatUtil.formatPrettyDateTime(rightTime) + " - new.txt",
               m.getDifferenceModel().getRightTitle(new NullRevisionsProgress()));
}
项目:consulo    文件:FileHistoryPanelImpl.java   
@Nonnull
public static String getPresentableText(@Nonnull VcsFileRevision revision, boolean withMessage) {
  // implementation reflected by com.intellij.vcs.log.ui.frame.VcsLogGraphTable.getPresentableText()
  StringBuilder sb = new StringBuilder();
  sb.append(FileHistoryPanelImpl.RevisionColumnInfo.toString(revision, true)).append(" ");
  sb.append(revision.getAuthor());
  long time = revision.getRevisionDate().getTime();
  sb.append(" on ").append(DateFormatUtil.formatDate(time)).append(" at ").append(DateFormatUtil.formatTime(time));
  if (revision instanceof VcsFileRevisionEx) {
    if (!Comparing.equal(revision.getAuthor(), ((VcsFileRevisionEx)revision).getCommitterName())) {
      sb.append(" (committed by ").append(((VcsFileRevisionEx)revision).getCommitterName()).append(")");
    }
  }
  if (withMessage) {
    sb.append(" ").append(MessageColumnInfo.getSubject(revision));
  }
  return sb.toString();
}
项目:consulo    文件:CurrentDateMacro.java   
static String formatUserDefined(Expression[] params, ExpressionContext context, boolean date) {
  long time = Clock.getTime();
  if (params.length == 1) {
    Result format = params[0].calculateResult(context);
    if (format != null) {
      String pattern = format.toString();
      try {
        return new SimpleDateFormat(pattern).format(new Date(time));
      }
      catch (Exception e) {
        return "Problem when formatting date/time for pattern \"" + pattern + "\": " + e.getMessage();
      }
    }
  }
  return date ? DateFormatUtil.formatDate(time) : DateFormatUtil.formatTime(time);
}
项目:consulo    文件:TodoCheckinHandler.java   
private void showTodo(TodoCheckinHandlerWorker worker) {
  String title = "For commit (" + DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ")";
  ServiceManager.getService(myProject, TodoView.class).addCustomTodoView(new TodoTreeBuilderFactory() {
    @Override
    public TodoTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, Project project) {
      return new CustomChangelistTodosTreeBuilder(tree, treeModel, myProject, title, worker.inOneList());
    }
  }, title, new TodoPanelSettings(myConfiguration.myTodoPanelSettings));

  ApplicationManager.getApplication().invokeLater(() -> {
    ToolWindowManager manager = ToolWindowManager.getInstance(myProject);
    if (manager != null) {
      ToolWindow window = manager.getToolWindow("TODO");
      if (window != null) {
        window.show(() -> {
          ContentManager cm = window.getContentManager();
          Content[] contents = cm.getContents();
          if (contents.length > 0) {
            cm.setSelectedContent(contents[contents.length - 1], true);
          }
        });
      }
    }
  }, ModalityState.NON_MODAL, myProject.getDisposed());
}
项目:intellij-ce-playground    文件:DefaultJavaProgramRunner.java   
private void showThreadDump(final String out, final List<ThreadState> threadStates) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      AnalyzeStacktraceUtil.addConsole(myProject, threadStates.size() > 1 ?
                                                new ThreadDumpConsoleFactory(myProject, threadStates) : null,
                                       "<Stacktrace> " + DateFormatUtil.formatDateTime(System.currentTimeMillis()), out);
    }
  }, ModalityState.NON_MODAL);
}
项目:intellij-ce-playground    文件:UnusedDeclarationPresentation.java   
private static void commentOutDead(PsiElement psiElement) {
  PsiFile psiFile = psiElement.getContainingFile();

  if (psiFile != null) {
    Document doc = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(psiFile);
    if (doc != null) {
      TextRange textRange = psiElement.getTextRange();
      String date = DateFormatUtil.formatDateTime(new Date());

      int startOffset = textRange.getStartOffset();
      CharSequence chars = doc.getCharsSequence();
      while (CharArrayUtil.regionMatches(chars, startOffset, InspectionsBundle.message("inspection.dead.code.comment"))) {
        int line = doc.getLineNumber(startOffset) + 1;
        if (line < doc.getLineCount()) {
          startOffset = doc.getLineStartOffset(line);
          startOffset = CharArrayUtil.shiftForward(chars, startOffset, " \t");
        }
      }

      int endOffset = textRange.getEndOffset();

      int line1 = doc.getLineNumber(startOffset);
      int line2 = doc.getLineNumber(endOffset - 1);

      if (line1 == line2) {
        doc.insertString(startOffset, InspectionsBundle.message("inspection.dead.code.date.comment", date));
      }
      else {
        for (int i = line1; i <= line2; i++) {
          doc.insertString(doc.getLineStartOffset(i), "//");
        }

        doc.insertString(doc.getLineStartOffset(Math.min(line2 + 1, doc.getLineCount() - 1)),
                         InspectionsBundle.message("inspection.dead.code.stop.comment", date));
        doc.insertString(doc.getLineStartOffset(line1), InspectionsBundle.message("inspection.dead.code.start.comment", date));
      }
    }
  }
}
项目:intellij-ce-playground    文件:BuildManager.java   
@Override
public void run() {
  // todo: make customizable in UI?
  final int unusedThresholdDays = Registry.intValue("compiler.build.data.unused.threshold", -1);
  if (unusedThresholdDays <= 0) {
    return;
  }
  final File buildSystemDir = getBuildSystemDirectory();
  final File[] dirs = buildSystemDir.listFiles(new FileFilter() {
    @Override
    public boolean accept(File pathname) {
      return pathname.isDirectory() && !TEMP_DIR_NAME.equals(pathname.getName());
    }
  });
  if (dirs != null) {
    final Date now = new Date();
    for (File buildDataProjectDir : dirs) {
      final File usageFile = getUsageFile(buildDataProjectDir);
      if (usageFile.exists()) {
        final Pair<Date, File> usageData = readUsageFile(usageFile);
        if (usageData != null) {
          final File projectFile = usageData.second;
          if ((projectFile != null && !projectFile.exists()) || DateFormatUtil.getDifferenceInDays(usageData.first, now) > unusedThresholdDays) {
            LOG.info("Clearing project build data because the project does not exist or was not opened for more than " + unusedThresholdDays + " days: " + buildDataProjectDir.getPath());
            FileUtil.delete(buildDataProjectDir);
          }
        }
      }
      else {
        updateUsageFile(null, buildDataProjectDir); // set usage stamp to start countdown
      }
    }
  }
}
项目:intellij-ce-playground    文件:Reverter.java   
public String getCommandName() {
  Revision to = getTargetRevision();
  String name = to.getChangeSetName();
  String date = DateFormatUtil.formatDateTime(to.getTimestamp());
  if (name != null) {
    return LocalHistoryBundle.message("system.label.revert.to.change.date", name, date);
  }
  else {
    return LocalHistoryBundle.message("system.label.revert.to.date", date);
  }
}
项目:intellij-ce-playground    文件:RecentChangesPopup.java   
public Component getListCellRendererComponent(JList l, Object val, int i, boolean isSelected, boolean cellHasFocus) {
  RecentChange c = (RecentChange)val;
  myActionLabel.setText(c.getChangeName());
  myDateLabel.setText(DateFormatUtil.formatPrettyDateTime(c.getTimestamp()));

  updateColors(isSelected);
  return myPanel;
}
项目:intellij-ce-playground    文件:FileDifferenceModel.java   
private String formatTitle(Entry e, boolean isAvailable) {
  String result = DateFormatUtil.formatPrettyDateTime(e.getTimestamp()) + " - " + e.getName();
  if (!isAvailable) {
    result += " - " + LocalHistoryBundle.message("content.not.available");
  }
  return result;
}
项目:intellij-ce-playground    文件:GraphTableModel.java   
@NotNull
@Override
public final Object getValueAt(int rowIndex, int columnIndex) {
  if (rowIndex >= getRowCount() - 1 && canRequestMore()) {
    requestToLoadMore(EmptyRunnable.INSTANCE);
  }

  VcsShortCommitDetails data = getShortDetails(rowIndex);
  switch (columnIndex) {
    case ROOT_COLUMN:
      return getRoot(rowIndex);
    case COMMIT_COLUMN:
      return getCommitColumnCell(rowIndex, data);
    case AUTHOR_COLUMN:
      if (data == null) {
        return "";
      }
      else {
        String authorString = data.getAuthor().getName();
        if (authorString.isEmpty()) authorString = data.getAuthor().getEmail();
        return authorString + (data.getAuthor().equals(data.getCommitter()) ? "" : "*");
      }
    case DATE_COLUMN:
      if (data == null || data.getAuthorTime() < 0) {
        return "";
      }
      else {
        return DateFormatUtil.formatDateTime(data.getAuthorTime());
      }
    default:
      throw new IllegalArgumentException("columnIndex is " + columnIndex + " > " + (COLUMN_COUNT - 1));
  }
}
项目:intellij-ce-playground    文件:ImportTestsFromHistoryAction.java   
private static String getPresentableText(Project project, String name) {
  String nameWithoutExtension = FileUtil.getNameWithoutExtension(name);
  final int lastIndexOf = nameWithoutExtension.lastIndexOf(" - ");
  if (lastIndexOf > 0) {
    final String date = nameWithoutExtension.substring(lastIndexOf + 3);
    try {
      final Date creationDate = new SimpleDateFormat(SMTestRunnerResultsForm.HISTORY_DATE_FORMAT).parse(date);
      final String configurationName = TestHistoryConfiguration.getInstance(project).getConfigurationName(name);
      return (configurationName != null ? configurationName : nameWithoutExtension.substring(0, lastIndexOf)) + 
             " (" + DateFormatUtil.formatDateTime(creationDate) + ")";
    }
    catch (ParseException ignore) {}
  }
  return nameWithoutExtension;
}
项目:intellij-ce-playground    文件:PluginManagerColumnInfo.java   
public String valueOf(IdeaPluginDescriptor base) {
  if (columnIdx == COLUMN_NAME) {
    return base.getName();
  }
  else if (columnIdx == COLUMN_DOWNLOADS) {
    //  Base class IdeaPluginDescriptor does not declare this field.
    return base.getDownloads();
  }
  if (columnIdx == COLUMN_DATE) {
    //  Base class IdeaPluginDescriptor does not declare this field.
    long date = (base instanceof PluginNode) ? ((PluginNode)base).getDate() : ((IdeaPluginDescriptorImpl)base).getDate();
    if (date != 0) {
      return DateFormatUtil.formatDate(date);
    }
    else {
      return IdeBundle.message("plugin.info.not.available");
    }
  }
  else if (columnIdx == COLUMN_CATEGORY) {
    return base.getCategory();
  }
  else if (columnIdx == COLUMN_RATE) {
    return ((PluginNode)base).getRating();
  }
  else {
    // For COLUMN_STATUS - set of icons show the actual state of installed plugins.
    return "";
  }
}
项目:intellij-ce-playground    文件:PluginManagerColumnInfo.java   
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  Component orig = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
  final Color bg = orig.getBackground();
  final Color grayedFg = isSelected ? orig.getForeground() : Color.GRAY;
  myLabel.setForeground(grayedFg);
  myLabel.setBackground(bg);
  myLabel.setOpaque(true);

  if (column == COLUMN_DATE) {
    long date = myPluginDescriptor.getDate();
    myLabel.setText(date != 0 && date != Long.MAX_VALUE ? DateFormatUtil.formatDate(date) : "n/a");
    myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  } else if (column == COLUMN_DOWNLOADS) {
    String downloads = myPluginDescriptor.getDownloads();
    myLabel.setText(!StringUtil.isEmpty(downloads) ? downloads : "n/a");
    myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  } else if (column == COLUMN_CATEGORY) {
    String category = myPluginDescriptor.getCategory();
    if (StringUtil.isEmpty(category)) {
      category = myPluginDescriptor.getRepositoryName();
    }
    myLabel.setText(!StringUtil.isEmpty(category) ? category : "n/a");
  }
  if (myPluginDescriptor.getStatus() == PluginNode.STATUS_INSTALLED) {
    PluginId pluginId = myPluginDescriptor.getPluginId();
    final boolean hasNewerVersion = ourState.hasNewerVersion(pluginId);
    if (hasNewerVersion) {
      if (!isSelected) myLabel.setBackground(LightColors.BLUE);
    }
  }
  return myLabel;
}
项目:intellij-ce-playground    文件:SelectionReverterTest.java   
public void testChangeSetName() throws IOException {
  long time = new Date(2001, 1, 11, 12, 30).getTime();
  Clock.setTime(time);

  f.setBinaryContent("one".getBytes());
  f.setBinaryContent("two".getBytes());

  revertToPreviousRevision(0, 0);

  List<Revision> rr = getRevisionsFor(f);
  assertEquals(5, rr.size());
  assertEquals("Reverted to " + DateFormatUtil.formatDateTime(time), rr.get(1).getChangeSetName());
}