Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorningyu2019-11-21 09:02:02 +0000
committerWim Jongman2019-12-12 10:51:20 +0000
commitc7961f3b854a808073e67cf9c56b3307d90bd8d4 (patch)
treeaecb21731c56c3936727cbc550102fcfade4ea48
parent6912838e8f92e2033f9cd26a7b0269a662c234b2 (diff)
downloadorg.eclipse.windowbuilder-c7961f3b854a808073e67cf9c56b3307d90bd8d4.tar.gz
org.eclipse.windowbuilder-c7961f3b854a808073e67cf9c56b3307d90bd8d4.tar.xz
org.eclipse.windowbuilder-c7961f3b854a808073e67cf9c56b3307d90bd8d4.zip
Bug 552936 - Cut and Paste a widget can't keep the original name.
Change-Id: I46e2b66be764e8b7f15e4423eee84661dc388dfa Signed-off-by: ningyu <yuning@msn.com>
-rw-r--r--org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/clipboard/JavaInfoMemento.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/clipboard/JavaInfoMemento.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/clipboard/JavaInfoMemento.java
index 5cc14138..fbf593ab 100644
--- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/clipboard/JavaInfoMemento.java
+++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/clipboard/JavaInfoMemento.java
@@ -17,6 +17,7 @@ import org.eclipse.wb.core.model.JavaInfo;
import org.eclipse.wb.internal.core.model.JavaInfoUtils;
import org.eclipse.wb.internal.core.model.creation.CreationSupport;
import org.eclipse.wb.internal.core.model.creation.IImplicitCreationSupport;
+import org.eclipse.wb.internal.core.model.variable.NamesManager;
import org.eclipse.wb.internal.core.utils.ast.AstEditor;
import org.eclipse.wb.internal.core.utils.check.Assert;
import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils;
@@ -99,6 +100,9 @@ public class JavaInfoMemento implements Serializable {
private final String m_componentClassName;
private final IClipboardCreationSupport m_creationSupport;
private final List<ClipboardCommand> m_commands = Lists.newArrayList();
+
+ //the variable.field name must be kept, it's not contained in javaInfo created during paste.
+ private String m_variableName;
////////////////////////////////////////////////////////////////////////////
//
@@ -110,6 +114,7 @@ public class JavaInfoMemento implements Serializable {
// creation
{
m_creationSupport = javaInfo.getCreationSupport().getClipboard();
+ m_variableName = getVariableName(javaInfo);
Assert.isNotNull(m_creationSupport, "No clipboard CreationSupport for %s", javaInfo);
cleanUpAnonymous(m_creationSupport);
}
@@ -197,6 +202,7 @@ public class JavaInfoMemento implements Serializable {
// create JavaInfo
m_javaInfo = JavaInfoUtils.createJavaInfo(editor, componentClass, creationSupport);
m_javaInfo.putArbitraryValue(KEY_MEMENTO, this);
+ JavaInfoUtils.setParameter(m_javaInfo, NamesManager.NAME_PARAMETER, m_variableName);
}
return m_javaInfo;
}
@@ -226,4 +232,18 @@ public class JavaInfoMemento implements Serializable {
command.execute(m_javaInfo);
}
}
+
+ /**
+ * Get the variable field name of the JavaInfo.
+ *
+ * @param javaInfo The JavaInfo will be queried.
+ *
+ * @return The variable field name.
+ */
+ private String getVariableName(JavaInfo javaInfo) {
+ if (javaInfo != null) {
+ return javaInfo.getVariableSupport().getName();
+ }
+ return null;
+ }
}

Back to the top