|
@@ -1,9 +1,6 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.GWT.forms.client.components.factories.others; |
3 |
3 |
|
|
4 |
|
- |
import java.io.*; |
5 |
|
- |
import java.util.*; |
6 |
|
- |
|
7 |
4 |
|
import org.litesoft.GWT.client.widgets.*; |
8 |
5 |
|
import org.litesoft.GWT.client.widgets.nonpublic.*; |
9 |
6 |
|
import org.litesoft.GWT.forms.client.components.*; |
|
@@ -15,23 +12,22 @@ |
15 |
12 |
|
|
16 |
13 |
|
import com.google.gwt.user.client.ui.*; |
17 |
14 |
|
|
18 |
|
- |
public class TabsWidgetFactory implements ContainerFactory |
19 |
|
- |
{ |
|
15 |
+ |
import java.io.*; |
|
16 |
+ |
import java.util.*; |
|
17 |
+ |
|
|
18 |
+ |
public class TabsWidgetFactory implements ContainerFactory { |
20 |
19 |
|
public Widget createContainerWidget( FormInstanceComponentHandler pComponentHandler, |
21 |
20 |
|
UiDef pUiDef, FormMetaData pFormMetaData, |
22 |
|
- |
DefWidgetStruct[] pChildDefWidgets ) |
23 |
|
- |
{ |
|
21 |
+ |
DefWidgetStruct[] pChildDefWidgets ) { |
24 |
22 |
|
UiTabsDef zTabsDef = (UiTabsDef) pUiDef; |
25 |
23 |
|
ISizeableTabPanel zSTP = zTabsDef.isVertical() ? // |
26 |
24 |
|
(ISizeableTabPanel) new SizeableSelectorPanel() : |
27 |
25 |
|
new SizeableTabPanel().stretchable(); |
28 |
26 |
|
HashMap zLabelCodeToIndexMap = new HashMap(); |
29 |
|
- |
for ( int i = 0; i < pChildDefWidgets.length; i++ ) |
30 |
|
- |
{ |
|
27 |
+ |
for ( int i = 0; i < pChildDefWidgets.length; i++ ) { |
31 |
28 |
|
DefWidgetStruct zChild = pChildDefWidgets[i]; |
32 |
29 |
|
UiTabDef zTabDef = (UiTabDef) zChild.getUiDef(); |
33 |
|
- |
if ( zTabDef.isDisabled() ) |
34 |
|
- |
{ |
|
30 |
+ |
if ( zTabDef.isDisabled() ) { |
35 |
31 |
|
continue; |
36 |
32 |
|
} |
37 |
33 |
|
Widget zWidget = zChild.getWidget(); // !null |
|
@@ -41,8 +37,7 @@ |
41 |
37 |
|
LabelMetaData zLabelMetaData = pFormMetaData.getLabel( zTabDef ); |
42 |
38 |
|
zLabelText = (zLabelMetaData != null) ? zLabelMetaData.getExternalText() : "No Label"; |
43 |
39 |
|
String zFont = ApplyFont.toHtmlStyle( zTabDef.getLabelFont() ); |
44 |
|
- |
if ( zFont.length() != 0 ) |
45 |
|
- |
{ |
|
40 |
+ |
if ( zFont.length() != 0 ) { |
46 |
41 |
|
zAsHTML = true; |
47 |
42 |
|
zLabelText = "<span" + zFont + ">" + zLabelText + "</span>"; |
48 |
43 |
|
} |
|
@@ -51,54 +46,44 @@ |
51 |
46 |
|
} |
52 |
47 |
|
|
53 |
48 |
|
AttributeMetaData zMD = pFormMetaData.getAttribute( zTabsDef ); |
54 |
|
- |
if ( zMD != null ) |
55 |
|
- |
{ |
|
49 |
+ |
if ( zMD != null ) { |
56 |
50 |
|
new MyFormAdapter( pComponentHandler, zLabelCodeToIndexMap, zSTP, zMD, new NullFormComponent() ).init(); |
57 |
51 |
|
} |
58 |
52 |
|
return (Widget) zSTP; |
59 |
53 |
|
} |
60 |
54 |
|
|
61 |
|
- |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter |
62 |
|
- |
{ |
|
55 |
+ |
private static final class MyFormAdapter extends AbstractFormAttributeAdapter { |
63 |
56 |
|
private HashMap mLabelCodeToIndexMap; |
64 |
57 |
|
private ISizeableTabPanel mSTP; |
65 |
58 |
|
|
66 |
59 |
|
public MyFormAdapter( FormInstanceComponentHandler pComponentHandler, HashMap pLabelCodeToIndexMap, // |
67 |
|
- |
ISizeableTabPanel pSTP, AttributeMetaData pMD, IFormComponent pComponent ) |
68 |
|
- |
{ |
|
60 |
+ |
ISizeableTabPanel pSTP, AttributeMetaData pMD, IFormComponent pComponent ) { |
69 |
61 |
|
super( pComponentHandler, pMD, pComponent ); |
70 |
62 |
|
mLabelCodeToIndexMap = pLabelCodeToIndexMap; |
71 |
63 |
|
mSTP = pSTP; |
72 |
64 |
|
} |
73 |
65 |
|
|
74 |
|
- |
protected Widget initWidget() |
75 |
|
- |
{ |
|
66 |
+ |
protected Widget initWidget() { |
76 |
67 |
|
return null; |
77 |
68 |
|
} |
78 |
69 |
|
|
79 |
|
- |
protected Object convertSendableToComponentValue( Serializable pValue ) |
80 |
|
- |
{ |
|
70 |
+ |
protected Object convertSendableToComponentValue( Serializable pValue ) { |
81 |
71 |
|
return pValue; |
82 |
72 |
|
} |
83 |
73 |
|
|
84 |
|
- |
protected String convertComponentValueToString( Object pValue ) |
85 |
|
- |
{ |
|
74 |
+ |
protected String convertComponentValueToString( Object pValue ) { |
86 |
75 |
|
return null; |
87 |
76 |
|
} |
88 |
77 |
|
|
89 |
|
- |
protected Object convertStringToComponentValue( String pValue ) |
90 |
|
- |
{ |
|
78 |
+ |
protected Object convertStringToComponentValue( String pValue ) { |
91 |
79 |
|
return null; |
92 |
80 |
|
} |
93 |
81 |
|
|
94 |
|
- |
protected void setComponentCurrentValue( Object pNewComponentCurrentValue ) |
95 |
|
- |
{ |
|
82 |
+ |
protected void setComponentCurrentValue( Object pNewComponentCurrentValue ) { |
96 |
83 |
|
super.setComponentCurrentValue( pNewComponentCurrentValue ); |
97 |
|
- |
if ( pNewComponentCurrentValue != null ) |
98 |
|
- |
{ |
|
84 |
+ |
if ( pNewComponentCurrentValue != null ) { |
99 |
85 |
|
Integer zIndex = (Integer) mLabelCodeToIndexMap.get( pNewComponentCurrentValue.toString() ); |
100 |
|
- |
if ( zIndex != null ) |
101 |
|
- |
{ |
|
86 |
+ |
if ( zIndex != null ) { |
102 |
87 |
|
mSTP.selectTab( zIndex.intValue() ); |
103 |
88 |
|
} |
104 |
89 |
|
} |