use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class PasswordResetFormPage method drawNonAuthzPasswordReset.
public Widget drawNonAuthzPasswordReset(VerticalPanel vp) {
final String i = Location.getParameter("i");
final String m = Location.getParameter("m");
final ExtendedPasswordBox passBox = new ExtendedPasswordBox();
final ExtendedPasswordBox secondPassBox = new ExtendedPasswordBox();
final ExtendedTextBox.TextBoxValidator validator;
final ExtendedTextBox.TextBoxValidator validator2;
final CustomButton resetPass = new CustomButton("Reset password", "Reset password", SmallIcons.INSTANCE.keyIcon());
validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (passBox.getTextBox().getValue().trim().isEmpty()) {
passBox.setError("Password can't be empty !");
return false;
} else if (!passBox.getTextBox().getValue().trim().equals(secondPassBox.getTextBox().getValue().trim())) {
passBox.setError("Password in both textboxes must be the same !");
return false;
} else {
passBox.setOk();
secondPassBox.setOk();
return true;
}
}
};
validator2 = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (secondPassBox.getTextBox().getValue().trim().isEmpty()) {
secondPassBox.setError("Password can't be empty !");
return false;
} else if (!secondPassBox.getTextBox().getValue().trim().equals(passBox.getTextBox().getValue().trim())) {
secondPassBox.setError("Password in both textboxes must be the same !");
return false;
} else {
secondPassBox.setOk();
passBox.setOk();
return true;
}
}
};
passBox.setValidator(validator);
secondPassBox.setValidator(validator2);
FlexTable ft = new FlexTable();
ft.setSize("300px", "100px");
ft.addStyleName("inputFormFlexTable");
ft.getElement().setAttribute("style", "margin: auto;");
ft.getFlexCellFormatter().setColSpan(0, 0, 2);
ft.setHTML(0, 0, "Password reset");
ft.getFlexCellFormatter().setStyleName(0, 0, "now-managing");
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.setHTML(1, 0, "New password:");
ft.getFlexCellFormatter().setStyleName(1, 0, "itemName");
ft.setWidget(1, 1, passBox);
ft.setHTML(2, 0, "Retype new password:");
ft.getFlexCellFormatter().setStyleName(2, 0, "itemName");
ft.setWidget(2, 1, secondPassBox);
resetPass.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ChangeNonAuthzPassword changepw = new ChangeNonAuthzPassword(JsonCallbackEvents.disableButtonEvents(resetPass, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
bodyContents.clear();
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>Password successfully changed!</h2>");
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
ft.setHTML(1, 0, "<h2>New password will work on all resources in approx. 15 minutes after reset.</h2>");
ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
bodyContents.setWidget(ft);
}
}));
if (validator.validateTextBox() && validator2.validateTextBox()) {
changepw.changeNonAuthzPassword(i, m, passBox.getTextBox().getText().trim());
}
}
});
vp.add(ft);
TabMenu menu = new TabMenu();
menu.addWidget(resetPass);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
return bodyContents;
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class VoResourcesPropagationsTabItem method draw.
public Widget draw() {
mainrow = 0;
okCounter = 0;
errorCounter = 0;
notDeterminedCounter = 0;
procesingCounter = 0;
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources state");
final TabItem tab = this;
VerticalPanel mainTab = new VerticalPanel();
mainTab.setWidth("100%");
// 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%");
final CustomButton cb = UiElements.getRefreshButton(this);
help.setWidget(0, 0, cb);
help.getFlexCellFormatter().setWidth(0, 0, "80px");
help.setHTML(0, 1, "<strong>Color notation:</strong>");
help.getFlexCellFormatter().setWidth(0, 1, "100px");
help.setHTML(0, 2, "<strong>OK</strong>");
help.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
help.getFlexCellFormatter().setWidth(0, 2, "50px");
help.getFlexCellFormatter().setStyleName(0, 2, "green");
help.setHTML(0, 3, "<strong>Error</strong>");
help.getFlexCellFormatter().setWidth(0, 3, "50px");
help.getFlexCellFormatter().setStyleName(0, 3, "red");
help.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
help.setHTML(0, 4, "<strong>Not determined</strong>");
help.getFlexCellFormatter().setWidth(0, 4, "50px");
help.getFlexCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);
help.getFlexCellFormatter().setStyleName(0, 4, "notdetermined");
/*
help.setHTML(0, 5, "<strong>Processing</strong>");
help.getFlexCellFormatter().setWidth(0, 5, "50px");
help.getFlexCellFormatter().setStyleName(0, 5, "yellow");
help.getFlexCellFormatter().setHorizontalAlignment(0, 5, HasHorizontalAlignment.ALIGN_CENTER);
*/
help.setHTML(0, 5, " ");
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 GetAllResourcesState callback = new GetAllResourcesState(voId, 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<ResourceState> list = JsonUtils.jsoAsList(jso);
if (list != null && !list.isEmpty()) {
list = new TableSorter<ResourceState>().sortByResourceName(list);
for (final ResourceState state : list) {
content.setHTML(mainrow, 0, new Image(LargeIcons.INSTANCE.serverGroupIcon()) + "<span class=\"now-managing\" style=\"display: inline-block; position: relative; top: -8px;\">" + state.getResource().getName() + "</span>");
ArrayList<Task> tasks = new TableSorter<Task>().sortByService(JsonUtils.<Task>jsoAsList(state.getTasks()));
if (tasks == null || tasks.isEmpty())
notDeterminedCounter++;
boolean allOk = true;
for (Task tsk : tasks) {
if (tsk.getStatus().equalsIgnoreCase("ERROR")) {
errorCounter++;
allOk = false;
break;
}
}
if (allOk && tasks != null && !tasks.isEmpty())
okCounter++;
ListDataProvider<Task> dataProvider = new ListDataProvider<Task>();
PerunTable<Task> table;
// Table data provider.
dataProvider = new ListDataProvider<Task>(tasks);
// Cell table
table = new PerunTable<Task>(tasks);
table.removeRowCountChangeHandler();
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ColumnSortEvent.ListHandler<Task> columnSortHandler = new ColumnSortEvent.ListHandler<Task>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// set empty content & loader
AjaxLoaderImage loaderImage = new AjaxLoaderImage();
loaderImage.setEmptyResultMessage("No service configuration was propagated to this resource.");
table.setEmptyTableWidget(loaderImage);
loaderImage.loadingFinished();
table.addIdColumn("Task Id");
// Service column
Column<Task, String> serviceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Task, String>() {
public String getValue(Task task) {
return String.valueOf(task.getExecService().getService().getName());
}
}, null);
// status column
Column<Task, String> statusColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Task, String>() {
public String getValue(Task task) {
return String.valueOf(task.getStatus());
}
}, null);
// start COLUMN
TextColumn<Task> startTimeColumn = new TextColumn<Task>() {
public String getValue(Task result) {
return result.getStartTime();
}
};
// end COLUMN
TextColumn<Task> endTimeColumn = new TextColumn<Task>() {
public String getValue(Task result) {
return result.getEndTime();
}
};
// schedule COLUMN
TextColumn<Task> scheduleColumn = new TextColumn<Task>() {
public String getValue(Task result) {
return result.getSchedule();
}
};
// Add the columns.
table.addColumn(serviceColumn, "Service");
table.addColumn(statusColumn, "Status");
table.addColumn(scheduleColumn, "Scheduled");
table.addColumn(startTimeColumn, "Started");
table.addColumn(endTimeColumn, "Ended");
// set row styles based on task state
table.setRowStyles(new RowStyles<Task>() {
public String getStyleNames(Task row, int rowIndex) {
if (row.getStatus().equalsIgnoreCase("NONE")) {
return "rowdarkgreen";
} else if (row.getStatus().equalsIgnoreCase("DONE")) {
return "rowgreen";
} else if (row.getStatus().equalsIgnoreCase("PROCESSING")) {
return "rowyellow";
} else if (row.getStatus().equalsIgnoreCase("ERROR")) {
return "rowred";
}
return "";
}
});
table.setWidth("100%");
content.setWidget(mainrow + 1, 0, table);
content.getFlexCellFormatter().setStyleName(mainrow + 1, 0, "propagationTablePadding");
mainrow++;
mainrow++;
}
}
// set counters
help.setHTML(0, 2, "<strong>Ok (" + okCounter + ")</strong>");
help.setHTML(0, 3, "<strong>Error (" + errorCounter + ")</strong>");
help.setHTML(0, 4, "<strong>Not determined (" + notDeterminedCounter + ")</strong>");
//help.setHTML(0, 5, "<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.widgets.CustomButton in project perun by CESNET.
the class VoResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources");
// 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 GetRichResources resources = new GetRichResources(voId);
if (!session.isVoAdmin(voId))
resources.setCheckable(false);
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichResource> resourcesForDeleting = resources.getTableSelectedList();
String text = "Following resources will be deleted and VO members won't be able to access them anymore.";
UiElements.showDeleteConfirm(resourcesForDeleting, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < resourcesForDeleting.size(); i++) {
DeleteResource request;
if (i == resourcesForDeleting.size() - 1) {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteResource(resourcesForDeleting.get(i).getId());
}
}
});
}
});
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
resources.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterResources());
CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
}
});
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resources, 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.widgets.CustomButton in project perun by CESNET.
the class VoResourcesTagsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources tags");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// members request
final GetAllResourcesTags resTags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, voId);
if (!session.isVoAdmin(voId))
resTags.setCheckable(false);
if (session.isVoAdmin(voId))
resTags.setEditable(true);
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resTags);
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResourceTag(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoResourceTagTabItem(voId));
}
});
menu.addWidget(addButton);
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResourceTag());
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToRemove = resTags.getTableSelectedList();
String text = "Following tags will be deleted and won't be used to tag VO resources.";
UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToRemove.size(); i++) {
DeleteResourceTag request;
if (i == tagsToRemove.size() - 1) {
request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteResourceTag(tagsToRemove.get(i));
}
}
});
}
});
menu.addFilterWidget(new ExtendedSuggestBox(resTags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resTags.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterTags());
final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.updateResourceTag());
menu.addWidget(saveButton);
if (!session.isVoAdmin(voId))
saveButton.setEnabled(false);
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToUpdate = resTags.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(tagsToUpdate)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToUpdate.size(); i++) {
UpdateResourceTag request;
if (i == tagsToUpdate.size() - 1) {
request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton, events));
} else {
request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton));
}
request.updateResourceTag(tagsToUpdate.get(i));
}
}
}
});
// get the table
CellTable<ResourceTag> table = resTags.getTable();
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resTags, table, removeButton);
saveButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resTags, table, saveButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.CustomButton in project perun by CESNET.
the class VoSettingsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": settings");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// Get Attributes
final GetAttributesV2 jsonCallback = new GetAttributesV2();
// We want VO attributes
jsonCallback.getVoAttributes(voId);
// get the table
CellTable<Attribute> table = jsonCallback.getTable();
if (!session.isVoAdmin(voId))
jsonCallback.setCheckable(false);
final CustomButton setButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
menu.addWidget(setButton);
if (!session.isVoAdmin(voId))
setButton.setEnabled(false);
// refresh table
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(jsonCallback);
// set button event with button disable
final JsonCallbackEvents setButtonEvent = JsonCallbackEvents.disableButtonEvents(setButton, events);
setButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
SetAttributes request = new SetAttributes(setButtonEvent);
request.setAttributes(ids, list);
}
}
});
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids, jsonCallback.getList()), true);
}
});
menu.addWidget(addButton);
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
// remove attr button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
menu.addWidget(removeButton);
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
// remove button event
final JsonCallbackEvents removeButtonEvent = JsonCallbackEvents.disableButtonEvents(removeButton, events);
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
Map<String, Integer> ids = new HashMap<String, Integer>();
ids.put("vo", voId);
RemoveAttributes request = new RemoveAttributes(removeButtonEvent);
request.removeAttributes(ids, list);
}
}
});
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
// add menu and the table to the main panel
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations