Search in sources :

Example 16 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class GetAttributes method getEmptyTable.

/**
	 * Returns empty table widget with attributes
	 *
	 * @return table widget
	 */
public CellTable<Attribute> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);
    // Cell table
    table = new PerunTable<Attribute>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // because of tabindex
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    if (checkable) {
        // checkbox column column
        Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {

            @Override
            public Attribute getValue(Attribute object) {
                // Get the value from the selection model.
                GeneralObject go = object.cast();
                go.setChecked(selectionModel.isSelected(object));
                return go.cast();
            }
        };
        // updates the columns size
        table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);
        // Add the columns
        // 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 (Attribute obj : list) {
                    if (obj.isWritable()) {
                        selectionModel.setSelected(obj, value);
                    }
                }
            }
        });
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    // Create ID column.
    table.addIdColumn("Attribute ID", this.tableFieldUpdater);
    // Name column
    Column<Attribute, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

        public String getValue(Attribute attribute) {
            return attribute.getFriendlyName();
        }
    }, this.tableFieldUpdater);
    // Create ENTITY column
    Column<Attribute, String> entityColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

        public String getValue(Attribute a) {
            return a.getEntity();
        }
    }, this.tableFieldUpdater);
    // Create def type column
    Column<Attribute, String> defTypeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

        public String getValue(Attribute a) {
            return a.getDefinition();
        }
    }, this.tableFieldUpdater);
    // Create type column.
    Column<Attribute, String> typeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

        public String getValue(Attribute attribute) {
            return renameContent(attribute.getType());
        }
    }, this.tableFieldUpdater);
    Column<Attribute, String> valueColumn;
    if (editable) {
        valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

            public String getValue(Attribute attribute) {
                return attribute.getValue();
            }
        }, new FieldUpdater<Attribute, String>() {

            public void update(int index, Attribute object, String newText) {
                if (object.setValue(newText)) {
                    selectionModel.setSelected(object, true);
                } else {
                    selectionModel.setSelected(object, false);
                    UiElements.cantSaveAttributeValueDialogBox(object);
                }
            }
        });
    } else {
        valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

            public String getValue(Attribute attribute) {
                return attribute.getValue();
            }
        }, this.tableFieldUpdater);
    }
    // Create description column.
    Column<Attribute, String> descriptionColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {

        public String getValue(Attribute attribute) {
            return attribute.getDescription();
        }
    }, this.tableFieldUpdater);
    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getFriendlyName().compareToIgnoreCase(o2.getFriendlyName());
        }
    });
    // Sorting type column
    typeColumn.setSortable(true);
    columnSortHandler.setComparator(typeColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getType().compareToIgnoreCase(o2.getType());
        }
    });
    // Sorting description column
    descriptionColumn.setSortable(true);
    columnSortHandler.setComparator(descriptionColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getDescription().compareToIgnoreCase(o2.getDescription());
        }
    });
    // Sorting value column
    valueColumn.setSortable(true);
    columnSortHandler.setComparator(valueColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getValue().compareToIgnoreCase(o2.getValue());
        }
    });
    // Sorting value column
    entityColumn.setSortable(true);
    columnSortHandler.setComparator(entityColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getEntity().compareToIgnoreCase(o2.getEntity());
        }
    });
    // Sorting value column
    defTypeColumn.setSortable(true);
    columnSortHandler.setComparator(defTypeColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            return o1.getDefinition().compareToIgnoreCase(o2.getDefinition());
        }
    });
    // column size
    this.table.setColumnWidth(typeColumn, 120.0, Unit.PX);
    this.table.setColumnWidth(entityColumn, 100.0, Unit.PX);
    this.table.setColumnWidth(defTypeColumn, 110.0, Unit.PX);
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
    this.table.setColumnWidth(valueColumn, 200.0, Unit.PX);
    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(entityColumn, "Entity");
    this.table.addColumn(defTypeColumn, "Definition");
    this.table.addColumn(typeColumn, "Value type");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) Attribute(cz.metacentrum.perun.webgui.model.Attribute) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Example 17 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class JsonUtils method addColumn.

/**
	 * Returns a column with a header.
	 *
	 * @param <R> the row type
	 * @param <R> the cell type
	 * @param cell the cell used to render the column
	 * @param headerText the header string
	 * @param getValue the value getter for the cell
	 * @deprecated Shouldn't be used when returning the same object - use the method without Getter in parameter instead	 *
	 */
public static <R> Column<R, R> addColumn(Cell<R> cell, String headerText, final GetValue<R, R> getValue, final FieldUpdater<R, String> tableFieldUpdater, boolean custom) {
    Column<R, R> column = new Column<R, R>(cell) {

        @Override
        public R getValue(R object) {
            return object;
        }

        @Override
        public String getCellStyleNames(Cell.Context context, R object) {
            if (tableFieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    if (tableFieldUpdater != null) {
        FieldUpdater<R, R> tableFieldUpdater2 = new FieldUpdater<R, R>() {

            public void update(int index, R object, R value) {
                GeneralObject go = (GeneralObject) value;
                tableFieldUpdater.update(index, object, go.getName());
            }
        };
        column.setFieldUpdater(tableFieldUpdater2);
    }
    return column;
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) Column(com.google.gwt.user.cellview.client.Column) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Example 18 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class AddVoManagerTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add manager");
    final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
    this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            ArrayList<User> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                users.getSelectionModel().setSelected(list.get(0), true);
            }
        }
    }));
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // get the table
    final CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = users.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = users.getTable();
    }
    rebuildAlreadyAddedWidget();
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToVo());
    final TabItem tab = this;
    // search textbox
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            startSearching(text);
            searchString = text;
        }
    }, searchButton);
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    // FIXME - Should have only one callback to core
                    final int n = i;
                    AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // put names to already added
                            alreadyAddedList.add(list.get(n));
                            rebuildAlreadyAddedWidget();
                            // unselect added person
                            users.getSelectionModel().setSelected(list.get(n), false);
                            // clear search
                            searchBox.getTextBox().setText("");
                        }
                    }));
                    request.addVoAdmin(vo, list.get(i));
                }
            }
        }
    });
    // if some text has been searched before
    if (!searchString.equals("")) {
        searchBox.getTextBox().setText(searchString);
        startSearching(searchString);
    }
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, 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(alreadyAdded);
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 19 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class UsersPublicationsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Publications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // CALLBACK
    final Map<String, Object> ids = new HashMap<String, Object>();
    ids.put("userId", user.getId());
    ids.put("authors", 1);
    final FindPublicationsByGUIFilter callback = new FindPublicationsByGUIFilter(ids);
    final JsonCallbackEvents refreshTable = JsonCallbackEvents.refreshTableEvents(callback);
    // GET CORRECT TABLE
    CellTable<Publication> table;
    table = callback.getTable(new FieldUpdater<Publication, String>() {

        public void update(int index, Publication object, String value) {
            session.getTabManager().addTab(new PublicationDetailTabItem(object, true));
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");
    // ADD, REMOVE menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // FILTER MENU
    final TabMenu filterMenu = new TabMenu();
    // not visible at start
    filterMenu.setVisible(false);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add new Publication", new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new AddPublicationsTabItem(user));
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove selected publication(s)");
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<Publication> list = callback.getTableSelectedList();
            UiElements.showDeleteConfirm(list, "Following publications will be removed.", new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < list.size(); i++) {
                        if (list.get(i).getLocked() && !session.isPerunAdmin()) {
                            // skip locked pubs
                            UiElements.generateAlert("Publication locked", "Publication <strong>" + list.get(i).getTitle() + "</strong> is locked by " + "administrator and can't be deleted. Please notify administrator about your request.");
                            continue;
                        } else {
                            if (list.get(i).getCreatedBy().equalsIgnoreCase(session.getPerunPrincipal().getActor()) || session.isPerunAdmin() || session.getActiveUser().getId() == list.get(i).getCreatedByUid()) {
                                // delete whole publication
                                if (i == list.size() - 1) {
                                    DeletePublication request = new DeletePublication(JsonCallbackEvents.disableButtonEvents(removeButton, refreshTable));
                                    request.deletePublication(list.get(i).getId());
                                } else {
                                    DeletePublication request = new DeletePublication(JsonCallbackEvents.disableButtonEvents(removeButton));
                                    request.deletePublication(list.get(i).getId());
                                }
                            } else {
                                // else delete only himself
                                if (i == list.size() - 1) {
                                    DeleteAuthorship request = new DeleteAuthorship(JsonCallbackEvents.disableButtonEvents(removeButton, refreshTable));
                                    request.deleteAuthorship(list.get(i).getId(), userId);
                                } else {
                                    DeleteAuthorship request = new DeleteAuthorship(JsonCallbackEvents.disableButtonEvents(removeButton));
                                    request.deleteAuthorship(list.get(i).getId(), userId);
                                }
                            }
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, removeButton);
    // fill category listbox
    final ListBoxWithObjects<Category> filterCategory = new ListBoxWithObjects<Category>();
    final GetCategories call = new GetCategories(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            filterCategory.clear();
            filterCategory.addNotSelectedOption();
            ArrayList<Category> list = JsonUtils.jsoAsList(jso.cast());
            list = new TableSorter<Category>().sortByName(list);
            for (int i = 0; i < list.size(); i++) {
                filterCategory.addItem(list.get(i));
                // set last selected
                if (lastCategoryId != 0) {
                    if (list.get(i).getId() == lastCategoryId) {
                        filterCategory.setSelected(list.get(i), true);
                    }
                }
            }
            if (lastCategoryId == 0) {
                filterCategory.setSelectedIndex(0);
            }
        }

        public void onError(PerunError error) {
            filterCategory.clear();
            filterCategory.removeNotSelectedOption();
            filterCategory.addItem("Error while loading");
        }

        @Override
        public void onLoadingStart() {
            filterCategory.clear();
            filterCategory.removeNotSelectedOption();
            filterCategory.addItem("Loading...");
        }
    });
    final CustomButton showButton = new CustomButton("Show / Hide filter", "Show / Hide filtering options", SmallIcons.INSTANCE.filterIcon());
    showButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // showing and hiding filter menu
            if (filterMenu.isVisible()) {
                filterMenu.setVisible(false);
            } else {
                filterMenu.setVisible(true);
                if (filterCategory.isEmpty()) {
                    call.retrieveData();
                }
            }
        }
    });
    menu.addWidget(showButton);
    // filter objects
    final TextBox filterTitle = new TextBox();
    filterTitle.setWidth("80px");
    filterTitle.setText(lastTitle);
    final TextBox filterYear = new TextBox();
    filterYear.setMaxLength(4);
    filterYear.setWidth("30px");
    filterYear.setText(lastYear);
    final TextBox filterIsbn = new TextBox();
    filterIsbn.setWidth("60px");
    filterIsbn.setText(lastIsbnOrDoiValue);
    final TextBox filterSince = new TextBox();
    filterSince.setMaxLength(4);
    filterSince.setWidth("30px");
    filterSince.setText(lastYearSince);
    final TextBox filterTill = new TextBox();
    filterTill.setMaxLength(4);
    filterTill.setWidth("30px");
    filterTill.setText(lastYearTill);
    final ListBox codeBox = new ListBox();
    codeBox.addItem("ISBN/ISSN:");
    codeBox.addItem("DOI:");
    if (!lastIsbnOrDoi) {
        codeBox.setSelectedIndex(1);
    }
    // buttons
    CustomButton applyFilter = new CustomButton("Apply", "Shows publications based on filter", SmallIcons.INSTANCE.filterAddIcon());
    CustomButton clearFilter = new CustomButton("Clear", "Shows all publications of User", SmallIcons.INSTANCE.filterDeleteIcon());
    // clear filter action
    clearFilter.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // clear last values
            lastCategoryId = 0;
            lastIsbnOrDoi = true;
            lastIsbnOrDoiValue = "";
            lastTitle = "";
            lastYear = "";
            lastYearTill = "";
            lastYearSince = "";
            filterTitle.setText("");
            filterYear.setText("");
            filterIsbn.setText("");
            filterSince.setText("");
            filterTill.setText("");
            filterCategory.setSelectedIndex(0);
            ids.clear();
            ids.put("userId", user.getId());
            ids.put("authors", 0);
            lastIds = ids;
            callback.setIds(ids);
            callback.clearTable();
            callback.retrieveData();
        }
    });
    // apply filter action
    applyFilter.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // refresh ids
            ids.clear();
            ids.put("userId", user.getId());
            ids.put("authors", 1);
            // checks input
            if (!filterTitle.getText().isEmpty()) {
                ids.put("title", filterTitle.getText());
                lastTitle = filterTitle.getText();
            } else {
                lastTitle = "";
            }
            if (!filterYear.getText().isEmpty()) {
                if (!JsonUtils.checkParseInt(filterYear.getText())) {
                    JsonUtils.cantParseIntConfirm("YEAR", filterYear.getText());
                    lastYear = "";
                    return;
                } else {
                    ids.put("year", filterYear.getText());
                    lastYear = filterYear.getText();
                }
            }
            if (!filterIsbn.getText().isEmpty()) {
                if (codeBox.getSelectedIndex() == 0) {
                    // ISBN/ISSN selected
                    lastIsbnOrDoi = true;
                    ids.put("isbn", filterIsbn.getText());
                } else {
                    // DOI selected
                    lastIsbnOrDoi = false;
                    ids.put("doi", filterIsbn.getText());
                }
                lastIsbnOrDoiValue = filterIsbn.getText();
            }
            if (!filterSince.getText().isEmpty()) {
                if (!JsonUtils.checkParseInt(filterSince.getText())) {
                    JsonUtils.cantParseIntConfirm("YEAR SINCE", filterSince.getText());
                    lastYearSince = "";
                    return;
                } else {
                    ids.put("yearSince", filterSince.getText());
                    lastYearSince = filterSince.getText();
                }
            }
            if (!filterTill.getText().isEmpty()) {
                if (!JsonUtils.checkParseInt(filterTill.getText())) {
                    JsonUtils.cantParseIntConfirm("YEAR TILL", filterTill.getText());
                    lastYearTill = "";
                    return;
                } else {
                    ids.put("yearTill", filterTill.getText());
                    lastYearTill = filterTill.getText();
                }
            }
            if (filterCategory.getSelectedIndex() > 0) {
                ids.put("category", filterCategory.getSelectedObject().getId());
                lastCategoryId = filterCategory.getSelectedObject().getId();
            } else {
                lastCategoryId = 0;
            }
            lastIds = ids;
            callback.setIds(ids);
            callback.clearTable();
            callback.retrieveData();
        }
    });
    // add to filter menu
    filterMenu.addWidget(new HTML("<strong>Title:</strong>"));
    filterMenu.addWidget(filterTitle);
    filterMenu.addWidget(codeBox);
    filterMenu.addWidget(filterIsbn);
    filterMenu.addWidget(new HTML("<strong>Category:</strong>"));
    filterMenu.addWidget(filterCategory);
    filterMenu.addWidget(new HTML("<strong>Year:</strong>"));
    filterMenu.addWidget(filterYear);
    filterMenu.addWidget(new HTML("<strong>Year&nbsp;between:</strong>"));
    filterMenu.addWidget(filterSince);
    filterMenu.addWidget(new HTML("&nbsp;/&nbsp;"));
    filterMenu.addWidget(filterTill);
    filterMenu.addWidget(applyFilter);
    filterMenu.addWidget(clearFilter);
    firstTabPanel.add(menu);
    firstTabPanel.add(filterMenu);
    firstTabPanel.add(sp);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.setCellHeight(sp, "100%");
    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Category(cz.metacentrum.perun.webgui.model.Category) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) GetCategories(cz.metacentrum.perun.webgui.json.cabinetManager.GetCategories) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) DeleteAuthorship(cz.metacentrum.perun.webgui.json.cabinetManager.DeleteAuthorship) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) Publication(cz.metacentrum.perun.webgui.model.Publication) DeletePublication(cz.metacentrum.perun.webgui.json.cabinetManager.DeletePublication) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) DeletePublication(cz.metacentrum.perun.webgui.json.cabinetManager.DeletePublication) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) FindPublicationsByGUIFilter(cz.metacentrum.perun.webgui.json.cabinetManager.FindPublicationsByGUIFilter)

Example 20 with FieldUpdater

use of com.google.gwt.cell.client.FieldUpdater in project perun by CESNET.

the class FacilitySecurityTeamsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Security teams");
    // main panel
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    final GetAssignedSecurityTeams securityTeams = new GetAssignedSecurityTeams(facilityId);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignSecurityTeam(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AssignSecurityTeamTabItem(facility), true);
        }
    }));
    // remove button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedSecurityTeams());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<SecurityTeam> list = securityTeams.getTableSelectedList();
            UiElements.showDeleteConfirm(list, 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) {
                            RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(securityTeams)));
                            request.removeSecurityTeam(facilityId, list.get(i).getId());
                        } else {
                            RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeSecurityTeam(facilityId, list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            securityTeams.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    CellTable<SecurityTeam> table;
    if (session.isPerunAdmin() || session.isSecurityAdmin()) {
        table = securityTeams.getTable(new FieldUpdater<SecurityTeam, String>() {

            @Override
            public void update(int index, SecurityTeam object, String value) {
                session.getTabManager().addTab(new SecurityTeamDetailTabItem(object));
            }
        });
    } else {
        table = securityTeams.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);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : RemoveSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam) GetAssignedSecurityTeams(cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedSecurityTeams) SecurityTeamDetailTabItem(cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

FieldUpdater (com.google.gwt.cell.client.FieldUpdater)28 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)19 ArrayList (java.util.ArrayList)19 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)17 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)17 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)17 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)16 User (cz.metacentrum.perun.webgui.model.User)15 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)15 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)8 Column (com.google.gwt.user.cellview.client.Column)6 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)6 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)6 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)5 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)2 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2