Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -25,6 +25,7 @@
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.PlatformObject;
Expand Down Expand Up @@ -475,7 +476,18 @@ protected void fireChanged() {
* properly created/initialized.
*/
protected void fireTerminate() {
setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, Long.toString(System.currentTimeMillis()));
String timeStamp = Long.toString(System.currentTimeMillis());
setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, timeStamp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I see it right, this would alter config stored on a disk every time it finishes. So all shared and git versioned configs will be automatically dirty after use. I would not do that.

Maybe better to restrict this to "not shared" configs and for shared configs in the workspace use bundle location to manage timestamps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check on this 👍

ILaunchConfiguration launchConfig = getLaunchConfiguration();
if (launchConfig != null) {
try {
Comment on lines +479 to +483
ILaunchConfigurationWorkingCopy launchCopy = getLaunchConfiguration().getWorkingCopy();
launchCopy.setAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, timeStamp);
launchCopy.doSave();
} catch (CoreException e) {
DebugPlugin.log(e);
}
}
Comment on lines +481 to +490
if (!fSuppressChange) {
((LaunchManager)getLaunchManager()).fireUpdate(this, LaunchManager.TERMINATE);
((LaunchManager)getLaunchManager()).fireUpdate(new ILaunch[] {this}, LaunchManager.TERMINATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,12 @@ public class ActionMessages extends NLS {
public static String ExpressionPasteDialog;
public static String ExpressionPasteRemember;
public static String ExpressionPastePromptButton;
public static String LaunchActionToolTip_Seconds;
public static String LaunchActionToolTip_Minutes;
public static String LaunchActionToolTip_OneMinute;
public static String LaunchActionToolTip_OneHour;
public static String LaunchActionToolTip_Hours;
public static String LaunchActionToolTip_OneDay;
public static String LaunchActionToolTip_Days;

}
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,15 @@ ExpressionPasteSingleButton=Single Expression
ExpressionPastePromptButton=Prompt
ExpressionPasteTitle=Paste Multiline Expression
ExpressionPasteDialog=You are pasting a multiline expression. Choose whether to paste it as a single combined expression or as separate multiple expressions.
ExpressionPasteRemember=Remember my preference next time
ExpressionPasteRemember=Remember my preference next time

LaunchActionToolTip_Seconds = a moment ago
LaunchActionToolTip_OneMinute = 1 min ago
LaunchActionToolTip_Minutes = {0} mins ago
LaunchActionToolTip_OneHour = 1 hour ago
LaunchActionToolTip_Hours = {0} hours ago
LaunchActionToolTip_OneDay = 1 day ago
LaunchActionToolTip_Days = {0} days ago



Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -50,6 +50,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
Expand Down Expand Up @@ -353,6 +354,8 @@ protected void fillMenu(Menu menu) {
LaunchAction action= new LaunchAction(launch, getMode());
if (checkIfLaunchActive(launch, launches)) {
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
} else {
addRecentLaunchTimeTooltip(launch, action);
}
addToMenu(menu, action, accelerator);
accelerator++;
Expand All @@ -368,7 +371,10 @@ protected void fillMenu(Menu menu) {
LaunchAction action= new LaunchAction(launch, getMode());
if (checkIfLaunchActive(launch, launches)) {
action.setText(action.getText() + " \u2699"); //$NON-NLS-1$
} else {
addRecentLaunchTimeTooltip(launch, action);
}
addRecentLaunchTimeTooltip(launch, action);
addToMenu(menu, action, accelerator);
Comment on lines +374 to 378
accelerator++;
}
Expand Down Expand Up @@ -627,4 +633,65 @@ private LaunchConfigurationManager getLaunchConfigurationManager() {
protected String getLaunchGroupIdentifier() {
return fLaunchGroup.getIdentifier();
}

/**
* Adds a tooltip showing how long ago the given launch was terminated if
* there's a valid terminate timestamp attribute.
*
* @param launch launch configuration
* @param launchAction launch action to update
*/
private void addRecentLaunchTimeTooltip(ILaunchConfiguration launch, LaunchAction launchAction) {
try {
String timeStamp = launch.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP, ""); //$NON-NLS-1$
if (!timeStamp.isEmpty()) {
long mytime = Long.parseLong(timeStamp);
String g = getRelativeTime(mytime);
launchAction.setToolTipText(g);
}
} catch (CoreException e) {
DebugUIPlugin.log(e);
}
}
Comment on lines +644 to +655

/**
* Returns a human-readable relative time string for the given timestamp.
*
* @param timestamp timestamp in milliseconds since the epoch
* @return relative time string
*/
private String getRelativeTime(long timestamp) {
long diffMillis = System.currentTimeMillis() - timestamp;
long seconds = diffMillis / 1000;
Comment on lines +664 to +665

if (seconds < 60) {
return ActionMessages.LaunchActionToolTip_Seconds;
}

long minutes = seconds / 60;

if (minutes == 1) {
return ActionMessages.LaunchActionToolTip_OneMinute;
}
if (minutes < 60) {
return NLS.bind(ActionMessages.LaunchActionToolTip_Minutes, minutes);
}

long hours = minutes / 60;

if (hours == 1) {
return ActionMessages.LaunchActionToolTip_OneHour;
}
if (hours < 24) {
return NLS.bind(ActionMessages.LaunchActionToolTip_Hours, hours);
}

long days = hours / 24;

if (days == 1) {
return ActionMessages.LaunchActionToolTip_OneDay;
}
return NLS.bind(ActionMessages.LaunchActionToolTip_Days, days);
}

}
Loading