use of com.github.openjson.JSONObject in project wicket by apache.
the class ModalWindow method getWindowOpenJavaScript.
/**
* Returns the javascript used to open the window. Subclass
* {@link #postProcessSettings(AppendingStringBuffer)} to modify the JavaScript if needed.
*
* See WICKET-12
*
* @return javascript that opens the window
*/
protected final String getWindowOpenJavaScript() {
JSONObject settings = new JSONObject();
settings.put("minWidth", getMinimalWidth());
settings.put("minHeight", getMinimalHeight());
settings.put("className", getCssClassName());
settings.put("width", getInitialWidth());
if ((isUseInitialHeight() == true) || (isCustomComponent() == false)) {
settings.put("height", getInitialHeight());
} else {
settings.put("height", (Object) null);
}
settings.put("resizable", isResizable());
if (isResizable() == false) {
settings.put("widthUnit", getWidthUnit());
settings.put("heightUnit", getHeightUnit());
}
if (isCustomComponent() == false) {
Page page = createPage();
if (page == null) {
throw new WicketRuntimeException("Error creating page for modal dialog.");
}
CharSequence pageUrl;
RequestCycle requestCycle = RequestCycle.get();
page.getSession().getPageManager().touchPage(page);
if (page.isPageStateless()) {
pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
} else {
IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
pageUrl = requestCycle.urlFor(handler);
}
settings.put("src", pageUrl);
} else {
settings.put("element", new JSONFunction("document.getElementById(\"" + getContentMarkupId() + "\")"));
}
if (getCookieName() != null) {
settings.put("cookieId", getCookieName());
}
String title = getTitle() != null ? getTitle().getObject() : null;
if (title != null) {
settings.put("title", getDefaultModelObjectAsString(title));
}
if (getMaskType() == MaskType.TRANSPARENT) {
settings.put("mask", "transparent");
} else if (getMaskType() == MaskType.SEMI_TRANSPARENT) {
settings.put("mask", "semi-transparent");
}
settings.put("autoSize", autoSize);
settings.put("unloadConfirmation", showUnloadConfirmation());
// set true if we set a windowclosedcallback
boolean haveCloseCallback = false;
// notification request
if (windowClosedCallback != null) {
WindowClosedBehavior behavior = getBehaviors(WindowClosedBehavior.class).get(0);
settings.put("onClose", new JSONFunction("function() { " + behavior.getCallbackScript() + " }"));
haveCloseCallback = true;
}
// close window property (thus cleaning the shown flag)
if ((closeButtonCallback != null) || (haveCloseCallback == false)) {
CloseButtonBehavior behavior = getBehaviors(CloseButtonBehavior.class).get(0);
settings.put("onCloseButton", new JSONFunction("function() { " + behavior.getCallbackScript() + "; return false; }"));
}
postProcessSettings(settings);
AppendingStringBuffer buffer = new AppendingStringBuffer(500);
buffer.append("var settings = ");
buffer.append(settings.toString());
buffer.append(";");
buffer.append(getShowJavaScript());
return buffer.toString();
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class Whiteboard method clearSlide.
public JSONArray clearSlide(int slide) {
JSONArray arr = new JSONArray();
roomItems.entrySet().removeIf(e -> {
JSONObject o = new JSONObject(e.getValue());
boolean match = !FileItem.Type.Presentation.name().equals(o.optString(ATTR_FILE_TYPE)) && o.optInt(ATTR_SLIDE, -1) == slide;
if (match) {
arr.put(e);
}
return match;
});
return arr;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class ExternalUserDTO method fromString.
public static ExternalUserDTO fromString(String s) {
JSONObject o = new JSONObject(s);
ExternalUserDTO u = new ExternalUserDTO();
u.email = o.optString("email", null);
u.externalId = o.optString("externalId", null);
u.externalType = o.optString("externalType", null);
u.firstname = o.optString("firstname", null);
u.lastname = o.optString("lastname", null);
u.login = o.optString("login", null);
u.profilePictureUrl = o.optString("profilePictureUrl", null);
return u;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class UserDTO method get.
public static UserDTO get(JSONObject o) {
if (o == null) {
return null;
}
UserDTO u = new UserDTO();
u.id = optLong(o, "id");
u.login = o.optString("login");
u.password = o.optString("password");
u.firstname = o.optString("firstname");
u.lastname = o.optString("lastname");
u.rights.addAll(optEnumList(Right.class, o.optJSONArray("rights")));
u.languageId = o.optLong("languageId");
JSONObject a = o.optJSONObject("address");
if (a != null) {
u.address.setId(optLong(a, "id"));
u.address.setCountry(a.optString("country"));
u.address.setEmail(a.optString("email"));
}
u.timeZoneId = o.optString("timeZoneId");
u.externalId = o.optString("externalId");
u.externalType = o.optString("externalType");
u.type = optEnum(Type.class, o, "type");
return u;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class KRoom method removeParticipant.
private void removeParticipant(final KurentoHandler h, String name) {
participants.remove(name);
log.debug("ROOM {}: notifying all users that {} is leaving the room", this.roomId, name);
final List<String> unnotifiedParticipants = new ArrayList<>();
final JSONObject msg = newKurentoMsg();
msg.put("id", "participantLeft");
msg.put("name", name);
for (final KUser participant : participants.values()) {
participant.cancelVideoFrom(name);
h.sendClient(participant.getUid(), msg);
}
if (!unnotifiedParticipants.isEmpty()) {
log.debug("ROOM {}: The users {} could not be notified that {} left the room", this.roomId, unnotifiedParticipants, name);
}
}
Aggregations