List of usage examples for com.jgoodies.forms.layout Sizes DEFAULT
ComponentSize DEFAULT
To view the source code for com.jgoodies.forms.layout Sizes DEFAULT.
Click Source Link
From source file:org.eclipse.wb.internal.swing.FormLayout.model.ui.DimensionEditDialog.java
License:Open Source License
/** * Creates the size editing {@link Composite}. *//*from w w w . j a v a 2 s .c o m*/ private void createSizeComposite(Composite parent) { createSeparator(parent, ModelMessages.DimensionEditDialog_size); // Composite composite = new Composite(parent, SWT.NONE); GridDataFactory.create(composite).grabH().fill().indentHC(2); GridLayoutFactory.create(composite).noMargins(); // default, preferred, minimum { Composite sizesComposite = new Composite(composite, SWT.NONE); GridDataFactory.create(sizesComposite).grabH().fill(); GridLayoutFactory.create(sizesComposite).columns(3).noMargins(); createComponentSizeButton(sizesComposite, Sizes.DEFAULT, "&default"); createComponentSizeButton(sizesComposite, Sizes.PREFERRED, "&preferred"); createComponentSizeButton(sizesComposite, Sizes.MINIMUM, "minim&um"); } // constants { Composite constantsComposite = new Composite(composite, SWT.NONE); GridDataFactory.create(constantsComposite).grabH().fill(); GridLayoutFactory.create(constantsComposite).columns(2).noMargins(); // constant size { { m_constantSizeButton = new Button(constantsComposite, SWT.RADIO); m_constantSizeButton.setText(ModelMessages.DimensionEditDialog_18); GridDataFactory.create(m_constantSizeButton).hintHC(15); m_constantSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setComponentSize(null); if (size.getConstantSize() == null) { size.setConstantSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_constantSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_constantSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setConstantSize(m_constantSizeComposite.getConstantSize()); showDimension(); } }); } // lower { { m_lowerSizeButton = new Button(constantsComposite, SWT.CHECK); m_lowerSizeButton.setText(ModelMessages.DimensionEditDialog_19); m_lowerSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setLowerSize(m_lowerSizeButton.getSelection()); if (size.getLowerSize() == null) { size.setLowerSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_lowerSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_lowerSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setLowerSize(m_lowerSizeComposite.getConstantSize()); showDimension(); } }); } // upper { { m_upperSizeButton = new Button(constantsComposite, SWT.CHECK); m_upperSizeButton.setText(ModelMessages.DimensionEditDialog_20); m_upperSizeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setUpperSize(m_upperSizeButton.getSelection()); if (size.getUpperSize() == null) { size.setUpperSize(new FormSizeConstantInfo(50, m_units[0].getUnit())); } showDimension(); } }); } // m_upperSizeComposite = new ConstantSizeComposite(constantsComposite, SWT.NONE, m_units); m_upperSizeComposite.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { FormSizeInfo size = m_dimension.getSize(); size.setUpperSize(m_upperSizeComposite.getConstantSize()); showDimension(); } }); } } }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormDimensionInfoTest.java
License:Open Source License
public void test_accessors() throws Exception { FormColumnInfo column = new FormColumnInfo(FormFactory.DEFAULT_COLSPEC); assertEquals("default", column.getDisplayString()); // check initial state assertSame(Sizes.DEFAULT, column.getSize().getSize()); assertSame(ColumnSpec.DEFAULT, column.getAlignment()); assertEquals(0.0, column.getWeight(), 0.001); assertFalse(column.hasGrow());// w ww. j ava 2 s .c om // modify column.setAlignment(ColumnSpec.LEFT); column.setWeight(0.2); assertEquals("left:default:grow(0.2)", column.getDisplayString()); assertTrue(column.hasGrow()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormDimensionInfoTest.java
License:Open Source License
public void test_sourceBounded() throws Exception { Size size = Sizes.bounded(Sizes.DEFAULT, Sizes.constant("3cm", true), Sizes.constant("40mm", true)); FormColumnInfo column = new FormColumnInfo(new ColumnSpec(ColumnSpec.LEFT, size, 0.0)); assertEquals(/* ww w. j a va2 s.c o m*/ "new com.jgoodies.forms.layout.ColumnSpec(com.jgoodies.forms.layout.ColumnSpec.LEFT, com.jgoodies.forms.layout.Sizes.bounded(com.jgoodies.forms.layout.Sizes.DEFAULT, com.jgoodies.forms.layout.Sizes.constant(\"3cm\", true), com.jgoodies.forms.layout.Sizes.constant(\"40mm\", true)), 0)", column.getSource()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_constantSet() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.DEFAULT, true); assertEquals("default", size.getSource()); assertNotNull(size.getComponentSize()); assertNull(size.getConstantSize());/*from ww w. ja va 2s. c o m*/ // set constant size.setConstantSize(new FormSizeConstantInfo(25, ConstantSize.PIXEL)); assertNull(size.getComponentSize()); assertEquals("25px", size.getConstantSize().getSource(true, true)); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_component_DEFAULT() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.DEFAULT, true); assertTrue(size.isString());//from w w w . ja va 2s . c o m assertEquals("default", size.getSource()); assertSame(Sizes.DEFAULT, size.getComponentSize()); assertEquals(Sizes.DEFAULT, size.getSize()); assertNull(size.getConstantSize()); // lower/upper assertFalse(size.hasLowerSize()); assertFalse(size.hasUpperSize()); assertNull(size.getLowerSize()); assertNull(size.getUpperSize()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_setComponentSize() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.DEFAULT, true); size.setComponentSize(Sizes.MINIMUM); assertTrue(size.isString());/*w w w . j a v a 2s.co m*/ assertEquals("min", size.getSource()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_boundedLower() throws Exception { FormSizeInfo size = new FormSizeInfo(new ColumnSpec("max(4cm;default)").getSize(), true); assertTrue(size.isString());/*w w w.j a v a 2s.com*/ assertEquals("max(4cm;default)", size.getSource()); assertSame(Sizes.DEFAULT, size.getComponentSize()); assertEquals(Sizes.bounded(Sizes.DEFAULT, Sizes.constant("4cm", true), null), size.getSize()); assertNull(size.getConstantSize()); assertNull(size.getUpperSize()); // FormSizeConstantInfo lowerSize = size.getLowerSize(); assertNotNull(lowerSize); assertEquals(4.0, lowerSize.getValue(), 0.001); assertSame(ConstantSize.CENTIMETER, lowerSize.getUnit()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_boundedUpper() throws Exception { FormSizeInfo size = new FormSizeInfo(new ColumnSpec("min(3cm;default)").getSize(), true); assertTrue(size.isString());/* ww w . ja v a 2 s . c o m*/ assertEquals("min(3cm;default)", size.getSource()); assertSame(Sizes.DEFAULT, size.getComponentSize()); assertEquals(Sizes.bounded(Sizes.DEFAULT, null, Sizes.constant("3cm", true)), size.getSize()); assertNull(size.getConstantSize()); // lower assertFalse(size.hasLowerSize()); assertNull(size.getLowerSize()); // upper assertTrue(size.hasUpperSize()); FormSizeConstantInfo upperSize = size.getUpperSize(); assertNotNull(upperSize); assertEquals(3.0, upperSize.getValue(), 0.001); assertSame(ConstantSize.CENTIMETER, upperSize.getUnit()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_boundedLowerSet() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.DEFAULT, true); assertTrue(size.isString());/*from www . j av a 2 s. c o m*/ assertEquals("default", size.getSource()); // no bounds assertFalse(size.hasLowerSize()); assertFalse(size.hasUpperSize()); // set lower size.setLowerSize(new FormSizeConstantInfo(5.0, ConstantSize.CM)); assertTrue(size.hasLowerSize()); assertTrue(size.isString()); assertEquals("max(5cm;default)", size.getSource()); // remove "hasLower" size.setLowerSize(false); assertEquals("default", size.getSource()); }
From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java
License:Open Source License
public void test_FormSize_boundedUpperSet() throws Exception { FormSizeInfo size = new FormSizeInfo(Sizes.DEFAULT, true); assertTrue(size.isString());/*from ww w. ja va 2 s . c o m*/ assertEquals("default", size.getSource()); // no bounds assertFalse(size.hasLowerSize()); assertFalse(size.hasUpperSize()); // set upper size.setUpperSize(new FormSizeConstantInfo(5.0, ConstantSize.CM)); assertTrue(size.hasUpperSize()); assertTrue(size.isString()); assertEquals("min(5cm;default)", size.getSource()); // remove "hasUpper" size.setUpperSize(false); assertEquals("default", size.getSource()); }