Search in sources :

Example 6 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class AddFacilityOwnerTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText("Add owner");
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // CALLBACK
    final GetOwners owners = new GetOwners();
    CellTable<Owner> table = owners.getTable();
    // ADD BUTTON
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addOwners());
    // tab to be closed
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // get
            ArrayList<Owner> list = owners.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                for (int i = 0; i < list.size(); i++) {
                    if (i == list.size() - 1) {
                        AddOwner request = new AddOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
                        request.addOwner(facilityId, list.get(i).getId());
                    } else {
                        AddOwner request = new AddOwner(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.addOwner(facilityId, list.get(i).getId());
                    }
                }
            }
        }
    });
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            owners.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterOwners());
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(owners, 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(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner) AddOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner) AddOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner) GetOwners(cz.metacentrum.perun.webgui.json.ownersManager.GetOwners) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 7 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class AssignSecurityTeamTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText("Add security team");
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // CALLBACK
    final GetSecurityTeams secTeams = new GetSecurityTeams();
    secTeams.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            if (secTeams.getList().size() == 1) {
                secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
            }
        }
    });
    secTeams.setForceAll(true);
    CellTable<SecurityTeam> table = secTeams.getTable();
    // ADD BUTTON
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSecurityTeam());
    // tab to be closed
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // get
            ArrayList<SecurityTeam> list = secTeams.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                for (int i = 0; i < list.size(); i++) {
                    if (i == list.size() - 1) {
                        AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
                        request.assignSecurityTeam(facilityId, list.get(i).getId());
                    } else {
                        AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.assignSecurityTeam(facilityId, list.get(i).getId());
                    }
                }
            }
        }
    });
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(secTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            secTeams.filterTable(text);
            if (secTeams.getList().size() == 1) {
                secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(secTeams, 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(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetSecurityTeams(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams) AssignSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) AssignSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 8 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class FacilitiesSelectTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // TAB MENU
    TabMenu tabMenu = new TabMenu();
    // get RICH facilities request
    final GetFacilities facilities = new GetFacilities(true);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(facilities);
    // retrieve data (table)
    final CellTable<Facility> table = facilities.getTable(new FieldUpdater<Facility, String>() {

        public void update(int index, Facility object, String value) {
            session.getTabManager().addTab(new FacilityDetailTabItem(object));
        }
    });
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // add new facility button
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createFacility(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new CreateFacilityTabItem(facilities.getFullBackupList(), events));
        }
    }));
    // add delete facilities button
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteFacilities());
    if (session.isPerunAdmin()) {
        tabMenu.addWidget(deleteButton);
    }
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Facility> list = facilities.getTableSelectedList();
            String text = "Following facilities will be deleted.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

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

        public void searchFor(String text) {
            facilities.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterFacilities());
    tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    tabMenu.addWidget(new HTML("<strong>Please select Facility you want to manage.</strong>"));
    deleteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(facilities, table, deleteButton);
    // 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(sp);
    firstTabPanel.setCellHeight(sp, "100%");
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) DeleteFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.DeleteFacility) GetFacilities(cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilities) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) DeleteFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.DeleteFacility) Facility(cz.metacentrum.perun.webgui.model.Facility)

Example 9 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent 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 10 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent 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)

Aggregations

PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)28 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)24 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)23 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)23 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)21 ArrayList (java.util.ArrayList)21 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)12 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)10 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4 Group (cz.metacentrum.perun.webgui.model.Group)4 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)4 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)2 JsArray (com.google.gwt.core.client.JsArray)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 HTML (com.google.gwt.user.client.ui.HTML)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2