use of cz.metacentrum.perun.webgui.tabs.TabItem 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();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class PropagationsTabItem method draw.
public Widget draw() {
mainrow = 0;
okCounter = 0;
errorCounter = 0;
notDeterminedCounter = 0;
procesingCounter = 0;
VerticalPanel mainTab = new VerticalPanel();
mainTab.setWidth("100%");
final TabItem tab = this;
// MAIN PANEL
final ScrollPanel firstTabPanel = new ScrollPanel();
firstTabPanel.setSize("100%", "100%");
firstTabPanel.setStyleName("perun-tableScrollPanel");
final FlexTable help = new FlexTable();
help.setCellPadding(4);
help.setWidth("100%");
help.setHTML(0, 0, "<strong>Color notation:</strong>");
help.getFlexCellFormatter().setWidth(0, 0, "100px");
help.setHTML(0, 1, "<strong>OK</strong>");
help.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
help.getFlexCellFormatter().setWidth(0, 1, "50px");
help.getFlexCellFormatter().setStyleName(0, 1, "green");
help.setHTML(0, 2, "<strong>Error</strong>");
help.getFlexCellFormatter().setWidth(0, 2, "50px");
help.getFlexCellFormatter().setStyleName(0, 2, "red");
help.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
help.setHTML(0, 3, "<strong>Not determined</strong>");
help.getFlexCellFormatter().setWidth(0, 3, "50px");
help.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
help.getFlexCellFormatter().setStyleName(0, 3, "notdetermined");
/*
help.setHTML(0, 4, "<strong>Processing</strong>");
help.getFlexCellFormatter().setWidth(0, 4, "50px");
help.getFlexCellFormatter().setStyleName(0, 4, "yellow");
help.getFlexCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);
*/
final CustomButton cb = new CustomButton(ButtonTranslation.INSTANCE.refreshButton(), ButtonTranslation.INSTANCE.refreshPropagationResults(), SmallIcons.INSTANCE.updateIcon(), new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().reloadTab(tab);
}
});
help.setWidget(0, 5, cb);
help.getFlexCellFormatter().setWidth(0, 5, "200px");
help.setHTML(0, 6, " ");
help.getFlexCellFormatter().setWidth(0, 6, "50%");
mainTab.add(help);
mainTab.add(new HTML("<hr size=\"2\" />"));
mainTab.add(firstTabPanel);
final FlexTable content = new FlexTable();
content.setWidth("100%");
content.setBorderWidth(0);
firstTabPanel.add(content);
content.setStyleName("propagationTable", true);
final AjaxLoaderImage im = new AjaxLoaderImage();
content.setWidget(0, 0, im);
content.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
final GetFacilityState callback = new GetFacilityState(0, 0, new JsonCallbackEvents() {
public void onLoadingStart() {
im.loadingStart();
cb.setProcessing(true);
}
public void onError(PerunError error) {
im.loadingError(error);
cb.setProcessing(false);
}
public void onFinished(JavaScriptObject jso) {
im.loadingFinished();
cb.setProcessing(false);
content.clear();
content.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
ArrayList<FacilityState> list = JsonUtils.jsoAsList(jso);
if (list != null && !list.isEmpty()) {
list = new TableSorter<FacilityState>().sortByNumberOfDestinations(list);
ArrayList<FacilityState> clusters = new ArrayList<FacilityState>();
ArrayList<FacilityState> hosts = new ArrayList<FacilityState>();
for (final FacilityState state : list) {
if (state.getDestinations().size() > 1) {
clusters.add(state);
} else {
hosts.add(state);
}
}
clusters = new TableSorter<FacilityState>().sortByFacilityName(clusters);
hosts = new TableSorter<FacilityState>().sortByFacilityName(hosts);
for (final FacilityState state : clusters) {
content.setHTML(mainrow, 0, "<strong>" + state.getFacility().getName() + "</strong>");
final FlowPanel inner = new FlowPanel();
content.setWidget(mainrow + 1, 0, inner);
content.getFlexCellFormatter().setStyleName(mainrow + 1, 0, "propagationTablePadding");
Set<String> destinations = state.getDestinations().keySet();
ArrayList<String> destList = new ArrayList<String>();
int width = 0;
for (String dest : destinations) {
destList.add(dest);
if (dest.indexOf(".") * 8 > width) {
width = dest.indexOf(".") * 8;
}
}
Collections.sort(destList);
for (final String dest : destList) {
String show = dest.substring(0, dest.indexOf("."));
Anchor hyp = new Anchor();
hyp.setHTML("<span style=\"display: inline-block; width: " + width + "px; text-align: center;\">" + show + "</span>");
hyp.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTab(new DestinationResultsTabItem(state.getFacility(), null, dest, true));
}
});
inner.add(hyp);
// style
if (state.getDestinations().get(dest).equals(new JSONString("ERROR"))) {
hyp.addStyleName("red");
errorCounter++;
} else if (state.getDestinations().get(dest).equals(new JSONString("OK"))) {
hyp.addStyleName("green");
okCounter++;
} else {
hyp.addStyleName("notdetermined");
notDeterminedCounter++;
}
}
if (destList.isEmpty()) {
notDeterminedCounter++;
}
mainrow++;
mainrow++;
}
// PROCESS HOSTS (with one or less destination)
// FIX WIDTH
int width = 0;
for (FacilityState state : hosts) {
if (state.getDestinations().size() < 2) {
if (state.getFacility().getName().length() * 8 > width) {
width = state.getFacility().getName().length() * 8;
}
}
}
FlowPanel inner = new FlowPanel();
for (final FacilityState state : hosts) {
Set<String> destinations = state.getDestinations().keySet();
ArrayList<String> destList = new ArrayList<String>();
for (String dest : destinations) {
destList.add(dest);
}
Collections.sort(destList);
for (final String dest : destList) {
Anchor hyp = new Anchor();
hyp.setHTML("<span style=\"display: inline-block; width: " + width + "px; text-align: center;\">" + dest + "</span>");
inner.add(hyp);
hyp.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTab(new DestinationResultsTabItem(state.getFacility(), null, dest, true));
}
});
// style
if (state.getDestinations().get(dest).equals(new JSONString("ERROR"))) {
hyp.addStyleName("red");
errorCounter++;
} else if (state.getDestinations().get(dest).equals(new JSONString("OK"))) {
hyp.addStyleName("green");
okCounter++;
} else {
hyp.addStyleName("notdetermined");
notDeterminedCounter++;
}
}
if (destList.isEmpty()) {
Anchor hyp = new Anchor();
hyp.setHTML("<span style=\"display: inline-block; width: " + width + "px; text-align: center;\">" + state.getFacility().getName() + "</span>");
inner.add(hyp);
hyp.addStyleName("notdetermined");
notDeterminedCounter++;
}
}
if (!hosts.isEmpty()) {
content.setHTML(mainrow, 0, "<strong>Single hosts</strong>");
mainrow++;
}
content.setWidget(mainrow, 0, inner);
content.getFlexCellFormatter().setStyleName(mainrow, 0, "propagationTablePadding");
mainrow++;
}
// set counters
help.setHTML(0, 1, "<strong>Ok (" + okCounter + ")</strong>");
help.setHTML(0, 2, "<strong>Error (" + errorCounter + ")</strong>");
help.setHTML(0, 3, "<strong>Not determined (" + notDeterminedCounter + ")</strong>");
//help.setHTML(0, 4, "<strong>Processing (" + procesingCounter + ")</strong>");
}
});
// get for all facilities for VO
callback.retrieveData();
// resize perun table to correct size on screen
session.getUiElements().resizePerunTable(firstTabPanel, 400, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class AssignGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Assign group");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// menu
TabMenu menu = new TabMenu();
final GetAllGroups voGroups = new GetAllGroups(resource.getVoId());
voGroups.setCoreGroupsCheckable(true);
final CellTable<Group> table = voGroups.getEmptyTable(new FieldUpdater<Group, String>() {
public void update(int index, Group object, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(object));
}
});
// remove already assigned groups from offering
voGroups.setEvents(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
final GetAssignedGroups alreadyAssigned = new GetAssignedGroups(resourceId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
JsArray<Group> groupsToRemove = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < groupsToRemove.length(); i++) {
voGroups.removeFromTable(groupsToRemove.get(i));
}
// if single group, select
if (voGroups.getList().size() == 1) {
table.getSelectionModel().setSelected(voGroups.getList().get(0), true);
}
}
});
alreadyAssigned.retrieveData();
}
});
// checbox is selected by default
final CheckBox chb = new CheckBox();
chb.setText(WidgetTranslation.INSTANCE.configureGroupBeforeAssign());
chb.setTitle(WidgetTranslation.INSTANCE.configureGroupBeforeAssignTitle());
chb.setValue(false);
final TabItem tab = this;
// button
final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedGroupsToResource());
assignButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Group> groupsToAssign = voGroups.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(groupsToAssign)) {
if (chb.getValue() == false) {
AssignGroupsToResource request = new AssignGroupsToResource(JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
request.assignGroupsToResource(groupsToAssign, resource);
}
if (chb.getValue() == true) {
session.getTabManager().addTabToCurrentTab(new ManageGroupsBeforeAssigning(resource, groupsToAssign), true);
}
}
}
});
menu.addWidget(assignButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
menu.addFilterWidget(new ExtendedSuggestBox(voGroups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
voGroups.filterTable(text);
// if single group, select
if (voGroups.getList().size() == 1) {
table.getSelectionModel().setSelected(voGroups.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterGroup());
if (session.isPerunAdmin()) {
// TODO - now is for testing so perun admin only
menu.addWidget(chb);
}
vp.add(menu);
vp.setCellHeight(menu, "30px");
assignButton.setEnabled(false);
JsonUtils.addTableManagedButton(voGroups, table, assignButton);
voGroups.retrieveData();
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.
the class EditFormItemTabItem method draw.
public Widget draw() {
this.tab = this;
this.titleWidget.setText("Edit form item: " + item.getShortname());
// languages
ArrayList<String> languages = item.getLocales();
if (!Utils.getNativeLanguage().isEmpty()) {
if (!languages.contains(Utils.getNativeLanguage().get(0)))
languages.add(Utils.getNativeLanguage().get(0));
}
if (!languages.contains("en"))
languages.add(0, "en");
// vertical panel
VerticalPanel vp = new VerticalPanel();
vp.setWidth("570px");
vp.setHeight("375px");
// tab panel
TabLayoutPanel tabPanel = new TabLayoutPanel(30, Unit.PX);
tabPanel.addStyleName("smallTabPanel");
tabPanel.setHeight("350px");
// basic settings
tabPanel.add(basicInformationTab(), "Basic settings");
// for each locale add tab
for (String locale : languages) {
tabPanel.add(itemTextTab(locale), "Lang: " + locale);
}
// add menu
final TabItem tab = this;
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveFormItem(), new ClickHandler() {
public void onClick(ClickEvent event) {
//save item and reload local content
saveItem();
events.onFinished(item);
// do not reload content from RPC !!
session.getTabManager().closeTab(tab, false);
}
}));
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
// add tab panel to main panel
vp.add(tabPanel);
vp.setCellHeight(tabPanel, "350px");
vp.setCellWidth(tabPanel, "570px");
//session.getUiElements().resizeSmallTabPanel(tabPanel.getWidget(0), 350, 60, tab);
vp.add(tabMenu);
vp.setCellHeight(tabMenu, "30px");
vp.setCellHorizontalAlignment(tabMenu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations