Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -771,20 +771,20 @@ public void run(ComponentInfo copy) throws Exception {
*/
@Test
public void test_getSource_forCreationId() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton(boolean b) {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <creation>",
" <source><![CDATA[new test.MyButton(false)]]></source>",
" </creation>",
" <creation id='true'>",
" <source><![CDATA[new test.MyButton(true)]]></source>",
" </creation>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton(boolean b) {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<creation>
<source><![CDATA[new test.MyButton(false)]]></source>
</creation>
<creation id="true">
<source><![CDATA[new test.MyButton(true)]]></source>
</creation>
</component>""");
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
parseContainer(lines);
Expand All @@ -809,11 +809,11 @@ public void test_getSource_forCreationId() throws Exception {
*/
@Test
public void test_getSource_forSource() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton(boolean b) {",
" }",
"}"}, null);
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton(boolean b) {
}
}""", null);
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
parseContainer(lines);
Expand All @@ -827,18 +827,18 @@ public void test_getSource_forSource() throws Exception {

@Test
public void test_CREATE_noInvocations() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton() {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <creation>",
" <source><![CDATA[new test.MyButton()]]></source>",
" <invocation signature='setEnabled(boolean)'><![CDATA[false]]></invocation>",
" </creation>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton() {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<creation>
<source><![CDATA[new test.MyButton()]]></source>
<invocation signature="setEnabled(boolean)"><![CDATA[false]]></invocation>
</creation>
</component>""");
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
ContainerInfo panel = parseContainer(lines1);
Expand Down Expand Up @@ -879,18 +879,18 @@ public void test_CREATE_noInvocations() throws Exception {

@Test
public void test_CREATE_addInvocations() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton() {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <creation>",
" <source><![CDATA[new test.MyButton()]]></source>",
" <invocation signature='setEnabled(boolean)'><![CDATA[false]]></invocation>",
" </creation>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton() {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<creation>
<source><![CDATA[new test.MyButton()]]></source>
<invocation signature="setEnabled(boolean)"><![CDATA[false]]></invocation>
</creation>
</component>""");
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
ContainerInfo panel = parseContainer(lines1);
Expand Down Expand Up @@ -918,19 +918,19 @@ public void test_CREATE_addInvocations() throws Exception {

@Test
public void test_template_index() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton(String value) {",
" }",
" public void setValue(String value) {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <creation>",
" <source><![CDATA[new test.MyButton(\"value_%index%\")]]></source>",
" </creation>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton(String value) {
}
public void setValue(String value) {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<creation>
<source><![CDATA[new test.MyButton(\"value_%index%\")]]></source>
</creation>
</component>""");
String[] lines1 = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
ContainerInfo panel = parseContainer(lines1);
Expand Down Expand Up @@ -1020,22 +1020,22 @@ public void test_getAssociation_noParent() throws Exception {
*/
@Test
public void test_getAssociation_hasParent() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton(JPanel parent) {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <creation>",
" <source><![CDATA[new test.MyButton(%parent%)]]></source>",
" </creation>",
" <constructors>",
" <constructor>",
" <parameter type='javax.swing.JPanel' parent='true'/>",
" </constructor>",
" </constructors>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton(JPanel parent) {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<creation>
<source><![CDATA[new test.MyButton(%parent%)]]></source>
</creation>
<constructors>
<constructor>
<parameter type="javax.swing.JPanel" parent="true"/>
</constructor>
</constructors>
</component>""");
String[] lines = {"public class Test extends JPanel {", " public Test() {", " }", "}"};
// parse
parseContainer(lines);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -108,19 +108,19 @@ public static void tearDownClass() throws Exception {
//
////////////////////////////////////////////////////////////////////////////
private ContainerInfo createDefaultProjectContents() throws Exception {
setJavaContentSrc("test", "TestPanel", new String[]{
"public class TestPanel extends JPanel {",
" public TestPanel(){",
" }",
" protected void setTestProperty(int value){",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <property id='setTestProperty(int)'>",
" <defaultValue value='7'/>",
" </property>",
"</component>"});
setJavaContentSrc("test", "TestPanel", """
public class TestPanel extends JPanel {
public TestPanel(){
}
protected void setTestProperty(int value){
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<property id="setTestProperty(int)">
<defaultValue value="7"/>
</property>
</component>""");
return parseContainer(
"// filler filler filler",
"public class Test extends TestPanel {",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -2685,20 +2685,20 @@ public void test_dontVisit_AnonymouseClassDeclaration() throws Exception {
*/
@Test
public void test_createAssociateAndInvokeMethod() throws Exception {
setJavaContentSrc("test", "MyButton", new String[]{
"public class MyButton extends JButton {",
" public MyButton(Container container) {",
" container.add(this);",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <constructors>",
" <constructor>",
" <parameter type='java.awt.Container' parent='true'/>",
" </constructor>",
" </constructors>",
"</component>"});
setJavaContentSrc("test", "MyButton", """
public class MyButton extends JButton {
public MyButton(Container container) {
container.add(this);
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<constructors>
<constructor>
<parameter type="java.awt.Container" parent="true"/>
</constructor>
</constructors>
</component>""");
// parse
ContainerInfo panel =
parseContainer(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -1378,17 +1378,17 @@ public void test_AbstractButton_setModel_null() throws Exception {
*/
@Test
public void test_preferredRoot_singlePreferred() throws Exception {
setJavaContentSrc("test", "MyPanel", new String[]{
"public class MyPanel extends JPanel {",
" public MyPanel() {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <parameters>",
" <parameter name='parser.preferredRoot'>true</parameter>",
" </parameters>",
"</component>"});
setJavaContentSrc("test", "MyPanel", """
public class MyPanel extends JPanel {
public MyPanel() {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<parameters>
<parameter name="parser.preferredRoot">true</parameter>
</parameters>
</component>""");
// standard JPanel has bigger hierarchy, so without "parser.preferredRoot" is would be selected
parseContainer(
"public class Test {",
Expand All @@ -1411,17 +1411,17 @@ public void test_preferredRoot_singlePreferred() throws Exception {
*/
@Test
public void test_preferredRoot_twoPreferred() throws Exception {
setJavaContentSrc("test", "MyPanel", new String[]{
"public class MyPanel extends JPanel {",
" public MyPanel() {",
" }",
"}"}, new String[]{
"<?xml version='1.0' encoding='UTF-8'?>",
"<component xmlns='http://www.eclipse.org/wb/WBPComponent'>",
" <parameters>",
" <parameter name='parser.preferredRoot'>true</parameter>",
" </parameters>",
"</component>"});
setJavaContentSrc("test", "MyPanel", """
public class MyPanel extends JPanel {
public MyPanel() {
}
}""", """
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.eclipse.org/wb/WBPComponent">
<parameters>
<parameter name="parser.preferredRoot">true</parameter>
</parameters>
</component>""");
parseContainer(
"public class Test {",
" public static void main(String[] args) {",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -39,25 +39,23 @@ public class ComponentClassPropertyTest extends SwingModelTest {
*/
@Test
public void test_noForNullClass() throws Exception {
ContainerInfo panel =
parseContainer(
"public class Test extends JPanel {",
" public Test() {",
" setLayout(null);",
" }",
"}");
ContainerInfo panel = parseContainer("""
public class Test extends JPanel {
public Test() {
setLayout(null);
}
}""");
assertNull(panel.getLayout().getPropertyByTitle("Class"));
}

@Test
public void test_property() throws Exception {
ContainerInfo panel =
parseContainer(
"// filler filler filler",
"public class Test extends JPanel {",
" public Test() {",
" }",
"}");
ContainerInfo panel = parseContainer("""
// filler filler filler
public class Test extends JPanel {
public Test() {
}
}""");
// property
ComponentClassProperty property = (ComponentClassProperty) panel.getPropertyByTitle("Class");
assertNotNull(property);
Expand Down
Loading
Loading