use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class SelfVosTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": VO settings");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final TabMenu menu = new TabMenu();
final ScrollPanel sp = new ScrollPanel();
sp.setSize("100%", "100%");
sp.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
final ListBoxWithObjects<VirtualOrganization> vosListbox = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(new HTML("<strong>Selected VO:</strong>"));
menu.addWidget(vosListbox);
vp.add(menu);
vp.setCellHeight(menu, "50px");
vp.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
vp.add(new HTML("<hr size=\"1\" color=\"#ccc\">"));
vp.add(sp);
vp.setCellHeight(sp, "100%");
final GetVosWhereUserIsMember whereMember = new GetVosWhereUserIsMember(userId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
vosListbox.clear();
if (vos != null && !vos.isEmpty()) {
for (VirtualOrganization vo : vos) {
vosListbox.addItem(vo);
if (vo.getId() == selectedVoId) {
vosListbox.setSelected(vo, true);
}
}
vosListbox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
selectedVoId = vosListbox.getSelectedObject().getId();
sp.setWidget(displayVoSubtab(vosListbox.getSelectedObject()));
}
});
sp.setWidget(displayVoSubtab(vosListbox.getSelectedObject()));
} else {
vosListbox.addItem("No VO available");
sp.setWidget(new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>You are not member of any VO.</h2>"));
}
}
@Override
public void onLoadingStart() {
vosListbox.clear();
vosListbox.addItem("Loading...");
}
@Override
public void onError(PerunError error) {
vosListbox.clear();
vosListbox.addItem("Error while loading");
sp.clear();
}
});
whereMember.retrieveData();
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class ShellChangeTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
final FlexTable ft = new FlexTable();
ft.setWidth("350px");
ft.setStyleName("inputFormFlexTable");
ft.setHTML(0, 0, "Available shells:");
ft.getFlexCellFormatter().setStyleName(0, 0, "itemName");
final ListBox shells = new ListBox();
shells.setWidth("200px");
ft.setWidget(0, 1, shells);
vp.add(ft);
final CustomButton selectShellButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save preferred shell");
// callback for available shells
GetAttributes attrs = new GetAttributes(new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
shells.clear();
shells.addItem("Error while loading");
}
@Override
public void onFinished(JavaScriptObject jso) {
shells.clear();
ArrayList<Attribute> list = JsonUtils.jsoAsList(jso);
if (list.isEmpty() || list == null) {
shells.addItem("No shells available");
return;
}
// fill shells
for (Attribute a : list) {
if (a.getFriendlyName().equalsIgnoreCase("shells")) {
for (int i = 0; i < a.getValueAsJsArray().length(); i++) {
// fill shell values
shells.addItem(a.getValueAsJsArray().get(i));
}
break;
}
}
// set selected
for (int i = 0; i < shells.getItemCount(); i++) {
if (shells.getValue(i).equals(a.getValue())) {
shells.setSelectedIndex(i);
break;
}
}
if (shells.getValue(shells.getSelectedIndex()).equals(a.getValue())) {
selectShellButton.setEnabled(false);
} else {
selectShellButton.setEnabled(true);
}
}
@Override
public void onLoadingStart() {
shells.clear();
shells.addItem("Loading...");
}
});
final TabItem tab = this;
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
selectShellButton.setEnabled(false);
selectShellButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// OK click button
// set new value
a.setValue(shells.getValue(shells.getSelectedIndex()));
// send request
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
ids.put("facility", resource.getFacilityId());
SetAttribute request = new SetAttribute(JsonCallbackEvents.disableButtonEvents(selectShellButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// refresh only what's necessary
events.onFinished(jso);
// don't refresh underlaying tab
session.getTabManager().closeTab(tab, false);
}
}));
request.setAttribute(ids, a);
}
});
attrs.getResourceAttributes(resource.getId());
attrs.retrieveData();
shells.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (shells.getValue(shells.getSelectedIndex()).equals(a.getValue())) {
selectShellButton.setEnabled(false);
} else {
selectShellButton.setEnabled(true);
}
}
});
final CustomButton defaultButton = new CustomButton("Use default", "", SmallIcons.INSTANCE.lightningIcon());
defaultButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
ids.put("facility", resource.getFacilityId());
RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(defaultButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// refresh only what's necessary
events.onFinished(jso);
// don't refresh underlaying tab
session.getTabManager().closeTab(tab, false);
}
}));
ArrayList<Attribute> list = new ArrayList<Attribute>();
list.add(a);
request.removeAttributes(ids, list);
}
});
menu.addWidget(selectShellButton);
menu.addWidget(defaultButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class UserDetailTabItem method loadFacilities.
private Widget loadFacilities() {
// whole content
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final ListBoxWithObjects<Facility> listbox = new ListBoxWithObjects<Facility>();
menu.addWidget(new HTML("<strong>Select user's Facility:</strong>"));
menu.addWidget(listbox);
// sub content
final SimplePanel subContent = new SimplePanel();
subContent.setSize("100%", "100%");
vp.add(subContent);
vp.setCellHeight(subContent, "100%");
final Hyperlink facilityLabel = new Hyperlink();
menu.addWidget(facilityLabel);
JsonCallbackEvents events = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
listbox.clear();
ArrayList<Facility> list = JsonUtils.jsoAsList(jso);
list = new TableSorter<Facility>().sortByName(list);
for (int i = 0; i < list.size(); i++) {
listbox.addItem(list.get(i));
}
if (!listbox.isEmpty()) {
loadFacilitySubContent(subContent, facilityLabel, listbox);
}
}
@Override
public void onLoadingStart() {
listbox.clear();
listbox.addItem("Loading...");
}
@Override
public void onError(PerunError error) {
listbox.clear();
listbox.addItem("Error while loading");
}
};
GetAssignedFacilities facCall = new GetAssignedFacilities(PerunEntity.USER, user.getId(), events);
facCall.retrieveData();
// change handler
listbox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
loadFacilitySubContent(subContent, facilityLabel, listbox);
}
});
return vp;
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class UserDetailTabItem method loadVosGroupsAccounts.
private Widget loadVosGroupsAccounts() {
// whole content
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
// final VO name widget
final Hyperlink voLabel = new Hyperlink();
final ListBoxWithObjects<VirtualOrganization> listbox = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(new HTML("<strong>Select user's VO:</strong>"));
menu.addWidget(listbox);
menu.addWidget(voLabel);
// sub content
final ScrollPanel subContent = new ScrollPanel();
subContent.setSize("100%", "100%");
vp.add(subContent);
subContent.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(subContent, 400, this);
JsonCallbackEvents events = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
listbox.clear();
ArrayList<VirtualOrganization> list = JsonUtils.jsoAsList(jso);
list = new TableSorter<VirtualOrganization>().sortByShortName(list);
for (int i = 0; i < list.size(); i++) {
listbox.addItem(list.get(i));
}
if (!listbox.isEmpty()) {
loadMemberSubContent(subContent, voLabel, listbox);
}
;
}
@Override
public void onLoadingStart() {
listbox.clear();
listbox.addItem("Loading...");
}
@Override
public void onError(PerunError error) {
listbox.clear();
listbox.addItem("Error while loading");
}
};
GetVosWhereUserIsMember vosCall = new GetVosWhereUserIsMember(user.getId(), events);
vosCall.retrieveData();
// change handler
listbox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
loadMemberSubContent(subContent, voLabel, listbox);
}
});
return vp;
}
use of com.google.gwt.event.dom.client.ChangeEvent in project perun by CESNET.
the class AddVoManagerGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager group");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
final TabMenu tabMenu = new TabMenu();
final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
// get the table
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
}
});
if (box.getAllObjects().isEmpty()) {
GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
box.clear();
ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
if (list != null && !list.isEmpty()) {
box.addAllItems(list);
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
} else {
box.addItem("No VOs found");
}
}
@Override
public void onError(PerunError error) {
box.clear();
box.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
box.clear();
box.addItem("Loading...");
}
});
vos.retrieveData();
}
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
// pass empty first item to tab menu to ensure rest is added
tabMenu.addWidget(new HTML(""));
final TabItem tab = this;
tabMenu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (refreshEvents != null)
refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addWidget(2, new HTML("<strong>Select VO:</strong>"));
tabMenu.addWidget(3, box);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations