use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class CopyMailsTabItem method draw.
public Widget draw() {
final FlexTable content = new FlexTable();
content.setStyleName("inputFormFlexTable");
// boxes
final ListBoxWithObjects<VirtualOrganization> vosBox = new ListBoxWithObjects<VirtualOrganization>();
final ListBoxWithObjects<Group> groupsBox = new ListBoxWithObjects<Group>();
final CustomButton save;
final TabItem tab = this;
VerticalPanel vp = new VerticalPanel();
TabMenu menu = new TabMenu();
titleWidget.setText("Copy form items from VO / group");
save = TabMenu.getPredefinedButton(ButtonType.OK, ButtonTranslation.INSTANCE.copyFromVo());
// get them
final GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
vosBox.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
vosBox.addAllItems(vos);
// get them
GetAllGroups getGroups = new GetAllGroups(voId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
@Override
public void onError(PerunError error) {
vosBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
vosBox.addItem("Loading...");
save.setEnabled(false);
}
});
vos.retrieveData();
vosBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (vosBox.getSelectedObject() != null) {
// get them
GetAllGroups getGroups = new GetAllGroups(vosBox.getSelectedObject().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
groupsBox.clear();
ArrayList<Group> groups = JsonUtils.jsoAsList(jso);
groups = new TableSorter<Group>().sortByName(groups);
groupsBox.addNotSelectedOption();
groupsBox.addAllItems(groups);
save.setEnabled(true);
}
@Override
public void onError(PerunError error) {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Error while loading");
save.setEnabled(false);
}
@Override
public void onLoadingStart() {
groupsBox.removeNotSelectedOption();
groupsBox.clear();
groupsBox.addItem("Loading...");
save.setEnabled(false);
}
});
getGroups.retrieveData();
}
}
});
content.setHTML(0, 0, "Source VO:");
content.getFlexCellFormatter().setStyleName(0, 0, "itemName");
content.setWidget(0, 1, vosBox);
content.setHTML(1, 0, "Source group:");
content.getFlexCellFormatter().setStyleName(1, 0, "itemName");
content.setWidget(1, 1, groupsBox);
save.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
CopyMails request = null;
if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId == 0) {
// from group to VO
request = new CopyMails(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId != 0) {
// from group to group
request = new CopyMails(PerunEntity.GROUP, groupsBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId == 0) {
// from VO to VO
request = new CopyMails(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
} else if (groupsBox.getSelectedIndex() == 0 && voId != 0 && groupId != 0) {
// from VO to group
request = new CopyMails(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
}
request.copyMails();
}
});
content.setHTML(2, 0, "All mail definitions will be added to yours.");
content.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
content.getFlexCellFormatter().setColSpan(2, 0, 2);
menu.addWidget(save);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(content);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class CreateFacilityResourceManageServicesTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Create resource: Assign and configure services");
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(alreadyAdded);
vp.add(new HTML("<hr>"));
// buttons
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Assign selected service to resource");
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove selected service from resource");
CustomButton finishButton = TabMenu.getPredefinedButton(ButtonType.FINISH, "Finishes services assigning and configuration");
finishButton.setImageAlign(true);
// listbox with services
final ListBoxWithObjects<Service> servicesListbox = new ListBoxWithObjects<Service>();
// checkbox to swith offered services
final CheckBox switchBox = new CheckBox("Show assigned", false);
switchBox.setTitle("Switching between 'all' and 'already assigned' services in menu.");
// fill menu
menu.addWidget(new HTML("<strong>Selected service: </strong>"));
menu.addWidget(servicesListbox);
menu.addWidget(switchBox);
menu.addWidget(assignButton);
menu.addWidget(removeButton);
menu.addWidget(finishButton);
// fill listbox with services (used for both callbacks)
JsonCallbackEvents fillEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<Service> services = JsonUtils.jsoAsList(jso);
services = new TableSorter<Service>().sortByName(services);
servicesListbox.clear();
for (Service serv : services) {
servicesListbox.addItem(serv);
}
if (servicesListbox.isEmpty()) {
servicesListbox.addItem("No service assigned");
if (vp.getWidgetCount() > 3) {
vp.remove(3);
}
return;
}
if (vp.getWidgetCount() > 3) {
vp.remove(3);
}
vp.add(new ResourceSettingsTabItem(resource, servicesListbox.getSelectedObject()).draw());
vp.setCellHeight(vp.getWidget(3), "100%");
}
@Override
public void onError(PerunError error) {
servicesListbox.clear();
servicesListbox.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
servicesListbox.clear();
servicesListbox.addItem("Loading...");
}
};
// callbacks
final GetServices services = new GetServices(fillEvents);
final GetAssignedServices assignedServices = new GetAssignedServices(resource.getId(), fillEvents);
services.retrieveData();
// switching event between services
servicesListbox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
// remove attributes management if there was
if (vp.getWidgetCount() > 3) {
vp.remove(3);
}
// add attributes management
vp.add(new ResourceSettingsTabItem(resource, servicesListbox.getSelectedObject()).draw());
vp.setCellHeight(vp.getWidget(3), "100%");
}
});
// switching between offered services (assigned - all)
switchBox.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (switchBox.getValue() == false) {
servicesListbox.clear();
services.retrieveData();
} else {
servicesListbox.clear();
assignedServices.retrieveData();
}
}
});
// button events
assignButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (servicesListbox.isEmpty()) {
UiElements.generateInfo("No Service selected", "You must select a service first.");
return;
}
final Service service = servicesListbox.getSelectedObject();
AssignService request = new AssignService(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
alreadyAddedList.add(service);
rebuildAlreadyAddedWidget();
}
}));
request.assignService(service.getId(), resource.getId());
}
});
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (servicesListbox.isEmpty()) {
UiElements.generateInfo("No Service selected", "You must select a service first.");
return;
}
final Service service = servicesListbox.getSelectedObject();
RemoveService request = new RemoveService(JsonCallbackEvents.disableButtonEvents(removeButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
Iterator<Service> iter = alreadyAddedList.iterator();
while (iter.hasNext()) {
Service s = iter.next();
if (s.getId() == service.getId()) {
iter.remove();
}
}
rebuildAlreadyAddedWidget();
}
}));
request.removeService(servicesListbox.getSelectedObject().getId(), resource.getId());
}
});
final TabItem tab = this;
finishButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab);
}
});
this.contentWidget.setWidget(vp);
rebuildAlreadyAddedWidget();
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class ManageGroupsBeforeAssigning method draw.
public Widget draw() {
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
final ListBoxWithObjects<Group> groupsDropDown = new ListBoxWithObjects<Group>();
for (Group grp : groupsToAssign) {
groupsDropDown.addItem(grp);
}
final ListBoxWithObjects<Group> subgroupsDropDown = new ListBoxWithObjects<Group>();
subgroupsDropDown.addNotSelectedOption();
final CustomButton finishAssigningButton = TabMenu.getPredefinedButton(ButtonType.FINISH, ButtonTranslation.INSTANCE.finishGroupAssigning());
final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(finishAssigningButton, this);
final JsonCallbackEvents disableButtonEvents = JsonCallbackEvents.disableButtonEvents(finishAssigningButton);
finishAssigningButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// assign all
if (groupsDropDown.getSelectedIndex() == 0) {
AssignGroupsToResource request = new AssignGroupsToResource(closeTabEvents);
request.assignGroupsToResource(groupsToAssign, resource);
} else {
// assign selected
if (groupsDropDown.getSelectedObject() == null) {
Window.alert("No group selected");
return;
}
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// call previus events
closeTabEvents.onFinished(null);
// removed finished group
groupsDropDown.removeSelectedItem();
if (groupsDropDown.isEmpty()) {
// if no group left - close windows
closeTabEvents.onFinished(null);
}
}
};
AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(finishAssigningButton, localEvents));
request.assignGroupToResources(groupsDropDown.getSelectedObject(), JsonUtils.<RichResource>toList(resource));
}
}
});
menu.addWidget(finishAssigningButton);
menu.addWidget(new HTML("<strong>Selected group: </strong>"));
menu.addWidget(groupsDropDown);
// TODO - get subgroups correctly too
//menu.addWidget(new HTML("<strong>Configure sub-groups: </strong>"));
//menu.addWidget(subgroupsDropDown);
vp.add(menu);
vp.setCellHeight(menu, "30px");
groupsDropDown.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
// removes previous table
if (vp.getWidgetCount() == 2) {
vp.remove(1);
}
if (groupsDropDown.getSelectedIndex() > 0) {
/*
// fill subgroups listbox with groups
subgroupsDropDown.removeAllOption();
subgroupsDropDown.removeNotSelectedOption();
subgroupsDropDown.clear();
subgroupsDropDown.addNotSelectedOption();
for (Group grp : findSubgroups(groupsDropDown.getSelectedObject())){
subgroupsDropDown.addItem(grp);
}
subgroupsDropDown.addAllOption();
*/
// some group selected
TabItem ti = new GroupResourceRequiredAttributesTabItem(resourceId, groupsDropDown.getSelectedObject().getId());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
} else {
/*
//clear listbox
subgroupsDropDown.removeAllOption();
subgroupsDropDown.removeNotSelectedOption();
subgroupsDropDown.clear();
subgroupsDropDown.addNotSelectedOption();
subgroupsDropDown.addItem("All");
*/
// all groups tab
TabItem ti = new GroupsResourceRequiredAttributesTabItem(resourceId, groupsToAssign);
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
}
}
});
/*
subgroupsDropDown.addChangeHandler(new ChangeHandler(){
public void onChange(ChangeEvent event) {
if (vp.getWidgetCount() == 2) { vp.remove(1); } // removes previous table
if (subgroupsDropDown.getSelectedIndex() > 1){
// sub-group selected
TabItem ti = new GroupResourceRequiredAttributesTabItem(session, resourceId, subgroupsDropDown.getSelectedObject().getId());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
} else if (subgroupsDropDown.getSelectedIndex() == 1){
// all selected
if (groupsDropDown.getSelectedIndex() > 0) {
// all subgroups of selected group
TabItem ti = new GroupsResourceRequiredAttributesTabItem(session, resourceId, subgroupsDropDown.getAllObjects());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
} else {
// all groups and subgroups
TabItem ti = new GroupsResourceRequiredAttributesTabItem(session, resourceId, allGroups);
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
}
} else {
// parent-group selected / subgroup not selected
TabItem ti = new GroupResourceRequiredAttributesTabItem(session, resourceId, groupsDropDown.getSelectedObject().getId());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
}
}
});
*/
TabItem ti = new GroupResourceRequiredAttributesTabItem(resourceId, groupsDropDown.getSelectedObject().getId());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
groupsDropDown.addAllOption();
/*
// if some group selected
if (groupsDropDown.getSelectedObject() != null){
// fill subgroups listbox with groups
subgroupsDropDown.addNotSelectedOption();
for (Group grp : findSubgroups(groupsDropDown.getSelectedObject())){
subgroupsDropDown.addItem(grp);
}
subgroupsDropDown.addAllOption();
}
*/
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class GroupsTabItem method draw.
public Widget draw() {
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// Horizontal menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
//call
ArrayList<String> attrNames = new ArrayList<>();
attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
groups.setCheckable(false);
// listbox
final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(new HTML("<strong>Selected VO: </strong>"));
menu.addWidget(vos);
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Select VO to see groups that you can manage.</strong>"));
final TabItem tab = this;
// groups table
CellTable<RichGroup> table = groups.getEmptyTable(new FieldUpdater<RichGroup, String>() {
public void update(int index, RichGroup group, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
// close group selection tab when group is selected
session.getTabManager().closeTab(tab, false);
}
});
// listbox change => load vo's groups
vos.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
});
// initial fill listbox and trigger groups loading
GetVos vosCall = new GetVos(new JsonCallbackEvents() {
public void onLoadingStart() {
vos.clear();
vos.addItem("Loading...");
}
public void onFinished(JavaScriptObject jso) {
vos.clear();
ArrayList<VirtualOrganization> returnedVos = JsonUtils.jsoAsList(jso);
returnedVos = new TableSorter<VirtualOrganization>().sortByName(returnedVos);
if (returnedVos == null || returnedVos.isEmpty()) {
vos.addItem("No VO available");
return;
}
// put and set selected
for (int i = 0; i < returnedVos.size(); i++) {
vos.addItem(returnedVos.get(i));
if (voId == returnedVos.get(i).getId()) {
vos.setSelected(returnedVos.get(i), true);
}
}
// trigger loading of groups for selected VO
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
public void onError(PerunError error) {
vos.clear();
vos.addItem("Error while loading");
}
;
});
vosCall.retrieveData();
// set width to 100%
table.setWidth("100%");
// add menu and table to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class SendPasswordResetRequestTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Send password reset request");
VerticalPanel vp = new VerticalPanel();
vp.setSize("300px", "100%");
final FlexTable layout = new FlexTable();
layout.setSize("100%", "100%");
layout.setStyleName("inputFormFlexTable");
layout.setHTML(0, 0, "Select namespace:");
layout.getFlexCellFormatter().setStyleName(0, 0, "itemName");
layout.setHTML(1, 0, "Login:");
layout.getFlexCellFormatter().setStyleName(1, 0, "itemName");
final ListBox namespaces = new ListBox();
layout.setWidget(0, 1, namespaces);
final CustomButton changeButton = new CustomButton("Send", "Send email with reset password link", SmallIcons.INSTANCE.emailIcon());
GetLogins logins = new GetLogins(member.getUserId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
namespaces.clear();
ArrayList<Attribute> logins = JsonUtils.jsoAsList(jso);
if (logins != null && !logins.isEmpty()) {
changeButton.setEnabled(true);
for (Attribute a : logins) {
if (Utils.getSupportedPasswordNamespaces().contains(a.getFriendlyNameParameter())) {
namespaces.addItem(a.getFriendlyNameParameter().toUpperCase(), a.getValue());
layout.setHTML(1, 1, a.getValue());
}
}
}
}
public void onLoadingStart() {
changeButton.setEnabled(false);
namespaces.clear();
namespaces.addItem("Loading...");
}
public void onError(PerunError error) {
namespaces.clear();
namespaces.addItem("Error while loading");
}
});
logins.retrieveData();
namespaces.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
layout.setHTML(1, 1, namespaces.getValue(namespaces.getSelectedIndex()));
}
});
TabMenu menu = new TabMenu();
final TabItem tab = this;
// by default false
changeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
SendPasswordResetLinkEmail request = new SendPasswordResetLinkEmail(JsonCallbackEvents.closeTabDisableButtonEvents(changeButton, tab));
request.sendEmail(member, namespaces.getItemText(namespaces.getSelectedIndex()).toLowerCase());
}
});
menu.addWidget(changeButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, ButtonTranslation.INSTANCE.cancelButton(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations