source: other-projects/FileTransfer-WebSocketPair/ServerActionResponseBundle/org/nbk4/gwt/action/client/ActionObjectBuilder.java@ 31449

Last change on this file since 31449 was 31449, checked in by davidb, 7 years ago

Adding three project folders for Nathan Kelly's 2016/2017 summer project, experimenting with Websockets for File Transfer with GWT and Sencha GXT

File size: 2.1 KB
Line 
1package org.nbk4.gwt.action.client;
2
3import java.io.Serializable;
4import java.util.ArrayList;
5
6import com.google.gwt.user.client.rpc.IsSerializable;
7
8@SuppressWarnings("serial")
9public class ActionObjectBuilder extends ActionObject implements Serializable, IsSerializable {
10 public static ActionObject loadBarUpdateActionObject(double progress, String message) {
11 int idIndex = 0;
12
13 ActionType actionType = ActionType.UPDATE_PROGRESSBAR;
14 long actionID = getID();
15 ArrayList<ActionProperty> properties = new ArrayList<ActionProperty>(2);
16
17 ActionProperty progressProperty = new ActionProperty(ActionTypeProperty.PROGRESS_BAR_PROGRESS, idIndex++, Double.toString(progress));
18
19 ActionProperty messageProperty = new ActionProperty(ActionTypeProperty.PROGRESS_BAR_STRING, idIndex++, message);
20
21 properties.add(progressProperty);
22 if(message != null) {
23 properties.add(messageProperty);
24 }
25
26 ActionObject loadbar = new ActionObject(actionType, actionID, properties);
27
28 return loadbar;
29 }
30
31 public static ActionObject messageBoxSpawnObject(String header, String text, String[] buttons, boolean response) {
32 int idIndex = 0;
33
34 ActionType actionType = response ? ActionType.SHOW_DIALOG : ActionType.SHOW_DIALOG_NORESPONSE;
35 long actionID = getID();
36 ArrayList<ActionProperty> properties = new ArrayList<ActionProperty>(buttons.length + 3); //buttons, window close, text, header
37
38 for(String button : buttons) {
39 ActionProperty buttonProperty = new ActionProperty(ActionTypeProperty.BUTTON, idIndex++, button);
40 properties.add(buttonProperty);
41 }
42
43 //ensure any additional fluff comes after the button offset, so we can accurately respond with the button index on the client side
44 ActionProperty windowTitleProperty = new ActionProperty(ActionTypeProperty.MESSAGE_WINDOW_TITLE, idIndex++, header);
45 ActionProperty windowTextProperty = new ActionProperty(ActionTypeProperty.MESSAGE_WINDOW_TEXT, idIndex++, text);
46
47 properties.add(windowTitleProperty);
48 properties.add(windowTextProperty);
49
50 ActionObject messageBoxObject = new ActionObject(actionType, actionID, properties);
51
52 return messageBoxObject;
53 }
54}
Note: See TracBrowser for help on using the repository browser.