();
+ CBreakIterator iterator = new CBreakIterator();
+ iterator.setText(name);
+ int end;
+ for (int start = iterator.first(); (end = iterator.next()) != BreakIterator.DONE; start = end) {
+ if (Character.isLetterOrDigit(name.charAt(start))) {
+ int pos = end;
+ while (--pos >= start && !Character.isLetterOrDigit(name.charAt(pos))) {
+ }
+ words.add(name.subSequence(start, pos + 1));
+ }
+ }
+ return words;
+ }
+
+ private void appendUpperCase(StringBuilder buf, CharSequence word) {
+ for (int i = 0; i < word.length(); i++) {
+ buf.append(Character.toUpperCase(word.charAt(i)));
+ }
+ }
+
+ private void appendLowerCase(StringBuilder buf, CharSequence word) {
+ for (int i = 0; i < word.length(); i++) {
+ buf.append(Character.toLowerCase(word.charAt(i)));
+ }
+ }
+
+ private void appendTitleCase(StringBuilder buf, CharSequence word) {
+ for (int i = 0; i < word.length(); i++) {
+ buf.append(i == 0 ?
+ Character.toUpperCase(word.charAt(i)) : Character.toLowerCase(word.charAt(i)));
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
index c0589297fed..3beb305e7df 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
@@ -63,7 +63,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
public class NewClassWizardUtil {
@@ -257,28 +256,6 @@ public class NewClassWizardUtil {
return null;
}
- /**
- * Creates a header file name from the given class name. This is the file name
- * to be used when the class is created. eg. "MyClass" -> "MyClass.h"
- *
- * @param className the class name
- * @return the header file name for the given class
- */
- public static String createHeaderFileName(String className) {
- return NewSourceFileGenerator.generateHeaderFileNameFromClass(className);
- }
-
- /**
- * Creates a source file name from the given class name. This is the file name
- * to be used when the class is created. eg. "MyClass" -> "MyClass.cpp"
- *
- * @param className the class name
- * @return the source file name for the given class
- */
- public static String createSourceFileName(String className) {
- return NewSourceFileGenerator.generateSourceFileNameFromClass(className);
- }
-
/**
* Returns the workspace root.
*
@@ -289,7 +266,7 @@ public class NewClassWizardUtil {
}
/**
- * Resolve the location of the given class.
+ * Resolves the location of the given class.
*
* @param type the class to resolve
* @param context the runnable context
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
index 3c3ddda0f6c..e5e9c73eca5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
public class LayoutUtil {
@@ -23,11 +24,20 @@ public class LayoutUtil {
* Calculates the number of columns needed by field editors
*/
public static int getNumberOfColumns(DialogField[] editors) {
- int nCulumns= 0;
+ int nColumns= 0;
for (int i= 0; i < editors.length; i++) {
- nCulumns= Math.max(editors[i].getNumberOfControls(), nCulumns);
+ nColumns= Math.max(editors[i].getNumberOfControls(), nColumns);
}
- return nCulumns;
+ return nColumns;
+ }
+
+ /**
+ * Returns the number of columns in the layout of a composite,
+ * or 1 if the composite doesn't have a grid layout.
+ */
+ public static int getNumberOfColumns(Composite composite) {
+ Layout layout = composite.getLayout();
+ return layout instanceof GridLayout ? ((GridLayout) layout).numColumns : 1;
}
/**
@@ -44,7 +54,8 @@ public class LayoutUtil {
* @param minWidth The minimal width of the composite
* @param minHeight The minimal height of the composite
*/
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight) {
+ public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
+ int minWidth, int minHeight) {
doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
}
@@ -55,10 +66,9 @@ public class LayoutUtil {
* @param minHeight The minimal height of the composite
* @param marginWidth The margin width to be used by the composite
* @param marginHeight The margin height to be used by the composite
- * @deprecated
*/
- @Deprecated
- public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight, int marginWidth, int marginHeight) {
+ private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
+ int minWidth, int minHeight, int marginWidth, int marginHeight) {
int nCulumns= getNumberOfColumns(editors);
Control[][] controls= new Control[editors.length][];
for (int i= 0; i < editors.length; i++) {
@@ -91,7 +101,7 @@ public class LayoutUtil {
public static void setHorizontalSpan(Control control, int span) {
Object ld= control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData)ld).horizontalSpan= span;
+ ((GridData) ld).horizontalSpan= span;
} else if (span != 1) {
GridData gd= new GridData();
gd.horizontalSpan= span;
@@ -105,7 +115,7 @@ public class LayoutUtil {
public static void setWidthHint(Control control, int widthHint) {
Object ld= control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData)ld).widthHint= widthHint;
+ ((GridData) ld).widthHint= widthHint;
}
}
@@ -115,7 +125,7 @@ public class LayoutUtil {
public static void setHeightHint(Control control, int heigthHint) {
Object ld= control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData)ld).heightHint= heigthHint;
+ ((GridData) ld).heightHint= heigthHint;
}
}
@@ -125,18 +135,27 @@ public class LayoutUtil {
public static void setHorizontalIndent(Control control, int horizontalIndent) {
Object ld= control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData)ld).horizontalIndent= horizontalIndent;
+ ((GridData) ld).horizontalIndent= horizontalIndent;
}
}
/**
- * Sets the horizontal indent of a control. Assumes that GridData is used.
+ * Sets the horizontal alignment of a control. Assumes that GridData is used.
+ */
+ public static void setHorizontalAlignment(Control control, int horizontalAlignment) {
+ Object ld= control.getLayoutData();
+ if (ld instanceof GridData) {
+ ((GridData) ld).horizontalAlignment= horizontalAlignment;
+ }
+ }
+
+ /**
+ * Makes a control grab all available horizontal space. Assumes that GridData is used.
*/
public static void setHorizontalGrabbing(Control control) {
Object ld= control.getLayoutData();
if (ld instanceof GridData) {
- ((GridData)ld).grabExcessHorizontalSpace= true;
+ ((GridData) ld).grabExcessHorizontalSpace= true;
}
- }
-
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
index fc60ace62d0..397e6cd86d5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
@@ -15,6 +15,10 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
@@ -23,23 +27,55 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.ui.dialogs.ContainerGenerator;
public class NewSourceFileGenerator {
- //TODO these should all be configurable in prefs
- private static final String HEADER_EXT = ".h"; //$NON-NLS-1$
- private static final String SOURCE_EXT = ".cpp"; //$NON-NLS-1$
-
+ /**
+ * Creates a header file name from the given class name. This is the file name
+ * to be used when the class is created. eg. "MyClass" -> "MyClass.h"
+ *
+ * @param className the class name
+ * @return the header file name for the given class
+ */
public static String generateHeaderFileNameFromClass(String className) {
- //TODO eventually make this a prefs option - filename pattern
- return className + HEADER_EXT;
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX, "", null); //$NON-NLS-1$
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX, ".h", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ return composer.compose(className);
}
+ /**
+ * Creates a source file name from the given class name. This is the file name
+ * to be used when the class is created. e.g. "MyClass" -> "MyClass.cpp"
+ *
+ * @param className the class name
+ * @return the source file name for the given class
+ */
public static String generateSourceFileNameFromClass(String className) {
- //TODO eventually make this a prefs option - filename pattern
- return className + SOURCE_EXT;
+ IPreferencesService preferences = Platform.getPreferencesService();
+ int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION,
+ PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+ String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+ String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX, "", null); //$NON-NLS-1$
+ String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+ PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX, ".cpp", null); //$NON-NLS-1$
+ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+ return composer.compose(className);
}
public static IFile createHeaderFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
index d9b15e0333e..de2f6053fd4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
@@ -1507,6 +1507,298 @@ public class PreferenceConstants {
* @since 5.2
*/
public static final int CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH = 2;
+
+ /**
+ * A named preference that controls how capitalization of a constant name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CONSTANT_CAPITALIZATION = "nameStyle.constant.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of a constant name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CONSTANT_PREFIX = "nameStyle.constant.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of a constant name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CONSTANT_SUFFIX = "nameStyle.constant.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * of a constant name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CONSTANT_WORD_DELIMITER = "nameStyle.constant.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of a field name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_FIELD_CAPITALIZATION = "nameStyle.field.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of a field name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_FIELD_PREFIX = "nameStyle.field.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of a field name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_FIELD_SUFFIX = "nameStyle.field.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * of a field name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_FIELD_WORD_DELIMITER = "nameStyle.field.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of the getter name
+ * depends on capitalization of the field name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_GETTER_CAPITALIZATION = "nameStyle.getter.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the getter name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_GETTER_PREFIX = "nameStyle.getter.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the getter name for a boolean field.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN = "nameStyle.getter.prefixForBoolean"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of the getter name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_GETTER_SUFFIX = "nameStyle.getter.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * when composing the getter name from the field name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_GETTER_WORD_DELIMITER = "nameStyle.getter.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of the setter name
+ * depends on capitalization of the field name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_SETTER_CAPITALIZATION = "nameStyle.setter.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the setter name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_SETTER_PREFIX = "nameStyle.setter.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of the setter name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_SETTER_SUFFIX = "nameStyle.setter.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * when composing the setter name from the field name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_SETTER_WORD_DELIMITER = "nameStyle.setter.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of the C++ source file name
+ * depends on capitalization of the class name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_SOURCE_CAPITALIZATION = "nameStyle.cpp.source.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the C++ source file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_SOURCE_PREFIX = "nameStyle.cpp.source.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of the C++ source file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_SOURCE_SUFFIX = "nameStyle.cpp.source.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * when composing the C++ source file name from the class name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_SOURCE_WORD_DELIMITER = "nameStyle.cpp.source.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of the C++ header file name
+ * depends on capitalization of the class name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_HEADER_CAPITALIZATION = "nameStyle.cpp.header.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the C++ header file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_HEADER_PREFIX = "nameStyle.cpp.header.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of the C++ header file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_HEADER_SUFFIX = "nameStyle.cpp.header.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * when composing the C++ header file name from the class name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_HEADER_WORD_DELIMITER = "nameStyle.cpp.header.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls how capitalization of the C++ test file name
+ * depends on capitalization of the class name.
+ *
+ * Value is of type Integer
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_TEST_CAPITALIZATION = "nameStyle.cpp.test.capitalization"; //$NON-NLS-1$
+ /**
+ * A named preference that controls prefix of the C++ test file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_TEST_PREFIX = "nameStyle.cpp.test.prefix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls suffix of the C++ test file name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_TEST_SUFFIX = "nameStyle.cpp.test.suffix"; //$NON-NLS-1$
+ /**
+ * A named preference that controls delimiter that is inserted between words
+ * when composing the C++ test file name from the class name.
+ *
+ * Value is of type String
.
+ *
+ * @since 5.3
+ */
+ public static final String NAME_STYLE_CPP_TEST_WORD_DELIMITER = "nameStyle.cpp.test.wordDelimiter"; //$NON-NLS-1$
+
+ /**
+ * The value of NAME_STYLE_*_CAPITALIZATION
specifying that the name
+ * is to be derived from the class or the variable name without changing
+ * capitalization.
+ *
+ * @since 5.3
+ */
+ public static final int NAME_STYLE_CAPITALIZATION_ORIGINAL = 0;
+ /**
+ * The value of NAME_STYLE_*_CAPITALIZATION
specifying that the name
+ * is to be derived from the class or the variable name by converting it to upper
+ * case.
+ *
+ * @since 5.3
+ */
+ public static final int NAME_STYLE_CAPITALIZATION_UPPER_CASE = 1;
+ /**
+ * The value of NAME_STYLE_*_CAPITALIZATION
specifying that the name
+ * is to be derived from the class or the variable name by converting it to lower
+ * case.
+ *
+ * @since 5.3
+ */
+ public static final int NAME_STYLE_CAPITALIZATION_LOWER_CASE = 2;
+ /**
+ * The value of NAME_STYLE_*_CAPITALIZATION
specifying that the name
+ * is to be derived from the class or the variable name by capitalizing first
+ * letter of every word.
+ *
+ * @since 5.3
+ */
+ public static final int NAME_STYLE_CAPITALIZATION_CAMEL_CASE = 3;
+ /**
+ * The value of NAME_STYLE_*_CAPITALIZATION
specifying that the name
+ * is to be derived from the class or the variable name by capitalizing first
+ * letter of every word except the first one.
+ *
+ * @since 5.3
+ */
+ public static final int NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE = 4;
/**
* Returns the CDT-UI preference store.
@@ -1682,7 +1974,7 @@ public class PreferenceConstants {
store.setDefault(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD, 20);
store.setDefault(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD, 100);
/*
- * XXX: This is currently disabled because the spelling engine
+ * TODO: This is currently disabled because the spelling engine
* cannot return word proposals but only correction proposals.
*/
store.setToDefault(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
@@ -1708,6 +2000,37 @@ public class PreferenceConstants {
// Code Templates
store.setDefault(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME);
+
+ // Name Style
+ store.setDefault(NAME_STYLE_FIELD_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE);
+ store.setDefault(NAME_STYLE_FIELD_PREFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_FIELD_SUFFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_FIELD_WORD_DELIMITER, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CONSTANT_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_UPPER_CASE);
+ store.setDefault(NAME_STYLE_CONSTANT_PREFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CONSTANT_SUFFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CONSTANT_WORD_DELIMITER, "_"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_GETTER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_CAMEL_CASE);
+ store.setDefault(NAME_STYLE_GETTER_PREFIX, "get"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN, "is"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_GETTER_SUFFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_GETTER_WORD_DELIMITER, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_SETTER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_CAMEL_CASE);
+ store.setDefault(NAME_STYLE_SETTER_PREFIX, "set"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_SETTER_SUFFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_SETTER_WORD_DELIMITER, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_HEADER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+ store.setDefault(NAME_STYLE_CPP_HEADER_PREFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_HEADER_SUFFIX, ".h"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_HEADER_WORD_DELIMITER, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_SOURCE_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+ store.setDefault(NAME_STYLE_CPP_SOURCE_PREFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_SOURCE_SUFFIX, ".cpp"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_TEST_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+ store.setDefault(NAME_STYLE_CPP_TEST_PREFIX, ""); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp"); //$NON-NLS-1$
+ store.setDefault(NAME_STYLE_CPP_TEST_WORD_DELIMITER, ""); //$NON-NLS-1$
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
index 48ce730723e..364c948afca 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * Copyright (c) 2004, 2011 QNX Software Systems 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
@@ -60,7 +60,6 @@ import org.eclipse.cdt.core.browser.TypeSearchScope;
import org.eclipse.cdt.core.browser.TypeUtil;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer;
@@ -103,9 +102,9 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
+import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
public class NewClassCreationWizardPage extends NewElementWizardPage {
-
protected final static String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
protected static final int MAX_FIELD_CHARS = 50;
@@ -141,9 +140,9 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
protected IStatus fSourceFileStatus;
protected final IStatus STATUS_OK = new StatusInfo();
- protected IFile fCreatedSourceFile = null;
- protected IFile fCreatedHeaderFile = null;
- protected ICElement fCreatedClass = null;
+ protected IFile fCreatedSourceFile;
+ protected IFile fCreatedHeaderFile;
+ protected ICElement fCreatedClass;
/**
* This flag isFirstTime is used to keep a note
@@ -1307,20 +1306,20 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
String sourceName = null;
if (folder == null) {
- headerName = NewClassWizardUtil.createHeaderFileName(className);
- sourceName = NewClassWizardUtil.createSourceFileName(className);
+ headerName = NewSourceFileGenerator.generateHeaderFileNameFromClass(className);
+ sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className);
} else {
// make sure the file names are unique
String currName = className;
int count = 0;
String separator = ""; //$NON-NLS-1$
- if (Character.isDigit(className.charAt(className.length()-1)))
+ if (Character.isDigit(className.charAt(className.length() - 1)))
separator = "_"; //$NON-NLS-1$
while (count < MAX_UNIQUE_CLASSNAME) {
- String header = NewClassWizardUtil.createHeaderFileName(currName);
+ String header = NewSourceFileGenerator.generateHeaderFileNameFromClass(currName);
IPath path = folder.append(header);
if (!path.toFile().exists()) {
- String source = NewClassWizardUtil.createSourceFileName(currName);
+ String source = NewSourceFileGenerator.generateSourceFileNameFromClass(currName);
path = folder.append(source);
if (!path.toFile().exists()) {
headerName = header;
diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java
index 7ac7822c09f..483bb1d6e26 100644
--- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java
+++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java
@@ -93,7 +93,7 @@ public class ControlFactory {
*
* @param parent the parent of the new composite
* @param color the separator color
- * @return preferedThickness - the prefered thickness of separator (or 2 if SWT.DEFAULT)
+ * @return preferedThickness - the preferred thickness of separator (or 2 if SWT.DEFAULT)
*/
public static Composite createCompositeSeparator(Composite parent, Color color, int preferedHeight) {
Composite separator = createComposite(parent, 1);
@@ -206,8 +206,8 @@ public class ControlFactory {
* @param style - control style
* @return the new label
*/
- public static Label createLabel(Composite parent, String text, int widthHint, int heightHint, int style) {
-
+ public static Label createLabel(Composite parent, String text, int widthHint, int heightHint,
+ int style) {
Label label = new Label(parent, style);
label.setFont(parent.getFont());
label.setText(text);
@@ -241,11 +241,11 @@ public class ControlFactory {
* @return the new label
*/
public static Label createBoldLabel(Composite parent, String text) {
- Label label = createLabel( parent, text );
+ Label label = createLabel(parent, text);
FontData[] fd = label.getFont().getFontData();
- fd[0].setStyle( SWT.BOLD );
- Font font = new Font( Display.getCurrent(), fd[0] );
- label.setFont( font );
+ fd[0].setStyle(SWT.BOLD);
+ Font font = new Font(Display.getCurrent(), fd[0]);
+ label.setFont(font);
return label;
}
@@ -310,7 +310,8 @@ public class ControlFactory {
* @param value the string to identify radiobutton
* @return the new checkbox
*/
- public static Button createRadioButton(Composite group, String label, String value, SelectionListener listener) {
+ public static Button createRadioButton(Composite group, String label, String value,
+ SelectionListener listener) {
Button button = new Button(group, SWT.RADIO | SWT.LEFT);
button.setFont(group.getFont());
button.setText(label);
@@ -574,7 +575,8 @@ public class ControlFactory {
return createSelectCCombo(parent, strdata, selData, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
}
- public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData, int style) {
+ public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData,
+ int style) {
CCombo combo = new CCombo(parent, style);
combo.setFont(parent.getFont());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
@@ -657,7 +659,7 @@ public class ControlFactory {
int n_sel = combo.indexOf(selData);
if (0 > n_sel) {
if ((combo.getStyle() & SWT.READ_ONLY) == 0) {
- combo.setText( selData );
+ combo.setText(selData);
return;
}
n_sel = 0;
@@ -668,39 +670,36 @@ public class ControlFactory {
/**
* Create a dialog shell, child to the top level workbench shell.
*
- * @return The new Shell useable for a dialog.
- *
+ * @return The new Shell usable for a dialog.
*/
public static Shell createDialogShell() {
- Shell parent = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getShell();
- return new Shell( parent, SWT.DIALOG_TRIM );
+ Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ return new Shell(parent, SWT.DIALOG_TRIM);
}
public static Composite insertSpace(Composite parent, int nSpan, int height) {
Composite space = ControlFactory.createCompositeSeparator(parent, parent.getBackground(),
(SWT.DEFAULT != height ? height : 5));
- ((GridData)space.getLayoutData()).horizontalSpan = nSpan;
+ ((GridData) space.getLayoutData()).horizontalSpan = nSpan;
return space;
}
- public static MessageBox createDialog( String title, String message, int style ) {
- MessageBox box = new MessageBox( createDialogShell(), style | SWT.APPLICATION_MODAL );
- box.setText( title );
- box.setMessage( message );
+ public static MessageBox createDialog(String title, String message, int style) {
+ MessageBox box = new MessageBox(createDialogShell(), style | SWT.APPLICATION_MODAL);
+ box.setText(title);
+ box.setMessage(message);
return box;
}
- public static MessageBox createYesNoDialog( String title, String message ) {
- return createDialog( title, message, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
+ public static MessageBox createYesNoDialog(String title, String message) {
+ return createDialog(title, message, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
}
- public static MessageBox createOkDialog( String title, String message ) {
- return createDialog( title, message, SWT.OK | SWT.ICON_INFORMATION );
+ public static MessageBox createOkDialog(String title, String message) {
+ return createDialog(title, message, SWT.OK | SWT.ICON_INFORMATION);
}
- public static MessageBox createOkCancelDialog( String title, String message ) {
- return createDialog( title, message, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION );
+ public static MessageBox createOkCancelDialog(String title, String message) {
+ return createDialog(title, message, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION);
}
}