use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class SetEntitylessAttribute method testSetting.
/**
* Tests the values, if the process can continue
*
* @return true/false for continue/stop
*/
private boolean testSetting() {
boolean result = true;
String errorMsg = "";
if (this.ids.isEmpty()) {
errorMsg += "Wrong attribute type value.\n";
result = false;
}
// skip attribute with empty or null value
if (attribute.getValue() == null || attribute.getValue().equalsIgnoreCase("")) {
errorMsg += "Can't save attribute with null or empty value.\n";
result = false;
}
if (errorMsg.length() > 0) {
Confirm c = new Confirm("Error while setting attribute", new Label(errorMsg), true);
c.show();
}
return result;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class MoveGroup method testCreating.
/**
* Tests the values, if the process can continue
*
* @return
*/
private boolean testCreating() {
boolean result = true;
String errorMsg = "";
if (movingGroup == null) {
errorMsg += "Moving group can't be NULL.<br />";
result = false;
}
if (errorMsg.length() > 0) {
Confirm c = new Confirm("Error while moving Group", new HTML(errorMsg), true);
c.show();
}
return result;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class CreateOwner method testCreating.
/**
* Tests the values, if the process can continue
*
* @return true/false for continue/stop
*/
private boolean testCreating() {
boolean result = true;
String errorMsg = "";
if (ownerName.length() == 0) {
errorMsg += "You must enter owners <strong>Name</strong>.</ br>";
result = false;
}
if (ownerContact.length() == 0) {
errorMsg += "You must enter owners <strong>Contact</strong>.</ br>";
result = false;
}
if (ownerType.length() == 0) {
errorMsg += "You must select owners <strong>Type</strong>.</ br>";
result = false;
}
if (errorMsg.length() > 0) {
Confirm c = new Confirm("Error while creating Owner", new HTML(errorMsg), true);
c.show();
}
return result;
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class AddUserToBlacklistTabItem method draw.
public Widget draw() {
titleWidget.setText("Add to blacklist");
final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// if found 1 item, select
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && list.size() == 1) {
users.getSelectionModel().setSelected(list.get(0), true);
}
}
}));
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// get the table
final CellTable<User> table;
if (session.isPerunAdmin()) {
table = users.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = users.getTable();
}
rebuildAlreadyAddedWidget();
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedUsersToBlacklist());
final TabItem tab = this;
// search textbox
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
@Override
public void searchFor(String text) {
startSearching(text);
searchString = text;
}
}, searchButton);
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> list = users.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
final TextArea textArea = new TextArea();
textArea.setSize("250px", "120px");
layout.getFlexCellFormatter().addStyleName(0, 0, "itemName");
layout.setHTML(0, 0, "Reason:");
layout.setWidget(1, 0, textArea);
layout.setHTML(2, 0, "Please specify why users are blacklisted.");
layout.getFlexCellFormatter().addStyleName(2, 0, "inputFormInlineComment");
Confirm c = new Confirm("Add user(s) to blacklist", layout, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (int i = 0; i < list.size(); i++) {
// FIXME - Should have only one callback to core
final int n = i;
AddUserToBlacklist request = new AddUserToBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// put names to already added
alreadyAddedList.add(list.get(n));
rebuildAlreadyAddedWidget();
// unselect added person
users.getSelectionModel().setSelected(list.get(n), false);
// clear search
searchBox.getTextBox().setText("");
}
}));
request.addUserToBlacklist(list.get(i).getId(), textArea.getText().trim());
}
}
}, "Add", true);
c.show();
}
}
});
// if some text has been searched before
if (!searchString.equals("")) {
searchBox.getTextBox().setText(searchString);
startSearching(searchString);
}
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(users, table, addButton);
// 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(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(alreadyAdded);
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.Confirm in project perun by CESNET.
the class GetApplicationForm method createWidget.
/**
* Create approval style change widget
*
* @param form
*/
private void createWidget(final ApplicationForm form) {
final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
if (form != null) {
boolean groupForm = form.getGroup() != null;
// create click handler
ClickHandler ch = new ClickHandler() {
public void onClick(ClickEvent event) {
// layout
FlexTable ft = new FlexTable();
ft.setCellSpacing(10);
ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
if (groupForm && voHasEmbeddedGroupApplication) {
ft.setHTML(2, 0, "<strong>EMBEDDED: </strong>");
ft.setHTML(3, 0, "<strong>Module name: </strong>");
} else {
ft.setHTML(2, 0, "<strong>Module name: </strong>");
}
// widgets
final ListBox lbInit = new ListBox();
final ListBox lbExt = new ListBox();
final ListBox lbEmbed = new ListBox();
final TextBox className = new TextBox();
lbInit.addItem("Automatic", "true");
lbInit.addItem("Manual", "false");
lbExt.addItem("Automatic", "true");
lbExt.addItem("Manual", "false");
if (form.getAutomaticApproval() == true) {
lbInit.setSelectedIndex(0);
} else {
lbInit.setSelectedIndex(1);
}
if (form.getAutomaticApprovalExtension() == true) {
lbExt.setSelectedIndex(0);
} else {
lbExt.setSelectedIndex(1);
}
className.setText(form.getModuleClassName());
ft.setWidget(0, 1, lbInit);
ft.setWidget(1, 1, lbExt);
if (groupForm && voHasEmbeddedGroupApplication) {
lbEmbed.addItem("Automatic", "true");
lbEmbed.addItem("Manual", "false");
if (form.getAutomaticApprovalEmbedded() == true) {
lbEmbed.setSelectedIndex(0);
} else {
lbEmbed.setSelectedIndex(1);
}
ft.setWidget(2, 1, lbEmbed);
ft.setWidget(3, 1, className);
} else {
ft.setWidget(2, 1, className);
}
// click on save
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
// switch and send request
UpdateForm request = new UpdateForm(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// recreate same widget
content.clear();
ApplicationForm newForm = jso.cast();
createWidget(newForm);
}
});
form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
if (groupForm && voHasEmbeddedGroupApplication) {
form.setAutomaticApprovalEmbedded(Boolean.parseBoolean(lbEmbed.getValue(lbEmbed.getSelectedIndex())));
}
form.setModuleClassName(className.getText().trim());
request.updateForm(form);
}
};
Confirm c = new Confirm("Change application form settings", ft, click, true);
c.show();
}
};
button.addClickHandler(ch);
String appStyle = "<strong>Approval style: </strong>";
String module = "</br><strong>Module name: </strong>" + SafeHtmlUtils.fromString(form.getModuleClassName()).asString();
if (form.getAutomaticApproval() == true) {
appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
} else {
appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
}
if (form.getAutomaticApprovalExtension() == true) {
appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
} else {
appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
}
if (groupForm && voHasEmbeddedGroupApplication) {
if (form.getAutomaticApprovalEmbedded() == true) {
appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EMBEDDED)";
} else {
appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EMBEDDED)";
}
}
if (!groupForm && !session.isVoAdmin(form.getVo().getId()))
button.setEnabled(false);
if (groupForm && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
button.setEnabled(false);
content.setHTML(0, 0, appStyle + module);
if (groupForm && voHasEmbeddedGroupApplication) {
CheckBox checkBox = new CheckBox("Allowed for embedded applications");
checkBox.setValue(autoRegistrationEnabled);
if (!session.isGroupAdmin(form.getGroup().getId()))
checkBox.setEnabled(false);
ClickHandler clickCHB = new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Group> list = new ArrayList<>();
list.add(group);
if (((CheckBox) event.getSource()).getValue()) {
AddAutoRegGroups request = new AddAutoRegGroups(JsonCallbackEvents.disableCheckboxEvents(checkBox));
request.setAutoRegGroups(list);
} else {
RemoveGroupsFromAutoRegistration request = new RemoveGroupsFromAutoRegistration(JsonCallbackEvents.disableCheckboxEvents(checkBox));
request.deleteGroups(list);
}
}
};
checkBox.addClickHandler(clickCHB);
content.setWidget(1, 0, checkBox);
}
content.setWidget(0, 1, button);
content.getFlexCellFormatter().setRowSpan(0, 1, 2);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
} else {
button.setEnabled(false);
String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
String module = "</br><strong>Module name: </strong> Form doesn't exists.";
content.setHTML(0, 0, appStyle + module);
content.setWidget(0, 1, button);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
}
}
Aggregations