From 848e4f524d084f15bf8594d3056307447f1050fe Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Tue, 17 Dec 2024 10:14:20 +0100 Subject: [PATCH] [eRCP] Remove obsolete FillLayoutSupport class Only used in the FillLayoutInfo and only to check whether the children are aligned horizontally or vertically. Contributes to https://github.com/eclipse-windowbuilder/windowbuilder/issues/942 --- .../swt/model/layout/FillLayoutInfo.java | 16 ++++- .../swt/support/FillLayoutSupport.java | 49 ------------- .../swt/support/FillLayoutSupportTest.java | 71 ------------------- .../designer/swt/support/SupportTests.java | 1 - 4 files changed, 13 insertions(+), 124 deletions(-) delete mode 100644 org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/support/FillLayoutSupport.java delete mode 100644 org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/FillLayoutSupportTest.java diff --git a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/FillLayoutInfo.java b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/FillLayoutInfo.java index 6c2c598d3..ed6aec637 100644 --- a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/FillLayoutInfo.java +++ b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/model/layout/FillLayoutInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2024 Google, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,8 +15,8 @@ import org.eclipse.wb.internal.core.model.description.ComponentDescription; import org.eclipse.wb.internal.core.utils.ast.AstEditor; import org.eclipse.wb.internal.swt.model.widgets.ControlInfo; -import org.eclipse.wb.internal.swt.support.FillLayoutSupport; +import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import java.util.List; @@ -40,13 +40,23 @@ public FillLayoutInfo(AstEditor editor, new FillLayoutAssistant(this); } + //////////////////////////////////////////////////////////////////////////// + // + // Accessors + // + //////////////////////////////////////////////////////////////////////////// + + protected FillLayout getLayout() { + return (FillLayout) super.getObject(); + } + //////////////////////////////////////////////////////////////////////////// // // Styles // //////////////////////////////////////////////////////////////////////////// public boolean isHorizontal() { - return FillLayoutSupport.isHorizontal(getObject()); + return getLayout().type == SWT.HORIZONTAL; } //////////////////////////////////////////////////////////////////////////// diff --git a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/support/FillLayoutSupport.java b/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/support/FillLayoutSupport.java deleted file mode 100644 index 93d9bd0d1..000000000 --- a/org.eclipse.wb.swt/src/org/eclipse/wb/internal/swt/support/FillLayoutSupport.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Google, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.wb.internal.swt.support; - -import org.eclipse.wb.internal.core.utils.execution.ExecutionUtils; -import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; - -/** - * Stub class for using SWT {@link org.eclipse.swt.layout.FillLayout}'s in another - * {@link ClassLoader}. - * - * @author lobas_av - * @coverage swt.support - */ -public class FillLayoutSupport extends AbstractSupport { - //////////////////////////////////////////////////////////////////////////// - // - // FillLayout - // - //////////////////////////////////////////////////////////////////////////// - /** - * @return value of field type. - */ - public static int getType(final Object layout) { - return ExecutionUtils.runObjectLog(() -> ReflectionUtils.getFieldInt(layout, "type"), SwtSupport.HORIZONTAL); - } - - /** - * @return true if this layout is horizontal (type == SWT.HORIZONTAL). - */ - public static boolean isHorizontal(Object layout) { - return getType(layout) == SwtSupport.HORIZONTAL; - } - - /** - * Create new {@link org.eclipse.swt.layout.FillLayout}. - */ - public static Object newInstance() throws Exception { - return loadClass("org.eclipse.swt.layout.FillLayout").newInstance(); - } -} \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/FillLayoutSupportTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/FillLayoutSupportTest.java deleted file mode 100644 index 40a61f082..000000000 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/FillLayoutSupportTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Google, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Google, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.wb.tests.designer.swt.support; - -import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; -import org.eclipse.wb.internal.swt.support.FillLayoutSupport; - -import org.eclipse.swt.SWT; - -import org.junit.Test; - -/** - * Test for {@link FillLayoutSupport}. - * - * @author lobas_av - */ -public class FillLayoutSupportTest extends AbstractSupportTest { - //////////////////////////////////////////////////////////////////////////// - // - // Exit zone :-) XXX - // - //////////////////////////////////////////////////////////////////////////// - public void _test_exit() throws Exception { - System.exit(0); - } - - //////////////////////////////////////////////////////////////////////////// - // - // Tests - // - //////////////////////////////////////////////////////////////////////////// - @Test - public void test_getType() throws Exception { - Object layout = getLayoutClass().newInstance(); - assertEquals(SWT.HORIZONTAL, FillLayoutSupport.getType(layout)); - ReflectionUtils.setField(layout, "type", SWT.VERTICAL); - assertEquals(SWT.VERTICAL, FillLayoutSupport.getType(layout)); - } - - @Test - public void test_isHorizontal() throws Exception { - Object layout = getLayoutClass().newInstance(); - assertTrue(FillLayoutSupport.isHorizontal(layout)); - ReflectionUtils.setField(layout, "type", SWT.VERTICAL); - assertFalse(FillLayoutSupport.isHorizontal(layout)); - } - - @Test - public void test_newInstance() throws Exception { - Object layout = FillLayoutSupport.newInstance(); - assertNotNull(layout); - assertSame(getLayoutClass(), layout.getClass()); - } - - //////////////////////////////////////////////////////////////////////////// - // - // Utils - // - //////////////////////////////////////////////////////////////////////////// - private Class getLayoutClass() throws Exception { - return m_lastLoader.loadClass("org.eclipse.swt.layout.FillLayout"); - } -} \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/SupportTests.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/SupportTests.java index c4d55506c..5fe0f5411 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/SupportTests.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/SupportTests.java @@ -25,7 +25,6 @@ ColorSupportTest.class, FontSupportTest.class, ImageSupportTest.class, - FillLayoutSupportTest.class, RowLayoutSupportTest.class, ControlSupportTest.class, ContainerSupportTest.class,