wlu: auto gen name implementation
diff --git a/1.5/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/DescriptionFormPage.java b/1.5/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/DescriptionFormPage.java
index b9b788e..f18849b 100644
--- a/1.5/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/DescriptionFormPage.java
+++ b/1.5/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/DescriptionFormPage.java
@@ -58,6 +58,7 @@
import org.eclipse.epf.library.edit.command.IActionManager;
import org.eclipse.epf.library.edit.itemsfilter.FilterConstants;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.MethodElementPropertyHelper;
import org.eclipse.epf.library.edit.util.TngUtil;
import org.eclipse.epf.library.edit.validation.DependencyChecker;
import org.eclipse.epf.library.edit.validation.IValidator;
@@ -68,8 +69,6 @@
import org.eclipse.epf.library.ui.util.ConvertGuidanceType;
import org.eclipse.epf.library.util.ResourceHelper;
import org.eclipse.epf.richtext.RichTextListener;
-import org.eclipse.epf.uma.ContentCategory;
-import org.eclipse.epf.uma.ContentDescription;
import org.eclipse.epf.uma.Guidance;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodElement;
@@ -309,7 +308,7 @@
private List<ISectionProvider> sectionProviders;
- private boolean nameFieldTouched = false;
+ private boolean autoGenName = false;
protected ILabelProvider labelProviderVariability = new AdapterFactoryLabelProvider(
TngAdapterFactory.INSTANCE
@@ -360,7 +359,6 @@
public void focusGained(FocusEvent e) {
((MethodElementEditor) getEditor()).setCurrentFeatureEditor(e.widget,
UmaPackage.eINSTANCE.getNamedElement_Name());
- setNameFieldTouched(true);
}
public void focusLost(FocusEvent e) {
@@ -370,15 +368,6 @@
e.widget, methodElement.getName())) {
return;
}
- if (AuthoringUIPreferences.getEnableAutoNameGen() && name.length() == 0) {
- name = generateName(ctrl_presentation_name.getText());
- if (name.length() >= 0) {
- ctrl_name.setText(name);
- changeElementName();
- setNameFieldTouched(false);
- return;
- }
- }
if (name.equals(methodElement.getName()))
return;
@@ -640,7 +629,16 @@
*/
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
-
+ if (AuthoringUIPreferences.getEnableAutoNameGen()) {
+ MethodElementProperty prop = MethodElementPropertyHelper
+ .getProperty(
+ methodElement,
+ MethodElementPropertyHelper.AUTO_NAME_GEN_DONE);
+ if (prop == null || !prop.getValue().equals("true")) { //$NON-NLS-1$
+ setAutoGenName(true);
+ }
+ }
+
VariabilityType[] types;
// if (methodElement instanceof ContentCategory) {
// types = new VariabilityType[] {
@@ -1569,6 +1567,11 @@
}
if (isAutoGenName()) {
changeElementName();
+ MethodElementPropertyHelper
+ .setProperty(
+ methodElement,
+ MethodElementPropertyHelper.AUTO_NAME_GEN_DONE,
+ "true"); //$NON-NLS-1$
}
}
@@ -3333,12 +3336,12 @@
}
- private boolean isAutoGenName() {
- return AuthoringUIPreferences.getEnableAutoNameGen() && !nameFieldTouched;
+ protected boolean isAutoGenName() {
+ return autoGenName;
}
- private void setNameFieldTouched(boolean touched) {
- nameFieldTouched = touched;
+ protected void setAutoGenName(boolean autoGenName) {
+ this.autoGenName = autoGenName;
}
}
diff --git a/1.5/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/MethodElementPropertyHelper.java b/1.5/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/MethodElementPropertyHelper.java
index 1e14407..57aebfb 100644
--- a/1.5/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/MethodElementPropertyHelper.java
+++ b/1.5/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/MethodElementPropertyHelper.java
@@ -33,6 +33,7 @@
public static final String CONFIG_PROPBLEM_HIDE_WARNINGS = "hide_warnings"; //$NON-NLS-1$
public static final String CONFIG_PROPBLEM_HIDE_INFOS = "hide_infos"; //$NON-NLS-1$
public static final String CUSTOM_CATEGORY__INCLUDED_ELEMENTS = "include"; //$NON-NLS-1$
+ public static final String AUTO_NAME_GEN_DONE = "auto_name_gen_done"; //$NON-NLS-1$
public static final MethodElementProperty getProperty(MethodElement e, String propertyName) {
if (e != null) {