Skip to content
Open
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 @@ -61,7 +61,7 @@
import com.jgoodies.forms.layout.FormSpec;
import com.jgoodies.forms.layout.FormSpecs;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.util.DefaultUnitConverter;
import com.jgoodies.forms.util.UnitConverter;

import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
Expand Down Expand Up @@ -1440,7 +1440,7 @@ protected void refresh_afterCreate2() throws Exception {
}
// initialize default sizes in pixels
{
DefaultUnitConverter converter = DefaultUnitConverter.getInstance();
UnitConverter converter = FormSizeConstantInfo.getUnitConverter();
//
m_defaultColumnSize = converter.millimeterAsPixel(DEFAULT_SIZE, container);
m_defaultRowSize = converter.millimeterAsPixel(DEFAULT_SIZE, container);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 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 All @@ -26,6 +26,7 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import java.util.Objects;

import javax.swing.JFrame;

Expand All @@ -36,6 +37,7 @@
* @coverage swing.FormLayout.model
*/
public final class FormSizeConstantInfo {
private static UnitConverter m_unitConverter = DefaultUnitConverter.getInstance();
private double m_value;
private Unit m_unit;

Expand Down Expand Up @@ -112,6 +114,20 @@ public void setUnit(Unit unit) throws Exception {
m_unit = unit;
}

/**
* @return the {@link UnitConverter}
*/
public static UnitConverter getUnitConverter() {
return m_unitConverter;
}

/**
* Sets the {@link UnitConverter}.
*/
public static void setUnitConverter(UnitConverter unitConverter) {
m_unitConverter = Objects.requireNonNull(unitConverter);
}

////////////////////////////////////////////////////////////////////////////
//
// Object
Expand Down Expand Up @@ -182,7 +198,7 @@ private static double convertValue(double value, Unit oldUnit, Unit newUnit) thr
* @return the value in pixels for value in given {@link Unit}.
*/
public static int convertToPixels(double value, Unit unit) {
UnitConverter converter = DefaultUnitConverter.getInstance();
UnitConverter converter = getUnitConverter();
//
int pixels = 0;
if (unit == ConstantSize.PIXEL) {
Expand Down Expand Up @@ -231,7 +247,7 @@ public static double convertFromPixels(int pixels, Unit unit) throws Exception {
* in pixels.
*/
private static int convertFromPixelsInt(int pixels, String methodName) throws Exception {
UnitConverter converter = DefaultUnitConverter.getInstance();
UnitConverter converter = getUnitConverter();
Method method =
UnitConverter.class.getMethod(methodName, new Class[]{int.class, Component.class});
int result = 0;
Expand All @@ -251,7 +267,7 @@ private static int convertFromPixelsInt(int pixels, String methodName) throws Ex
* in pixels.
*/
private static double convertFromPixelsDouble(int pixels, String methodName) throws Exception {
UnitConverter converter = DefaultUnitConverter.getInstance();
UnitConverter converter = getUnitConverter();
Method method =
UnitConverter.class.getMethod(methodName, new Class[]{double.class, Component.class});
double result = 0;
Expand Down
4 changes: 3 additions & 1 deletion org.eclipse.wb.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ Export-Package: org.eclipse.wb.tests.designer;x-internal:=true,
org.eclipse.wb.tests.draw2d;x-internal:=true,
org.eclipse.wb.tests.gef;x-internal:=true,
org.eclipse.wb.tests.utils;x-internal:=true
Import-Package: com.jgoodies.forms.factories;version="[1.9.0,2.0.0]",
Import-Package: com.jgoodies.common.bean;version="[1.8.1,2.0.0)",
com.jgoodies.forms.factories;version="[1.9.0,2.0.0]",
com.jgoodies.forms.layout;version="[1.9.0,2.0.0]",
com.jgoodies.forms.util;version="[1.9.0,2.0.0)",
net.miginfocom.layout;version="[11.3.0,12.0.0]",
net.miginfocom.swing;version="[11.3.0,12.0.0]",
org.apache.commons.collections4;version="[4.4.0,5.0.0)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 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 All @@ -13,13 +13,20 @@
package org.eclipse.wb.tests.designer.swing.model.layout.FormLayout;

import org.eclipse.wb.internal.core.utils.jdt.core.CodeUtils;
import org.eclipse.wb.internal.swing.FormLayout.model.FormSizeConstantInfo;
import org.eclipse.wb.internal.swing.laf.LafSupport;
import org.eclipse.wb.tests.designer.swing.model.layout.AbstractLayoutTest;

import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.util.AbstractUnitConverter;
import com.jgoodies.forms.util.DefaultUnitConverter;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;

import java.awt.Component;

/**
* Abstract test for {@link FormLayout}.
*
Expand All @@ -33,6 +40,16 @@ public abstract class AbstractFormLayoutTest extends AbstractLayoutTest {
// Life cycle
//
////////////////////////////////////////////////////////////////////////////
@BeforeAll
public static void setUpUnitConverter() {
FormSizeConstantInfo.setUnitConverter(new UnitConverterStub());
}

@AfterAll
public static void tearDownUnitConverter() {
FormSizeConstantInfo.setUnitConverter(DefaultUnitConverter.getInstance());
}

@Override
@BeforeEach
public void setUp() throws Exception {
Expand Down Expand Up @@ -66,4 +83,23 @@ public String getTestSource(String... lines) {
}
return super.getTestSource(lines);
}

private static class UnitConverterStub extends AbstractUnitConverter {
private static final long serialVersionUID = 1L;

@Override
protected double getDialogBaseUnitsX(Component component) {
return 6;
}

@Override
protected double getDialogBaseUnitsY(Component component) {
return 12;
}

@Override
protected int getScreenResolution(Component c) {
return 96;
}
}
}
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 @@ -29,7 +29,6 @@
import com.jgoodies.forms.factories.DefaultComponentFactory;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -109,7 +108,6 @@ public void test_createLabel() throws Exception {
* Test for {@link DefaultComponentFactoryCreateLabelEntryInfo}.
*/
@DisposeProjectAfter
@Disabled
@Test
public void test_createLabel_tool() throws Exception {
do_projectDispose();
Expand Down Expand Up @@ -142,7 +140,7 @@ public void test_createLabel_tool() throws Exception {
Image image = newComponent.getImage();
assertNotNull(image);
org.eclipse.swt.graphics.Rectangle bounds = image.getBounds();
Assertions.assertThat(bounds.width).isGreaterThan(50).isLessThan(100);
Assertions.assertThat(bounds.width).isGreaterThan(50).isLessThan(150);
Assertions.assertThat(bounds.height).isGreaterThan(10).isLessThan(20);
image.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.jgoodies.forms.layout.Size;
import com.jgoodies.forms.layout.Sizes;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -264,7 +263,6 @@ public void test_rowTemplates() throws Exception {
// Convert to GAP template
//
////////////////////////////////////////////////////////////////////////////
@Disabled
@Test
public void test_convertToNearestGap_columns() throws Exception {
check_convertToNearestGap_column("4px", 5, "LABEL_COMPONENT_GAP_COLSPEC");
Expand All @@ -279,7 +277,6 @@ public void test_convertToNearestGap_columns() throws Exception {
check_convertToNearestGap_column("20px", 5, null);
}

@Disabled
@Test
public void test_convertToNearestGap_rows() throws Exception {
check_convertToNearestGap_row("4px", 5, "LABEL_COMPONENT_GAP_ROWSPEC");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* 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
Expand All @@ -18,7 +18,6 @@

import com.jgoodies.forms.layout.FormLayout;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -60,7 +59,6 @@ public void test_empty() throws Exception {
"}");
}

@Disabled
@Test
public void test_oneRow() throws Exception {
ContainerInfo panel =
Expand Down Expand Up @@ -96,7 +94,7 @@ public void test_oneRow() throws Exception {
" setLayout(new FormLayout(new ColumnSpec[] {",
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
" ColumnSpec.decode('100px'),",
" ColumnSpec.decode('16px'),",
" FormSpecs.UNRELATED_GAP_COLSPEC,",
" ColumnSpec.decode('80px'),},",
" new RowSpec[] {",
" FormSpecs.UNRELATED_GAP_ROWSPEC,",
Expand All @@ -118,7 +116,6 @@ public void test_oneRow() throws Exception {
}
}

@Disabled
@Test
public void test_twoRows_spanColumns() throws Exception {
ContainerInfo panel =
Expand Down Expand Up @@ -181,7 +178,6 @@ public void test_twoRows_spanColumns() throws Exception {
"}");
}

@Disabled
@Test
public void test_Switching_fromGridBagLayout() throws Exception {
ContainerInfo panel =
Expand Down Expand Up @@ -243,17 +239,17 @@ public void test_Switching_fromGridBagLayout() throws Exception {
"public class Test extends JPanel {",
" public Test() {",
" setLayout(new FormLayout(new ColumnSpec[] {",
" ColumnSpec.decode('46px'),",
" ColumnSpec.decode('60px'),",
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
" ColumnSpec.decode('305px'),",
" ColumnSpec.decode('275px'),",
" FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,",
" ColumnSpec.decode('89px'),},",
" ColumnSpec.decode('105px'),},",
" new RowSpec[] {",
" RowSpec.decode('20px'),",
" RowSpec.decode('26px'),",
" FormSpecs.LINE_GAP_ROWSPEC,",
" RowSpec.decode('20px'),",
" RowSpec.decode('21px'),",
" FormSpecs.LINE_GAP_ROWSPEC,",
" RowSpec.decode('23px'),}));",
" RowSpec.decode('27px'),}));",
" {",
" JComboBox comboBox = new JComboBox();",
" add(comboBox, '3, 1, fill, center');",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 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 @@ -861,7 +861,6 @@ public Test() {
{
ComponentInfo button_2 = getJavaInfoByName("button_2");
canvas.target(button_2).inX(0.5).outY(ROW_GAP + 1).move();
waitEventLoop(1000 * 5);
canvas.assertCommandNull();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.jgoodies.forms.layout.Sizes;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -61,7 +60,6 @@ public void _test_exit() throws Exception {
/**
* Test for {@link FormSizeConstantInfo}.
*/
@Disabled
@Test
public void test_FormSizeConstantInfo() throws Exception {
FormSizeConstantInfo size = new FormSizeConstantInfo(25, ConstantSize.PIXEL);
Expand Down Expand Up @@ -131,15 +129,14 @@ public void test_FormSizeConstantInfo_convertSpecial() throws Exception {
/**
* Test for {@link FormSizeConstantInfo#convertFromPixels(int, Unit)}
*/
@Disabled
@Test
public void test_FormSizeConstantInfo_convertFromPixels() throws Exception {
{
double expected = 50.0;
check_convertFromPixels(50, ConstantSize.PIXEL, expected);
}
{
double expected = 39.0;
double expected = 38.0;
check_convertFromPixels(50, ConstantSize.POINT, expected);
}
{
Expand Down Expand Up @@ -171,7 +168,6 @@ private void check_convertFromPixels(int pixels, Unit unit, double expected) thr
/**
* Test for {@link FormSizeConstantInfo#convertToPixels(double, Unit)}
*/
@Disabled
@Test
public void test_FormSizeConstantInfo_convertToPixels() throws Exception {
{
Expand Down
Loading