use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class ServiceRequiredAttributesTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(service.getName()) + ": Required attributes");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// create new json call for required attributes of service with id=?
final GetServiceRequiredAttributes servReqAttr = new GetServiceRequiredAttributes(serviceId);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// custom event
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(servReqAttr);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addRequiredAttribute(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddRequiredAttributesTabItem(service), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedRequiredAttributes());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<AttributeDefinition> attrsForRemoving = servReqAttr.getTableSelectedList();
UiElements.showDeleteConfirm(attrsForRemoving, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < attrsForRemoving.size(); i++) {
if (i == attrsForRemoving.size() - 1) {
RemoveRequiredAttribute request = new RemoveRequiredAttribute(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.removeRequiredAttribute(serviceId, attrsForRemoving.get(i).getId());
} else {
RemoveRequiredAttribute request = new RemoveRequiredAttribute(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeRequiredAttribute(serviceId, attrsForRemoving.get(i).getId());
}
}
}
});
}
});
menu.addWidget(removeButton);
final ExtendedSuggestBox box = new ExtendedSuggestBox(servReqAttr.getOracle());
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
servReqAttr.filterTable(text);
}
}, "Filter required attributes by name");
vp.add(menu);
vp.setCellHeight(menu, "30px");
// get table = make call
CellTable<AttributeDefinition> reqAttrTable = servReqAttr.getTable();
// create scroll panel for table
reqAttrTable.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(reqAttrTable);
sp.addStyleName("perun-tableScrollPanel");
sp.setWidth("100%");
vp.add(sp);
vp.setCellHeight(sp, "100%");
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(servReqAttr, reqAttrTable, removeButton);
session.getUiElements().resizePerunTable(sp, 350, this);
// add tabs to the main panel
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class UserDetailTabItem method loadCertificatesLoginsPasswords.
private Widget loadCertificatesLoginsPasswords() {
// set content
final VerticalPanel attributesTable = new VerticalPanel();
final TabMenu menu = new TabMenu();
attributesTable.add(menu);
attributesTable.setWidth("100%");
final ScrollPanel sp = new ScrollPanel();
sp.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
sp.setWidth("100%");
//attributesTable.setStyleName("userDetailTable");
// clear logins when page refreshed
userLoginAttrs.clear();
// ids used for attribute handling
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("user", userId);
// attribute table
final PerunAttributeTableWidget table = new PerunAttributeTableWidget(ids);
table.setDescriptionShown(true);
table.setDisplaySaveButton(false);
// load data
GetListOfAttributes attributes = new GetListOfAttributes(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
userLoginAttrs.addAll(JsonUtils.<Attribute>jsoAsList(jso));
userLoginAttrs = new TableSorter<Attribute>().sortByAttrNameTranslation(userLoginAttrs);
for (Attribute a : userLoginAttrs) {
if (a.getFriendlyName().equalsIgnoreCase("userCertificates")) {
table.add(a);
} else if (a.getFriendlyName().equalsIgnoreCase("sshPublicKey")) {
table.add(a);
} else if (a.getFriendlyName().equalsIgnoreCase("kerberosAdminPrincipal")) {
table.add(a);
} else if (a.getFriendlyName().equalsIgnoreCase("sshPublicAdminKey")) {
table.add(a);
}
}
// build attr table
table.build();
menu.addWidget(table.getSaveButton());
// content
VerticalPanel vpContent = new VerticalPanel();
vpContent.add(table.asWidget());
FlexTable innerTable = new FlexTable();
innerTable.setCellPadding(5);
vpContent.add(innerTable);
// set content to page
sp.add(vpContent);
attributesTable.add(sp);
int rowCount = 0;
for (final Attribute a : userLoginAttrs) {
if (a.getBaseFriendlyName().equalsIgnoreCase("login-namespace")) {
if (a.getValueAsObject() != null) {
// name
innerTable.setHTML(rowCount, 0, "<strong>" + a.getDisplayName() + "</strong>");
// value
innerTable.setHTML(rowCount, 1, a.getValue());
// change password
if (Utils.getSupportedPasswordNamespaces().contains(a.getFriendlyNameParameter())) {
CustomButton cb = new CustomButton("Change password…", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, a.getFriendlyNameParameter(), a.getValue(), SelfPasswordTabItem.Actions.CHANGE));
}
});
innerTable.setWidget(rowCount, 2, cb);
}
rowCount++;
}
}
}
}
});
HashSet<String> set = new HashSet<String>();
set.add("urn:perun:user:attribute-def:def:userCertificates");
set.add("urn:perun:user:attribute-def:def:kerberosAdminPrincipal");
set.add("urn:perun:user:attribute-def:def:sshPublicKey");
set.add("urn:perun:user:attribute-def:def:sshPublicAdminKey");
set.add("urn:perun:user:attribute-def:def:login-namespace:mu");
set.add("urn:perun:user:attribute-def:def:login-namespace:einfra");
set.add("urn:perun:user:attribute-def:def:login-namespace:sitola");
set.add("urn:perun:user:attribute-def:def:login-namespace:egi-ui");
set.add("urn:perun:user:attribute-def:def:login-namespace:cesnet");
set.add("urn:perun:user:attribute-def:def:login-namespace:meta");
set.add("urn:perun:user:attribute-def:def:login-namespace:einfra-services");
set.add("urn:perun:user:attribute-def:def:login-namespace:shongo");
// TODO - FIXME - must be dynamic !!
for (String namespace : Utils.getSupportedPasswordNamespaces()) {
set.add("urn:perun:user:attribute-def:def:login-namespace:" + namespace);
}
// TODO - remove SHONGO
ArrayList<String> list = JsonUtils.setToList(set);
attributes.getListOfAttributes(ids, list);
return attributesTable;
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class UserExtSourceSettingsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(userExtSource.getLogin().trim()));
// MAIN TAB PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final GetAttributesV2 callback = new GetAttributesV2(true);
callback.getUserExtSourceAttributes(userExtSource.getId());
final CellTable<Attribute> table = callback.getEmptyTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
menu.addWidget(UiElements.getRefreshButton(this));
// save changes in attributes
final CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
saveChangesButton.setEnabled(false);
saveChangesButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(saveChangesButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
callback.clearTable();
callback.getUserExtSourceAttributes(userExtSourceId);
callback.retrieveData();
}
}));
final Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSourceId);
request.setAttributes(ids, callback.getTableSelectedList());
}
}
});
menu.addWidget(saveChangesButton);
// buttons
CustomButton setNewMemberAttributeButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSource.getId());
session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids), true);
}
});
menu.addWidget(setNewMemberAttributeButton);
// REMOVE ATTRIBUTES BUTTON
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// if selected
if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("userExtSource", userExtSource.getId());
RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(removeButton, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
callback.clearTable();
callback.getUserExtSourceAttributes(userExtSource.getId());
callback.retrieveData();
}
}));
// make removeAttributes call
request.removeAttributes(ids, callback.getTableSelectedList());
}
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(callback, table, removeButton);
menu.addWidget(removeButton);
callback.retrieveData();
// ATTRIBUTES TABLE
vp.add(sp);
vp.setCellHeight(sp, "100%");
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class AddVoExtSourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Add external source");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetExtSources extSources = new GetExtSources();
// remove already assigned ext sources from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetVoExtSources alreadyAssigned = new GetVoExtSources(voId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<ExtSource> esToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < esToRemove.length(); i++) {
extSources.removeFromTable(esToRemove.get(i));
}
}
});
alreadyAssigned.retrieveData();
}
};
extSources.setEvents(localEvents);
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceX509");
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceKerberos");
extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceIdp");
final ExtendedSuggestBox box = new ExtendedSuggestBox(extSources.getOracle());
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
final TabItem tab = this;
assignButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ExtSource> extSourcesToAdd = extSources.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(extSourcesToAdd)) {
// FIXME - Should have only one callback to core
for (int i = 0; i < extSourcesToAdd.size(); i++) {
final int n = i;
AddExtSource request = new AddExtSource(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added person
extSources.getSelectionModel().setSelected(extSourcesToAdd.get(n), false);
alreadyAddedList.add(extSourcesToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.addExtSource(voId, extSourcesToAdd.get(i).getId());
}
}
}
});
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
extSources.filterTable(text);
}
}, "Filter by ext source name or type");
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(alreadyAdded);
CellTable<ExtSource> table = extSources.getTable();
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(extSources, table, assignButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// do not use resizePerunTable() when tab is in overlay - wrong width is calculated
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class ApplicationFormPage method prepareVoForm.
/**
* Prepares a VO form
*/
protected void prepareVoForm() {
if (submittedOrError)
formContent.clear();
bodyContents.setWidget(formContent);
formContent.setStyleName("formContentTable");
submittedOrError = false;
FlexTable header = new FlexTable();
header.setWidth("100%");
header.setCellPadding(5);
int row = 0;
// display VO logo if present in attribute
for (int i = 0; i < vo.getAttributes().length(); i++) {
if (vo.getAttributes().get(i).getFriendlyName().equalsIgnoreCase("voLogoURL")) {
header.setWidget(row, 0, new Image(vo.getAttributes().get(i).getValue()));
row++;
}
}
/*
String headerString = "";
// display application header
if (type.equalsIgnoreCase("INITIAL")) {
if (group != null) {
headerString = ApplicationMessages.INSTANCE.applicationFormForGroup(group.getName());
} else {
headerString = ApplicationMessages.INSTANCE.applicationFormForVo(vo.getName());
}
} else if (type.equalsIgnoreCase("EXTENSION")) {
if (group != null) {
headerString = ApplicationMessages.INSTANCE.membershipExtensionForGroup(group.getName());
} else {
headerString = ApplicationMessages.INSTANCE.membershipExtensionForVo(vo.getName());
}
}
header.setHTML(row, 0, "<h1>" + headerString + "</h1>");
*/
// language button
prepareToggleLanguageButton();
FlexTable lang = new FlexTable();
lang.setWidget(0, 1, languageButton);
header.setWidget(0, 1, lang);
header.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
formContent.add(header);
final GetFormItemsWithPrefilledValues fitems;
if (group != null) {
fitems = new GetFormItemsWithPrefilledValues(PerunEntity.GROUP, group.getId());
} else {
fitems = new GetFormItemsWithPrefilledValues(PerunEntity.VIRTUAL_ORGANIZATION, vo.getId());
}
fitems.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// when form is auto-submitting
ArrayList<ApplicationFormItemWithPrefilledValue> items = JsonUtils.<ApplicationFormItemWithPrefilledValue>jsoAsList(jso);
for (ApplicationFormItemWithPrefilledValue item : items) {
if (item.getFormItem().getType().equals("AUTO_SUBMIT_BUTTON")) {
if (fitems.getSendButton() != null) {
// enforce first click to validate and submit the form
fitems.getSendButton().click();
}
}
}
// try to get user for VOs initial application (only for authz origin when form is defined)
if (items != null && !items.isEmpty()) {
if (session.getUser() == null && !session.getPerunPrincipal().getExtSource().equalsIgnoreCase("LOCAL")) {
tryToFindUserByName(null);
}
}
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
positionLinker();
}
});
}
});
if (Location.getParameter("type") != null && (Location.getParameter("type").equalsIgnoreCase("INITIAL") || Location.getParameter("type").equalsIgnoreCase("EXTENSION"))) {
fitems.setType(Location.getParameter("type").toUpperCase());
} else {
fitems.setType(type);
}
fitems.setHidden(true);
fitems.setSendFormHandler(new SendsApplicationForm() {
public void sendApplicationForm(CustomButton button) {
data = fitems.getValues();
sendForm(button);
}
});
fitems.retrieveData();
formContent.add(fitems.getContents());
formContent.add(new HTML("<br /><br /><br />"));
JsonCallbackEvents formEvent = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
form = jso.cast();
}
};
GetApplicationForm formRequest;
if (group != null) {
formRequest = new GetApplicationForm(PerunEntity.GROUP, group.getId(), formEvent);
} else {
formRequest = new GetApplicationForm(PerunEntity.VIRTUAL_ORGANIZATION, vo.getId(), formEvent);
}
formRequest.retrieveData();
}
Aggregations