Java Code Examples for com.intellij.util.text.DateFormatUtil#formatDateTime()

The following examples show how to use com.intellij.util.text.DateFormatUtil#formatDateTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TodoCheckinHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
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, Project project) {
      return new CustomChangelistTodosTreeBuilder(tree, 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());
}
 
Example 2
Source File: ImportTestsFromHistoryAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: Reverter.java    From consulo with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 4
Source File: GraphTableModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@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 new GraphCommitCell(data.getSubject(), getRefsAtRow(rowIndex),
                                 myDataPack.getVisibleGraph().getRowInfo(rowIndex).getPrintElements());
    case AUTHOR_COLUMN:
      String authorString = VcsUserUtil.getShortPresentation(data.getAuthor());
      return authorString + (VcsUserUtil.isSamePerson(data.getAuthor(), data.getCommitter()) ? "" : "*");
    case DATE_COLUMN:
      if (data.getAuthorTime() < 0) {
        return "";
      }
      else {
        return DateFormatUtil.formatDateTime(data.getAuthorTime());
      }
    default:
      throw new IllegalArgumentException("columnIndex is " + columnIndex + " > " + (COLUMN_COUNT - 1));
  }
}
 
Example 5
Source File: DocumentationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private static String generateFileDoc(@Nonnull PsiFile psiFile, boolean withUrl) {
  VirtualFile file = PsiUtilCore.getVirtualFile(psiFile);
  File ioFile = file == null || !file.isInLocalFileSystem() ? null : VfsUtilCore.virtualToIoFile(file);
  BasicFileAttributes attr = null;
  try {
    attr = ioFile == null ? null : Files.readAttributes(Paths.get(ioFile.toURI()), BasicFileAttributes.class);
  }
  catch (Exception ignored) {
  }
  if (attr == null) return null;
  FileType type = file.getFileType();
  String typeName = type == UnknownFileType.INSTANCE ? "Unknown" : type == PlainTextFileType.INSTANCE ? "Text" : type instanceof ArchiveFileType ? "Archive" : type.getId();
  String languageName = type.isBinary() ? "" : psiFile.getLanguage().getDisplayName();
  return (withUrl ? DocumentationMarkup.DEFINITION_START + file.getPresentableUrl() + DocumentationMarkup.DEFINITION_END + DocumentationMarkup.CONTENT_START : "") +
         getVcsStatus(psiFile.getProject(), file) +
         getScope(psiFile.getProject(), file) +
         "<p><span class='grayed'>Size:</span> " +
         StringUtil.formatFileSize(attr.size()) +
         "<p><span class='grayed'>Type:</span> " +
         typeName +
         (type.isBinary() || typeName.equals(languageName) ? "" : " (" + languageName + ")") +
         "<p><span class='grayed'>Modified:</span> " +
         DateFormatUtil.formatDateTime(attr.lastModifiedTime().toMillis()) +
         "<p><span class='grayed'>Created:</span> " +
         DateFormatUtil.formatDateTime(attr.creationTime().toMillis()) +
         (withUrl ? DocumentationMarkup.CONTENT_END : "");
}
 
Example 6
Source File: DirDiffElementImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String getLastModification(DiffElement file) {
  final long timeStamp = file.getTimeStamp();
  return timeStamp < 0 ? "" : DateFormatUtil.formatDateTime(timeStamp);
}