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