Search in sources :

Example 1 with ListExecServicesThisExecServiceDependsOn

use of cz.metacentrum.perun.webgui.json.generalServiceManager.ListExecServicesThisExecServiceDependsOn in project perun by CESNET.

the class ViewExecServiceTabItem method getDependencyContent.

public VerticalPanel getDependencyContent() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // MAIN MENU
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // callback
    final ListExecServicesThisExecServiceDependsOn callback = new ListExecServicesThisExecServiceDependsOn(execServiceId);
    // refresh event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(callback);
    // add button
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addDependantExecService(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddDependencyTabItem(execService));
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedDependantExecServices());
    tabMenu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ExecService> dependencyForDeletion = callback.getTableSelectedList();
            UiElements.showDeleteConfirm(dependencyForDeletion, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < dependencyForDeletion.size(); i++) {
                        if (i == dependencyForDeletion.size() - 1) {
                            RemoveDependency request = new RemoveDependency(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            request.removeDependency(execServiceId, dependencyForDeletion.get(i).getId());
                        } else {
                            RemoveDependency request = new RemoveDependency(JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeDependency(execServiceId, dependencyForDeletion.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    vp.add(tabMenu);
    vp.setCellHeight(tabMenu, "30px");
    // get table
    CellTable<ExecService> table = callback.getTable();
    // create scroll panel for table
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    sp.setWidth("100%");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, removeButton);
    vp.add(sp);
    vp.setCellHeight(sp, "100%");
    session.getUiElements().resizePerunTable(sp, 250, this);
    return vp;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ExecService(cz.metacentrum.perun.webgui.model.ExecService) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveDependency(cz.metacentrum.perun.webgui.json.generalServiceManager.RemoveDependency) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ListExecServicesThisExecServiceDependsOn(cz.metacentrum.perun.webgui.json.generalServiceManager.ListExecServicesThisExecServiceDependsOn) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 ListExecServicesThisExecServiceDependsOn (cz.metacentrum.perun.webgui.json.generalServiceManager.ListExecServicesThisExecServiceDependsOn)1 RemoveDependency (cz.metacentrum.perun.webgui.json.generalServiceManager.RemoveDependency)1 ExecService (cz.metacentrum.perun.webgui.model.ExecService)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 ArrayList (java.util.ArrayList)1