From 0d2ef6de03d4a801c76064d6064607f5f00fa2a8 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 4 Jun 2020 17:00:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-32149=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E3=80=91@harrison=E4=B8=A4=E4=B8=AA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=BF=9B=E8=A1=8C=E6=8B=96=E5=85=A5=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=A2=84=E8=A7=88=E5=BE=88=E5=A5=87=E6=80=AA=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E9=BB=98=E8=AE=A4=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E4=B8=8D=E6=BB=A1=E8=B6=B3=E8=A6=81=E6=B1=82=E3=80=82=20?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E7=BB=84=E4=BB=B6=E5=A4=96=E9=9D=A2=E4=BC=9A?= =?UTF-8?q?=E5=B5=8C=E5=A5=97=20TitileLayout=20=E6=89=80=E4=BB=A5=E6=A0=B9?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BE=9D=E6=97=A7=E4=BF=9D=E6=8C=81=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E9=80=BB=E8=BE=91=E3=80=82=20=E5=AD=90?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BD=BF=E7=94=A8=E7=BB=84=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E9=80=92=E5=A2=9E=E7=9A=84=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/beans/models/AddingModel.java | 57 +--------- .../designer/beans/models/ModelUtils.java | 101 ++++++++++++++++++ .../beans/models/AddingModelTest.java | 95 +++++++++++----- 3 files changed, 168 insertions(+), 85 deletions(-) create mode 100644 designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index 833101750b..bf9b708fe1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -6,17 +6,11 @@ import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.mainframe.FormDesigner; import com.fr.design.utils.ComponentUtils; -import com.fr.form.main.Form; -import com.fr.form.ui.container.WTitleLayout; import com.fr.general.ComparatorUtils; import java.awt.Rectangle; -import java.util.HashSet; -import java.util.Set; /** * 添加状态下的model @@ -44,7 +38,7 @@ public class AddingModel { * @param designer 设计器 */ public void instantiateCreator(FormDesigner designer) { - renameWidgetName(designer.getTarget(), creator); + ModelUtils.recursiveRenameWidgetName(designer.getTarget(), creator); ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); adapter.initialize(); creator.addNotify(); @@ -68,55 +62,6 @@ public class AddingModel { currentY = -this.creator.getHeight(); } - /** - * 防止冲突,重命名 XCreator 内部的 widget - * - * @param form 表单 - * @param xCreator 创建器 - */ - private static void renameWidgetName(Form form, XCreator xCreator) { - - Set nameSpace = new HashSet<>(); - recursiveRenameWidgetName(form, xCreator, nameSpace); - } - - private static void recursiveRenameWidgetName(Form form, XCreator xCreator, Set nameSpace) { - - String creatorName = uniqueName(form, xCreator, nameSpace); - if (xCreator.toData() instanceof WTitleLayout) { - XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize()); - xwTitleLayout.resetCreatorName(creatorName); - return; - } - xCreator.resetCreatorName(creatorName); - int count = xCreator.getComponentCount(); - for (int a = 0; a < count; a++) { - if (xCreator.getComponent(a) instanceof XCreator) { - XCreator child = (XCreator) xCreator.getComponent(a); - recursiveRenameWidgetName(form, child, nameSpace); - } - - } - } - - /** - * 组件命名规则 - */ - public static String uniqueName(Form form, XCreator x, Set nameSpace) { - - String def = x.createDefaultName(); - if (x.acceptType(XWParameterLayout.class)) { - return def; - } - int i = 0; - String name = def + i; - while (form.isNameExist(name) || nameSpace.contains(name)) { - i++; - name = def + i; - } - return name; - } - public int getCurrentX() { return currentX; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java new file mode 100644 index 0000000000..687aaf77bf --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java @@ -0,0 +1,101 @@ +package com.fr.design.designer.beans.models; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.form.main.Form; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.stable.StringUtils; + +import java.util.HashSet; +import java.util.Set; + +/** + * created by Harrison on 2020/06/04 + **/ +public class ModelUtils { + + /** + * 防止冲突,重命名 XCreator 内部的 widget + * + * @param form 表单 + * @param xCreator 创建器 + */ + public static void recursiveRenameWidgetName(Form form, XCreator xCreator) { + + Set nameSpace = new HashSet<>(); + //重命名根名字 + //这里主要是为了兼容老的命名规则。 + renameRootName(form, xCreator, nameSpace); + //这里要用新的命名规则 + recursiveRenameChildName(form, xCreator, nameSpace); + } + + private static void renameRootName(Form form, XCreator xCreator, Set nameSpace) { + + String creatorName = getNameByXCreator(form, xCreator, nameSpace); + xCreator.resetCreatorName(creatorName); + } + + private static void recursiveRenameChildName(Form form, XCreator xCreator, Set nameSpace) { + + int count = xCreator.getComponentCount(); + for (int a = 0; a < count; a++) { + if (xCreator.getComponent(a) instanceof XCreator) { + + XCreator child = (XCreator) xCreator.getComponent(a); + String childName = getNameByWidget(form, child, nameSpace); + if (child.toData() instanceof WTitleLayout) { + XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) child.toData(), child.getSize()); + xwTitleLayout.resetCreatorName(childName); + continue; + } + child.resetCreatorName(childName); + recursiveRenameChildName(form, child, nameSpace); + } + } + } + + /** + * 组件命名规则 + * 根据组件的名字,如果组件没有名字,就用 XCreator 的对应名字 + */ + private static String getNameByWidget(Form form, XCreator xCreator, Set nameSpace) { + + Widget widget = xCreator.toData(); + String name = widget.getWidgetName(); + //没有 widgetName, 就创建默认的 + if (StringUtils.isEmpty(name)) { + return getNameByXCreator(form, xCreator, nameSpace); + } + return getNameByDefault(form, xCreator, nameSpace, name); + } + + /** + * 组件命名规则 + * 根据组件的默认名 + */ + private static String getNameByXCreator(Form form, XCreator x, Set nameSpace) { + + String defaultName = x.createDefaultName(); + return getNameByDefault(form, x, nameSpace, defaultName); + } + + private static String getNameByDefault(Form form, XCreator xCreator, Set nameSpace, String defaultName) { + + String name = defaultName; + if (xCreator.acceptType(XWParameterLayout.class)) { + return name; + } + int i = 0; + //保留第一次的值 + String raw = name; + while (form.isNameExist(name) || nameSpace.contains(name)) { + name = raw + i; + i++; + } + nameSpace.add(name); + return name; + } +} diff --git a/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java b/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java index 1487eb574a..78d7f578d9 100644 --- a/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java +++ b/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java @@ -5,53 +5,90 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.mainframe.FormDesigner; import com.fr.form.main.Form; import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WTitleLayout; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; import javax.swing.JComponent; import java.awt.Dimension; +import java.awt.Rectangle; import java.beans.IntrospectionException; public class AddingModelTest { @Test public void testInstantiateCreator() throws Exception { - - ChartEditor chartEditor = new ChartEditor(); - chartEditor.setWidgetName("test01"); - XCreator xCreator = new XCreator(chartEditor, new Dimension(20, 20)) { - @Override - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[0]; - } - - @Override - protected JComponent initEditor() { - return null; - } - - @Override - protected void initXCreatorProperties() { - } - - @Override - public String createDefaultName() { - return "test"; - } - }; - AddingModel addingModel = new AddingModel(xCreator, 20, 20); - + + Dimension dimension = new Dimension(20, 20); + + ChartEditor chartEditor1 = new ChartEditor(); + chartEditor1.setWidgetName("test01"); + XCreator xCreator1 = new DemoCreator(chartEditor1, dimension, "test"); + + ChartEditor chartEditor2 = new ChartEditor(); + chartEditor2.setWidgetName("test02"); + XCreator xCreator2 = new DemoCreator(chartEditor2, dimension, "test02"); + xCreator1.add(xCreator2); + + ChartEditor chartEditor3 = new ChartEditor(); + chartEditor3.setWidgetName("test03"); + WAbsoluteLayout.BoundsWidget boundsWidget = new WAbsoluteLayout.BoundsWidget(chartEditor3, new Rectangle(dimension)); + WTitleLayout wTitleLayout03 = new WTitleLayout(); + wTitleLayout03.addWidget(boundsWidget); + DemoCreator xCreator3 = new DemoCreator(wTitleLayout03, dimension, "test03"); + xCreator1.add(xCreator3); + + AddingModel addingModel = new AddingModel(xCreator1, 20, 20); + Form form = EasyMock.mock(Form.class); - EasyMock.expect(form.isNameExist("test0")).andReturn(true).once(); + EasyMock.expect(form.isNameExist("test")).andReturn(true).once(); + EasyMock.expect(form.isNameExist("test03")).andReturn(true).once(); EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes(); EasyMock.replay(form); - + FormDesigner mock = EasyMock.mock(FormDesigner.class); EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes(); EasyMock.replay(mock); - + addingModel.instantiateCreator(mock); - Assert.assertEquals("test1", xCreator.toData().getWidgetName()); + //后接0 + Assert.assertEquals("test0", xCreator1.toData().getWidgetName()); + //直接返回 + Assert.assertEquals("test02", xCreator2.toData().getWidgetName()); + //后接0 + Assert.assertEquals("test030", xCreator3.toData().getWidgetName()); + } + + private static class DemoCreator extends XCreator { + + private String widgetName; + + public DemoCreator(Widget ob, Dimension initSize, String widgetName) { + super(ob, initSize); + this.widgetName = widgetName; + } + + @Override + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[0]; + } + + @Override + protected JComponent initEditor() { + return null; + } + + @Override + protected void initXCreatorProperties() { + + } + + @Override + public String createDefaultName() { + return this.widgetName; + } } } \ No newline at end of file From 97649d7f517ddc675baa6fdb1a633f85ddcf6129 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 4 Jun 2020 19:27:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-32149=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E3=80=91@harrison=E4=B8=A4=E4=B8=AA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=BF=9B=E8=A1=8C=E6=8B=96=E5=85=A5=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=A2=84=E8=A7=88=E5=BE=88=E5=A5=87=E6=80=AA=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/beans/models/AddingModel.java | 26 ++++- .../designer/beans/models/ModelUtils.java | 101 ------------------ 2 files changed, 21 insertions(+), 106 deletions(-) delete mode 100644 designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java index bf9b708fe1..9285b35ca7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java @@ -6,6 +6,7 @@ import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.mainframe.FormDesigner; import com.fr.design.utils.ComponentUtils; import com.fr.general.ComparatorUtils; @@ -25,20 +26,22 @@ public class AddingModel { private boolean added; public AddingModel(FormDesigner designer, XCreator xCreator) { + String creatorName = getXCreatorName(designer, xCreator); this.creator = xCreator; - instantiateCreator(designer); + instantiateCreator(designer, creatorName); // 初始的时候隐藏该组件的图标 currentY = -this.creator.getWidth(); currentX = -this.creator.getHeight(); } /** - * 初始化创建器 + * 待说明 * - * @param designer 设计器 + * @param designer 设计器 + * @param creatorName 组件名 */ - public void instantiateCreator(FormDesigner designer) { - ModelUtils.recursiveRenameWidgetName(designer.getTarget(), creator); + public void instantiateCreator(FormDesigner designer, String creatorName) { + creator.toData().setWidgetName(creatorName); ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); adapter.initialize(); creator.addNotify(); @@ -62,6 +65,19 @@ public class AddingModel { currentY = -this.creator.getHeight(); } + public String getXCreatorName(FormDesigner designer, XCreator x) { + String def = x.createDefaultName(); + if (x.acceptType(XWParameterLayout.class)) { + return def; + } + int i = 0; + while (designer.getTarget().isNameExist(def + i)) { + i++; + } + return def + i; + } + + public int getCurrentX() { return currentX; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java deleted file mode 100644 index 687aaf77bf..0000000000 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtils.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.fr.design.designer.beans.models; - -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWTitleLayout; -import com.fr.form.main.Form; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WTitleLayout; -import com.fr.stable.StringUtils; - -import java.util.HashSet; -import java.util.Set; - -/** - * created by Harrison on 2020/06/04 - **/ -public class ModelUtils { - - /** - * 防止冲突,重命名 XCreator 内部的 widget - * - * @param form 表单 - * @param xCreator 创建器 - */ - public static void recursiveRenameWidgetName(Form form, XCreator xCreator) { - - Set nameSpace = new HashSet<>(); - //重命名根名字 - //这里主要是为了兼容老的命名规则。 - renameRootName(form, xCreator, nameSpace); - //这里要用新的命名规则 - recursiveRenameChildName(form, xCreator, nameSpace); - } - - private static void renameRootName(Form form, XCreator xCreator, Set nameSpace) { - - String creatorName = getNameByXCreator(form, xCreator, nameSpace); - xCreator.resetCreatorName(creatorName); - } - - private static void recursiveRenameChildName(Form form, XCreator xCreator, Set nameSpace) { - - int count = xCreator.getComponentCount(); - for (int a = 0; a < count; a++) { - if (xCreator.getComponent(a) instanceof XCreator) { - - XCreator child = (XCreator) xCreator.getComponent(a); - String childName = getNameByWidget(form, child, nameSpace); - if (child.toData() instanceof WTitleLayout) { - XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) child.toData(), child.getSize()); - xwTitleLayout.resetCreatorName(childName); - continue; - } - child.resetCreatorName(childName); - recursiveRenameChildName(form, child, nameSpace); - } - } - } - - /** - * 组件命名规则 - * 根据组件的名字,如果组件没有名字,就用 XCreator 的对应名字 - */ - private static String getNameByWidget(Form form, XCreator xCreator, Set nameSpace) { - - Widget widget = xCreator.toData(); - String name = widget.getWidgetName(); - //没有 widgetName, 就创建默认的 - if (StringUtils.isEmpty(name)) { - return getNameByXCreator(form, xCreator, nameSpace); - } - return getNameByDefault(form, xCreator, nameSpace, name); - } - - /** - * 组件命名规则 - * 根据组件的默认名 - */ - private static String getNameByXCreator(Form form, XCreator x, Set nameSpace) { - - String defaultName = x.createDefaultName(); - return getNameByDefault(form, x, nameSpace, defaultName); - } - - private static String getNameByDefault(Form form, XCreator xCreator, Set nameSpace, String defaultName) { - - String name = defaultName; - if (xCreator.acceptType(XWParameterLayout.class)) { - return name; - } - int i = 0; - //保留第一次的值 - String raw = name; - while (form.isNameExist(name) || nameSpace.contains(name)) { - name = raw + i; - i++; - } - nameSpace.add(name); - return name; - } -} From 955559bb4c71dc7c099c1ded390a2838ab1f3fa3 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 4 Jun 2020 19:49:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-32149=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E3=80=91@harrison=E4=B8=A4=E4=B8=AA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=BF=9B=E8=A1=8C=E6=8B=96=E5=85=A5=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E9=A2=84=E8=A7=88=E5=BE=88=E5=A5=87=E6=80=AA=20?= =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=B2=A1=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A=E5=AE=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beans/models/AddingModelTest.java | 94 ------------------- 1 file changed, 94 deletions(-) delete mode 100644 designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java diff --git a/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java b/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java deleted file mode 100644 index 78d7f578d9..0000000000 --- a/designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.fr.design.designer.beans.models; - -import com.fr.design.designer.creator.CRPropertyDescriptor; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.mainframe.FormDesigner; -import com.fr.form.main.Form; -import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WAbsoluteLayout; -import com.fr.form.ui.container.WTitleLayout; -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Test; - -import javax.swing.JComponent; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.beans.IntrospectionException; - -public class AddingModelTest { - - @Test - public void testInstantiateCreator() throws Exception { - - Dimension dimension = new Dimension(20, 20); - - ChartEditor chartEditor1 = new ChartEditor(); - chartEditor1.setWidgetName("test01"); - XCreator xCreator1 = new DemoCreator(chartEditor1, dimension, "test"); - - ChartEditor chartEditor2 = new ChartEditor(); - chartEditor2.setWidgetName("test02"); - XCreator xCreator2 = new DemoCreator(chartEditor2, dimension, "test02"); - xCreator1.add(xCreator2); - - ChartEditor chartEditor3 = new ChartEditor(); - chartEditor3.setWidgetName("test03"); - WAbsoluteLayout.BoundsWidget boundsWidget = new WAbsoluteLayout.BoundsWidget(chartEditor3, new Rectangle(dimension)); - WTitleLayout wTitleLayout03 = new WTitleLayout(); - wTitleLayout03.addWidget(boundsWidget); - DemoCreator xCreator3 = new DemoCreator(wTitleLayout03, dimension, "test03"); - xCreator1.add(xCreator3); - - AddingModel addingModel = new AddingModel(xCreator1, 20, 20); - - Form form = EasyMock.mock(Form.class); - EasyMock.expect(form.isNameExist("test")).andReturn(true).once(); - EasyMock.expect(form.isNameExist("test03")).andReturn(true).once(); - EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes(); - EasyMock.replay(form); - - FormDesigner mock = EasyMock.mock(FormDesigner.class); - EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes(); - EasyMock.replay(mock); - - addingModel.instantiateCreator(mock); - //后接0 - Assert.assertEquals("test0", xCreator1.toData().getWidgetName()); - //直接返回 - Assert.assertEquals("test02", xCreator2.toData().getWidgetName()); - //后接0 - Assert.assertEquals("test030", xCreator3.toData().getWidgetName()); - } - - private static class DemoCreator extends XCreator { - - private String widgetName; - - public DemoCreator(Widget ob, Dimension initSize, String widgetName) { - super(ob, initSize); - this.widgetName = widgetName; - } - - @Override - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[0]; - } - - @Override - protected JComponent initEditor() { - return null; - } - - @Override - protected void initXCreatorProperties() { - - } - - @Override - public String createDefaultName() { - return this.widgetName; - } - } -} \ No newline at end of file