Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/client/taskbar/nonpublic/DockablePanelHelper.java

Diff revisions: vs.
  @@ -1,184 +1,184 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.taskbar.nonpublic;
3 -
4 - import org.litesoft.GWT.client.*;
5 - import org.litesoft.GWT.client.commands.*;
6 - import org.litesoft.GWT.client.taskbar.*;
7 - import org.litesoft.GWT.client.widgets.*;
8 - import org.litesoft.GWT.client.widgets.nonpublic.*;
9 - import org.litesoft.core.delayed.*;
10 - import org.litesoft.core.util.*;
11 -
12 - import com.google.gwt.user.client.*;
13 - import com.google.gwt.user.client.ui.*;
14 -
15 - public class DockablePanelHelper implements OnBrowserEventListener {
16 - public static final int COLLAPSABLE_BAR_SIZE = 9;
17 -
18 - private AbstractSizeableOneDimensionalPanel mDockablePanel;
19 - private GwtDomDimensionHelper mDimensionHelper;
20 - private TaskbarHelper mTaskbarHelper;
21 - private Widget mDecoratedContent;
22 - private MoveNEWScommands mContextMenu;
23 - private CommonRectangularPoint mPopupRelativeMeetingPoint;
24 - private RectangleContainmentStrategy mRectangleContainmentStrategy;
25 - private String[] mArrows;
26 - private Image mArrow;
27 - private int mIndexArrow;
28 -
29 - private boolean mShowing = true;
30 - private Integer mDecoratedContentSize = null;
31 -
32 - public DockablePanelHelper( AbstractSizeableOneDimensionalPanel pDockablePanel,
33 - GwtDomDimensionHelper pDimensionHelper, TaskbarHelper pTaskbarHelper,
34 - NEWSposition pPosition, String pSeparatorURL, MoveNEWScommands pContextMenu,
35 - AbstractSizeableOneDimensionalPanel pDecoratedContent,
36 - AbstractSizeableOneDimensionalPanel pInnerDecoratedContent,
37 - AbstractSizeableOneDimensionalPanel pContent,
38 - AbstractSizeableOneDimensionalPanel pCollapsableBar,
39 - boolean pContentThenCollapsableBar, String pDefaultUrl,
40 - CommonRectangularPoint pPopupRelativeMeetingPoint, String[] pArrows,
41 - RectangleContainmentStrategy pRectangleContainmentStrategy ) {
42 - mDockablePanel = pDockablePanel;
43 - mDimensionHelper = pDimensionHelper;
44 - (mTaskbarHelper = pTaskbarHelper).setPosition( pPosition );
45 - mDecoratedContent = pDecoratedContent;
46 - mTaskbarHelper.addTo( pContent, pSeparatorURL );
47 - mContextMenu = pContextMenu;
48 - mPopupRelativeMeetingPoint = pPopupRelativeMeetingPoint;
49 - mRectangleContainmentStrategy = pRectangleContainmentStrategy;
50 - mArrows = pArrows;
51 -
52 - mArrow = new Image( pDefaultUrl );
53 - mIndexArrow = mArrows[0].equals( pDefaultUrl ) ? 0 : 1;
54 -
55 - pInnerDecoratedContent.add( pContent );
56 - // pInnerDecoratedContent.add( new SizeableSpacer( 1 ).stretchable() );
57 -
58 - pDecoratedContent.add( new TransparentImage( "TaskBarPreItems" + pPosition ) );
59 - pInnerDecoratedContent.addStyleName( "taskbar_bg" + pPosition );
60 - pDecoratedContent.add( pInnerDecoratedContent );
61 - pDecoratedContent.add( new TransparentImage( "TaskBarPostItems" + pPosition ) );
62 -
63 - pCollapsableBar.addStyleName( "collapsablebar_bg" + pPosition );
64 - pCollapsableBar.add( new SizeableSpacer( COLLAPSABLE_BAR_SIZE ).stretchable() );
65 - pCollapsableBar.add( mArrow );
66 - pCollapsableBar.add( new SizeableSpacer( COLLAPSABLE_BAR_SIZE ).stretchable() );
67 -
68 - if ( pContentThenCollapsableBar ) {
69 - mDockablePanel.add( pDecoratedContent );
70 - mDockablePanel.add( pCollapsableBar );
71 - } else {
72 - mDockablePanel.add( pCollapsableBar );
73 - mDockablePanel.add( pDecoratedContent );
74 - }
75 -
76 - pCollapsableBar.setOnBrowserEventListener( Event.MOUSEEVENTS, this );
77 - }
78 -
79 - public void updateArrow() {
80 - mArrow.setUrl( mArrows[mIndexArrow = (mIndexArrow + 1) & 1] );
81 - }
82 -
83 - public boolean onBrowserEvent( Event event ) {
84 - switch ( DOM.eventGetType( event ) ) {
85 - case Event.ONMOUSEUP:
86 - UtilsGwt.eventPreventDefaultAndCancelBubble( event );
87 - if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
88 - AbstractContextPopup zPopup = new MoveDockedWidgetContextPopup( mContextMenu );
89 - zPopup.addStyleName( "DockPopupMenu" );
90 - zPopup.showContextPopup( event, mRectangleContainmentStrategy, null,
91 - mPopupRelativeMeetingPoint );
92 - } else {
93 - setOpen( !isOpen() );
94 - }
95 - case Event.ONMOUSEOVER:
96 - case Event.ONMOUSEOUT:
97 - case Event.ONMOUSEDOWN:
98 - case Event.ONMOUSEMOVE:
99 - default:
100 - break;
101 - }
102 - return false;
103 - }
104 -
105 - public TaskbarHelper getTaskbarHelper() {
106 - return mTaskbarHelper;
107 - }
108 -
109 - public boolean isOpen() {
110 - return mShowing;
111 - }
112 -
113 - private class SetOpenDelayedProcess implements DelayedProcess {
114 - private boolean mRequestedOpenState;
115 -
116 - public boolean isRequestedOpenState() {
117 - return mRequestedOpenState;
118 - }
119 -
120 - public void setRequestedOpenState( boolean pRequestedOpenState ) {
121 - mRequestedOpenState = pRequestedOpenState;
122 - }
123 -
124 - public boolean process() {
125 - mPendingSetOpen = false;
126 - return LLsetOpen( mRequestedOpenState );
127 - }
128 - }
129 -
130 - private SetOpenDelayedProcess mSetOpenDelayedProcess = new SetOpenDelayedProcess();
131 - private EscalatingProcess mSetOpenEscalatingProcess = null;
132 - private boolean mPendingSetOpen = false;
133 -
134 - private void cancelPendingSetOpen() {
135 - if ( mPendingSetOpen && (mSetOpenEscalatingProcess != null) ) {
136 - mPendingSetOpen = false;
137 - mSetOpenEscalatingProcess.cancel();
138 - }
139 - }
140 -
141 - private void schedulePendingSetOpen( boolean pRequestedOpenState ) {
142 - mSetOpenDelayedProcess.setRequestedOpenState( pRequestedOpenState );
143 - if ( !mPendingSetOpen ) {
144 - if ( mSetOpenEscalatingProcess == null ) {
145 - mSetOpenEscalatingProcess = new EscalatingProcess( mSetOpenDelayedProcess );
146 - }
147 - mPendingSetOpen = true;
148 - }
149 - mSetOpenEscalatingProcess.schedule();
150 - }
151 -
152 - public void setOpen( boolean pOpen ) {
153 - if ( LLsetOpen( pOpen ) ) {
154 - cancelPendingSetOpen();
155 - } else {
156 - schedulePendingSetOpen( pOpen );
157 - }
158 - }
159 -
160 - private boolean LLsetOpen( boolean pOpen ) {
161 - if ( isOpen() != pOpen ) {
162 - if ( !isContentReady() ) {
163 - return false;
164 - }
165 - updateArrow();
166 - int zNewSize = COLLAPSABLE_BAR_SIZE + (pOpen ? mDecoratedContentSize : 0);
167 - mDecoratedContent.setVisible( mShowing = pOpen );
168 - mDimensionHelper.setDimension( mDockablePanel, zNewSize );
169 - mDockablePanel.relayout();
170 - }
171 - return true;
172 - }
173 -
174 - private boolean isContentReady() {
175 - if ( mDecoratedContentSize == null ) {
176 - int zContentSize = mDimensionHelper.getOffsetDimension( mDecoratedContent.getElement() );
177 - if ( zContentSize < 15 ) {
178 - return false;
179 - }
180 - mDecoratedContentSize = zContentSize;
181 - }
182 - return true;
183 - }
184 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.taskbar.nonpublic;
3 +
4 + import org.litesoft.GWT.client.*;
5 + import org.litesoft.GWT.client.commands.*;
6 + import org.litesoft.GWT.client.taskbar.*;
7 + import org.litesoft.GWT.client.widgets.*;
8 + import org.litesoft.GWT.client.widgets.nonpublic.*;
9 + import org.litesoft.core.delayed.*;
10 + import org.litesoft.core.util.*;
11 +
12 + import com.google.gwt.user.client.*;
13 + import com.google.gwt.user.client.ui.*;
14 +
15 + public class DockablePanelHelper implements OnBrowserEventListener {
16 + public static final int COLLAPSABLE_BAR_SIZE = 9;
17 +
18 + private AbstractSizeableOneDimensionalPanel mDockablePanel;
19 + private GwtDomDimensionHelper mDimensionHelper;
20 + private TaskbarHelper mTaskbarHelper;
21 + private Widget mDecoratedContent;
22 + private MoveNEWScommands mContextMenu;
23 + private CommonRectangularPoint mPopupRelativeMeetingPoint;
24 + private RectangleContainmentStrategy mRectangleContainmentStrategy;
25 + private String[] mArrows;
26 + private Image mArrow;
27 + private int mIndexArrow;
28 +
29 + private boolean mShowing = true;
30 + private Integer mDecoratedContentSize = null;
31 +
32 + public DockablePanelHelper( AbstractSizeableOneDimensionalPanel pDockablePanel,
33 + GwtDomDimensionHelper pDimensionHelper, TaskbarHelper pTaskbarHelper,
34 + NEWSposition pPosition, String pSeparatorURL, MoveNEWScommands pContextMenu,
35 + AbstractSizeableOneDimensionalPanel pDecoratedContent,
36 + AbstractSizeableOneDimensionalPanel pInnerDecoratedContent,
37 + AbstractSizeableOneDimensionalPanel pContent,
38 + AbstractSizeableOneDimensionalPanel pCollapsableBar,
39 + boolean pContentThenCollapsableBar, String pDefaultUrl,
40 + CommonRectangularPoint pPopupRelativeMeetingPoint, String[] pArrows,
41 + RectangleContainmentStrategy pRectangleContainmentStrategy ) {
42 + mDockablePanel = pDockablePanel;
43 + mDimensionHelper = pDimensionHelper;
44 + (mTaskbarHelper = pTaskbarHelper).setPosition( pPosition );
45 + mDecoratedContent = pDecoratedContent;
46 + mTaskbarHelper.addTo( pContent, pSeparatorURL );
47 + mContextMenu = pContextMenu;
48 + mPopupRelativeMeetingPoint = pPopupRelativeMeetingPoint;
49 + mRectangleContainmentStrategy = pRectangleContainmentStrategy;
50 + mArrows = pArrows;
51 +
52 + mArrow = new Image( pDefaultUrl );
53 + mIndexArrow = mArrows[0].equals( pDefaultUrl ) ? 0 : 1;
54 +
55 + pInnerDecoratedContent.add( pContent );
56 + // pInnerDecoratedContent.add( new SizeableSpacer( 1 ).stretchable() );
57 +
58 + pDecoratedContent.add( new TransparentImage( "TaskBarPreItems" + pPosition ) );
59 + pInnerDecoratedContent.addStyleName( "taskbar_bg" + pPosition );
60 + pDecoratedContent.add( pInnerDecoratedContent );
61 + pDecoratedContent.add( new TransparentImage( "TaskBarPostItems" + pPosition ) );
62 +
63 + pCollapsableBar.addStyleName( "collapsablebar_bg" + pPosition );
64 + pCollapsableBar.add( new SizeableSpacer( COLLAPSABLE_BAR_SIZE ).stretchable() );
65 + pCollapsableBar.add( mArrow );
66 + pCollapsableBar.add( new SizeableSpacer( COLLAPSABLE_BAR_SIZE ).stretchable() );
67 +
68 + if ( pContentThenCollapsableBar ) {
69 + mDockablePanel.add( pDecoratedContent );
70 + mDockablePanel.add( pCollapsableBar );
71 + } else {
72 + mDockablePanel.add( pCollapsableBar );
73 + mDockablePanel.add( pDecoratedContent );
74 + }
75 +
76 + pCollapsableBar.setOnBrowserEventListener( Event.MOUSEEVENTS, this );
77 + }
78 +
79 + public void updateArrow() {
80 + mArrow.setUrl( mArrows[mIndexArrow = (mIndexArrow + 1) & 1] );
81 + }
82 +
83 + public boolean onBrowserEvent( Event event ) {
84 + switch ( DOM.eventGetType( event ) ) {
85 + case Event.ONMOUSEUP:
86 + UtilsGwt.eventPreventDefaultAndCancelBubble( event );
87 + if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
88 + AbstractContextPopup zPopup = new MoveDockedWidgetContextPopup( mContextMenu );
89 + zPopup.addStyleName( "DockPopupMenu" );
90 + zPopup.showContextPopup( event, mRectangleContainmentStrategy, null,
91 + mPopupRelativeMeetingPoint );
92 + } else {
93 + setOpen( !isOpen() );
94 + }
95 + case Event.ONMOUSEOVER:
96 + case Event.ONMOUSEOUT:
97 + case Event.ONMOUSEDOWN:
98 + case Event.ONMOUSEMOVE:
99 + default:
100 + break;
101 + }
102 + return false;
103 + }
104 +
105 + public TaskbarHelper getTaskbarHelper() {
106 + return mTaskbarHelper;
107 + }
108 +
109 + public boolean isOpen() {
110 + return mShowing;
111 + }
112 +
113 + private class SetOpenDelayedProcess implements DelayedProcess {
114 + private boolean mRequestedOpenState;
115 +
116 + public boolean isRequestedOpenState() {
117 + return mRequestedOpenState;
118 + }
119 +
120 + public void setRequestedOpenState( boolean pRequestedOpenState ) {
121 + mRequestedOpenState = pRequestedOpenState;
122 + }
123 +
124 + public boolean process() {
125 + mPendingSetOpen = false;
126 + return LLsetOpen( mRequestedOpenState );
127 + }
128 + }
129 +
130 + private SetOpenDelayedProcess mSetOpenDelayedProcess = new SetOpenDelayedProcess();
131 + private EscalatingProcess mSetOpenEscalatingProcess = null;
132 + private boolean mPendingSetOpen = false;
133 +
134 + private void cancelPendingSetOpen() {
135 + if ( mPendingSetOpen && (mSetOpenEscalatingProcess != null) ) {
136 + mPendingSetOpen = false;
137 + mSetOpenEscalatingProcess.cancel();
138 + }
139 + }
140 +
141 + private void schedulePendingSetOpen( boolean pRequestedOpenState ) {
142 + mSetOpenDelayedProcess.setRequestedOpenState( pRequestedOpenState );
143 + if ( !mPendingSetOpen ) {
144 + if ( mSetOpenEscalatingProcess == null ) {
145 + mSetOpenEscalatingProcess = new EscalatingProcess( mSetOpenDelayedProcess );
146 + }
147 + mPendingSetOpen = true;
148 + }
149 + mSetOpenEscalatingProcess.schedule();
150 + }
151 +
152 + public void setOpen( boolean pOpen ) {
153 + if ( LLsetOpen( pOpen ) ) {
154 + cancelPendingSetOpen();
155 + } else {
156 + schedulePendingSetOpen( pOpen );
157 + }
158 + }
159 +
160 + private boolean LLsetOpen( boolean pOpen ) {
161 + if ( isOpen() != pOpen ) {
162 + if ( !isContentReady() ) {
163 + return false;
164 + }
165 + updateArrow();
166 + int zNewSize = COLLAPSABLE_BAR_SIZE + (pOpen ? mDecoratedContentSize : 0);
167 + mDecoratedContent.setVisible( mShowing = pOpen );
168 + mDimensionHelper.setDimension( mDockablePanel, zNewSize );
169 + mDockablePanel.relayout();
170 + }
171 + return true;
172 + }
173 +
174 + private boolean isContentReady() {
175 + if ( mDecoratedContentSize == null ) {
176 + int zContentSize = mDimensionHelper.getOffsetDimension( mDecoratedContent.getElement() );
177 + if ( zContentSize < 15 ) {
178 + return false;
179 + }
180 + mDecoratedContentSize = zContentSize;
181 + }
182 + return true;
183 + }
184 + }