Search in sources :

Example 1 with ApplicationForm

use of cz.metacentrum.perun.webgui.model.ApplicationForm in project perun by CESNET.

the class GetApplicationForm method onFinished.

public void onFinished(JavaScriptObject jso) {
    ApplicationForm form = jso.cast();
    createWidget(form);
    session.getUiElements().setLogText("Loading application form settings for " + entity + " finished.");
    events.onFinished(form);
}
Also used : ApplicationForm(cz.metacentrum.perun.webgui.model.ApplicationForm)

Example 2 with ApplicationForm

use of cz.metacentrum.perun.webgui.model.ApplicationForm 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) {
        // 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>");
                ft.setHTML(2, 0, "<strong>Module name: </strong>");
                // widgets
                final ListBox lbInit = new ListBox();
                final ListBox lbExt = 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);
                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())));
                        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>" + form.getModuleClassName();
        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 (form.getGroup() == null && !session.isVoAdmin(form.getVo().getId()))
            button.setEnabled(false);
        if (form.getGroup() != null && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
            button.setEnabled(false);
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) 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) ListBox(com.google.gwt.user.client.ui.ListBox)

Aggregations

ApplicationForm (cz.metacentrum.perun.webgui.model.ApplicationForm)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1