diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/SwingTests.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/SwingTests.java index 1ef596315..515c74c4e 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/SwingTests.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/SwingTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. + * Copyright (c) 2011, 2025 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 @@ -12,7 +12,6 @@ *******************************************************************************/ package org.eclipse.wb.tests.designer.swing; -import org.eclipse.wb.tests.designer.swing.ams.AmsTests; import org.eclipse.wb.tests.designer.swing.laf.LookAndFeelTest; import org.eclipse.wb.tests.designer.swing.model.ModelTests; import org.eclipse.wb.tests.designer.swing.swingx.SwingXTests; @@ -29,7 +28,6 @@ ConvertersTest.class, CustomizeTest.class, ModelTests.class, - AmsTests.class, SwingXTests.class, // WaitForMemoryProfilerTest.class, }) diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/AmsTests.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/AmsTests.java deleted file mode 100644 index bbab4fc63..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/AmsTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Google, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * https://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Google, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.wb.tests.designer.swing.ams; - -import org.junit.platform.suite.api.SelectClasses; -import org.junit.platform.suite.api.Suite; - -/** - * All AMS tests. - * - * @author scheglov_ke - */ -@Suite -@SelectClasses({ - PropertyTweaksTest.class, - VarmenuLayoutTest.class -}) -public class AmsTests { -} diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/PropertyTweaksTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/PropertyTweaksTest.java deleted file mode 100644 index f68454879..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/PropertyTweaksTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2025 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 - * https://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Google, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.wb.tests.designer.swing.ams; - -import org.eclipse.wb.internal.core.model.property.Property; -import org.eclipse.wb.internal.core.model.property.category.PropertyCategory; -import org.eclipse.wb.internal.core.model.util.PropertyUtils; -import org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils; -import org.eclipse.wb.internal.swing.model.component.ComponentInfo; -import org.eclipse.wb.internal.swing.model.component.ContainerInfo; -import org.eclipse.wb.tests.designer.TestUtils; -import org.eclipse.wb.tests.designer.core.annotations.DisposeProjectAfter; -import org.eclipse.wb.tests.designer.swing.SwingGefTest; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * We should tweak properties for AMS components: group them and change {@link PropertyCategory}. - * - * @author scheglov_ke - */ -public class PropertyTweaksTest extends SwingGefTest { - //////////////////////////////////////////////////////////////////////////// - // - // Exit zone :-) XXX - // - //////////////////////////////////////////////////////////////////////////// - public void _test_exit() throws Exception { - System.exit(0); - } - - //////////////////////////////////////////////////////////////////////////// - // - // Tests - // - //////////////////////////////////////////////////////////////////////////// - @Disabled - @Test - public void test_Groups_fromBundle() throws Exception { - prepareParse_MyButton(); - assertEquals(2, m_propertyTable.forTests_getPropertiesCount()); - // check "AMS" group - { - Property propertyAMS = m_propertyTable.forTests_getProperty(0); - assertEquals("AMS", propertyAMS.getTitle()); - Property[] subProperties = getSubProperties(propertyAMS); - assertNotNull(PropertyUtils.getByTitle(subProperties, "buttonColor")); - } - // check "Other" group - { - Property propertyOther = m_propertyTable.forTests_getProperty(1); - assertEquals("Other", propertyOther.getTitle()); - Property[] subProperties = getSubProperties(propertyOther); - assertNotNull(PropertyUtils.getByTitle(subProperties, "text")); - } - } - - @DisposeProjectAfter - @Disabled - @Test - public void test_Groups_fromJar() throws Exception { - // add JAR - { - String jarPath = - TestUtils.createTemporaryJar( - "wbp-meta/AMS.property-tweaks.xml", - getSource( - "", - " ", - " ", - " ", - "")); - ProjectUtils.addExternalJar(m_javaProject, jarPath, null); - } - // parse - prepareParse_MyButton(); - assertEquals(1, m_propertyTable.forTests_getPropertiesCount()); - // check "ALL" group - { - Property propertyALL = m_propertyTable.forTests_getProperty(0); - assertEquals("ALL", propertyALL.getTitle()); - Property[] subProperties = getSubProperties(propertyALL); - assertNotNull(PropertyUtils.getByTitle(subProperties, "buttonColor")); - } - } - - @Disabled - @Test - public void test_categories() throws Exception { - prepareParse_MyButton(); - // expand "Other" group - m_propertyTable.forTests_expand(1); - // "Variable" property should be marked as "advanced-really", not not visible - assertFalse(hasPropertyWithTitle("Variable")); - // enabled "advanced" displaying, so show "Variable" property - m_propertyTable.setShowAdvancedProperties(true); - assertTrue(hasPropertyWithTitle("Variable")); - } - - private boolean hasPropertyWithTitle(String title) { - int count = m_propertyTable.forTests_getPropertiesCount(); - for (int i = 0; i < count; i++) { - Property property = m_propertyTable.forTests_getProperty(i); - if (property.getTitle().equals(title)) { - return true; - } - } - return false; - } - - //////////////////////////////////////////////////////////////////////////// - // - // Utils - // - //////////////////////////////////////////////////////////////////////////// - private ComponentInfo prepareParse_MyButton() throws Exception { - prepare_MyButton(); - ComponentInfo button = parse_MyButton(); - canvas.select(button); - return button; - } - - private void prepare_MyButton() throws Exception { - setFileContentSrc( - "ams/zpointcs/MyButton.java", - getSource( - "package ams.zpointcs;", - "import java.awt.*;", - "import javax.swing.*;", - "public class MyButton extends JButton {", - " public void setButtonColor(Color color) {", - " }", - "}")); - waitForAutoBuild(); - } - - private ComponentInfo parse_MyButton() throws Exception { - ContainerInfo panel = openContainer(""" - import ams.zpointcs.MyButton; - public class Test extends JPanel { - public Test() { - MyButton button = new MyButton(); - add(button); - } - }"""); - panel.refresh(); - ComponentInfo button = panel.getChildrenComponents().get(0); - return button; - } -} \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuConstraints.txt b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuConstraints.txt deleted file mode 100644 index 60d38aa4b..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuConstraints.txt +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * AMS Engineering Project: ZPointCS Project number: 84912700 Documentation: - ******************************************************************************/ - -package ams.zpointcs.components; - -/** - * Constraint class for an X-Y layout for custom panels. - * - * @author desa - * @version 0.0 2001-04-26 desa initial version - */ -public class VarmenuConstraints implements Cloneable, java.io.Serializable -{ - - /** - * - */ - private static final long serialVersionUID = -304267304358008776L; - int x; - int y; - int width; // <= 0 means use the components's preferred size - int height; // <= 0 means use the components's preferred size - - - /** - * Constructor. - */ - public VarmenuConstraints() - { - this(0, 0, 0, 0); - } - - - /** - * Constructor. - */ - public VarmenuConstraints(final int x, final int y, final int width, - final int height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - - public int getX() - { - return x; - } - - - public void setX(final int x) - { - this.x = x; - } - - - public int getY() - { - return y; - } - - - public void setY(final int y) - { - this.y = y; - } - - - public int getWidth() - { - return width; - } - - - public void setWidth(final int width) - { - this.width = width; - } - - - public int getHeight() - { - return height; - } - - - public void setHeight(final int height) - { - this.height = height; - } - - - /** - * Returns the hashcode for this VarmenuConstraints. - */ - public int hashCode() - { - return x ^ (y * 37) ^ (width * 43) ^ (height * 47); - } - - - /** - * Checks whether two VarmenuConstraints are equal. - */ - public boolean equals(final Object that) - { - if (that instanceof VarmenuConstraints) - { - final VarmenuConstraints other = (VarmenuConstraints) that; - return other.x == x && other.y == y && other.width == width - && other.height == height; - } - return false; - } - - - /** - * clone() - */ - public Object clone() - { - return new VarmenuConstraints(x, y, width, height); - } - - - /** - * toString() - */ - public String toString() - { - return "VarmenuConstraints[" + x + "," + y + "," + width + "," + height - + "]"; - } -} \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayout.txt b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayout.txt deleted file mode 100644 index d7e13cefb..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayout.txt +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * AMS Engineering Project: ZPointCS Project number: 84912700 Documentation: - ******************************************************************************/ - -package ams.zpointcs.components; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.LayoutManager2; -import java.awt.Rectangle; -import java.util.Hashtable; - -/** - * Class for an X-Y layout for custom panels. - * - * @author desa - * @version 0.0 2001-04-26 desa initial version - */ -public class VarmenuLayout implements LayoutManager2, java.io.Serializable -{ - - private static final long serialVersionUID = 200L; - - int width; // <= 0 means use the container's preferred size - int height; // <= 0 means use the container's preferred size - - - /** - * Constructor. - */ - public VarmenuLayout() - { - } - - - /** - * Constructor. - */ - public VarmenuLayout(final int width, final int height) - { - this.width = width; - this.height = height; - } - - - public int getWidth() - { - return width; - } - - - public void setWidth(final int width) - { - this.width = width; - } - - - public int getHeight() - { - return height; - } - - - public void setHeight(final int height) - { - this.height = height; - } - - - public String toString() - { - return "VarmenuLayout" + "[width=" + width + ",height=" + height + "]"; //NORES - } - - - // LayoutManager interface - - public void addLayoutComponent(final String name, final Component component) - { - //System.err.println("VarmenuLayout.addLayoutComponent(" + name + "," + - // component + ")"); - } - - - public void removeLayoutComponent(final Component component) - { - //System.err.println("VarmenuLayout.removeLayoutComponent(" + component + - // ")"); - info.remove(component); - } - - - public Dimension preferredLayoutSize(final Container target) - { - return getLayoutSize(target, true); - } - - - public Dimension minimumLayoutSize(final Container target) - { - return getLayoutSize(target, false); - } - - - public void layoutContainer(final Container target) - { - final Insets insets = target.getInsets(); - - final int count = target.getComponentCount(); - - //System.err.println("VarmenuLayout.layoutContainer(" + target + ") - // insets=" + insets + " count=" + count); - - for (int i = 0; i < count; i++) - { - final Component component = target.getComponent(i); - if (component.isVisible()) - { - final Rectangle r = getComponentBounds(component, true); - component.setBounds(insets.left + r.x, insets.top + r.y, r.width, - r.height); - } - } - } - - - // LayoutManager2 interface - - public void addLayoutComponent(final Component component, - final Object constraints) - { - //System.err.println("VarmenuLayout.addLayoutComponent(" + component + "," - // + constraints + ")"); - if (constraints instanceof VarmenuConstraints) - { - info.put(component, constraints); - } - } - - - public Dimension maximumLayoutSize(final Container target) - { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - } - - - public float getLayoutAlignmentX(final Container target) - { - return 0.5f; - } - - - public float getLayoutAlignmentY(final Container target) - { - return 0.5f; - } - - - public void invalidateLayout(final Container target) - { - } - - // internal - - Hashtable info = new Hashtable(); // leave this as non-transient - static final VarmenuConstraints defaultConstraints = new VarmenuConstraints(); - - - private Rectangle getComponentBounds(final Component component, - final boolean doPreferred) - { - VarmenuConstraints constraints = (VarmenuConstraints) info.get(component); - - //System.err.println("VarmenuLayout.getComponentBounds(" + component + "," - // + doPreferred + ") constraints=" + constraints + " width=" + width + " - // height=" + height); - - if (constraints == null) - { - constraints = defaultConstraints; - } - - final Rectangle r = new Rectangle(constraints.x, constraints.y, - constraints.width, constraints.height); - - if (r.width <= 0 || r.height <= 0) - { - final Dimension d = doPreferred ? component.getPreferredSize() - : component.getMinimumSize(); - if (r.width <= 0) - { - r.width = d.width; - } - if (r.height <= 0) - { - r.height = d.height; - } - } - return r; - } - - - private Dimension getLayoutSize(final Container target, - final boolean doPreferred) - { - final Dimension dim = new Dimension(0, 0); - - if (width <= 0 || height <= 0) - { - final int count = target.getComponentCount(); - for (int i = 0; i < count; i++) - { - final Component component = target.getComponent(i); - if (component.isVisible()) - { - final Rectangle r = getComponentBounds(component, doPreferred); - dim.width = Math.max(dim.width, r.x + r.width); - dim.height = Math.max(dim.height, r.y + r.height); - } - } - } - if (width > 0) - { - dim.width = width; - } - if (height > 0) - { - dim.height = height; - } - final Insets insets = target.getInsets(); - dim.width += insets.left + insets.right; - dim.height += insets.top + insets.bottom; - - return dim; - } -} \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayoutTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayoutTest.java deleted file mode 100644 index 5ac9dec3b..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swing/ams/VarmenuLayoutTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2025 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 - * https://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Google, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.wb.tests.designer.swing.ams; - -import org.eclipse.wb.internal.core.utils.IOUtils2; -import org.eclipse.wb.internal.swing.model.component.ComponentInfo; -import org.eclipse.wb.internal.swing.model.component.ContainerInfo; -import org.eclipse.wb.tests.designer.swing.SwingGefTest; - -import org.eclipse.draw2d.PositionConstants; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * Test for VarmenuLayout support. - * - * @author scheglov_ke - */ -public class VarmenuLayoutTest extends SwingGefTest { - //////////////////////////////////////////////////////////////////////////// - // - // Life cycle - // - //////////////////////////////////////////////////////////////////////////// - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - setFileContentSrc( - "ams/zpointcs/components/VarmenuConstraints.java", - IOUtils2.readString(getClass().getResourceAsStream("VarmenuConstraints.txt"))); - setFileContentSrc( - "ams/zpointcs/components/VarmenuLayout.java", - IOUtils2.readString(getClass().getResourceAsStream("VarmenuLayout.txt"))); - prepareBox(); - } - - //////////////////////////////////////////////////////////////////////////// - // - // Exit zone :-) XXX - // - //////////////////////////////////////////////////////////////////////////// - public void _test_exit() throws Exception { - System.exit(0); - } - - //////////////////////////////////////////////////////////////////////////// - // - // Tests - // - //////////////////////////////////////////////////////////////////////////// - @Disabled - @Test - public void test_CREATE() throws Exception { - ContainerInfo panel = openContainer(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - } - }"""); - panel.refresh(); - // - loadCreationBox(); - canvas.sideMode().create(100, 50); - canvas.target(panel).in(150, 100).move(); - canvas.click(); - assertEditor(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 0)); - } - } - }"""); - } - - @Disabled - @Test - public void test_RESIZE_width() throws Exception { - ContainerInfo panel = openContainer(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 0)); - } - } - }"""); - panel.refresh(); - ComponentInfo box = panel.getChildrenComponents().get(0); - // drag to non-default width - canvas.beginResize(box, PositionConstants.EAST).dragOn(30, 0).endDrag(); - assertEditor(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 130, 0)); - } - } - }"""); - // drag to default width - canvas.beginResize(box, PositionConstants.EAST).dragOn(-30, 0).endDrag(); - assertEditor(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 0)); - } - } - }"""); - } - - @Disabled - @Test - public void test_RESIZE_height() throws Exception { - ContainerInfo panel = openContainer(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 0)); - } - } - }"""); - panel.refresh(); - ComponentInfo box = panel.getChildrenComponents().get(0); - // drag to non-default width - canvas.beginResize(box, PositionConstants.SOUTH).dragOn(0, 50).endDrag(); - assertEditor(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 100)); - } - } - }"""); - // drag to default width - canvas.beginResize(box, PositionConstants.SOUTH).dragOn(0, -50).endDrag(); - assertEditor(""" - import ams.zpointcs.components.*; - public class Test extends JPanel { - public Test() { - setLayout(new VarmenuLayout()); - { - Box box = new Box(); - add(box, new VarmenuConstraints(150, 100, 0, 0)); - } - } - }"""); - } -} \ No newline at end of file