Search in sources :

Example 31 with Confirm

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;
}
Also used : Label(com.google.gwt.user.client.ui.Label) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) JSONString(com.google.gwt.json.client.JSONString)

Example 32 with Confirm

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;
}
Also used : Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML)

Example 33 with Confirm

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;
}
Also used : Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) JSONString(com.google.gwt.json.client.JSONString)

Example 34 with Confirm

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();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AddUserToBlacklist(cz.metacentrum.perun.webgui.json.securityTeamsManager.AddUserToBlacklist) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 35 with Confirm

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");
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationForm(cz.metacentrum.perun.webgui.model.ApplicationForm) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) TextBox(com.google.gwt.user.client.ui.TextBox) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CheckBox(com.google.gwt.user.client.ui.CheckBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ListBox(com.google.gwt.user.client.ui.ListBox)

Aggregations

Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)49 HTML (com.google.gwt.user.client.ui.HTML)26 JSONString (com.google.gwt.json.client.JSONString)19 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)16 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)16 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)15 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)12 Label (com.google.gwt.user.client.ui.Label)8 PerunError (cz.metacentrum.perun.webgui.model.PerunError)8 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)8 Column (com.google.gwt.user.cellview.client.Column)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)5 ArrayList (java.util.ArrayList)5 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)4 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)4 FlexTable (com.google.gwt.user.client.ui.FlexTable)3 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)3 RegistrarFormItemGenerator (cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 Context (com.google.gwt.cell.client.Cell.Context)2