litesoft
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
|
package com.temp.client.foundation.util;
import com.google.gwt.user.client.ui.HasEnabled;
/**
* The purpose of this class is to manage the "Enabled" State of a a bunch of
* objects that implement "HasEnabled" (usually UI Widgets, specifically
* Buttons, and Input, which share this interface, but do not have a common
* super class that has "setEnabled(boolean)"). It is planned to be used for
* disabling a bunch of widgets when the data is being collected from the
* Server.
*
* This class, when disable is requested, snags the current Enabled State of all
* the Objects, and will then restore this state when enable is requested.
*
* @author georgs
*/
public class HasEnabledSetManager {
private final HasEnabled[] enableManageables;
private boolean[] snaggedState;
public HasEnabledSetManager(HasEnabled... enableManageables) {
this.enableManageables = enableManageables;
}
public void snagStateAndDisable() {
snagStateAndSetState(false);
}
public void snagStateAndEnable() {
snagStateAndSetState(true);
}
public boolean restoreState() {
if (snaggedState == null) {
return false;
}
for (int i = 0; i < enableManageables.length; i++) {
enableManageables[i].setEnabled(snaggedState[i]);
}
return true;
}
private void snagStateAndSetState(boolean enable) {
snaggedState = new boolean[enableManageables.length];
for (int i = 0; i < enableManageables.length; i++) {
HasEnabled enableManageable = enableManageables[i];
snaggedState[i] = enableManageable.isEnabled();
enableManageable.setEnabled(enable);
}
}
}
|
Revision |
Author |
Commited |
Message |
626
|
GeorgeS
|
Wed 11 Apr, 2012 19:39:41 +0000 |
|