Index: plugin.properties =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/plugin.properties,v retrieving revision 1.11 diff -u -r1.11 plugin.properties --- plugin.properties 16 Jun 2003 08:20:38 -0000 1.11 +++ plugin.properties 20 Jun 2003 17:15:28 -0000 @@ -29,6 +29,10 @@ upperCase.label= To Upper Case lowerCase.description= Changes the selection to lower case lowerCase.label= To Lower Case +invertCase.description= Inverts the case of the selection +invertCase.label= Invert Case +capitalizeCase.description= Capitalizes the selection +capitalizeCase.label= Capitalize markerAnnotationSpecification.label= Marker Annotation Specification Index: plugin.xml =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/plugin.xml,v retrieving revision 1.18 diff -u -r1.18 plugin.xml --- plugin.xml 13 May 2003 11:46:32 -0000 1.18 +++ plugin.xml 20 Jun 2003 17:15:28 -0000 @@ -129,7 +129,37 @@ configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> - + + + + + + + + + + + + + Index: src/org/eclipse/ui/texteditor/AbstractTextEditor.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java,v retrieving revision 1.63 diff -u -r1.63 AbstractTextEditor.java --- src/org/eclipse/ui/texteditor/AbstractTextEditor.java 16 Jun 2003 08:20:04 -0000 1.63 +++ src/org/eclipse/ui/texteditor/AbstractTextEditor.java 20 Jun 2003 17:15:31 -0000 @@ -3730,15 +3730,25 @@ action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN); setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action); - action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.UpperCase.", this, true); //$NON-NLS-1$ + action = new UpperLowerCaseAction(EditorMessages.getResourceBundle(), "Editor.UpperCase.", this, true); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.UPPER_CASE_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.UPPER_CASE); setAction(ITextEditorActionConstants.UPPER_CASE, action); - action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.LowerCase.", this, false); //$NON-NLS-1$ + action = new UpperLowerCaseAction(EditorMessages.getResourceBundle(), "Editor.LowerCase.", this, false); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.LOWER_CASE_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE); setAction(ITextEditorActionConstants.LOWER_CASE, action); + + action = new InvertCaseAction(EditorMessages.getResourceBundle(), "Editor.InvertCase.", this); //$NON-NLS-1$ + action.setHelpContextId(IAbstractTextEditorHelpContextIds.INVERT_CASE_ACTION); + action.setActionDefinitionId(ITextEditorActionDefinitionIds.INVERT_CASE); + setAction(ITextEditorActionConstants.INVERT_CASE, action); + + action = new CapitalizeCaseAction(EditorMessages.getResourceBundle(), "Editor.CapitalizeCase.", this); //$NON-NLS-1$ + action.setHelpContextId(IAbstractTextEditorHelpContextIds.INVERT_CASE_ACTION); + action.setActionDefinitionId(ITextEditorActionDefinitionIds.CAPITALIZE_CASE); + setAction(ITextEditorActionConstants.INVERT_CASE, action); action = new SmartEnterAction(EditorMessages.getResourceBundle(), "Editor.SmartEnter.", this, false); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION); Index: src/org/eclipse/ui/texteditor/CaseAction.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java,v retrieving revision 1.1 diff -u -r1.1 CaseAction.java --- src/org/eclipse/ui/texteditor/CaseAction.java 13 May 2003 09:09:15 -0000 1.1 +++ src/org/eclipse/ui/texteditor/CaseAction.java 20 Jun 2003 17:15:32 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Sebastian Davids - bug 8515 *******************************************************************************/ package org.eclipse.ui.texteditor; @@ -21,17 +22,14 @@ import org.eclipse.swt.graphics.Point; /** - * Action that converts the current selection to lower case. + * Action that converts the current selection to a different case. * @since 3.0 */ -public class CaseAction extends ResourceAction implements IUpdate { +public abstract class CaseAction extends ResourceAction implements IUpdate { /** The editor we are working on. */ private AbstractTextEditor fEditor; - /** true if this action converts to upper case, false otherwise. */ - private boolean fToUpper; - /** * Creates and initializes the action for the given text editor. * The action configures its visual representation from the given resource @@ -41,14 +39,11 @@ * @param prefix a prefix to be prepended to the various resource keys * (described in ResourceAction constructor), or null if none * @param editor the text editor - * @param toUpper true if this is an uppercase action, false otherwise. - * * @see ResourceAction#ResourceAction */ - public CaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean toUpper) { + public CaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor) { super(bundle, prefix); fEditor= editor; - fToUpper= toUpper; update(); } @@ -77,11 +72,11 @@ Point sel= viewer.getSelectedRange(); if (sel == null) return; - + int selY = sel.y; try { // if the selection is emtpy, we select the word / string using the viewer's // doubleclick strategy - if (sel.y == 0) { + if (selY == 0) { SourceViewerConfiguration svc= fEditor.getSourceViewerConfiguration(); // never null when viewer instantiated String partition= document.getContentType(sel.x); ITextDoubleClickStrategy dcs= svc.getDoubleClickStrategy(viewer, partition); @@ -89,14 +84,19 @@ dcs.doubleClicked(viewer); sel= viewer.getSelectedRange(); } - if (sel.y == 0) + if (selY == 0) return; // if the selection is still empty, we're done } - String target= document.get(sel.x, sel.y); - String replacement= (fToUpper ? target.toUpperCase() : target.toLowerCase()); + String target= document.get(sel.x, selY); + //bug 8515 + String replacement= replace(target); if (!target.equals(replacement)) { document.replace(sel.x, target.length(), replacement); + //the replacement might be larger than the original + int adjustment = replacement.length() - target.length(); + if (adjustment > 0) + selY += adjustment; } } catch (BadLocationException x) { // ignore and return @@ -104,7 +104,7 @@ } // reinstall selection and move it into view - viewer.setSelectedRange(sel.x, sel.y); + viewer.setSelectedRange(sel.x, selY); // don't use the viewer's reveal feature in order to avoid jumping around st.showSelection(); } @@ -123,4 +123,6 @@ } setEnabled(enabled); } + + protected abstract String replace(String original); } Index: src/org/eclipse/ui/texteditor/EditorMessages.properties =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties,v retrieving revision 1.15 diff -u -r1.15 EditorMessages.properties --- src/org/eclipse/ui/texteditor/EditorMessages.properties 16 Jun 2003 08:20:20 -0000 1.15 +++ src/org/eclipse/ui/texteditor/EditorMessages.properties 20 Jun 2003 17:15:32 -0000 @@ -286,6 +286,15 @@ Editor.LowerCase.image= Editor.LowerCase.description=Changes the selection to lower case +Editor.InvertCase.label=Invert Case +Editor.InvertCase.tooltip=Inverts the case of the selection +Editor.InvertCase.image= +Editor.InvertCase.description=Inverts the case of the selection + +Editor.CapitalizeCase.label=Capitalize Case +Editor.CapitalizeCase.tooltip=Capitalizes the selection +Editor.CapitalizeCase.image= +Editor.CapitalizeCase.description=Capitalizes the selection ## Status line ## Index: src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java,v retrieving revision 1.8 diff -u -r1.8 IAbstractTextEditorHelpContextIds.java --- src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java 13 May 2003 09:09:15 -0000 1.8 +++ src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java 20 Jun 2003 17:15:32 -0000 @@ -282,6 +282,20 @@ /** * Help context id for the action. + * Value: "org.eclipse.ui.invert_case_action_context" + * @since 3.0 + */ + public static final String INVERT_CASE_ACTION= PREFIX + "invert_case" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the action. + * Value: "org.eclipse.ui.capitalize_case_action_context" + * @since 3.0 + */ + public static final String CAPITALIZE_CASE_ACTION= PREFIX + "capitalize_case" + ACTION_POSTFIX; //$NON-NLS-1$ + + /** + * Help context id for the action. * Value: "org.eclipse.ui.smart_enter_action_context" * @since 3.0 */ Index: src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java,v retrieving revision 1.6 diff -u -r1.6 ITextEditorActionConstants.java --- src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java 13 May 2003 09:09:15 -0000 1.6 +++ src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java 20 Jun 2003 17:15:32 -0000 @@ -196,6 +196,20 @@ * @since 3.0 */ static final String LOWER_CASE= "LowerCase"; //$NON-NLS-1$ + + /** + * Name of the action to invert a selection's case + * Value: "LowerCase" + * @since 3.0 + */ + static final String INVERT_CASE= "InvertCase"; //$NON-NLS-1$ + + /** + * Name of the action to turn a selection to capitalized case + * Value: "LowerCase" + * @since 3.0 + */ + static final String CAPITALIZE_CASE= "CapitalizeCase"; //$NON-NLS-1$ /** * Name of the action to find next. Index: src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java =================================================================== RCS file: /home/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java,v retrieving revision 1.9 diff -u -r1.9 ITextEditorActionDefinitionIds.java --- src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java 13 May 2003 09:09:15 -0000 1.9 +++ src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java 20 Jun 2003 17:15:32 -0000 @@ -111,15 +111,28 @@ * @since 3.0 */ public static final String UPPER_CASE= "org.eclipse.ui.edit.text.upperCase"; //$NON-NLS-1$ + + /** + * Action definition id of the upper case action. + * Value: "org.eclipse.ui.edit.text.lowerCase" + * @since 3.0 + */ + public static final String LOWER_CASE= "org.eclipse.ui.edit.text.lowerCase"; //$NON-NLS-1$ + + /** + * Action definition id of the lower case action. + * Value: "org.eclipse.ui.edit.text.lowerCase" + * @since 3.0 + */ + public static final String INVERT_CASE= "org.eclipse.ui.edit.text.invertCase"; //$NON-NLS-1$ /** * Action definition id of the lower case action. * Value: "org.eclipse.ui.edit.text.lowerCase" * @since 3.0 */ - public static final String LOWER_CASE= "org.eclipse.ui.edit.text.lowerCase"; //$NON-NLS-1$ + public static final String CAPITALIZE_CASE= "org.eclipse.ui.edit.text.capitalizeCase"; //$NON-NLS-1$ - // navigation /** Index: src/org/eclipse/ui/internal/texteditor/Strings.java =================================================================== RCS file: src/org/eclipse/ui/internal/texteditor/Strings.java diff -N src/org/eclipse/ui/internal/texteditor/Strings.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ui/internal/texteditor/Strings.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,147 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Sebastian Davids - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.internal.texteditor; + +import java.util.StringTokenizer; + +/** + * Helper class to provide String manipulation functions not available in standard JDK. + */ +public class Strings { + + private Strings() {} + + /** + * Inverts the case of each letter of the given String. + *

+ * This methods handles the special cases where a lower case letter will be + * represented as two upper case letters, e.g. German ß -> SS. + *

+ * Attention: + *

    + *
  • The length of the inverted string may be greater than the original + * one's.
  • + *
  • The inversion might not be reversible, e.g. German Maße + * will be inverted to mASSE; but inverting mASSE will + * produce Masse.
  • + *
+ * + * @param s the String to be inverted. + * @return the inverted String + */ + public static String invertCase(String s) { + if (s == null) + return null; + + final int len= s.length(); + + if (len == 0) + return s; + + int i; + char c; + + //skip to the first lower case letter + for (i= 0; i < len; ++i) { + c= s.charAt(i); + + if (Character.isLetter(c) && Character.isLowerCase(c)) + break; + } + + if (i == len) + return s.toLowerCase(); + + StringBuffer result= new StringBuffer(len); + + //append characters before first lower case letter + result.append(s.substring(0, i).toLowerCase()); + + String cS; + + for (; i < len; ++i) { + c= s.charAt(i); + + if (Character.isLetter(c)) { + if (Character.isLowerCase(c)) { + cS= ("" + c).toUpperCase(); //$NON-NLS-1$ + + result.append(cS); + } else + result.append(Character.toLowerCase(c)); + } else + result.append(c); + } + + return result.toString(); + } + + /** + * Capitalizes the given String. + *

+ * Rules: + *

+ *

    + *
  • if the first character is a letter it will be upper case
  • + *
  • each letter directly after a whitespace will be in upper case
  • + *
+ * + * @param s the String to be capitalized. + * @return the capitalized String + */ + public static String capitalize(String s) { + if (s == null) + return null; + + final int len= s.length(); + + if (len == 0) + return s; + + if (len == 1) + return s.toUpperCase(); + + StringTokenizer st= new StringTokenizer(s, " \t\n\r\f", true); //$NON-NLS-1$ + + StringBuffer result= new StringBuffer(s.length()); + + while (st.hasMoreTokens()) + upperCaseFirstLetter(result, st.nextToken()); + + return result.toString(); + } + + /** + * Converts the first character of token to upper case if it is + * a letter and append the converted String to buf; + * if the first character is not a letter, token will be + * appended to buf without any processing. + * + * @param buf the StringBuffer the processed token will be appended to. + * @param token the token. + */ + private static void upperCaseFirstLetter(StringBuffer buf, String token) { + //assert token.length() != 0; + char firstChar= token.charAt(0); + + if (!Character.isLetter(firstChar)) { + buf.append(token); + return; + } + + buf.append(("" + firstChar).toUpperCase()); //$NON-NLS-1$ + + int len= token.length(); + + if (len > 1) + buf.append(token.substring(1, len)); + } +} Index: src/org/eclipse/ui/internal/texteditor/StringsTest.java =================================================================== RCS file: src/org/eclipse/ui/internal/texteditor/StringsTest.java diff -N src/org/eclipse/ui/internal/texteditor/StringsTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ui/internal/texteditor/StringsTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.internal.texteditor; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.eclipse.jdt.internal.corext.util.Strings; + +public class StringsTest extends TestCase { + + public void testInvertCase() { + assertEquals("null", null, Strings.invertCase(null)); //$NON-NLS-1$ + + assertEquals("empty", //$NON-NLS-1$ + "", //$NON-NLS-1$ + Strings.invertCase("")); //$NON-NLS-1$ + + assertEquals("&ABC1", //$NON-NLS-1$ + "&abc1", //$NON-NLS-1$ + Strings.invertCase("&ABC1")); //$NON-NLS-1$ + + assertEquals("A", //$NON-NLS-1$ + "a", //$NON-NLS-1$ + Strings.invertCase("A")); //$NON-NLS-1$ + + assertEquals("AAA", //$NON-NLS-1$ + "aaa", //$NON-NLS-1$ + Strings.invertCase("AAA")); //$NON-NLS-1$ + + assertEquals("b", //$NON-NLS-1$ + "B", //$NON-NLS-1$ + Strings.invertCase("b")); //$NON-NLS-1$ + + assertEquals("aB", //$NON-NLS-1$ + "Ab", //$NON-NLS-1$ + Strings.invertCase("aB")); //$NON-NLS-1$ + + assertEquals("Ab", //$NON-NLS-1$ + "aB", //$NON-NLS-1$ + Strings.invertCase("Ab")); //$NON-NLS-1$ + + assertEquals("aBa", //$NON-NLS-1$ + "AbA", //$NON-NLS-1$ + Strings.invertCase("aBa")); //$NON-NLS-1$ + + assertEquals("AbA", //$NON-NLS-1$ + "aBa", //$NON-NLS-1$ + Strings.invertCase("AbA")); //$NON-NLS-1$ + + assertEquals("Maße", //$NON-NLS-1$ + "mASSE", //$NON-NLS-1$ + Strings.invertCase("Maße")); //$NON-NLS-1$ + + assertEquals("mASSE", //$NON-NLS-1$ + "Masse", //$NON-NLS-1$ + Strings.invertCase("mASSE")); //$NON-NLS-1$ + + assertEquals("&ßö\t\";AÜ4", //$NON-NLS-1$ + "&SSÖ\t\";aü4", //$NON-NLS-1$ + Strings.invertCase("&ßö\t\";AÜ4")); //$NON-NLS-1$ + } + + + public void testCapitalize() { + assertEquals("null", null, Strings.capitalize(null)); //$NON-NLS-1$ + + assertEquals("empty", //$NON-NLS-1$ + "", //$NON-NLS-1$ + Strings.capitalize("")); //$NON-NLS-1$ + + assertEquals("a", //$NON-NLS-1$ + "A", //$NON-NLS-1$ + Strings.capitalize("a")); //$NON-NLS-1$ + + assertEquals("A", //$NON-NLS-1$ + "A", //$NON-NLS-1$ + Strings.capitalize("A")); //$NON-NLS-1$ + + assertEquals("ß", //$NON-NLS-1$ + "SS", //$NON-NLS-1$ + Strings.capitalize("ß")); //$NON-NLS-1$ + + assertEquals("ab", //$NON-NLS-1$ + "Ab", //$NON-NLS-1$ + Strings.capitalize("Ab")); //$NON-NLS-1$ + + assertEquals("1a", //$NON-NLS-1$ + "1a", //$NON-NLS-1$ + Strings.capitalize("1a")); //$NON-NLS-1$ + + assertEquals(" a", //$NON-NLS-1$ + " A", //$NON-NLS-1$ + Strings.capitalize(" a")); //$NON-NLS-1$ + + assertEquals("a ", //$NON-NLS-1$ + "A ", //$NON-NLS-1$ + Strings.capitalize("a ")); //$NON-NLS-1$ + + assertEquals(" A", //$NON-NLS-1$ + " A", //$NON-NLS-1$ + Strings.capitalize(" A")); //$NON-NLS-1$ + + assertEquals("A ", //$NON-NLS-1$ + "A ", //$NON-NLS-1$ + Strings.capitalize("A ")); //$NON-NLS-1$ + + assertEquals(" ß", //$NON-NLS-1$ + " SS", //$NON-NLS-1$ + Strings.capitalize(" ß")); //$NON-NLS-1$ + + assertEquals("ß ", //$NON-NLS-1$ + "SS ", //$NON-NLS-1$ + Strings.capitalize("ß ")); //$NON-NLS-1$ + + assertEquals(" ab", //$NON-NLS-1$ + " Ab", //$NON-NLS-1$ + Strings.capitalize(" ab")); //$NON-NLS-1$ + + assertEquals(" 1a", //$NON-NLS-1$ + " 1a", //$NON-NLS-1$ + Strings.capitalize(" 1a")); //$NON-NLS-1$ + + assertEquals("\\ta", //$NON-NLS-1$ + "\tA", //$NON-NLS-1$ + Strings.capitalize("\ta")); //$NON-NLS-1$ + + assertEquals("a\\t", //$NON-NLS-1$ + "A\t", //$NON-NLS-1$ + Strings.capitalize("a\t")); //$NON-NLS-1$ + + assertEquals("\\tA", //$NON-NLS-1$ + "\tA", //$NON-NLS-1$ + Strings.capitalize("\tA")); //$NON-NLS-1$ + + assertEquals("A\\t", //$NON-NLS-1$ + "A\t", //$NON-NLS-1$ + Strings.capitalize("A\t")); //$NON-NLS-1$ + + assertEquals("\\t1ab", //$NON-NLS-1$ + "\t1ab", //$NON-NLS-1$ + Strings.capitalize("\t1ab")); //$NON-NLS-1$ + + assertEquals("\\t1a", //$NON-NLS-1$ + "\t1a", //$NON-NLS-1$ + Strings.capitalize("\t1a")); //$NON-NLS-1$ + + assertEquals("a\\tb cd", //$NON-NLS-1$ + "A\tBa SSd", //$NON-NLS-1$ + Strings.capitalize("a\tba ßd")); //$NON-NLS-1$ + } + + public static Test suite() { + return new TestSuite(StringsTest.class); + } +} + Index: src/org/eclipse/ui/texteditor/CapitalizeCaseAction.java =================================================================== RCS file: src/org/eclipse/ui/texteditor/CapitalizeCaseAction.java diff -N src/org/eclipse/ui/texteditor/CapitalizeCaseAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ui/texteditor/CapitalizeCaseAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Sebastian Davids - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.texteditor; + +import java.util.ResourceBundle; + +import org.eclipse.ui.internal.texteditor.Strings; + +/** + * Action that capitalizes the current selection. + * @since 3.0 + */ +public class CapitalizeCaseAction extends CaseAction { + + /** + * Creates and initializes the action for the given text editor. + * The action configures its visual representation from the given resource + * bundle. + * + * @param bundle the resource bundle + * @param prefix a prefix to be prepended to the various resource keys + * (described in ResourceAction constructor), or null if none + * @param editor the text editor + * @param toUpper true if this is an uppercase action, false otherwise. + * + * @see ResourceAction#ResourceAction + */ + public CapitalizeCaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor) { + super(bundle, prefix, editor); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.CaseAction#replace(java.lang.String) + */ + protected String replace(String original) { + return Strings.capitalize(original); + } +} Index: src/org/eclipse/ui/texteditor/InvertCaseAction.java =================================================================== RCS file: src/org/eclipse/ui/texteditor/InvertCaseAction.java diff -N src/org/eclipse/ui/texteditor/InvertCaseAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ui/texteditor/InvertCaseAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Sebastian Davids - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.texteditor; + +import java.util.ResourceBundle; + +import org.eclipse.ui.internal.texteditor.Strings; + +/** + * Action that inverts the case of the current selection. + * @since 3.0 + */ +public class InvertCaseAction extends CaseAction { + + /** + * Creates and initializes the action for the given text editor. + * The action configures its visual representation from the given resource bundle. + * + * @param bundle the resource bundle + * @param prefix a prefix to be prepended to the various resource keys + * (described in ResourceAction constructor), or null if none + * @param editor the text editor + * + * @see ResourceAction#ResourceAction + */ + public InvertCaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor) { + super(bundle, prefix, editor); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.CaseAction#replace(java.lang.String) + */ + protected String replace(String original) { + return Strings.invertCase(original); + } +} Index: src/org/eclipse/ui/texteditor/UpperLowerCaseAction.java =================================================================== RCS file: src/org/eclipse/ui/texteditor/UpperLowerCaseAction.java diff -N src/org/eclipse/ui/texteditor/UpperLowerCaseAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ui/texteditor/UpperLowerCaseAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Sebastian Davids - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.texteditor; + +import java.util.ResourceBundle; + +/** + * Action that converts the current selection to upper or lower case. + * @since 3.0 + */ +public class UpperLowerCaseAction extends CaseAction { + + /** true if this action converts to upper case, false otherwise. */ + private boolean fToUpper; + + /** + * Creates and initializes the action for the given text editor. + * The action configures its visual representation from the given resource bundle. + * + * @param bundle the resource bundle + * @param prefix a prefix to be prepended to the various resource keys + * (described in ResourceAction constructor), or null if none + * @param editor the text editor + * @param toUpper true if this is an uppercase action, false otherwise. + * + * @see ResourceAction#ResourceAction + */ + public UpperLowerCaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean toUpper) { + super(bundle, prefix, editor); + fToUpper= toUpper; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.CaseAction#replace(java.lang.String) + */ + protected String replace(String original) { + return (fToUpper ? original.toUpperCase() : original.toLowerCase()); + } +}