aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2012-07-11 12:59:39 (EDT)
committerMike Rennie2012-07-11 22:29:27 (EDT)
commit1570cacb1959a671ff5b61e43492d7896436f5d6 (patch)
tree6f0550a31e58b53e5f7eafcceae0719d09df2c6c
parent94b0c8b7da7e2ff4d1cfb63e61b50535f7ed3197 (diff)
downloadeclipse.platform.debug-1570cacb1959a671ff5b61e43492d7896436f5d6.zip
eclipse.platform.debug-1570cacb1959a671ff5b61e43492d7896436f5d6.tar.gz
eclipse.platform.debug-1570cacb1959a671ff5b61e43492d7896436f5d6.tar.bz2
Bug 384844 - Add a current time variable and resolver v20120712-022927I20120717-0800
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/DateTimeResolver.java52
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java3
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties3
-rw-r--r--org.eclipse.debug.core/plugin.properties3
-rw-r--r--org.eclipse.debug.core/plugin.xml10
5 files changed, 66 insertions, 5 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/DateTimeResolver.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/DateTimeResolver.java
new file mode 100644
index 0000000..c95bf3f
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/DateTimeResolver.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 EclipseSource Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.core.variables;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IDynamicVariableResolver;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Resolver for the <code>current_date</code> dynamic variable for launch configurations. The optional argument
+ * must be a string pattern for {@link SimpleDateFormat}. Default pattern is <code>yyyyMMdd_HHmm</code>.
+ *
+ * @since 3.8
+ */
+public class DateTimeResolver implements IDynamicVariableResolver {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.variables.IDynamicVariableResolver#resolveValue(org.eclipse.core.variables.IDynamicVariable, java.lang.String)
+ */
+ public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
+ SimpleDateFormat format = null;
+ if (argument != null && argument.trim().length() > 0){
+ try {
+ format = new SimpleDateFormat(argument);
+ } catch (IllegalArgumentException e){
+ DebugPlugin.log(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), NLS.bind(Messages.DateTimeResolver_ProblemWithDateArgument, argument), e));
+ }
+ }
+
+ if (format == null){
+ format = new SimpleDateFormat("yyyyMMdd_HHmm"); //$NON-NLS-1$
+ }
+
+ return format.format(new Date());
+ }
+
+}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
index 739cdb4..5a3c4e0 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.debug.internal.core.variables.Messages"; //$NON-NLS-1$
+ public static String DateTimeResolver_ProblemWithDateArgument;
public static String ResourceResolver_0;
public static String ResourceResolver_1;
public static String ResourceResolver_2;
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
index 9029703..b125733 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2008, 2009 IBM Corporation and others.
+# Copyright (c) 2008, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
+DateTimeResolver_ProblemWithDateArgument=Problem with current_date argument: {0}
ResourceResolver_0=Variable references non-existent resource : {0}
ResourceResolver_1=Variable references empty selection: {0}
ResourceResolver_2=Variable not recognized: {0}
diff --git a/org.eclipse.debug.core/plugin.properties b/org.eclipse.debug.core/plugin.properties
index 62739c1..4cc7b08 100644
--- a/org.eclipse.debug.core/plugin.properties
+++ b/org.eclipse.debug.core/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2012 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -63,6 +63,7 @@ project_name.description=Returns the name of a resource's project. The target re
resource_loc.description=Returns the absolute file system path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
resource_path.description=Returns the workspace relative path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
resource_name.description=Returns the name of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
+current_date.description=Returns the current system time formatted as yyyyMMdd_HHmm. An optional argument can be used to provide alternative formatting. The argument must be valid pattern for java.util.SimpleDateFormat.
LineBreakpoint.name = Line Breakpoint
Breakpoint.name = Breakpoint
diff --git a/org.eclipse.debug.core/plugin.xml b/org.eclipse.debug.core/plugin.xml
index 19ba532..989b29a 100644
--- a/org.eclipse.debug.core/plugin.xml
+++ b/org.eclipse.debug.core/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
- Copyright (c) 2005, 2010 IBM Corporation and others.
+ Copyright (c) 2005, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
@@ -161,7 +161,13 @@
name="container_name"
description="%container_name.description"
resolver="org.eclipse.debug.internal.core.variables.ContainerResolver">
- </variable>
+ </variable>
+ <variable
+ description="%current_date.description"
+ name="current_date"
+ resolver="org.eclipse.debug.internal.core.variables.DateTimeResolver"
+ supportsArgument="true">
+ </variable>
</extension>
<!-- ====================== -->