Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-02-14 21:18:42 +0000
committerPaul Pazderski2020-02-16 22:41:13 +0000
commit296b2b78ef97e1aecb6e46e0eb45e4aed37c0ffb (patch)
tree8c8cca28755f62116b3a9e31d055dd0ef1c48d09 /org.eclipse.debug.ui/ui/org
parent74e688a23653d390662d791d63d879af077a4217 (diff)
downloadeclipse.platform.debug-296b2b78ef97e1aecb6e46e0eb45e4aed37c0ffb.tar.gz
eclipse.platform.debug-296b2b78ef97e1aecb6e46e0eb45e4aed37c0ffb.tar.xz
eclipse.platform.debug-296b2b78ef97e1aecb6e46e0eb45e4aed37c0ffb.zip
Bug 251642 - Store termination timestamp as launch and process attributeI20200217-0600I20200216-1800
Also show termination time in process property dialog and process console label and set launch time as process attribute for external tool launches. Change-Id: I052d280d16d8ad42d70992b0a57324a9ce2e4963 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.ui/ui/org')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java110
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java60
7 files changed, 145 insertions, 40 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
index d1d2216c4..56b7a8b67 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java
@@ -137,6 +137,7 @@ public interface IDebugHelpContextIds {
// Property pages
String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
+ String PROCESS_PAGE_TERMINATE_AT = PREFIX + "process_page_terminate_at_time_widget"; //$NON-NLS-1$
String RUN_DEBUG_RESOURCE_PROPERTY_PAGE = PREFIX + "run_debug_resource_property_page"; //$NON-NLS-1$
// Launch configuration dialog pages
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
index b74176979..14fa191ee 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
@@ -185,6 +185,8 @@ public class DebugPreferencesMessages extends NLS {
public static String ProcessPropertyPage_0;
+ public static String ProcessPropertyPage_10;
+
public static String ProcessPropertyPage_1;
public static String ProcessPropertyPage_2;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
index c4cabbc6c..2a454274d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
@@ -95,6 +95,7 @@ LaunchingPreferencePage_42=Termin&ate and Relaunch while launching (Press 'Shift
ProcessPropertyPage_Command_Line__1=Co&mmand Line:
ProcessPropertyPage_0=Run-&at time:
+ProcessPropertyPage_10=&Terminated-at time:
ProcessPropertyPage_1=&Path:
ProcessPropertyPage_2=Process properties
ProcessPropertyPage_3=No path information available
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
index 2100fdd96..51dc1b90d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Paul Pazderski - Bug 251642: show process termination time
*******************************************************************************/
package org.eclipse.debug.internal.ui.preferences;
@@ -58,12 +59,21 @@ public class ProcessPropertyPage extends PropertyPage {
IProcess proc = getProcess();
- //create the process time section
+ // create the process launch time section
SWTFactory.createLabel(parent, DebugPreferencesMessages.ProcessPropertyPage_0, fHeadingFont, 1);
Text text = SWTFactory.createText(parent, SWT.READ_ONLY, 1);
((GridData)text.getLayoutData()).horizontalIndent = 10;
PlatformUI.getWorkbench().getHelpSystem().setHelp(text, IDebugHelpContextIds.PROCESS_PAGE_RUN_AT);
- text.setText(getTimeText(proc));
+ text.setText(getLaunchTimeText(proc));
+ text.setBackground(parent.getBackground());
+ SWTFactory.createVerticalSpacer(parent, 2);
+
+ // create the process terminate time section
+ SWTFactory.createLabel(parent, DebugPreferencesMessages.ProcessPropertyPage_10, fHeadingFont, 1);
+ text = SWTFactory.createText(parent, SWT.READ_ONLY, 1);
+ ((GridData) text.getLayoutData()).horizontalIndent = 10;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(text, IDebugHelpContextIds.PROCESS_PAGE_TERMINATE_AT);
+ text.setText(getTerminateTimeText(proc));
text.setBackground(parent.getBackground());
SWTFactory.createVerticalSpacer(parent, 2);
@@ -189,6 +199,8 @@ public class ProcessPropertyPage extends PropertyPage {
return tmp;
}
tmp = proc.getLabel();
+ // TODO remove this ugly workaround after removing start time from process label
+ // in jdt
int idx = tmp.lastIndexOf('(');
if(idx < 0) {
idx = tmp.length();
@@ -199,44 +211,70 @@ public class ProcessPropertyPage extends PropertyPage {
}
/**
- * gets the pattern of text from the process label specified by RegEx
- * @param proc the process to compile the RegEx against
- * @param deftext the default text to return if the process is null
- * @param regex the RegEx to match in the process label
- * @return the RegEx matched text or the default supplied text if the process is null
+ * Try to get the launch time for the process.
*
- * @see DebugPlugin#ATTR_RUN_AT_TIME
+ * @param proc the process to get launch time for
+ * @return the launch time or default replacement
* @since 3.2
*/
- private String getTimeText(IProcess proc) {
- String text = DebugPreferencesMessages.ProcessPropertyPage_4;
- if(proc != null) {
- String tmp = proc.getAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP);
- if(tmp != null) {
- //check to see if the date/time is just the raw long (as a string)
- try {
- long l = Long.parseLong(tmp);
- return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(l));
- }
- catch(NumberFormatException nfe) {
- //not a number try to format the string so it always looks the same
- try {
- Date fdate = DateFormat.getInstance().parse(tmp);
- return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(fdate);
- }
- catch(ParseException pe) {
- //couldn't do it, return the raw string
- }
- }
- return tmp;
- }
- Pattern pattern = Pattern.compile("\\(.*\\)"); //$NON-NLS-1$
- Matcher matcher = pattern.matcher(proc.getLabel());
- if(matcher.find()) {
- text = matcher.group(0);
+ private String getLaunchTimeText(IProcess proc) {
+ String text = getTimeFromAttribute(proc, DebugPlugin.ATTR_LAUNCH_TIMESTAMP);
+ if (text != null) {
+ return text;
+ }
+ // TODO remove this parsing when launch time is no fixed part of label anymore
+ Pattern pattern = Pattern.compile("\\(.*\\)"); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher(proc.getLabel());
+ if (matcher.find()) {
+ text = matcher.group(0);
+ }
+ if (text != null) {
+ return text;
+ }
+ return DebugPreferencesMessages.ProcessPropertyPage_4;
+ }
+
+ /**
+ * Try to get the terminate time for the process.
+ *
+ * @param proc the process to get terminate time for
+ * @return the terminate time or default replacement
+ */
+ private String getTerminateTimeText(IProcess proc) {
+ String text = getTimeFromAttribute(proc, DebugPlugin.ATTR_TERMINATE_TIMESTAMP);
+ return text != null ? text : DebugPreferencesMessages.ProcessPropertyPage_4;
+ }
+
+ /**
+ * Try to process launch timestamp attribute.
+ *
+ * @param proc the process to check
+ * @param attr the process attribute to check for timestamp
+ * @return the timestamp string or <code>null</code>
+ * @since 3.2
+ */
+ private String getTimeFromAttribute(IProcess proc, String attr) {
+ if (proc == null || attr == null) {
+ return null;
+ }
+ String time = proc.getAttribute(attr);
+ if (time == null) {
+ return null;
+ }
+ // check to see if the date/time is just the raw long (as a string)
+ try {
+ long l = Long.parseLong(time);
+ return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(l));
+ } catch (NumberFormatException nfe) {
+ // not a number try to format the string so it always looks the same
+ try {
+ Date fdate = DateFormat.getInstance().parse(time);
+ return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(fdate);
+ } catch (ParseException pe) {
+ // couldn't do it, return the raw string
}
}
- return text;
+ return time;
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java
index b88e18a22..67b75c5d8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -30,6 +30,10 @@ public class ConsoleMessages extends NLS {
public static String ProcessConsole_2;
public static String ProcessConsole_3;
+ public static String ProcessConsole_commandLabel_withStart;
+ public static String ProcessConsole_commandLabel_withEnd;
+ public static String ProcessConsole_commandLabel_withStartEnd;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
index d5ad69724..b979431cd 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2014 IBM Corporation and others.
+# Copyright (c) 2000, 2020 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -25,5 +25,8 @@ ProcessConsole_0=<terminated> {0}
ProcessConsole_1=[Console output redirected to file:{0}]\n
ProcessConsole_2=[Invalid file specified for console output: {0}]\n
ProcessConsole_3=[Invalid file specified for stdin file: {0}]\n
+ProcessConsole_commandLabel_withStart={0} ({1})
+ProcessConsole_commandLabel_withEnd={0} (Terminated {1})
+ProcessConsole_commandLabel_withStartEnd={0} ({1} \u2013 {2})
ShowStandardErrorAction_0=Show Console When Standard Error Changes
ShowStandardOutAction_0=Show Console When Standard Out Changes
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
index 6034b3efa..de6f63c70 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
* IBM Corporation - initial API and implementation
* Paul Pazderski - Bug 545769: fixed rare UTF-8 character corruption bug
* Paul Pazderski - Bug 552015: console finished signaled to late if input is connected to file
+ * Paul Pazderski - Bug 251642: add termination time in console label
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.console;
@@ -24,7 +25,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
+import java.text.ParseException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -89,6 +92,7 @@ import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.progress.UIJob;
+import com.ibm.icu.text.DateFormat;
import com.ibm.icu.text.MessageFormat;
@@ -301,7 +305,39 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
buffer.append(type);
buffer.append("] "); //$NON-NLS-1$
}
- buffer.append(process.getLabel());
+
+ String launchTime = formatTimestamp(process.getAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP));
+ String terminateTime = formatTimestamp(process.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP));
+
+ String procLabel = process.getLabel();
+ if (launchTime != null) {
+ // FIXME workaround to remove start time from process label added from jdt for
+ // java launches
+ int idx = procLabel.lastIndexOf('(');
+ if (idx >= 0) {
+ int end = procLabel.lastIndexOf(')');
+ if (end > idx) {
+ String jdtTime = procLabel.substring(idx + 1, end);
+ try {
+ DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).parse(jdtTime);
+ procLabel = procLabel.substring(0, idx);
+ } catch (ParseException pe) {
+ // not a date. Label just contains parentheses
+ }
+ }
+ }
+ }
+
+ if (launchTime != null && terminateTime != null) {
+ buffer.append(MessageFormat.format(ConsoleMessages.ProcessConsole_commandLabel_withStartEnd,
+ procLabel, launchTime, terminateTime));
+ } else if (launchTime != null) {
+ buffer.append(MessageFormat.format(ConsoleMessages.ProcessConsole_commandLabel_withStart,
+ procLabel, launchTime));
+ } else if (terminateTime != null) {
+ buffer.append(MessageFormat.format(ConsoleMessages.ProcessConsole_commandLabel_withEnd,
+ procLabel, terminateTime));
+ }
label = buffer.toString();
}
}
@@ -314,6 +350,26 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe
}
/**
+ * Format timestamp as datetime.
+ *
+ * @param timestamp a timestamp as returned from
+ * {@link System#currentTimeMillis()} or <code>null</code>
+ * @return timestamp formatted as datetime or <code>null</code> if timestamp is
+ * invalid
+ */
+ private static String formatTimestamp(String timestamp) {
+ if (timestamp == null) {
+ return null;
+ }
+ try {
+ long lTimestamp = Long.parseLong(timestamp);
+ return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(lTimestamp));
+ } catch (NumberFormatException ex) {
+ return null;
+ }
+ }
+
+ /**
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
@Override

Back to the top