Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 98429 Details for
Bug 75981
[templates][preferences] Allow to specify format of date variable in templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch to add ${day_of_month} and ${month} templates
20080502-bugzilla-75981.patch (text/plain), 10.71 KB, created by
Michael Pellaton
on 2008-05-02 10:49:48 EDT
(
hide
)
Description:
Proposed patch to add ${day_of_month} and ${month} templates
Filename:
MIME Type:
Creator:
Michael Pellaton
Created:
2008-05-02 10:49:48 EDT
Size:
10.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ant.ui >Index: Ant Editor/org/eclipse/ant/internal/ui/editor/templates/BuildFileContextType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/BuildFileContextType.java,v >retrieving revision 1.4 >diff -u -r1.4 BuildFileContextType.java >--- Ant Editor/org/eclipse/ant/internal/ui/editor/templates/BuildFileContextType.java 23 Feb 2005 17:31:02 -0000 1.4 >+++ Ant Editor/org/eclipse/ant/internal/ui/editor/templates/BuildFileContextType.java 2 May 2008 14:37:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -35,6 +35,8 @@ > addResolver(new GlobalTemplateVariables.LineSelection()); > addResolver(new GlobalTemplateVariables.Dollar()); > addResolver(new GlobalTemplateVariables.Date()); >+ addResolver(new GlobalTemplateVariables.DayOfMonth()); >+ addResolver(new GlobalTemplateVariables.Month()); > addResolver(new GlobalTemplateVariables.Year()); > addResolver(new GlobalTemplateVariables.Time()); > addResolver(new GlobalTemplateVariables.User()); >#P org.eclipse.jdt.ui >Index: core extension/org/eclipse/jdt/internal/corext/template/java/AbstractJavaContextType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/AbstractJavaContextType.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractJavaContextType.java >--- core extension/org/eclipse/jdt/internal/corext/template/java/AbstractJavaContextType.java 12 Mar 2008 16:52:54 -0000 1.1 >+++ core extension/org/eclipse/jdt/internal/corext/template/java/AbstractJavaContextType.java 2 May 2008 14:37:43 -0000 >@@ -315,6 +315,8 @@ > addResolver(new GlobalTemplateVariables.LineSelection()); > addResolver(new GlobalTemplateVariables.Dollar()); > addResolver(new GlobalTemplateVariables.Date()); >+ addResolver(new GlobalTemplateVariables.DayOfMonth()); >+ addResolver(new GlobalTemplateVariables.Month()); > addResolver(new GlobalTemplateVariables.Year()); > addResolver(new GlobalTemplateVariables.Time()); > addResolver(new GlobalTemplateVariables.User()); >Index: core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContextType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContextType.java,v >retrieving revision 1.26 >diff -u -r1.26 JavaDocContextType.java >--- core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContextType.java 11 Sep 2007 15:50:56 -0000 1.26 >+++ core extension/org/eclipse/jdt/internal/corext/template/java/JavaDocContextType.java 2 May 2008 14:37:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -38,6 +38,8 @@ > addResolver(new GlobalTemplateVariables.WordSelection()); > addResolver(new GlobalTemplateVariables.Dollar()); > addResolver(new GlobalTemplateVariables.Date()); >+ addResolver(new GlobalTemplateVariables.DayOfMonth()); >+ addResolver(new GlobalTemplateVariables.Month()); > addResolver(new GlobalTemplateVariables.Year()); > addResolver(new GlobalTemplateVariables.Time()); > addResolver(new GlobalTemplateVariables.User()); >Index: core extension/org/eclipse/jdt/internal/corext/template/java/CodeTemplateContextType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CodeTemplateContextType.java,v >retrieving revision 1.37 >diff -u -r1.37 CodeTemplateContextType.java >--- core extension/org/eclipse/jdt/internal/corext/template/java/CodeTemplateContextType.java 14 Nov 2006 10:34:49 -0000 1.37 >+++ core extension/org/eclipse/jdt/internal/corext/template/java/CodeTemplateContextType.java 2 May 2008 14:37:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -166,6 +166,8 @@ > // global > addResolver(new GlobalTemplateVariables.Dollar()); > addResolver(new GlobalTemplateVariables.Date()); >+ addResolver(new GlobalTemplateVariables.DayOfMonth()); >+ addResolver(new GlobalTemplateVariables.Month()); > addResolver(new GlobalTemplateVariables.Year()); > addResolver(new GlobalTemplateVariables.Time()); > addResolver(new GlobalTemplateVariables.User()); >#P org.eclipse.jdt.doc.user >Index: reference/ref-preferences-template-variables.htm >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.doc.user/reference/ref-preferences-template-variables.htm,v >retrieving revision 1.12 >diff -u -r1.12 ref-preferences-template-variables.htm >--- reference/ref-preferences-template-variables.htm 10 Dec 2007 13:13:18 -0000 1.12 >+++ reference/ref-preferences-template-variables.htm 2 May 2008 14:37:44 -0000 >@@ -52,6 +52,10 @@ > <td>Evaluates to the current date.</td> > </tr> > <tr> >+ <td><strong>${day_of_month}</strong></td> >+ <td>Evaluates to the current day of month.</td> >+ </tr> >+ <tr> > <td><strong>${dollar}</strong></td> > <td>Evaluates to the dollar symbol '$'. Alternatively, two dollars can be used: '$$'.</td> > </tr> >@@ -84,6 +88,10 @@ > <td>Evaluates to content of all currently selected lines.</td> > </tr> > <tr> >+ <td><strong>${month}</strong></td> >+ <td>Evaluates to the current month.</td> >+ </tr> >+ <tr> > <td><strong>${primary_type_name}</strong></td> > <td>Evaluates to the name primary type of the current compilation unit.</td> > </tr> >#P org.eclipse.text >Index: src/org/eclipse/jface/text/templates/TextTemplateMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.text/src/org/eclipse/jface/text/templates/TextTemplateMessages.properties,v >retrieving revision 1.8 >diff -u -r1.8 TextTemplateMessages.properties >--- src/org/eclipse/jface/text/templates/TextTemplateMessages.properties 9 May 2007 11:03:53 -0000 1.8 >+++ src/org/eclipse/jface/text/templates/TextTemplateMessages.properties 2 May 2008 14:37:45 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2006 IBM Corporation and others. >+# Copyright (c) 2000, 2008 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 >@@ -18,6 +18,8 @@ > GlobalVariables.variable.description.cursor=The cursor position after editing template variables > GlobalVariables.variable.description.dollar=The dollar symbol > GlobalVariables.variable.description.date=Current date >+GlobalVariables.variable.description.dayOfMonth=Current day of month >+GlobalVariables.variable.description.month=Current month > GlobalVariables.variable.description.year=Current year > GlobalVariables.variable.description.time=Current time > GlobalVariables.variable.description.user=User name >Index: src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java,v >retrieving revision 1.11 >diff -u -r1.11 GlobalTemplateVariables.java >--- src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java 12 May 2006 11:12:07 -0000 1.11 >+++ src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java 2 May 2008 14:37:45 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -119,6 +119,46 @@ > } > > /** >+ * The day of month variable evaluates to the current day of the month. >+ */ >+ public static class DayOfMonth extends SimpleTemplateVariableResolver { >+ >+ /** Name of the day of month variable. */ >+ public static final String NAME = "day_of_month"; //$NON-NLS-1$ >+ >+ /** >+ * Creates a new day of month variable >+ */ >+ public DayOfMonth() { >+ super(NAME, TextTemplateMessages.getString("GlobalVariables.variable.description.dayOfMonth")); //$NON-NLS-1$ >+ } >+ protected String resolve(TemplateContext context) { >+ String dayOfMonth = Integer.toString(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); >+ return dayOfMonth.length() > 1 ? dayOfMonth : "0" + dayOfMonth; //$NON-NLS-1$ >+ } >+ } >+ >+ /** >+ * The month variable evaluates to the current month. >+ */ >+ public static class Month extends SimpleTemplateVariableResolver { >+ >+ /** Name of the month variable. */ >+ public static final String NAME = "month"; //$NON-NLS-1$ >+ >+ /** >+ * Creates a new month variable >+ */ >+ public Month() { >+ super(NAME, TextTemplateMessages.getString("GlobalVariables.variable.description.month")); //$NON-NLS-1$ >+ } >+ protected String resolve(TemplateContext context) { >+ String month = Integer.toString(Calendar.getInstance().get(Calendar.MONTH) + 1); >+ return month.length() > 1 ? month : "0" + month; //$NON-NLS-1$ >+ } >+ } >+ >+ /** > * The year variable evaluates to the current year. > */ > public static class Year extends SimpleTemplateVariableResolver {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review-
Actions:
View
|
Diff
Attachments on
bug 75981
:
98429
|
213533
|
235875
|
235894