use of cz.metacentrum.perun.webgui.model.ExtSource in project perun by CESNET.
the class ExtSourcesTabItem method draw.
public Widget draw() {
// create main panel for content
VerticalPanel mainPage = new VerticalPanel();
mainPage.setWidth("100%");
// create new instance for jsonCall getExtSources
final GetExtSources getExtSources = new GetExtSources();
getExtSources.setCheckable(false);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addFilterWidget(new ExtendedSuggestBox(getExtSources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getExtSources.filterTable(text);
}
}, "Filter external sources by name or type");
final CustomButton loadButton = new CustomButton("Load ext sources", "Load ext sources definitions from a local file.", SmallIcons.INSTANCE.worldIcon());
loadButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
LoadExtSourcesDefinitions loadCall = new LoadExtSourcesDefinitions(JsonCallbackEvents.disableButtonEvents(loadButton, JsonCallbackEvents.refreshTableEvents(getExtSources)));
loadCall.retrieveData();
}
});
menu.addWidget(loadButton);
// get CellTable from jsonCall
CellTable<ExtSource> extSourcesTable = getExtSources.getTable();
extSourcesTable.setStyleName("perun-table");
ScrollPanel scrollTable = new ScrollPanel(extSourcesTable);
scrollTable.addStyleName("perun-tableScrollPanel");
// put page into scroll panel
mainPage.add(menu);
mainPage.setCellHeight(menu, "30px");
mainPage.add(scrollTable);
session.getUiElements().resizePerunTable(scrollTable, 350, this);
this.contentWidget.setWidget(mainPage);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.ExtSource 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, isRefreshParentOnClose());
}
}));
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.model.ExtSource in project perun by CESNET.
the class AddUserExtSourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Add ext. identity");
VerticalPanel vp = new VerticalPanel();
// get available ext sources
final ListBoxWithObjects<ExtSource> extSourcesDropDown = new ListBoxWithObjects<ExtSource>();
final TextBox externalLogin = new TextBox();
final TextBox loaTextBox = new TextBox();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add external identity to user");
// fill listbox
JsonCallbackEvents fillEvent = new JsonCallbackEvents() {
@Override
public void onError(PerunError error) {
extSourcesDropDown.clear();
extSourcesDropDown.addItem("Error while loading");
callDone = false;
}
@Override
public void onFinished(JavaScriptObject jso) {
extSourcesDropDown.clear();
ArrayList<ExtSource> list = JsonUtils.jsoAsList(jso);
list = new TableSorter<ExtSource>().sortByName(list);
if (list == null || list.isEmpty()) {
extSourcesDropDown.addItem("No external sources available");
return;
}
for (ExtSource ex : list) {
extSourcesDropDown.addItem(ex);
}
callDone = true;
if (!externalLogin.getText().isEmpty() && !extSourcesDropDown.isEmpty() && JsonUtils.checkParseInt(loaTextBox.getText()) && callDone) {
addButton.setEnabled(true);
}
}
@Override
public void onLoadingStart() {
extSourcesDropDown.clear();
extSourcesDropDown.addItem("Loading...");
callDone = false;
}
};
// callback
final GetExtSources extSources = new GetExtSources(fillEvent);
extSources.retrieveData();
// create layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
layout.setHTML(0, 0, "External login:");
layout.setWidget(0, 1, externalLogin);
layout.setHTML(1, 0, "External source:");
layout.setWidget(1, 1, extSourcesDropDown);
layout.setHTML(2, 0, "Level of Assurance:");
layout.setWidget(2, 1, loaTextBox);
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.setStyleName(i, 0, "itemName");
}
cellFormatter.setStyleName(3, 1, "inputFormInlineComment");
layout.setHTML(3, 1, "0 - not verified = default</br>1 - verified email</br>2 - verified identity</br>3 - verified identity, strict password strength");
TabMenu menu = new TabMenu();
// close tab events
final JsonCallbackEvents addExtSrcEvents = JsonCallbackEvents.closeTabDisableButtonEvents(addButton, this, true);
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ExtSource selected = extSourcesDropDown.getObjectAt(extSourcesDropDown.getSelectedIndex());
String login = externalLogin.getText();
AddUserExtSource request = new AddUserExtSource(addExtSrcEvents);
int loa = 0;
if (JsonUtils.checkParseInt(loaTextBox.getText())) {
loa = Integer.parseInt(loaTextBox.getText());
} else {
JsonUtils.cantParseIntConfirm("Level of Assurance", loaTextBox.getText());
return;
}
request.addUserExtSource(userId, login.trim(), selected, loa);
}
});
addButton.setEnabled(false);
menu.addWidget(addButton);
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
KeyUpHandler handler = new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
if (!externalLogin.getText().isEmpty() && !extSourcesDropDown.isEmpty() && JsonUtils.checkParseInt(loaTextBox.getText()) && callDone) {
addButton.setEnabled(true);
} else {
addButton.setEnabled(false);
}
}
};
externalLogin.addKeyUpHandler(handler);
loaTextBox.addKeyUpHandler(handler);
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.ExtSource in project perun by CESNET.
the class VoExtSourcesTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "ext sources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetVoExtSources extSources = new GetVoExtSources(voId);
// refresh table event
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);
// create ext source button
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddVoExtSourceTabItem(voId), true);
}
});
menu.addWidget(addButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
String text = "Following external sources will be removed from VO. You won't be able to import members from them anymore.";
UiElements.showDeleteConfirm(extSourcesToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < extSourcesToRemove.size(); i++) {
RemoveExtSource request;
if (i == extSourcesToRemove.size() - 1) {
request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeVoExtSource(voId, extSourcesToRemove.get(i).getId());
}
}
});
}
});
menu.addWidget(removeButton);
// authorization - enable buttons for perun admin only.
if (!session.isPerunAdmin()) {
addButton.setEnabled(false);
removeButton.setEnabled(false);
extSources.setCheckable(false);
}
menu.addFilterWidget(new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
extSources.filterTable(text);
}
}, "Filter external sources by name or type");
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<ExtSource> table = extSources.getTable();
if (session.isPerunAdmin()) {
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(extSources, table, removeButton);
}
table.addStyleName("perun-table");
table.setWidth("100%");
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 cz.metacentrum.perun.webgui.model.ExtSource in project perun by CESNET.
the class AddGroupExtSourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Add external source");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
menu.addWidget(new HTML(""));
final GetVoExtSources extSources = new GetVoExtSources(group.getVoId());
// remove already assigned ext sources from offering
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// second callback
final GetGroupExtSources alreadyAssigned = new GetGroupExtSources(groupId, 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);
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.addGroupExtSource(groupId, 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, isRefreshParentOnClose());
}
}));
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();
}
Aggregations