use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class CreateCompleteService method createCompleteService.
/**
* Attempts to create a new Service including both ExecServices with dependency,
* it first tests the values and then submits them.
*
* @param name service Name
* @param scriptPath Path to the service script, default "./service_name"
* @param defaultDelay Delay in minutes when service is rescheduled (10 min is default)
* @param enabled TRUE if service should be enabled
*/
public void createCompleteService(final String name, final String scriptPath, final int defaultDelay, final boolean enabled) {
this.serviceName = name;
this.scriptPath = scriptPath;
this.defaultDelay = defaultDelay;
this.enabled = enabled;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Creating service " + serviceName + " failed.");
// custom events
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Service " + serviceName + " created.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class DeleteTask method deleteTask.
/**
* Deletes Task from DB
*
* @param taskId id of Task to be deleted
*/
public void deleteTask(final int taskId) {
this.taskId = taskId;
// test arguments
if (!this.testArguments()) {
return;
}
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("task", new JSONNumber(taskId));
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting of Task: " + taskId + " failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Task: " + taskId + " deleted successfully.");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class AddGroupManagerTabItem method startSearching.
/**
* Starts the search for users
*/
protected void startSearching(String text) {
users.clearTable();
// IS searched string IDs?
if (JsonUtils.isStringWithIds(text)) {
FindUsersByIdsNotInRpc req = new FindUsersByIdsNotInRpc(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<User> usersList = JsonUtils.jsoAsList(jso);
for (User u : usersList) {
users.addToTable(u);
}
}
}, text);
req.retrieveData();
return;
}
users.searchFor(text);
}
use of com.google.gwt.core.client.JavaScriptObject in project perun by CESNET.
the class AddDependencyTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add dependency");
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
final ListBoxWithObjects<ExecService> listBox = new ListBoxWithObjects<ExecService>();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addDependantExecService());
// fill listbox after callback finishes
final JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
listBox.clear();
ArrayList<ExecService> execs = JsonUtils.jsoAsList(jso);
if (execs != null && !execs.isEmpty()) {
execs = new TableSorter<ExecService>().sortByService(execs);
for (int i = 0; i < execs.size(); i++) {
listBox.addItem(execs.get(i));
if (execService.getService().getName().equals(execs.get(i).getService().getName()) && !execService.getType().equals(execs.get(i).getType())) {
// preselect different type of exec service from same service
listBox.setSelected(execs.get(i), true);
}
}
addButton.setEnabled(true);
} else {
listBox.addItem("No exec service available");
}
}
@Override
public void onLoadingStart() {
listBox.clear();
listBox.addItem("Loading...");
addButton.setEnabled(false);
}
@Override
public void onError(PerunError error) {
listBox.addItem("Error while loading");
addButton.setEnabled(false);
}
};
// callback for all services
ListExecServices callback = new ListExecServices(0, localEvents);
callback.retrieveData();
// layout
layout.setHTML(0, 0, "ExecService:");
layout.setHTML(1, 0, "Depend On:");
layout.setHTML(0, 1, execService.getService().getName() + " " + execService.getType());
layout.setWidget(1, 1, listBox);
final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab);
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
CreateDependency request = new CreateDependency(closeTabEvents);
request.createDependancy(execServiceId, listBox.getSelectedObject().getId());
}
});
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
menu.addWidget(addButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.core.client.JavaScriptObject in project gerrit by GerritCodeReview.
the class ProjectGlue method onAction.
public static void onAction(Project.NameKey project, BranchInfo branch, ActionInfo action, ActionButton button) {
RestApi api = ProjectApi.project(project).view("branches").id(branch.ref()).view(action.id());
JavaScriptObject f = branchAction(action.id());
if (f != null) {
ActionContext c = ActionContext.create(api);
c.set(action);
c.set(project);
c.set(branch);
c.button(button);
ApiGlue.invoke(f, c);
} else {
DefaultActions.invoke(project, action, api);
}
}
Aggregations