Search in sources :

Example 56 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class ResourceDetailTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()));
    // main widget panel
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    AbsolutePanel dp = new AbsolutePanel();
    //dp.setStyleName("decoration");
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);
    // MAIN INFO PANEL
    // resource info
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.serverGroupIcon()));
    Label resourceName = new Label();
    resourceName.setText(Utils.getStrippedStringWithEllipsis(resource.getName(), 40));
    resourceName.setStyleName("now-managing");
    resourceName.setTitle(resource.getName());
    menu.setWidget(0, 1, resourceName);
    menu.setHTML(0, 2, " ");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");
    int column = 3;
    final JsonCallbackEvents events = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            new GetEntityById(PerunEntity.RICH_RESOURCE, resourceId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    resource = jso.cast();
                    open();
                    draw();
                }
            }).retrieveData();
        }
    };
    CustomButton change = new CustomButton("", ButtonTranslation.INSTANCE.editResourceDetails(), SmallIcons.INSTANCE.applicationFormEditIcon());
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        change.setEnabled(false);
    change.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // prepare confirm content
            Resource r = resource.cast();
            session.getTabManager().addTabToCurrentTab(new EditResourceDetailsTabItem(r, events));
        }
    });
    menu.setWidget(0, column, change);
    column++;
    menu.setHTML(0, column, " ");
    menu.getFlexCellFormatter().setWidth(0, column, "25px");
    column++;
    if (JsonUtils.isExtendedInfoVisible()) {
        menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getId() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    if (facilityId > 0) {
        // facility admin view
        menu.setHTML(0, column, "<strong>VO:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getVoId() + " / " + resource.getVo().getShortName() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getDescription() + "&nbsp;</span>");
    if (session.isFacilityAdmin(resource.getFacilityId())) {
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
        Anchor a = new Anchor("View facility details >>");
        a.setStyleName("pointer");
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new FacilityDetailTabItem(resource.getFacility()));
            }
        });
        menu.setWidget(0, column, a);
    }
    dp.add(menu);
    vp.add(dp);
    vp.setCellHeight(dp, "30px");
    // TAB PANEL WITH INNER TABS
    tabPanel.clear();
    Resource r = resource.cast();
    tabPanel.add(new ResourceAssignedGroupsTabItem(r), "Assigned groups");
    tabPanel.add(new ResourceAssignedServicesTabItem(r), "Assigned services");
    tabPanel.add(new ResourceSettingsTabItem(r, null), "Service settings");
    tabPanel.add(new ResourceGroupSettingsTabItem(r), "Group settings");
    tabPanel.add(new ResourceMemberSettingsTabItem(resource), "Member settings");
    if (session.isVoAdmin(r.getVoId()) || session.isVoObserver(r.getVoId())) {
        tabPanel.add(new ResourceTagsTabItem(r), "Tags");
    }
    // Resize must be called after page fully displays
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            tabPanel.finishAdding();
        }
    });
    vp.add(tabPanel);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource(com.google.gwt.resources.client.ImageResource) Resource(cz.metacentrum.perun.webgui.model.Resource) RichResource(cz.metacentrum.perun.webgui.model.RichResource) FacilityDetailTabItem(cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Command(com.google.gwt.user.client.Command) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Example 57 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class StatisticsTabItem method draw.

public Widget draw() {
    // PAGE CONTENTS
    ScrollPanel scroll = new ScrollPanel();
    final VerticalPanel vp = new VerticalPanel();
    vp.setStyleName("perun-table");
    vp.setSpacing(5);
    scroll.setWidget(vp);
    scroll.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(scroll, 350, this);
    final DisclosurePanel vosStatistics = new DisclosurePanel();
    vosStatistics.setWidth("100%");
    //vosStatistics.setOpen(true);
    FlexTable vosHeader = new FlexTable();
    vosHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
    vosHeader.setWidget(0, 1, new HTML("<h3>Virtual Organizations</h3>"));
    vosHeader.setTitle("Click to show/hide VOs statistics");
    vosStatistics.setHeader(vosHeader);
    vp.add(vosStatistics);
    // the general statistics table
    final FlexTable statisticsTable = new FlexTable();
    statisticsTable.addStyleName("statisticsTable");
    // the VOs table
    final FlexTable vosTable = new FlexTable();
    vosTable.addStyleName("statisticsTable");
    vosTable.setWidget(0, 0, new HTML("<strong>" + "VO name" + "</strong>"));
    vosTable.setWidget(0, 1, new HTML("<strong>" + "Members" + "</strong>"));
    vosTable.setWidget(0, 2, new HTML("<strong>" + "Valid members" + "</strong>"));
    vosTable.setWidget(0, 3, new HTML("<strong>" + "Invalid members" + "</strong>"));
    vosTable.setWidget(0, 4, new HTML("<strong>" + "Suspended members" + "</strong>"));
    vosTable.setWidget(0, 5, new HTML("<strong>" + "Expired members" + "</strong>"));
    vosTable.setWidget(0, 6, new HTML("<strong>" + "Disabled members" + "</strong>"));
    vosTable.setWidget(0, 7, new HTML("<strong>" + "Groups" + "</strong>"));
    vosTable.setWidget(0, 8, new HTML("<strong>" + "Resources" + "</strong>"));
    // vos events - adds the VOs to the table and calls how many members the VO has
    JsonCallbackEvents vosEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            // conversion
            ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
            vos = new TableSorter<VirtualOrganization>().sortByName(vos);
            // iterating VOs
            for (int i = 0; i < vos.size(); i++) {
                VirtualOrganization vo = vos.get(i);
                // call the request for number of members
                GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
                countMembers.retrieveData();
                GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
                countValidMembers.retrieveData();
                GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
                countInvalidMembers.retrieveData();
                GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
                countSuspendedMembers.retrieveData();
                GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
                countExpiredMembers.retrieveData();
                GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
                countDisabledMembers.retrieveData();
                // call the request for number of resources
                GetResourcesCount countResources = new GetResourcesCount(vo.getId());
                countResources.retrieveData();
                GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
                countGroups.retrieveData();
                //adds the VO to the table
                vosTable.setText(i + 1, 0, vo.getName());
                vosTable.setWidget(i + 1, 1, countMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 2, countValidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 3, countInvalidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 4, countSuspendedMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 5, countExpiredMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 6, countDisabledMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 7, countGroups.getGroupsCountHyperlink());
                vosTable.setWidget(i + 1, 8, countResources.getResourcesCountHyperlink());
            }
        }
    };
    // requests
    final GetVos vos = new GetVos(vosEvents);
    vosHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (vosStatistics.getContent() == null) {
                // retrieve data
                vosStatistics.setContent(vosTable);
                vos.retrieveData();
            }
        }
    });
    this.contentWidget.setWidget(scroll);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) TableSorter(cz.metacentrum.perun.webgui.client.resources.TableSorter) GetGroupsCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetMembersCount(cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount) GetResourcesCount(cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)

Example 58 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class CreateFormItemTabItem method draw.

public Widget draw() {
    // vertical panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("425px", "100%");
    // flex table
    final FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // select widget short name
    final ExtendedTextBox shortNameTextBox = new ExtendedTextBox();
    shortNameTextBox.setWidth("200px");
    final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (shortNameTextBox.getTextBox().getText().trim().isEmpty()) {
                shortNameTextBox.setError("Short name can't be empty.");
                return false;
            } else {
                shortNameTextBox.setOk();
                return true;
            }
        }
    };
    shortNameTextBox.setValidator(validator);
    // select widget type
    final ListBox typeListBox = new ListBox();
    for (String type : inputTypes.keySet()) {
        typeListBox.addItem(inputTypes.get(type), type);
    }
    // insert after
    final ListBox insertAfterListBox = new ListBox();
    insertAfterListBox.addItem(" - insert to the beginning - ", 0 + "");
    for (int i = 0; i < sourceList.size(); i++) {
        ApplicationFormItem item = sourceList.get(i);
        // with default en locale
        RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item, "");
        String label = gen.getFormItem().getShortname();
        // crop length
        if (label.length() > CROP_LABEL_LENGTH) {
            label = label.substring(0, CROP_LABEL_LENGTH);
        }
        // add to box
        insertAfterListBox.addItem(label, (i + 1) + "");
    }
    layout.setHTML(0, 0, "Short name:");
    layout.setWidget(0, 1, shortNameTextBox);
    layout.setHTML(1, 0, "Input widget:");
    layout.setWidget(1, 1, typeListBox);
    layout.setHTML(2, 0, "Insert after:");
    layout.setWidget(2, 1, insertAfterListBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    layout.setHTML(3, 0, "");
    cellFormatter.setColSpan(3, 0, 2);
    cellFormatter.setStyleName(3, 0, "inputFormInlineComment");
    typeListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            String type = typeListBox.getValue(typeListBox.getSelectedIndex());
            if (type.equals("TEXTFIELD")) {
                layout.setHTML(3, 0, "Editable text field useful to gather short text input, e.g. name, phone.");
            } else if (type.equals("TEXTAREA")) {
                layout.setHTML(3, 0, "Editable text area useful to gather longer text input with linebreaks, e.g. comments, SSH key");
            } else if (type.equals("SELECTIONBOX")) {
                layout.setHTML(3, 0, "Simple selection box with defined custom values that user can choose.");
            } else if (type.equals("COMBOBOX")) {
                layout.setHTML(3, 0, "Selection box with defined custom values and one special option: \"--custom value--\", which allows users to input own text (as simple text field).");
            } else if (type.equals("CHECKBOX")) {
                layout.setHTML(3, 0, "List of defined custom options with checkboxes. Selected values are gathered as comma separated string.");
            } else if (type.equals("USERNAME")) {
                layout.setHTML(3, 0, "Special text field to gather user`s login. It checks login availability on user input.");
            } else if (type.equals("PASSWORD")) {
                layout.setHTML(3, 0, "Two password fields to gather user`s new password. Input is never displayed. User must type same password in both fields.");
            } else if (type.equals("VALIDATED_EMAIL")) {
                layout.setHTML(3, 0, "Special text field to gather and verify user`s email address. Input is checked on email address format. If user enters new value, then validation email is sent. Application then can't be approved unless provided email address is validated.");
            } else if (type.equals("SUBMIT_BUTTON")) {
                layout.setHTML(3, 0, "Button used to submit the form with custom label. All other form items are checked on valid input before submission. If it fails, form is not sent.");
            } else if (type.equals("AUTO_SUBMIT_BUTTON")) {
                layout.setHTML(3, 0, "Button used to auto-submit the form with custom label. All other form items are checked on valid input before submission. If validation fail (at least once) user must submit form manually. If it's OK, then form is automatically submitted.");
            } else if (type.equals("HTML_COMMENT")) {
                layout.setHTML(3, 0, "Item is used to display custom HTML content anywhere on form. Useful for explanation descriptions, dividing parts of form etc.");
            } else if (type.equals("HEADING")) {
                layout.setHTML(3, 0, "Item is used to display customizable heading of form. Can have any HTML content.");
            } else if (type.equals("TIMEZONE")) {
                layout.setHTML(3, 0, "Selection box with pre-defined values of UTC timezones.");
            } else if (type.equals("FROM_FEDERATION_HIDDEN")) {
                layout.setHTML(3, 0, "Non-editable and hidden form item. Form is submitted even on invalid input ! Useful to automatically gather information provided by AUTH mechanism (IdP federation, certificate).");
            } else if (type.equals("FROM_FEDERATION_SHOW")) {
                layout.setHTML(3, 0, "Non-editable and visible form item. Form is submitted even on invalid input ! Useful to automatically gather information provided by AUTH mechanism (IdP federation, certificate).");
            } else {
                layout.setHTML(3, 0, "");
            }
        }
    });
    layout.setHTML(3, 0, "Editable text field useful to gather short text input, e.g. name, phone.");
    TabMenu menu = new TabMenu();
    // create button
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createFormItem(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (validator.validateTextBox()) {
                int positionToAdd = Integer.parseInt(insertAfterListBox.getValue(insertAfterListBox.getSelectedIndex()));
                String type = typeListBox.getValue(typeListBox.getSelectedIndex());
                String shortName = shortNameTextBox.getTextBox().getText().trim();
                createItem(shortName, type, positionToAdd);
            }
        }
    }));
    final TabItem tab = this;
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    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) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) JSONString(com.google.gwt.json.client.JSONString) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ApplicationFormItem(cz.metacentrum.perun.webgui.model.ApplicationFormItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) RegistrarFormItemGenerator(cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 59 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class VoDetailTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()));
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // The table
    AbsolutePanel dp = new AbsolutePanel();
    //dp.setStyleName("decoration");
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);
    // Add VO information
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
    Label voName = new Label();
    voName.setText(Utils.getStrippedStringWithEllipsis(vo.getName(), 40));
    voName.setStyleName("now-managing");
    voName.setTitle(vo.getName());
    menu.setWidget(0, 1, voName);
    menu.setHTML(0, 2, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");
    int column = 3;
    if (session.isVoAdmin(voId)) {
        final JsonCallbackEvents events = new JsonCallbackEvents() {

            @Override
            public void onFinished(JavaScriptObject jso) {
                // set VO and redraw tab
                vo = jso.cast();
                open();
                draw();
            }
        };
        CustomButton change = new CustomButton("", "Edit VO name", SmallIcons.INSTANCE.applicationFormEditIcon());
        change.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new EditVoDetailsTabItem(vo, events));
            }
        });
        menu.setWidget(0, column, change);
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    if (JsonUtils.isExtendedInfoVisible()) {
        menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + vo.getId() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
        menu.setHTML(0, column, "<strong>Short&nbsp;name:</strong><br/><span class=\"inputFormInlineComment\">" + vo.getShortName() + "</span>");
    }
    /*
		CustomButton cb = new CustomButton("", "Refresh page content", SmallIcons.INSTANCE.updateIcon(), new ClickHandler() {
			@Override
			public void onClick(ClickEvent clickEvent) {
				tabPanel.getSelectedTabItem().draw();
			}
		});
		dp.add(cb);
		cb.getElement().setAttribute("style", "position: absolute; right: 50px; top: 5px;");



		final JsonCallbackEvents events = new JsonCallbackEvents() {
			@Override
			public void onFinished(JavaScriptObject jso) {
				// set VO and redraw tab
				vo = jso.cast();
				open();
				draw();
			}
		};

		CustomButton change = new CustomButton("", "Edit VO name", SmallIcons.INSTANCE.applicationFormEditIcon());
		change.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				session.getTabManager().addTabToCurrentTab(new EditVoDetailsTabItem(vo, events));
			}
		});

		if (!session.isVoAdmin(voId)) change.setEnabled(false);
		dp.add(change);
		change.getElement().setAttribute("style", "position: absolute; right: 5px; top: 5px;");
		*/
    dp.add(menu);
    vp.add(dp);
    vp.setCellHeight(dp, "30px");
    tabPanel.clear();
    tabPanel.add(new VoOverviewTabItem(vo), "Overview");
    tabPanel.add(new VoMembersTabItem(vo), "Members");
    tabPanel.add(new VoGroupsTabItem(vo), "Groups");
    tabPanel.add(new VoResourcesTabItem(vo), "Resources");
    tabPanel.add(new VoApplicationsTabItem(vo), "Applications");
    tabPanel.add(new VoApplicationFormSettingsTabItem(vo), "Application form");
    tabPanel.add(new VoSettingsTabItem(vo), "Settings");
    tabPanel.add(new VoManagersTabItem(vo), "Managers");
    tabPanel.add(new VoExtSourcesTabItem(vo), "External sources");
    //tabPanel.add(new VoFacilitiesPropagationsTabItem(session, vo), "Facilities states");
    // Resize must be called after page fully displays
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            tabPanel.finishAdding();
        }
    });
    vp.add(tabPanel);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Command(com.google.gwt.user.client.Command) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 60 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class VoExtSourcesTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "ext sources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetVoExtSources extSources = new GetVoExtSources(voId);
    // refresh table event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);
    // create ext source button
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoExtSourceTabItem(voId), true);
        }
    });
    menu.addWidget(addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
            String text = "Following external sources will be removed from VO. You won't be able to import members from them anymore.";
            UiElements.showDeleteConfirm(extSourcesToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < extSourcesToRemove.size(); i++) {
                        RemoveExtSource request;
                        if (i == extSourcesToRemove.size() - 1) {
                            request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoExtSource(voId, extSourcesToRemove.get(i).getId());
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // authorization - enable buttons for perun admin only.
    if (!session.isPerunAdmin()) {
        addButton.setEnabled(false);
        removeButton.setEnabled(false);
        extSources.setCheckable(false);
    }
    menu.addFilterWidget(new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            extSources.filterTable(text);
        }
    }, "Filter external sources by name or type");
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<ExtSource> table = extSources.getTable();
    if (session.isPerunAdmin()) {
        removeButton.setEnabled(false);
        JsonUtils.addTableManagedButton(extSources, table, removeButton);
    }
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource) RemoveExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource) RemoveExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)385 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)382 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)135 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)124 ArrayList (java.util.ArrayList)117 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)105 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)76 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)42 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)41 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)40 PerunError (cz.metacentrum.perun.webgui.model.PerunError)36 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 HashMap (java.util.HashMap)32 Button (com.google.gwt.user.client.ui.Button)30 Image (com.google.gwt.user.client.ui.Image)28 HTML (com.google.gwt.user.client.ui.HTML)26 Button (org.gwtbootstrap3.client.ui.Button)26 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)25 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)23