private boolean setColumnPreferredSize() { boolean sizeCalculated = false; Font tableFont = UIManager.getFont("Table.font"); 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 maxWidth = 0; for (int row = 0; row < maxRowsToCheck; row++) { String value = getModel().getValueAt(row, i).toString(); maxWidth = Math.max(getFontMetrics(tableFont).stringWidth(value), maxWidth); if (!value.isEmpty()) sizeCalculated = true; } column.setMinWidth( Math.min(maxWidth + UIUtil.DEFAULT_HGAP, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); column.setWidth(column.getMinWidth()); } else if (i == GraphTableModel.DATE_COLUMN) { // all dates have nearly equal sizes column.setMinWidth( getFontMetrics(tableFont) .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date()))); column.setWidth(column.getMinWidth()); } } return sizeCalculated; }
/** * 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(); }
private void setColumnPreferredSize() { for (int i = 0; i < getColumnCount(); i++) { TableColumn column = getColumnModel().getColumn(i); if (i == AbstractVcsLogTableModel.ROOT_COLUMN) { // thin stripe or nothing int rootWidth = myUI.getColorManager().isMultipleRoots() ? ROOT_INDICATOR_WIDTH : 0; // NB: all further instructions and their order are important, otherwise the minimum size // which is less than 15 won't be applied column.setMinWidth(rootWidth); column.setMaxWidth(rootWidth); column.setPreferredWidth(rootWidth); } else if (i == AbstractVcsLogTableModel .COMMIT_COLUMN) { // let commit message occupy as much as possible column.setPreferredWidth(Short.MAX_VALUE); } else if (i == AbstractVcsLogTableModel.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 == AbstractVcsLogTableModel.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()); } } }
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); } }
public static void generateStubs(Framework framework, File location) { final StringBuilder builder = new StringBuilder(); builder .append("# This is a machine generated stub for: ") .append(framework.getName()) .append("\n"); builder .append("# Created on: ") .append(DateFormatUtil.formatDateTime(new Date())) .append("\n\n"); for (Class aClass : framework.getClasses()) { generateClassStub(builder, framework, aClass); } for (Function function : framework.getFunctions()) { generateFunctionStub(builder, function, ""); } for (Constant constant : framework.getConstants()) { generateConstantStub(builder, constant); } for (Map.Entry<String, String> entry : framework.getFunctionAliases().entrySet()) { generateAlias(builder, entry); } try { FileUtil.writeToFile(location, builder.toString()); } catch (Throwable ignored) { } }
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); } }
@Override public String getLineText(int line, Editor editor) { LastRevision revision = myRevisions.get(line); if (revision != null) { return String.format( "%" + myMaxDateLength + "s", DateFormatUtil.formatPrettyDate(revision.getDate())) + " " + revision.getAuthor(); } return ""; }
@Override public String getToolTip(int line, Editor editor) { LastRevision revision = myRevisions.get(line); if (revision != null) { return XmlStringUtil.escapeString( revision.getAuthor() + " " + DateFormatUtil.formatDateTime(revision.getDate()) + "\n" + revision.getMessage()); } return null; }
@Override public void setUp() throws Exception { super.setUp(); Random rnd = new Random(); long time = Clock.getTime(); PROJECT_NAME = "new_project_from_" + getTestName(false) + "_" + DateFormatUtil.formatDate(time).replace('/', '-') + "_" + rnd.nextLong(); registerHttpAuthService(); }
protected void showErrors(final CvsHandler handler, final CvsTabbedWindow tabbedWindow) { final List<VcsException> errors = handler.getErrorsExceptAborted(); if (!myShowErrors || myIsQuietOperation) return; if (tabbedWindow == null) { if (errors.isEmpty()) return; final List<String> messages = new ArrayList<String>(); for (VcsException error : errors) { if (!StringUtil.isEmptyOrSpaces(error.getMessage())) { messages.add(error.getMessage()); } } final String errorMessage = StringUtil.join(messages, "\n"); Messages.showErrorDialog(errorMessage, "CVS Error"); return; } if (errors.isEmpty()) { tabbedWindow.hideErrors(); } else { ErrorTreeView errorTreeView = tabbedWindow.getErrorsTreeView(); for (final VcsException exception : errors) { final String groupName = DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ' ' + handler.getTitle(); if (exception.isWarning()) { errorTreeView.addMessage( MessageCategory.WARNING, exception.getMessages(), groupName, DummyNavigatable.INSTANCE, null, null, exception); } else { errorTreeView.addMessage( MessageCategory.ERROR, exception.getMessages(), groupName, DummyNavigatable.INSTANCE, null, null, exception); } } tabbedWindow.ensureVisible(myProject); } }
@CalledInAwt public void updateData(@NotNull Map<Integer, LastRevision> revisions) { myRevisions = revisions; Date newestDate = null; int maxDateLength = 0; for (LastRevision revision : myRevisions.values()) { Date date = revision.getDate(); if (newestDate == null || date.after(newestDate)) { newestDate = date; } int length = DateFormatUtil.formatPrettyDate(date).length(); if (length > maxDateLength) { maxDateLength = length; } } myNewestDate = newestDate; myMaxDateLength = maxDateLength; }
@Override public UpdateInfoTree showUpdateProjectInfo( UpdatedFiles updatedFiles, String displayActionName, ActionInfo actionInfo, boolean canceled) { if (!myProject.isOpen() || myProject.isDisposed()) return null; ContentManager contentManager = getContentManager(); if (contentManager == null) { return null; // content manager is made null during dispose; flag is set later } final UpdateInfoTree updateInfoTree = new UpdateInfoTree(contentManager, myProject, updatedFiles, displayActionName, actionInfo); ContentUtilEx.addTabbedContent( contentManager, updateInfoTree, "Update Info", DateFormatUtil.formatDateTime(System.currentTimeMillis()), true, updateInfoTree); ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.VCS).activate(null); updateInfoTree.expandRootChildren(); return updateInfoTree; }
void doPrintNotification(final Notification notification) { Editor editor = myLogEditor.getValue(); if (editor.isDisposed()) { return; } Document document = editor.getDocument(); boolean scroll = document.getTextLength() == editor.getCaretModel().getOffset() || !editor.getContentComponent().hasFocus(); Long notificationTime = myProjectModel.getNotificationTime(notification); if (notificationTime == null) { return; } String date = DateFormatUtil.formatTimeWithSeconds(notificationTime) + " "; append(document, date); int startLine = document.getLineCount() - 1; EventLog.LogEntry pair = EventLog.formatForLog(notification, StringUtil.repeatSymbol(' ', date.length())); final NotificationType type = notification.getType(); TextAttributesKey key = type == NotificationType.ERROR ? ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY : type == NotificationType.INFORMATION ? ConsoleViewContentType.NORMAL_OUTPUT_KEY : ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY; int msgStart = document.getTextLength(); String message = pair.message; append(document, message); TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key); int layer = HighlighterLayer.CARET_ROW + 1; editor .getMarkupModel() .addRangeHighlighter( msgStart, document.getTextLength(), layer, attributes, HighlighterTargetArea.EXACT_RANGE); for (Pair<TextRange, HyperlinkInfo> link : pair.links) { myHyperlinkSupport .getValue() .addHyperlink( link.first.getStartOffset() + msgStart, link.first.getEndOffset() + msgStart, null, link.second); } append(document, "\n"); if (scroll) { editor.getCaretModel().moveToOffset(document.getTextLength()); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); } if (notification.isImportant()) { highlightNotification(notification, pair.status, startLine, document.getLineCount() - 1); } }
@NotNull private static String formatDateTime(long time) { return " on " + DateFormatUtil.formatDate(time) + " at " + DateFormatUtil.formatTime(time); }
private boolean reorderCommitsIfNeeded(@NotNull final RebaseInfo rebaseInfo) { if (rebaseInfo.reorderedCommits.isEmpty()) { return true; } ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator == null) { progressIndicator = new EmptyProgressIndicator(); } String stashMessage = "Uncommitted changes before rebase operation at " + DateFormatUtil.formatDateTime(Clock.getTime()); final GitChangesSaver saver = rebaseInfo.policy == GitVcsSettings.UpdateChangesPolicy.SHELVE ? new GitShelveChangesSaver(myProject, progressIndicator, stashMessage) : new GitStashChangesSaver(myProject, progressIndicator, stashMessage); final Boolean[] result = new Boolean[1]; result[0] = false; final ProgressIndicator finalProgressIndicator = progressIndicator; GitComplexProcess.Operation reorderOperation = new GitComplexProcess.Operation() { @Override public void run(ContinuationContext context) { try { final Set<VirtualFile> rootsToReorder = rebaseInfo.reorderedCommits.keySet(); saver.saveLocalChanges(rootsToReorder); try { GitRebaser rebaser = new GitRebaser(myProject, finalProgressIndicator); for (Map.Entry<VirtualFile, List<String>> rootToCommits : rebaseInfo.reorderedCommits.entrySet()) { final VirtualFile root = rootToCommits.getKey(); GitBranch b = GitBranch.current(myProject, root); if (b == null) { LOG.info("executeRebase: current branch is null"); continue; } GitBranch t = b.tracked(myProject, root); if (t == null) { LOG.info("executeRebase: tracked branch is null"); continue; } final GitRevisionNumber mergeBase = b.getMergeBase(myProject, root, t); if (mergeBase == null) { LOG.info("executeRebase: merge base is null for " + b + " and " + t); continue; } String parentCommit = mergeBase.getRev(); result[0] = rebaser.reoderCommitsIfNeeded(root, parentCommit, rootToCommits.getValue()); } } catch (VcsException e) { notifyMessage( myProject, "Commits weren't pushed", "Failed to reorder commits", NotificationType.WARNING, true, Collections.singleton(e)); } finally { saver.restoreLocalChanges(context); } } catch (VcsException e) { LOG.info("Couldn't save local changes", e); notifyError( myProject, "Couldn't save local changes", "Tried to save uncommitted changes in " + saver.getSaverName() + " before update, but failed with an error.<br/>" + "Update was cancelled.", true, e); } } }; GitComplexProcess.execute(myProject, "reordering commits", reorderOperation); return result[0]; }
private static String getLastModification(DiffElement file) { final long timeStamp = file.getTimeStamp(); return timeStamp < 0 ? "" : DateFormatUtil.formatDateTime(timeStamp); }
@NotNull public static String getDateString(@NotNull TimedVcsCommit commit) { return DateFormatUtil.formatPrettyDateTime(commit.getTimestamp()) + " "; }