Search in sources :

Example 26 with ExtendedSuggestBox

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

the class TestDataGridTabItem method draw.

public Widget draw() {
    //contentWidget.setSize("100%", "100%");
    DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
    contentWidget.setWidget(ft);
    final DataGrid gridTable = new DataGrid();
    gridTable.setSize("100%", "100%");
    final ArrayList<VirtualOrganization> vosList = new ArrayList<VirtualOrganization>();
    final GetVos getVos = new GetVos(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            vosList.addAll(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
            gridTable.setRowData(vosList);
            gridTable.redraw();
        }
    });
    getVos.retrieveData();
    gridTable.setSelectionModel(new MultiSelectionModel<VirtualOrganization>(new GeneralKeyProvider<VirtualOrganization>()));
    final SelectionModel<VirtualOrganization> selectionModel = gridTable.getSelectionModel();
    Column<VirtualOrganization, Boolean> checkBoxColumn = new Column<VirtualOrganization, Boolean>(new CheckboxCell(true, true)) {

        @Override
        public Boolean getValue(VirtualOrganization object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
        }
    };
    checkBoxColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, Boolean>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, Boolean aBoolean) {
            selectionModel.setSelected(virtualOrganization, aBoolean);
        }
    });
    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

        public Boolean getValue() {
            //return true to see a checked checkbox.
            return false;
        }
    };
    checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (VirtualOrganization obj : vosList) {
                selectionModel.setSelected(obj, value);
            }
        }
    });
    gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
    gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    TextColumn<VirtualOrganization> idColumn = new TextColumn<VirtualOrganization>() {

        @Override
        public String getValue(VirtualOrganization object) {
            return String.valueOf(object.getId());
        }
    };
    gridTable.addColumn(idColumn, "Id", "Id");
    gridTable.setColumnWidth(idColumn, "90px");
    Column<VirtualOrganization, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<VirtualOrganization, String>() {

        public String getValue(VirtualOrganization object) {
            return object.getName();
        }
    }, new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    gridTable.addColumn(nameColumn, "Name", "Name");
    TextColumn<VirtualOrganization> shortnameColumn = new TextColumn<VirtualOrganization>() {

        @Override
        public String getValue(VirtualOrganization object) {
            return object.getShortName();
        }
    };
    gridTable.addColumn(shortnameColumn, "Short name", "Short name");
    shortnameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    idColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    nameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    TabMenu tabMenu = new TabMenu();
    // CREATE & DELETE ONLY WITH PERUN ADMIN
    if (session.isPerunAdmin()) {
        tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
            }
        }));
        final cz.metacentrum.perun.webgui.widgets.CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteVo());
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
                if (UiElements.cantSaveEmptyListDialogBox(itemsToRemove)) {
                    VerticalPanel removePanel = new VerticalPanel();
                    removePanel.add(new Label("These VOs will be removed:"));
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        VirtualOrganization vo = itemsToRemove.get(i);
                        removePanel.add(new Label(" - " + vo.getName()));
                    }
                    // confirmation
                    Confirm c = new Confirm("Remove VOs", removePanel, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            for (int i = 0; i < itemsToRemove.size(); i++) {
                                DeleteVo request;
                                // if last, refresh
                                if (i == itemsToRemove.size() - 1) {
                                    request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
                                } else {
                                    request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
                                }
                                request.deleteVo(itemsToRemove.get(i).getId(), false);
                            }
                            getVos.clearTableSelectedSet();
                        }
                    }, true);
                    c.show();
                }
            }
        });
        tabMenu.addWidget(removeButton);
    }
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            getVos.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterVo());
    ft.addNorth(tabMenu, 50);
    ft.add(gridTable);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) DataGrid(com.google.gwt.user.cellview.client.DataGrid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) DeleteVo(cz.metacentrum.perun.webgui.json.vosManager.DeleteVo) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) CreateVoTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.CreateVoTabItem) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) GeneralKeyProvider(cz.metacentrum.perun.webgui.json.keyproviders.GeneralKeyProvider) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Header(com.google.gwt.user.cellview.client.Header) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) VoDetailTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoDetailTabItem)

Example 27 with ExtendedSuggestBox

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

the class VoResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources");
    // 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 GetRichResources resources = new GetRichResources(voId);
    if (!session.isVoAdmin(voId))
        resources.setCheckable(false);
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<RichResource> resourcesForDeleting = resources.getTableSelectedList();
            String text = "Following resources will be deleted and VO members won't be able to access them anymore.";
            UiElements.showDeleteConfirm(resourcesForDeleting, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < resourcesForDeleting.size(); i++) {
                        DeleteResource request;
                        if (i == resourcesForDeleting.size() - 1) {
                            request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteResource(resourcesForDeleting.get(i).getId());
                    }
                }
            });
        }
    });
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {

        public void update(int index, RichResource object, String value) {
            session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
        }
    });
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(resources, 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) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources) DeleteResource(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResource) 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) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 28 with ExtendedSuggestBox

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

the class VoResourcesTagsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources tags");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // members request
    final GetAllResourcesTags resTags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, voId);
    if (!session.isVoAdmin(voId))
        resTags.setCheckable(false);
    if (session.isVoAdmin(voId))
        resTags.setEditable(true);
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resTags);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResourceTag(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateVoResourceTagTabItem(voId));
        }
    });
    menu.addWidget(addButton);
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResourceTag());
    if (!session.isVoAdmin(voId))
        removeButton.setEnabled(false);
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<ResourceTag> tagsToRemove = resTags.getTableSelectedList();
            String text = "Following tags will be deleted and won't be used to tag VO resources.";
            UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {

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

        @Override
        public void searchFor(String text) {
            resTags.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterTags());
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.updateResourceTag());
    menu.addWidget(saveButton);
    if (!session.isVoAdmin(voId))
        saveButton.setEnabled(false);
    saveButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ResourceTag> tagsToUpdate = resTags.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(tagsToUpdate)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                for (int i = 0; i < tagsToUpdate.size(); i++) {
                    UpdateResourceTag request;
                    if (i == tagsToUpdate.size() - 1) {
                        request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton, events));
                    } else {
                        request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton));
                    }
                    request.updateResourceTag(tagsToUpdate.get(i));
                }
            }
        }
    });
    // get the table
    CellTable<ResourceTag> table = resTags.getTable();
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(resTags, table, removeButton);
    saveButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(resTags, table, saveButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UpdateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) DeleteResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DeleteResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) UpdateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 29 with ExtendedSuggestBox

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

the class VoApplicationsTabItem method draw.

public Widget draw() {
    // request
    final GetApplicationsForVo applicationsRequest = new GetApplicationsForVo(vo.getId());
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
    applicationsRequest.setCheckable(false);
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "applications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    /*

		// verify button
		final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
		verify.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
							request.verifyApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
							request.verifyApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		// accept button
		final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
		approve.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
							request.approveApplication(list.get(i));
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
							request.approveApplication(list.get(i));
						}
					}
				}
			}
		});

		//reject button
		final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
		reject.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					// confirm content
					FlexTable content = new FlexTable();
					content.setCellSpacing(10);
					content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
					content.getFlexCellFormatter().setColSpan(0, 0, 2);
					final TextArea reason = new TextArea();
					reason.setSize("300px", "150px");
					content.setHTML(1, 0, "<strong>Reason: </strong>");
					content.setWidget(1, 1, reason);

					Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
						public void onClick(ClickEvent event) {

							for (int i=0; i<list.size(); i++) {
								if (i != list.size()-1) {
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								} else {
									// refresh table on last call
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								}
							}

						}
					}, true);
					c.show();
				}
			}
		});

		// delete button
		final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
		delete.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
							request.deleteApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
							request.deleteApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		menu.addWidget(verify);
		menu.addWidget(approve);
		menu.addWidget(reject);
		menu.addWidget(delete);

		*/
    // FILTER
    menu.addWidget(new HTML("<strong>State: </strong>"));
    // state
    final ListBox stateListBox = new ListBox();
    stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
    stateListBox.addItem("Pending", "NEW,VERIFIED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
    stateListBox.setSelectedIndex(selectedIndex);
    menu.addWidget(stateListBox);
    stateListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            selectedIndex = stateListBox.getSelectedIndex();
            applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
            applicationsRequest.clearTable();
            applicationsRequest.retrieveData();
        }
    });
    // FILTER 2
    menu.addWidget(new HTML("<strong>Submitted&nbsp;by: </strong>"));
    menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            applicationsRequest.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterApplications());
    // TABLE
    applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
    CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    /*
		verify.setEnabled(false);
		approve.setEnabled(false);
		reject.setEnabled(false);
		delete.setEnabled(false);

		if (session.isVoAdmin(voId)) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
			JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
			JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
		}
		if (session.isPerunAdmin()) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
		}
		*/
    session.getUiElements().resizePerunTable(sp, 100);
    firstTabPanel.add(sp);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationDetailTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem) GetApplicationsForVo(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForVo) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application) HandleApplication(cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)

Example 30 with ExtendedSuggestBox

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

the class VoGroupsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "groups");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // VO Groups request
    ArrayList<String> attrNames = new ArrayList<>();
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
    attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
    final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
    if (!session.isVoAdmin(voId))
        groups.setCheckable(false);
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // add new group button
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
        }
    });
    if (!session.isVoAdmin(voId))
        createButton.setEnabled(false);
    menu.addWidget(createButton);
    // delete selected groups button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteGroup());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<RichGroup> groupsToDelete = groups.getTableSelectedList();
            String text = "Following groups (including all sub-groups) will be deleted.";
            UiElements.showDeleteConfirm(groupsToDelete, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    DeleteGroups request = new DeleteGroups(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    request.deleteGroups(groupsToDelete);
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // add a table with a onclick
    CellTable<RichGroup> table = groups.getTable(new FieldUpdater<RichGroup, String>() {

        public void update(int index, RichGroup group, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
        }
    });
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(groups, table, removeButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) CreateGroupTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) GetAllRichGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) DeleteGroups(cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)

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