Search in sources :

Example 16 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class TaskResultsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText("Tasks results: " + task.getExecService().getService().getName() + " " + task.getExecService().getType());
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    final GetRichTaskResultsByTask callback = new GetRichTaskResultsByTask(task.getId());
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            callback.filterTable(text);
        }
    }, "Filter results by destination");
    CellTable<TaskResult> table = callback.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) TaskResult(cz.metacentrum.perun.webgui.model.TaskResult) GetRichTaskResultsByTask(cz.metacentrum.perun.webgui.json.propagationStatsReader.GetRichTaskResultsByTask) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 17 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AddGroupExtSourceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add external source");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(new HTML(""));
    final GetVoExtSources extSources = new GetVoExtSources(group.getVoId());
    // remove already assigned ext sources from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetGroupExtSources alreadyAssigned = new GetGroupExtSources(groupId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<ExtSource> esToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < esToRemove.length(); i++) {
                        extSources.removeFromTable(esToRemove.get(i));
                    }
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    extSources.setEvents(localEvents);
    final ExtendedSuggestBox box = new ExtendedSuggestBox(extSources.getOracle());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
    final TabItem tab = this;
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToAdd = extSources.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(extSourcesToAdd)) {
                // FIXME - Should have only one callback to core
                for (int i = 0; i < extSourcesToAdd.size(); i++) {
                    final int n = i;
                    AddExtSource request = new AddExtSource(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // unselect added person
                            extSources.getSelectionModel().setSelected(extSourcesToAdd.get(n), false);
                            alreadyAddedList.add(extSourcesToAdd.get(n));
                            rebuildAlreadyAddedWidget();
                            // clear search
                            box.getSuggestBox().setText("");
                        }
                    }));
                    request.addGroupExtSource(groupId, extSourcesToAdd.get(i).getId());
                }
            }
        }
    });
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            extSources.filterTable(text);
        }
    }, "Filter by ext source name or type");
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(alreadyAdded);
    CellTable<ExtSource> table = extSources.getTable();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(extSources, table, assignButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // do not use resizePerunTable() when tab is in overlay - wrong width is calculated
    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) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GetVoExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetVoExtSources) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) AddExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.AddExtSource) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource) AddExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.AddExtSource) GetGroupExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetGroupExtSources)

Example 18 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AddGroupUnionTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText("Add group union");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(new HTML(""));
    final GetAllGroups groups = new GetAllGroups(group.getVoId());
    groups.setCoreGroupsCheckable(true);
    // remove already added union groups from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetGroupUnions alreadyAssigned = new GetGroupUnions(group, false, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < esToRemove.length(); i++) {
                        groups.removeFromTable(esToRemove.get(i));
                    }
                    // remove itself
                    groups.removeFromTable(group);
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    groups.setEvents(localEvents);
    final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.getOracle());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
    final TabItem tab = this;
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> groupsToAdd = groups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(groupsToAdd)) {
                // FIXME - Should have only one callback to core
                for (int i = 0; i < groupsToAdd.size(); i++) {
                    final int n = i;
                    AddGroupUnion request = new AddGroupUnion(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // unselect added person
                            groups.getSelectionModel().setSelected(groupsToAdd.get(n), false);
                            alreadyAddedList.add(groupsToAdd.get(n));
                            rebuildAlreadyAddedWidget();
                            // clear search
                            box.getSuggestBox().setText("");
                        }
                    }));
                    request.createGroupUnion(group, groupsToAdd.get(i));
                }
            }
        }
    });
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, "Filter by ext source name or type");
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(alreadyAdded);
    CellTable<Group> table = groups.getTable();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(groups, table, assignButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // do not use resizePerunTable() when tab is in overlay - wrong width is calculated
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) JsArray(com.google.gwt.core.client.JsArray) AddGroupUnion(cz.metacentrum.perun.webgui.json.groupsManager.AddGroupUnion) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) 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) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 19 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AssignGroupTabItem method draw.

public Widget draw() {
    // set tab name
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": assign to resource");
    // main content
    VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // callback
    final GetRichResources callback = new GetRichResources(group.getVoId());
    callback.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            for (RichResource rr : resources) {
                callback.removeFromTable(rr);
            }
            ArrayList<RichResource> temp = new ArrayList<RichResource>();
            temp.addAll(callback.getList());
            callback.setList(temp);
        }
    });
    CellTable<RichResource> table = callback.getTable();
    // close tab event
    final TabItem tab = this;
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            callback.filterTable(text);
            // if single group, select
            if (callback.getList().size() == 1) {
                callback.getSelectionModel().setSelected(callback.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignGroupToSelectedResources());
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<RichResource> toAssign = callback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(toAssign)) {
                AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        alreadyAddedList.addAll(toAssign);
                        for (RichResource r : toAssign) {
                            callback.getSelectionModel().setSelected(r, false);
                        }
                        rebuildAlreadyAddedWidget();
                    }
                }));
                request.assignGroupToResources(group, toAssign);
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, assignButton);
    // add menu and the table to the main panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // do not use resizePerunTable() in overlay mode - calculated width is wrong
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    rebuildAlreadyAddedWidget();
    mainTab.add(alreadyAdded);
    mainTab.add(sp);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichResource(cz.metacentrum.perun.webgui.model.RichResource) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) AssignGroupToResources(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupToResources) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 20 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class FacilityResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Resources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetAssignedRichResources resources = new GetAssignedRichResources(facility.getId());
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    // create resource button
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceTabItem(facility), false);
        }
    }));
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
    menu.addWidget(deleteButton);
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            final ArrayList<RichResource> toDelete = resources.getTableSelectedList();
            String text = "Following resources will be deleted.";
            UiElements.showDeleteConfirm(toDelete, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < toDelete.size(); i++) {
                        if (i == toDelete.size() - 1) {
                            DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                            request.deleteResource(toDelete.get(i).getId());
                        } else {
                            DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton));
                            request.deleteResource(toDelete.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, "Filter resources by name or VO name");
    CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {

        public void update(int index, RichResource object, String value) {
            session.getTabManager().addTab(new ResourceDetailTabItem(object, facilityId));
        }
    });
    deleteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(resources, table, deleteButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) DeleteResource(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResource) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAssignedRichResources(cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedRichResources) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CreateFacilityResourceTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.CreateFacilityResourceTabItem) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Aggregations

ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)48 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)40 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)40 ArrayList (java.util.ArrayList)39 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)38 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)38 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)24 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)13 Group (cz.metacentrum.perun.webgui.model.Group)6 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)4 JsArray (com.google.gwt.core.client.JsArray)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4 ExtSource (cz.metacentrum.perun.webgui.model.ExtSource)4 Service (cz.metacentrum.perun.webgui.model.Service)4 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)4 GetVoExtSources (cz.metacentrum.perun.webgui.json.extSourcesManager.GetVoExtSources)3