use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AddRequiredAttributesTabItem method draw.
public Widget draw() {
titleWidget.setText("Add required attributes");
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
final GetAttributesDefinition attrDefs = new GetAttributesDefinition();
attrDefs.setEditable(false);
CellTable<AttributeDefinition> table = attrDefs.getTable();
TabMenu menu = new TabMenu();
final TabItem tab = this;
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedRequiredAttribute());
final ExtendedSuggestBox box = new ExtendedSuggestBox(attrDefs.getOracle());
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
attrDefs.filterTable(text);
if (attrDefs.getList().size() == 1) {
attrDefs.getSelectionModel().setSelected(attrDefs.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterAttributeDefinition());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<AttributeDefinition> attributesToAdd = attrDefs.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(attributesToAdd)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < attributesToAdd.size(); i++) {
final int n = i;
AddRequiredAttribute request = new AddRequiredAttribute(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added attribute
attrDefs.getSelectionModel().setSelected(attributesToAdd.get(n), false);
alreadyAddedList.add(attributesToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.addRequiredAttribute(serviceId, attributesToAdd.get(i).getId());
}
}
}
});
menu.addWidget(addButton);
// cancel button
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(attrDefs, table, addButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
mainTab.add(menu);
mainTab.setCellHeight(menu, "30px");
mainTab.add(alreadyAdded);
mainTab.add(sp);
mainTab.setCellHeight(sp, "100%");
// add tabs to the main panel
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class CreateServicePackageTabItem method draw.
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final ExtendedTextBox packageName = new ExtendedTextBox();
final ExtendedTextBox packageDescription = new ExtendedTextBox();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (packageName.getTextBox().getText().trim().isEmpty()) {
packageName.setError("Name can't be empty");
return false;
} else {
packageName.setOk();
return true;
}
}
};
packageName.setValidator(validator);
final ExtendedTextBox.TextBoxValidator validator2 = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (packageDescription.getTextBox().getText().trim().isEmpty()) {
packageDescription.setError("Description can't be empty");
return false;
} else {
packageDescription.setOk();
return true;
}
}
};
packageDescription.setValidator(validator);
// prepares layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexTable.FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// close tab events
final TabItem tab = this;
TabMenu menu = new TabMenu();
// fill form
layout.setHTML(0, 0, "Name:");
layout.setWidget(0, 1, packageName);
layout.setHTML(1, 0, "Description:");
layout.setWidget(1, 1, packageDescription);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
// create button
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createServicePackage());
createButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (validator.validateTextBox() && validator2.validateTextBox()) {
CreateServicePackage request = new CreateServicePackage(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
request.createServicePackage(packageName.getTextBox().getText().trim(), packageDescription.getTextBox().getText().trim());
}
}
});
// cancel button
final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
});
menu.addWidget(createButton);
menu.addWidget(cancelButton);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
// add tabs to the main panel
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AddMemberToGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add member(s)");
// MAIN PANEL
final VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
boolean isMembersGroup = group.isCoreGroup();
// if members or admins group, hide
if (isMembersGroup) {
firstTabPanel.add(new HTML("<p>Group \"" + group.getName() + "\" can't have members managed from Group admin. Please use VO admin section.</p>"));
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
// MENU
TabMenu tabMenu = new TabMenu();
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// for resize
final TabItem tab = this;
// CALLBACKS
// for both
final FindCompleteRichMembers findMembers;
// for both
final GetCompleteRichMembers getAllMembers;
// for VO/group admin differs search
final FindCandidatesOrUsersToAddToVo findCandidatesOrUsersToAddToVo;
// elements handled by callback events
final CustomButton searchButton = new CustomButton("Search in VO", ButtonTranslation.INSTANCE.searchMemberInVo(), SmallIcons.INSTANCE.findIcon());
final CustomButton searchGloballyButton = new CustomButton("Search globally", ButtonTranslation.INSTANCE.searchForMembersInExtSources(), SmallIcons.INSTANCE.findIcon());
final CustomButton listAllButton = new CustomButton("List all VO members", ButtonTranslation.INSTANCE.listAllMembersInVo(), SmallIcons.INSTANCE.userGreenIcon());
final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
// search through whole VO
findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), "", null);
getAllMembers = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), null);
if (session.isVoAdmin(group.getVoId())) {
// will search vo ext sources and users
findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), 0, "", null);
} else {
// will search group ext sources only
findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), group.getId(), "", null);
}
final CellTable<Candidate> candidatesTable = findCandidatesOrUsersToAddToVo.getEmptyTable();
final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {
// when user click on a row -> open new tab
public void update(int index, RichMember object, RichMember value) {
session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
}
});
final CustomButton inviteButton = new CustomButton("Invite selected", SmallIcons.INSTANCE.emailIcon());
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedMemberToGroup());
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
public void searchFor(String text) {
searchString = text;
findMembers.searchFor(searchString);
search = true;
searchCandidates = false;
// remove previous table
firstTabPanel.getWidget(2).removeFromParent();
firstTabPanel.add(sp);
UiElements.runResizeCommands(tab);
}
}, searchButton);
searchBox.getTextBox().setText(searchString);
// bind text box also to search globally
searchBox.getTextBox().addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
if (!searchBox.getTextBox().getText().trim().isEmpty()) {
searchGloballyButton.setEnabled(true);
// do not trigger search on both !!
} else {
searchGloballyButton.setEnabled(false);
}
}
});
searchBox.getTextBox().addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent event) {
// fake some meaningless KeyUpEvent
DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
}
});
searchBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
// fake some meaningless KeyUpEvent
DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
}
});
// button click triggers action
searchGloballyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (UiElements.searchStingCantBeEmpty(searchBox.getTextBox().getText().trim())) {
new PerunSearchEvent() {
public void searchFor(String text) {
searchString = text;
findCandidatesOrUsersToAddToVo.searchFor(searchString);
searchCandidates = true;
search = false;
// remove previous table
firstTabPanel.getWidget(2).removeFromParent();
firstTabPanel.add(sp2);
UiElements.runResizeCommands(tab);
}
}.searchFor(searchBox.getTextBox().getText().trim());
}
}
});
searchGloballyButton.setEnabled(false);
findMembers.setEvents(JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
listAllButton.setEnabled(true);
searchGloballyButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
ArrayList<RichMember> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
findMembers.getSelectionModel().setSelected(list.get(0), true);
}
}
@Override
public void onError(PerunError error) {
listAllButton.setEnabled(true);
searchGloballyButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
}
@Override
public void onLoadingStart() {
listAllButton.setEnabled(false);
searchGloballyButton.setEnabled(false);
disabled.setVisible(false);
searchBox.getTextBox().setEnabled(false);
addButton.setEnabled(false);
inviteButton.setEnabled(false);
}
}));
getAllMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// pass data to table handling callback
findMembers.onFinished(jso);
((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
searchButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
}
@Override
public void onError(PerunError error) {
// pass data to table handling callback
findMembers.onError(error);
searchButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
}
@Override
public void onLoadingStart() {
searchButton.setEnabled(false);
disabled.setVisible(true);
searchBox.getTextBox().setEnabled(false);
addButton.setEnabled(false);
inviteButton.setEnabled(false);
}
}));
findCandidatesOrUsersToAddToVo.setEvents(JsonCallbackEvents.disableButtonEvents(searchGloballyButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
listAllButton.setEnabled(true);
searchButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
ArrayList<Candidate> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
findCandidatesOrUsersToAddToVo.setSelected(list.get(0));
}
}
@Override
public void onError(PerunError error) {
listAllButton.setEnabled(true);
searchButton.setEnabled(true);
searchBox.getTextBox().setEnabled(true);
}
@Override
public void onLoadingStart() {
disabled.setVisible(false);
listAllButton.setEnabled(false);
searchButton.setEnabled(false);
searchBox.getTextBox().setEnabled(false);
addButton.setEnabled(false);
inviteButton.setEnabled(false);
}
}));
// DISABLED CHECKBOX
disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
disabled.setVisible(false);
// checkbox click handler
disabled.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
getAllMembers.excludeDisabled(!disabled.getValue());
findMembers.clearTable();
getAllMembers.retrieveData();
}
});
listAllButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
search = false;
searchCandidates = false;
searchString = "";
searchBox.getTextBox().setText("");
findMembers.clearTable();
findCandidatesOrUsersToAddToVo.clearTable();
getAllMembers.retrieveData();
// remove previous table
firstTabPanel.getWidget(2).removeFromParent();
firstTabPanel.add(sp);
UiElements.runResizeCommands(tab);
}
});
// click handler
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (searchCandidates) {
// searched users or candidates
Candidate candidateToBeAdded = findCandidatesOrUsersToAddToVo.getSelected();
if (candidateToBeAdded == null) {
UiElements.cantSaveEmptyListDialogBox(null);
} else {
if (candidateToBeAdded.getObjectType().equalsIgnoreCase("Candidate")) {
CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
private Candidate saveSelected;
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
if (saveSelected != null) {
GeneralObject go = saveSelected.cast();
alreadyAddedList.add(go);
}
findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
rebuildAlreadyAddedWidget();
// clear search
searchBox.getTextBox().setText("");
}
@Override
public void onLoadingStart() {
saveSelected = findCandidatesOrUsersToAddToVo.getSelected();
}
}));
request.createMember(group.getVoId(), group, candidateToBeAdded);
} else {
CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
private User saveSelected;
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
if (saveSelected != null) {
GeneralObject go = saveSelected.cast();
alreadyAddedList.add(go);
findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
rebuildAlreadyAddedWidget();
// clear search
searchBox.getTextBox().setText("");
}
}
@Override
public void onLoadingStart() {
Candidate cand = findCandidatesOrUsersToAddToVo.getSelected();
saveSelected = cand.cast();
}
}));
User user = candidateToBeAdded.cast();
request.createMember(group.getVoId(), group, user);
}
}
} else {
// searched members / all members
final ArrayList<RichMember> membersToAdd = findMembers.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(membersToAdd)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < membersToAdd.size(); i++) {
final int n = i;
AddMember request = new AddMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
private RichMember saveSelected;
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added person
findMembers.getSelectionModel().setSelected(saveSelected, false);
// put names to already added
GeneralObject go = saveSelected.cast();
alreadyAddedList.add(go);
rebuildAlreadyAddedWidget();
// clear search
searchBox.getTextBox().setText("");
}
@Override
public void onLoadingStart() {
saveSelected = membersToAdd.get(n);
}
}));
request.addMemberToGroup(group, membersToAdd.get(i));
}
}
}
}
});
tabMenu.addWidget(searchGloballyButton);
tabMenu.addWidget(listAllButton);
tabMenu.addWidget(addButton);
tabMenu.addWidget(inviteButton);
inviteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (searchCandidates) {
// we expect, that candidate is always single
Candidate candid = findCandidatesOrUsersToAddToVo.getSelected();
if (candid != null) {
if (candid.getObjectType().equalsIgnoreCase("Candidate")) {
SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
}
}));
invite.inviteUser(candid);
} else {
SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
}
}));
User user = candid.cast();
invite.inviteUser(user);
}
}
} else {
// members / all members
SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
ArrayList<RichMember> usrs = findMembers.getTableSelectedList();
for (int i = 0; i < usrs.size(); i++) {
if (i == usrs.size() - 1) {
invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
findMembers.clearTableSelectedSet();
}
}));
} else {
invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton));
}
invite.inviteUser(usrs.get(i).getUser());
}
}
}
});
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// with refresh if somebody was added
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
tabMenu.addWidget(disabled);
rebuildAlreadyAddedWidget();
firstTabPanel.add(alreadyAdded);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(findMembers, table, addButton);
inviteButton.setEnabled(false);
JsonUtils.addTableManagedButton(findMembers, table, inviteButton);
JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, addButton);
JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, inviteButton);
table.addStyleName("perun-table");
sp.setWidget(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
candidatesTable.addStyleName("perun-table");
sp2.setWidget(candidatesTable);
sp2.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp2, 350, this);
// if not empty - start searching
if (search) {
findMembers.searchFor(searchString);
firstTabPanel.add(sp);
} else if (searchCandidates) {
findCandidatesOrUsersToAddToVo.searchFor(searchString);
firstTabPanel.add(sp2);
} else {
getAllMembers.excludeDisabled(!disabled.getValue());
getAllMembers.retrieveData();
firstTabPanel.add(sp);
}
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class ChangeStatusTabItem method draw.
public Widget draw() {
this.titleWidget.setText("Change member's status");
VerticalPanel vp = new VerticalPanel();
vp.setSize("300px", "100%");
FlexTable layout = new FlexTable();
layout.setSize("100%", "100%");
layout.setStyleName("inputFormFlexTable");
final HTML text = new HTML("");
final ListBox lb = new ListBox(false);
lb.addItem("VALID", "VALID");
lb.addItem("INVALID", "INVALID");
lb.addItem("SUSPENDED", "SUSPENDED");
lb.addItem("EXPIRED", "EXPIRED");
lb.addItem("DISABLED", "DISABLED");
layout.setHTML(0, 0, "Current status:");
layout.getFlexCellFormatter().setStyleName(0, 0, "itemName");
layout.setHTML(0, 1, member.getStatus());
if (member.getStatus().equalsIgnoreCase("VALID")) {
layout.setHTML(1, 0, "Member is properly configured and have access on provided resources.");
} else if (member.getStatus().equalsIgnoreCase("INVALID")) {
layout.setHTML(1, 0, "Member have configuration error and DON'T have access on provided resources. You can check what is wrong by changing member's status to VALID. If possible, procedure will configure all necessary settings by itself.");
} else if (member.getStatus().equalsIgnoreCase("SUSPENDED")) {
layout.setHTML(1, 0, "Member violated some rules and DON'T have access on provided resources.");
} else if (member.getStatus().equalsIgnoreCase("EXPIRED")) {
layout.setHTML(1, 0, "Member didn't extend membership and DON'T have access on provided resources.");
} else if (member.getStatus().equalsIgnoreCase("DISABLED")) {
layout.setHTML(1, 0, "Member didn't extend membership long time ago or was manually disabled and DON'T have access on provided resources.");
}
layout.getFlexCellFormatter().setColSpan(1, 0, 2);
layout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
layout.setHTML(2, 0, "New status:");
layout.getFlexCellFormatter().setStyleName(2, 0, "itemName");
layout.setWidget(2, 1, lb);
layout.setWidget(3, 0, text);
layout.getFlexCellFormatter().setColSpan(3, 0, 2);
layout.getFlexCellFormatter().setStyleName(3, 0, "inputFormInlineComment");
// pick which one is already set
for (int i = 0; i < lb.getItemCount(); i++) {
if (lb.getItemText(i).equalsIgnoreCase(member.getStatus())) {
lb.setSelectedIndex(i);
}
}
TabMenu menu = new TabMenu();
final TabItem tab = this;
final CustomButton changeButton = new CustomButton("Change status", ButtonTranslation.INSTANCE.changeStatus(member.getUser().getFullName()), SmallIcons.INSTANCE.diskIcon());
// by default false
changeButton.setEnabled(false);
changeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
SetStatus request = new SetStatus(memberId, JsonCallbackEvents.disableButtonEvents(changeButton, JsonCallbackEvents.mergeEvents(events, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// close without refresh
session.getTabManager().closeTab(tab, false);
}
})));
request.setStatus(lb.getValue(lb.getSelectedIndex()));
}
});
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);
}
}));
// listbox change handler
lb.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (lb.getValue(lb.getSelectedIndex()).equalsIgnoreCase(member.getStatus())) {
changeButton.setEnabled(false);
} else {
changeButton.setEnabled(true);
}
// clear
text.setHTML("");
if (lb.getSelectedIndex() == 0) {
// VALIDATING NOTICE
if (!member.getStatus().equalsIgnoreCase("VALID"))
text.setHTML("Changing status to VALID <strong>will trigger automatic configuration</strong> for provided resources. <br/><strong>If successful</strong>, member will have access on provided resources. <br /><strong>If not</strong>, see displayed error message and do manual configuration on 'settings' tab on members detail.");
} else {
// INVALIDATING NOTICE
if (member.getStatus().equalsIgnoreCase("VALID"))
text.setHTML("Changing status to " + lb.getValue(lb.getSelectedIndex()) + " will <strong>prevent member from access to provided resources (based on provided service's rules)</strong>.<br /><br />");
}
// SET INFO
if (lb.getSelectedIndex() == 1) {
text.setHTML(text.getHTML() + "INVALID status means there is configuration error, which prevents him from access on provided resources.");
} else if (lb.getSelectedIndex() == 2) {
text.setHTML(text.getHTML() + "SUSPENDED status means, that member did something bad (against VO rules).");
} else if (lb.getSelectedIndex() == 3) {
text.setHTML(text.getHTML() + "EXPIRED status means, that member didn't extend his membership in VO, but it's still possible for him to do so.");
} else if (lb.getSelectedIndex() == 4) {
text.setHTML(text.getHTML() + "DISABLED status means, that member didn't extend his membership long ago or was manually disabled by administrator. Member can't enable/extend membership by himself.");
}
}
});
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class CopyFormTabItem 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) {
CopyForm request = null;
if (groupsBox.getSelectedIndex() != 0 && voId != 0 && groupId == 0) {
// from group to VO
request = new CopyForm(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 CopyForm(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 CopyForm(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 CopyForm(PerunEntity.VIRTUAL_ORGANIZATION, vosBox.getSelectedObject().getId(), PerunEntity.GROUP, groupId, JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
}
request.copyForm();
}
});
content.setHTML(2, 0, "All form items 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();
}
Aggregations