Search in sources :

Example 16 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class GetFormItems method prepareErrorSettings.

private void prepareErrorSettings(PerunError error) {
    FlexTable ft = new FlexTable();
    ft.setWidth("100%");
    ft.setCellPadding(8);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    ft.addStyleName("borderTable");
    ft.setHTML(0, 0, "<strong>Short name</strong>");
    ft.setHTML(0, 1, "<strong>Type</strong>");
    ft.setHTML(0, 2, "<strong>Preview</strong>");
    ft.setHTML(0, 3, "<strong>Edit</strong>");
    fcf.setStyleName(0, 0, "header");
    fcf.setStyleName(0, 1, "header");
    fcf.setStyleName(0, 2, "header");
    fcf.setStyleName(0, 3, "header");
    if (error != null && error.getName().equalsIgnoreCase("FormNotExistsException")) {
        // no form, add create button
        final CustomButton create = new CustomButton("Create empty form", ButtonTranslation.INSTANCE.createEmptyApplicationForm(), SmallIcons.INSTANCE.addIcon());
        create.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                // disable button event with refresh page on finished
                CreateApplicationForm request = new CreateApplicationForm(entity, id, JsonCallbackEvents.disableButtonEvents(create, new JsonCallbackEvents() {

                    private TabItem item = null;

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        if (item != null) {
                            item.draw();
                        }
                    }

                    @Override
                    public void onLoadingStart() {
                        item = session.getTabManager().getActiveTab();
                    }
                }));
                request.createApplicationForm();
            }
        });
        if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && !session.isVoAdmin(id)) {
            create.setEnabled(false);
        } else if (PerunEntity.GROUP.equals(entity) && !session.isGroupAdmin(id) && !session.isVoAdmin(group.getVoId())) {
            create.setEnabled(false);
        }
        loaderImage.setEmptyResultMessage("Application form doesn't exists.");
        loaderImage.loadingFinished();
        ft.setWidget(1, 0, loaderImage);
        ft.getFlexCellFormatter().addStyleName(1, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(1, 0, 4);
        ft.setWidget(2, 0, create);
        ft.getFlexCellFormatter().addStyleName(2, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(2, 0, 4);
        ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
        ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    } else {
        // standard error
        ft.setWidget(1, 0, loaderImage);
        fcf.setColSpan(1, 0, 4);
    }
    contents.setWidget(ft);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) CreateFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.CreateFormItemTabItem) EditFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.EditFormItemTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 17 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class GetApplicationDataById method prepareApplicationForm.

/**
	 * Prepares the widgets from the items as A DISPLAY FOR THE USER
	 */
public void prepareApplicationForm() {
    FlexTable ft = new FlexTable();
    ft.setWidth("100%");
    ft.setCellPadding(10);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    String locale = "en";
    if (!Utils.getNativeLanguage().isEmpty() && !LocaleInfo.getCurrentLocale().getLocaleName().equals("default") && !LocaleInfo.getCurrentLocale().getLocaleName().equals("en")) {
        locale = Utils.getNativeLanguage().get(0);
    }
    int i = 0;
    for (final ApplicationFormItemData item : applFormItems) {
        RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item.getFormItem(), item.getValue(), locale);
        this.applFormGenerators.add(gen);
        // show only visible items - show also hidden to perun admin and vo/group admin
        if (!gen.isVisible() && !(session.isPerunAdmin() || session.isVoAdmin() || session.isGroupAdmin())) {
            continue;
        }
        // if only for admin
        if (!showAdminItems && gen.isVisibleOnlyToAdmin()) {
            continue;
        }
        // WITH LABEL (input box ...)
        if (gen.isLabelShown()) {
            // don't show password
            if (!item.getFormItem().getType().equalsIgnoreCase("PASSWORD")) {
                // 0 = label or shortname
                if (item.getFormItem().getType().startsWith("FROM_FEDERATION_HIDDEN")) {
                    // hidden
                    ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "</strong><br /><i>(value provided by external source)</i>");
                } else if (item.getFormItem().getType().startsWith("FROM_FEDERATION_SHOW")) {
                    // show
                    ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "</strong><br /><i>(value provided by external source)</i>");
                } else {
                    ft.setHTML(i, 0, "<strong>" + gen.getLabelOrShortname() + "</strong>");
                }
                // 1 = value
                ft.setWidget(i, 1, new HTML(item.getValue()));
                // format
                fcf.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_TOP);
                fcf.setVerticalAlignment(i, 1, HasVerticalAlignment.ALIGN_TOP);
                fcf.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
                fcf.setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_LEFT);
                fcf.setWidth(i, 0, "25%");
                fcf.setWidth(i, 1, "75%");
            }
        }
        i++;
    }
    // set empty text
    if (!applFormItems.isEmpty()) {
        contents.setWidget(ft);
    }
}
Also used : RegistrarFormItemGenerator(cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ApplicationFormItemData(cz.metacentrum.perun.webgui.model.ApplicationFormItemData)

Example 18 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class CreateAttributeDefinitionTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // creates HTML elements
    final ExtendedTextBox attributeDisplayName = new ExtendedTextBox();
    final ExtendedTextBox attributeName = new ExtendedTextBox();
    final ExtendedTextBox attributeDescription = new ExtendedTextBox();
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (attributeName.getTextBox().getText().trim().isEmpty()) {
                attributeName.setError("Name of attribute can't be empty.");
            } else if (!attributeName.getTextBox().getText().trim().matches(Utils.ATTRIBUTE_FRIENDLY_NAME_MATCHER)) {
                attributeName.setError("Name of attribute can contain only letters, numbers, dash and colon.");
            } else {
                attributeName.setOk();
                return true;
            }
            return false;
        }
    };
    final ExtendedTextBox.TextBoxValidator descriptionValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!attributeDescription.getTextBox().getText().trim().isEmpty()) {
                attributeDescription.setOk();
                return true;
            } else {
                attributeDescription.setError("Description of attribute can't be empty.");
                return false;
            }
        }
    };
    final ExtendedTextBox.TextBoxValidator displayNameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!attributeDisplayName.getTextBox().getText().trim().isEmpty()) {
                attributeDisplayName.setOk();
                return true;
            } else {
                attributeDisplayName.setError("Display name of attribute can't be empty.");
                return false;
            }
        }
    };
    attributeName.setValidator(nameValidator);
    attributeDisplayName.setValidator(displayNameValidator);
    attributeDescription.setValidator(descriptionValidator);
    final ListBox entityListBox = new ListBox();
    final ListBox definitionListBox = new ListBox();
    final ListBox typeListBox = new ListBox();
    // fill listboxs with pre-defined values
    entityListBox.addItem("facility", "urn:perun:facility:");
    entityListBox.addItem("resource", "urn:perun:resource:");
    entityListBox.addItem("group", "urn:perun:group:");
    entityListBox.addItem("group_resource", "urn:perun:group_resource:");
    entityListBox.addItem("host", "urn:perun:host:");
    entityListBox.addItem("member", "urn:perun:member:");
    entityListBox.addItem("member_group", "urn:perun:member_group:");
    entityListBox.addItem("member_resource", "urn:perun:member_resource:");
    entityListBox.addItem("user", "urn:perun:user:");
    entityListBox.addItem("user_ext_source", "urn:perun:ues:");
    entityListBox.addItem("user_facility", "urn:perun:user_facility:");
    entityListBox.addItem("vo", "urn:perun:vo:");
    entityListBox.addItem("entityless", "urn:perun:entityless:");
    definitionListBox.addItem("def", "attribute-def:def");
    definitionListBox.addItem("opt", "attribute-def:opt");
    definitionListBox.addItem("virt", "attribute-def:virt");
    definitionListBox.addItem("core", "attribute-def:core");
    typeListBox.addItem("String", "java.lang.String");
    typeListBox.addItem("Integer", "java.lang.Integer");
    typeListBox.addItem("Boolean", "java.lang.Boolean");
    typeListBox.addItem("Array", "java.util.ArrayList");
    typeListBox.addItem("LinkedHashMap", "java.util.LinkedHashMap");
    typeListBox.addItem("LargeString", Utils.largeStringClassName);
    typeListBox.addItem("LargeArrayList", Utils.largeArrayListClassName);
    // prepare layout for this tab
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    TabMenu menu = new TabMenu();
    // BUTTONS
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createAttributeDefinition());
    menu.addWidget(createButton);
    // close tab events & enable, disable buttons
    final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(createButton, this);
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (nameValidator.validateTextBox() && descriptionValidator.validateTextBox() && displayNameValidator.validateTextBox()) {
                String displayName = attributeDisplayName.getTextBox().getText().trim();
                String friendlyName = attributeName.getTextBox().getText().trim();
                String description = attributeDescription.getTextBox().getText().trim();
                String namespace = entityListBox.getValue(entityListBox.getSelectedIndex()) + definitionListBox.getValue(definitionListBox.getSelectedIndex());
                String type = typeListBox.getValue(typeListBox.getSelectedIndex());
                CreateAttribute request = new CreateAttribute(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        AttributeDefinition a = jso.cast();
                        ArrayList<AttributeRights> list = new ArrayList<AttributeRights>();
                        AttributeRights right = AttributeRights.create(a.getId(), "SELF");
                        list.add(getRightsFromWidgets(selfRead, selfWrite, right));
                        AttributeRights right2 = AttributeRights.create(a.getId(), "VOADMIN");
                        list.add(getRightsFromWidgets(voRead, voWrite, right2));
                        AttributeRights right3 = AttributeRights.create(a.getId(), "GROUPADMIN");
                        list.add(getRightsFromWidgets(groupRead, groupWrite, right3));
                        AttributeRights right4 = AttributeRights.create(a.getId(), "FACILITYADMIN");
                        list.add(getRightsFromWidgets(facilityRead, facilityWrite, right4));
                        // after update - update rights
                        SetAttributeRights request = new SetAttributeRights(JsonCallbackEvents.disableButtonEvents(createButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                enableDisableWidgets(true);
                                closeTabEvents.onFinished(jso);
                            }

                            @Override
                            public void onLoadingStart() {
                                enableDisableWidgets(false);
                            }

                            @Override
                            public void onError(PerunError error) {
                                enableDisableWidgets(true);
                            }
                        }));
                        request.setAttributeRights(list);
                    }
                }));
                request.createAttributeDefinition(displayName, friendlyName, description, namespace, type);
            }
        }
    });
    // insert layout
    layout.setHTML(0, 0, "Friendly name:");
    layout.setWidget(0, 1, attributeName);
    layout.setHTML(1, 0, "Display name:");
    layout.setWidget(1, 1, attributeDisplayName);
    layout.setHTML(2, 0, "Description:");
    layout.setWidget(2, 1, attributeDescription);
    layout.setHTML(3, 0, "Entity:");
    layout.setWidget(3, 1, entityListBox);
    layout.setHTML(4, 0, "Definition type:");
    layout.setWidget(4, 1, definitionListBox);
    layout.setHTML(5, 0, "Value type:");
    layout.setWidget(5, 1, typeListBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    final TabItem tab = this;
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    final FlexTable rightsTable = new FlexTable();
    rightsTable.setStyleName("inputFormFlexTable");
    rightsTable.setHTML(0, 1, "<strong>SELF</strong>");
    rightsTable.setHTML(0, 2, "<strong>VO</strong>");
    rightsTable.setHTML(0, 3, "<strong>GROUP</strong>");
    rightsTable.setHTML(0, 4, "<strong>FACILITY</strong>");
    rightsTable.setHTML(1, 0, "<strong>READ</strong>");
    rightsTable.setHTML(2, 0, "<strong>WRITE</strong>");
    rightsTable.setWidget(1, 1, selfRead);
    rightsTable.setWidget(2, 1, selfWrite);
    rightsTable.setWidget(1, 2, voRead);
    rightsTable.setWidget(2, 2, voWrite);
    rightsTable.setWidget(1, 3, groupRead);
    rightsTable.setWidget(2, 3, groupWrite);
    rightsTable.setWidget(1, 4, facilityRead);
    rightsTable.setWidget(2, 4, facilityWrite);
    rightsTable.addStyleName("centeredTable");
    vp.add(layout);
    vp.add(rightsTable);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) CreateAttribute(cz.metacentrum.perun.webgui.json.attributesManager.CreateAttribute) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) 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) AttributeRights(cz.metacentrum.perun.webgui.model.AttributeRights) SetAttributeRights(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributeRights) PerunError(cz.metacentrum.perun.webgui.model.PerunError) SetAttributeRights(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributeRights)

Example 19 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class AddDependencyTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText("Add dependency");
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    final ListBoxWithObjects<ExecService> listBox = new ListBoxWithObjects<ExecService>();
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addDependantExecService());
    // fill listbox after callback finishes
    final JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            listBox.clear();
            ArrayList<ExecService> execs = JsonUtils.jsoAsList(jso);
            if (execs != null && !execs.isEmpty()) {
                execs = new TableSorter<ExecService>().sortByService(execs);
                for (int i = 0; i < execs.size(); i++) {
                    listBox.addItem(execs.get(i));
                    if (execService.getService().getName().equals(execs.get(i).getService().getName()) && !execService.getType().equals(execs.get(i).getType())) {
                        // preselect different type of exec service from same service
                        listBox.setSelected(execs.get(i), true);
                    }
                }
                addButton.setEnabled(true);
            } else {
                listBox.addItem("No exec service available");
            }
        }

        @Override
        public void onLoadingStart() {
            listBox.clear();
            listBox.addItem("Loading...");
            addButton.setEnabled(false);
        }

        @Override
        public void onError(PerunError error) {
            listBox.addItem("Error while loading");
            addButton.setEnabled(false);
        }
    };
    // callback for all services
    ListExecServices callback = new ListExecServices(0, localEvents);
    callback.retrieveData();
    // layout
    layout.setHTML(0, 0, "ExecService:");
    layout.setHTML(1, 0, "Depend On:");
    layout.setHTML(0, 1, execService.getService().getName() + " " + execService.getType());
    layout.setWidget(1, 1, listBox);
    final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab);
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            CreateDependency request = new CreateDependency(closeTabEvents);
            request.createDependancy(execServiceId, listBox.getSelectedObject().getId());
        }
    });
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(addButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ExecService(cz.metacentrum.perun.webgui.model.ExecService) CreateDependency(cz.metacentrum.perun.webgui.json.generalServiceManager.CreateDependency) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ListExecServices(cz.metacentrum.perun.webgui.json.generalServiceManager.ListExecServices) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 20 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class AddExecServiceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Create exec service");
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    layout.setWidth("350px");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // define objects
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createExecService());
    Label serviceLabel = new Label();
    serviceLabel.setText(service.getName() + " (" + serviceId + ")");
    final ListBox type = new ListBox();
    type.addItem("GENERATE", "GENERATE");
    type.addItem("SEND", "SEND");
    final VerticalPanel fp = new VerticalPanel();
    final RadioButton radio1 = new RadioButton("rd-type", "GENERATE + SEND");
    final RadioButton radio2 = new RadioButton("rd-type", "GENERATE");
    final RadioButton radio3 = new RadioButton("rd-type", "SEND");
    radio1.setValue(true);
    fp.add(radio1);
    fp.add(radio2);
    fp.add(radio3);
    final CheckBox enabled = new CheckBox();
    enabled.setText("Enabled / Disabled");
    enabled.setValue(true);
    final ExtendedTextBox delay = new ExtendedTextBox();
    delay.getTextBox().setText(DEFAULT_DELAY);
    final ExtendedTextBox.TextBoxValidator delayValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!JsonUtils.checkParseInt(delay.getTextBox().getText().trim())) {
                delay.setError("Delay must be a number (time in minutes) !");
                return false;
            } else {
                delay.setOk();
                return true;
            }
        }
    };
    delay.setValidator(delayValidator);
    final ExtendedTextBox scriptPath = new ExtendedTextBox();
    final ExtendedTextBox.TextBoxValidator scriptValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (scriptPath.getTextBox().getText().trim().isEmpty()) {
                scriptPath.setError("Script path can't be empty !");
                return false;
            } else {
                scriptPath.setOk();
                return true;
            }
        }
    };
    scriptPath.setValidator(scriptValidator);
    // put default path
    scriptPath.getTextBox().setValue("./" + service.getName());
    // layout
    layout.setHTML(0, 0, "Service:");
    layout.setHTML(1, 0, "Type:");
    layout.setHTML(2, 0, "Status:");
    layout.setHTML(3, 0, "Delay:");
    layout.setHTML(4, 0, "Script path:");
    layout.setWidget(0, 1, serviceLabel);
    layout.setWidget(1, 1, fp);
    layout.setWidget(2, 1, enabled);
    layout.setWidget(3, 1, delay);
    layout.setWidget(4, 1, scriptPath);
    // send button
    createButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (delayValidator.validateTextBox() && scriptValidator.validateTextBox()) {
                int delayNum = Integer.parseInt(delay.getTextBox().getText().trim());
                InsertExecService request = new InsertExecService(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
                if (radio1.getValue()) {
                    request.addExecService(service, "GENERATE", enabled.getValue(), delayNum, scriptPath.getTextBox().getText().trim());
                    request.addExecService(service, "SEND", enabled.getValue(), delayNum, scriptPath.getTextBox().getText().trim());
                } else if (radio2.getValue()) {
                    request.addExecService(service, "GENERATE", enabled.getValue(), delayNum, scriptPath.getTextBox().getText().trim());
                } else if (radio3.getValue()) {
                    request.addExecService(service, "SEND", enabled.getValue(), delayNum, scriptPath.getTextBox().getText().trim());
                }
            }
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(createButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : InsertExecService(cz.metacentrum.perun.webgui.json.generalServiceManager.InsertExecService) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)25 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)25 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)19 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)19 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)17 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 RegistrarFormItemGenerator (cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)5 JSONString (com.google.gwt.json.client.JSONString)3 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)3 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)3 ArrayList (java.util.ArrayList)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 ImageResource (com.google.gwt.resources.client.ImageResource)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 Image (com.google.gwt.user.client.ui.Image)2