Search in sources :

Example 1 with Service

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

the class AssignServiceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Assign service");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetServices services = new GetServices();
    final CellTable<Service> table = services.getEmptyTable(new FieldUpdater<Service, String>() {

        public void update(int index, Service object, String value) {
            session.getTabManager().addTab(new ResourceSettingsTabItem(resource, object));
        }
    });
    // remove already assigned services from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetAssignedServices alreadyAssigned = new GetAssignedServices(resourceId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Service> srvToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < srvToRemove.length(); i++) {
                        services.removeFromTable(srvToRemove.get(i));
                    }
                    if (services.getList().size() == 1) {
                        table.getSelectionModel().setSelected(services.getList().get(0), true);
                    }
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    services.setEvents(localEvents);
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedServicesToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Service> servicesToAssign = services.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(servicesToAssign)) {
                AssignServices request = new AssignServices(JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab, true));
                request.assignService(resourceId, servicesToAssign);
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            services.filterTable(text);
            if (services.getList().size() == 1) {
                table.getSelectionModel().setSelected(services.getList().get(0), true);
            }
        }
    }, "Filter services by name");
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    services.retrieveData();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(services, table, assignButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JsArray(com.google.gwt.core.client.JsArray) GetAssignedServices(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedServices) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AssignServices(cz.metacentrum.perun.webgui.json.resourcesManager.AssignServices) ArrayList(java.util.ArrayList) Service(cz.metacentrum.perun.webgui.model.Service) GetServices(cz.metacentrum.perun.webgui.json.servicesManager.GetServices) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 2 with Service

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

the class EditServiceDetailsTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit service");
    VerticalPanel vp = new VerticalPanel();
    final ExtendedTextBox serviceName = new ExtendedTextBox();
    final ExtendedTextBox serviceDescription = new ExtendedTextBox();
    final ExtendedTextBox scriptPath = new ExtendedTextBox();
    final CheckBox enabled = new CheckBox();
    final ExtendedTextBox delay = new ExtendedTextBox();
    final ExtendedTextBox recurrence = new ExtendedTextBox();
    serviceName.getTextBox().setText(service.getName());
    serviceDescription.getTextBox().setText(service.getDescription());
    scriptPath.getTextBox().setText(service.getScriptPath());
    enabled.setValue(service.isEnabled());
    delay.getTextBox().setText(String.valueOf(service.getDelay()));
    recurrence.getTextBox().setText(String.valueOf(service.getRecurrence()));
    final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (serviceName.getTextBox().getText().trim().isEmpty()) {
                serviceName.setError("Name can't be empty");
                return false;
            } else if (!serviceName.getTextBox().getText().trim().matches(Utils.SERVICE_NAME_MATCHER)) {
                serviceName.setError("Name can contain only letters, numbers and underscore.");
                return false;
            } else {
                serviceName.setOk();
                // fill script path on service name change
                scriptPath.getTextBox().setValue("./" + serviceName.getTextBox().getText().trim().toLowerCase().replaceAll(Utils.SERVICE_NAME_TO_SCRIP_PATH_MATCHER, "_"));
                return true;
            }
        }
    };
    serviceName.setValidator(validator);
    enabled.setText("Enabled / Disabled");
    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.TextBoxValidator recurrenceValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!JsonUtils.checkParseInt(delay.getTextBox().getText().trim())) {
                recurrence.setError("Recurrence must be a number!");
                return false;
            } else {
                recurrence.setOk();
                return true;
            }
        }
    };
    recurrence.setValidator(recurrenceValidator);
    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);
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, buttonTranslation.saveServiceDetails());
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (validator.validateTextBox() && delayValidator.validateTextBox() && scriptValidator.validateTextBox() && recurrenceValidator.validateTextBox()) {
                Service serv = JsonUtils.clone(service).cast();
                serv.setName(serviceName.getTextBox().getText().trim());
                String desc = serviceDescription.getTextBox().getText().trim();
                if (desc.isEmpty())
                    desc = null;
                serv.setDescription(desc);
                serv.setDelay(Integer.parseInt(delay.getTextBox().getText().trim()));
                serv.setRecurrence(Integer.parseInt(recurrence.getTextBox().getText().trim()));
                serv.setEnabled(enabled.getValue());
                serv.setScriptPath(scriptPath.getTextBox().getText().trim());
                UpdateService request = new UpdateService(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, true, events));
                request.updateService(serv);
            }
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    });
    // Add some standard form options
    // fill form
    layout.setHTML(0, 0, "Name:");
    layout.setHTML(1, 0, "Description:");
    layout.setHTML(2, 0, "Status:");
    layout.setHTML(3, 0, "Delay:");
    layout.setHTML(4, 0, "Recurrence:");
    layout.setHTML(5, 0, "Script path:");
    layout.setWidget(0, 1, serviceName);
    layout.setWidget(1, 1, serviceDescription);
    layout.setWidget(2, 1, enabled);
    layout.setWidget(3, 1, delay);
    layout.setWidget(4, 1, recurrence);
    layout.setWidget(5, 1, scriptPath);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(saveButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Label(com.google.gwt.user.client.ui.Label) FlexTable(com.google.gwt.user.client.ui.FlexTable) Service(cz.metacentrum.perun.webgui.model.Service) UpdateService(cz.metacentrum.perun.webgui.json.servicesManager.UpdateService) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) UpdateService(cz.metacentrum.perun.webgui.json.servicesManager.UpdateService) CheckBox(com.google.gwt.user.client.ui.CheckBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 3 with Service

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

the class ResourceSettingsTabItem method draw.

public Widget draw() {
    if (service != null) {
        titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": " + service.getName() + " configuration");
    } else {
        titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": service configuration");
    }
    vp.setSize("100%", "100%");
    vp.clear();
    // menu
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    // callback
    final GetRequiredAttributesV2 resAttrs = new GetRequiredAttributesV2();
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("resource", resourceId);
    resAttrs.setIds(ids);
    final GetAttributesV2 attrs = new GetAttributesV2();
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        resAttrs.setCheckable(false);
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        attrs.setCheckable(false);
    // puts first table
    final CellTable<Attribute> table = resAttrs.getEmptyTable();
    final CellTable<Attribute> table2 = attrs.getEmptyTable();
    // if for one service only modify empty table message
    if (service != null) {
        AjaxLoaderImage empty = (AjaxLoaderImage) table.getEmptyTableWidget();
        empty.setEmptyResultMessage("Service " + service.getName() + " requires no setting on resource.");
        AjaxLoaderImage empty2 = (AjaxLoaderImage) table2.getEmptyTableWidget();
        empty2.setEmptyResultMessage("Service " + service.getName() + " requires no setting on resource.");
    }
    final ListBoxWithObjects<Service> servList = new ListBoxWithObjects<Service>();
    sp.setWidget(table);
    sp2.setWidget(table2);
    // switch between assigned and all
    final CheckBox chb = new CheckBox();
    chb.setText(WidgetTranslation.INSTANCE.offerAvailableServicesOnly());
    chb.setTitle(WidgetTranslation.INSTANCE.offerAvailableServicesOnlyTitle());
    // default true
    chb.setValue(lastOfferAvailableOnly);
    // event which fills the listbox and call getRequiredAttributes
    JsonCallbackEvents event = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // clear services list
            servList.clear();
            // process services
            ArrayList<Service> srv = JsonUtils.jsoAsList(jso);
            srv = new TableSorter<Service>().sortByName(srv);
            for (int i = 0; i < srv.size(); i++) {
                // fill listbox
                servList.addItem(srv.get(i));
            }
            if (servList.isEmpty()) {
                servList.addNotSelectedOption();
                lastSelectedService = 0;
                indexInList = 0;
                attrs.retrieveData();
                setTable(false);
                return;
            }
            if (lastSelectedService == 0 && chb.getValue() == true) {
                servList.addNotSelectedOption();
                servList.addAllOption();
                if (indexInList == 0) {
                    servList.setSelectedIndex(0);
                    attrs.retrieveData();
                    setTable(false);
                    return;
                } else if (indexInList == 1) {
                    servList.setSelectedIndex(1);
                }
            } else if (lastSelectedService == 0 && chb.getValue() == false) {
                servList.addNotSelectedOption();
                servList.setSelectedIndex(0);
                attrs.retrieveData();
                setTable(false);
                return;
            } else if (lastSelectedService != 0) {
                if (chb.getValue() == true) {
                    servList.addNotSelectedOption();
                    servList.addAllOption();
                } else {
                    servList.addNotSelectedOption();
                }
                // remove last service, we can't be sure it was loaded again
                ids.remove("service");
                // either all or specific service
                servList.setSelectedIndex(1);
                for (Service s : servList.getAllObjects()) {
                    if (s.getId() == lastSelectedService) {
                        // service selected last time was found in a list
                        servList.setSelected(s, true);
                        ids.put("service", s.getId());
                        break;
                    }
                }
            }
            // make call
            resAttrs.clearTable();
            resAttrs.setIds(ids);
            resAttrs.retrieveData();
            setTable(true);
        }

        @Override
        public void onError(PerunError error) {
            servList.clear();
            servList.addItem("Error while loading");
            if (required) {
                ((AjaxLoaderImage) table.getEmptyTableWidget()).loadingError(error);
            } else {
                ((AjaxLoaderImage) table2.getEmptyTableWidget()).loadingError(error);
            }
        }

        @Override
        public void onLoadingStart() {
            servList.removeAllOption();
            servList.removeNotSelectedOption();
            servList.clear();
            servList.addItem("Loading...");
        }
    };
    final GetAssignedServices services = new GetAssignedServices(resourceId, event);
    final GetServices allServices = new GetServices(event);
    // offer services selection
    if (serviceId == 0) {
        // services listbox
        servList.setTitle("Services");
        attrs.setIds(ids);
        // on change of service update table
        servList.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                // if service selected
                if (servList.getSelectedIndex() == 0) {
                    attrs.retrieveData();
                    setTable(false);
                    lastSelectedService = 0;
                    indexInList = 0;
                    return;
                } else if (chb.getValue() == true && servList.getSelectedIndex() == 1) {
                    ids.remove("service");
                    lastSelectedService = 0;
                    indexInList = 1;
                } else if ((chb.getValue() == true && servList.getSelectedIndex() > 1) || (chb.getValue() == false && servList.getSelectedIndex() > 0)) {
                    ids.put("service", servList.getSelectedObject().getId());
                    lastSelectedService = servList.getSelectedObject().getId();
                }
                lastOfferAvailableOnly = chb.getValue();
                resAttrs.clearTable();
                resAttrs.setIds(ids);
                resAttrs.retrieveData();
                setTable(true);
            }
        });
        if (chb.getValue() == false) {
            allServices.retrieveData();
        } else {
            services.retrieveData();
        }
    } else {
        // retrieve data for selected service only
        lastSelectedService = serviceId;
        lastOfferAvailableOnly = chb.getValue();
        ids.put("service", serviceId);
        resAttrs.setIds(ids);
        resAttrs.retrieveData();
        setTable(true);
    }
    // refresh table event - refresh only on finished / on error keep selected
    final JsonCallbackEvents refreshTable = JsonCallbackEvents.refreshTableEvents(resAttrs);
    final JsonCallbackEvents refreshTable2 = JsonCallbackEvents.refreshTableEvents(attrs);
    // add save changes to menu
    final CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
    menu.addWidget(saveChangesButton);
    // set button disable event
    final JsonCallbackEvents saveChangesButtonEvent = JsonCallbackEvents.disableButtonEvents(saveChangesButton, refreshTable);
    final JsonCallbackEvents saveChangesButtonEvent2 = JsonCallbackEvents.disableButtonEvents(saveChangesButton, refreshTable2);
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        saveChangesButton.setEnabled(false);
    saveChangesButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Attribute> list = new ArrayList<Attribute>();
            if (required) {
                list = resAttrs.getTableSelectedList();
            } else {
                list = attrs.getTableSelectedList();
            }
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("resource", resourceId);
                SetAttributes request = new SetAttributes((required) ? saveChangesButtonEvent : saveChangesButtonEvent2);
                request.setAttributes(ids, list);
            }
        }
    });
    // add set new to menu
    CustomButton setNewAttributeButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Attribute> list = new ArrayList<Attribute>();
            if (required) {
                list = resAttrs.getList();
            } else {
                list = attrs.getList();
            }
            Map<String, Integer> ids = new HashMap<String, Integer>();
            ids.put("resource", resourceId);
            session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids, list), true);
        }
    });
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        setNewAttributeButton.setEnabled(false);
    if (service == null) {
        menu.addWidget(setNewAttributeButton);
    }
    // fill button
    final CustomButton fillDefaultButton = TabMenu.getPredefinedButton(ButtonType.FILL, ButtonTranslation.INSTANCE.fillResourceAttributes());
    menu.addWidget(fillDefaultButton);
    // remove attr button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
    // remove button event
    final JsonCallbackEvents removeButtonEvent = JsonCallbackEvents.disableButtonEvents(removeButton, refreshTable);
    final JsonCallbackEvents removeButtonEvent2 = JsonCallbackEvents.disableButtonEvents(removeButton, refreshTable2);
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        removeButton.setEnabled(false);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Attribute> list = new ArrayList<Attribute>();
            if (required) {
                list = resAttrs.getTableSelectedList();
            } else {
                list = attrs.getTableSelectedList();
            }
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("resource", resourceId);
                RemoveAttributes request = new RemoveAttributes((required) ? removeButtonEvent : removeButtonEvent2);
                request.removeAttributes(ids, list);
            }
        }
    });
    menu.addWidget(removeButton);
    // add service selection to menu and switcher
    if (serviceId == 0) {
        menu.addWidget(new HTML("<strong>Selected&nbsp;service: </strong>"));
        menu.addWidget(servList);
        menu.addWidget(chb);
    }
    // checkbox switcher on click
    chb.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (chb.getValue() == false) {
                lastOfferAvailableOnly = false;
                allServices.retrieveData();
            } else {
                lastOfferAvailableOnly = true;
                services.retrieveData();
            }
        }
    });
    fillDefaultButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // automatically try to fill all attributes
            ArrayList<Attribute> prepareList = new ArrayList<Attribute>();
            if (required) {
                prepareList = resAttrs.getTableSelectedList();
            } else {
                prepareList = attrs.getTableSelectedList();
            }
            final ArrayList<Attribute> list = prepareList;
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("resource", resourceId);
                FillAttributes request = new FillAttributes(JsonCallbackEvents.disableButtonEvents(fillDefaultButton, new JsonCallbackEvents() {

                    boolean wasRequiredTable = required;

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        // remove attribute from original table and put new ones
                        ArrayList<Attribute> newList = JsonUtils.jsoAsList(jso);
                        for (Attribute a : newList) {
                            for (Attribute oldA : list) {
                                // deselect old
                                if (a.getId() == oldA.getId()) {
                                    if (wasRequiredTable) {
                                        resAttrs.getSelectionModel().setSelected(oldA, false);
                                        resAttrs.removeFromTable(oldA);
                                    } else {
                                        attrs.getSelectionModel().setSelected(oldA, false);
                                        attrs.removeFromTable(oldA);
                                    }
                                }
                            }
                            if (wasRequiredTable) {
                                // add new
                                resAttrs.addToTable(a);
                                // select returned
                                resAttrs.getSelectionModel().setSelected(a, true);
                            } else {
                                // add new
                                attrs.addToTable(a);
                                // select returned
                                attrs.getSelectionModel().setSelected(a, true);
                            }
                        }
                        if (wasRequiredTable) {
                            resAttrs.sortTable();
                        } else {
                            attrs.sortTable();
                        }
                    }
                }));
                request.fillAttributes(ids, list);
            }
        }
    });
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        fillDefaultButton.setEnabled(false);
    /* TODO - not implemented

			 Button checkValuesButton = new CustomButton("Check values", SmallIcons.INSTANCE.scriptGearIcon());
			 menu.addWidget(checkValuesButton);
			 checkValuesButton.setTitle("Checks inserted values against current Perun state - nothing is saved unless you click on 'Save changes'");


			 checkValuesButton.addClickHandler(new ClickHandler(){
			 public void onClick(ClickEvent event) {
			 Window.alert("not yet implemented");
			 }
			 });

*/
    table.addStyleName("perun-table");
    table.setWidth("100%");
    table2.addStyleName("perun-table");
    table2.setWidth("100%");
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    sp2.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp2, 350, this);
    // default is required attributes
    setTable(true);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) HashMap(java.util.HashMap) Attribute(cz.metacentrum.perun.webgui.model.Attribute) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetServices(cz.metacentrum.perun.webgui.json.servicesManager.GetServices) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) SetNewAttributeTabItem(cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem) GetAssignedServices(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedServices) Service(cz.metacentrum.perun.webgui.model.Service) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with Service

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

the class GetServices method filterTable.

@Override
public void filterTable(String filter) {
    // store list only for first time
    if (backupList.isEmpty() || backupList == null) {
        backupList.addAll(list);
    }
    // always clear selected items
    selectionModel.clear();
    list.clear();
    if (filter.equalsIgnoreCase("")) {
        list.addAll(backupList);
    } else {
        for (Service s : backupList) {
            // store facility by filter
            if (s.getName().toLowerCase().startsWith(filter.toLowerCase())) {
                list.add(s);
            }
        }
    }
    if (list.isEmpty() && !filter.isEmpty()) {
        loaderImage.setEmptyResultMessage("No service matching '" + filter + "' found.");
    } else {
        loaderImage.setEmptyResultMessage("No service defined in Perun.");
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : Service(cz.metacentrum.perun.webgui.model.Service)

Example 5 with Service

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

the class GetServicesByAttrDefinition method setList.

public void setList(ArrayList<Service> list) {
    clearTable();
    this.list.addAll(list);
    for (Service s : list) {
        oracle.add(s.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : Service(cz.metacentrum.perun.webgui.model.Service)

Aggregations

Service (cz.metacentrum.perun.webgui.model.Service)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)11 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)10 ArrayList (java.util.ArrayList)9 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)7 GetServices (cz.metacentrum.perun.webgui.json.servicesManager.GetServices)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 GetAssignedServices (cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedServices)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 ConvertAttributeToUnique (cz.metacentrum.perun.webgui.json.attributesManager.ConvertAttributeToUnique)2 GetAttributeRights (cz.metacentrum.perun.webgui.json.attributesManager.GetAttributeRights)2 SetAttributeRights (cz.metacentrum.perun.webgui.json.attributesManager.SetAttributeRights)2 UpdateAttribute (cz.metacentrum.perun.webgui.json.attributesManager.UpdateAttribute)2