litesoft
@ 947
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.ui.def.nonpublic.support; import org.litesoft.ui.support.*; import org.litesoft.uispecification.*; public abstract class UiLayoutTwoDimensionalDef extends UiMultiCellLayoutDef { public static final int DEFAULT_COLUMNS = 2; protected UiLayoutTwoDimensionalDef() { } protected UiLayoutTwoDimensionalDef( int pColumns ) throws IllegalArgumentException { setColumns( pColumns ); } public UiLayoutTwoDimensionalDef forEdit() { setIntendedUse( IntendedUse.ForEdit ); return this; } public UiLayoutTwoDimensionalDef forSearch() { setIntendedUse( IntendedUse.ForSearch ); return this; } public UiLayoutTwoDimensionalDef forView() { setIntendedUse( IntendedUse.ForView ); return this; } public UiLayoutTwoDimensionalDef bordered() { setBordered( true ); return this; } public UiLayoutTwoDimensionalDef bordered( String pExtName ) { setExtTitle( pExtName ); return this; } public UiLayoutTwoDimensionalDef bordered( String pExtName, UiFont pFont ) { setExtTitle( pExtName ); setTitleFont( pFont ); return this; } public UiLayoutTwoDimensionalDef scrolled() { LLsetScrolled(); return this; } public UiLayoutTwoDimensionalDef clipped() { LLsetClipped(); return this; } public UiLayoutTwoDimensionalDef allCellsSameSize() { setAllCellsSameSize( true ); return this; } private UiD_Attribute_Column mColumns = new UiD_Attribute_Column(); public int getColumns() { return mColumns.getValue(); } public void setColumns( int pColumns ) throws IllegalArgumentException { validateAtLeastTwoColumns( pColumns ); mColumns.setValue( pColumns ); } public static void validateAtLeastTwoColumns( int pColumns ) { if ( pColumns < 2 ) { throw new IllegalArgumentException( "The number of Columns may NOT be less than 2" ); } } public int getRows() { return getComponentGrid().getRows(); } public ComponentGrid getComponentGrid() { if ( isDefineMode() ) { throw new IllegalStateException( "method only available in Rendered Mode" ); } validate(); return ((AbstractUiChildrenHelperTwoDimensional) getChildrenHelper()).getComponentGrid(); } public static class UiD_Attribute_Column extends UiD_Attribute_int { public UiD_Attribute_Column() { super( "Columns", DEFAULT_COLUMNS ); } public String nonDefaultValueToString() { return Integer.toString( getValue() ); // Always show value! } } } |