Search in sources :

Example 81 with TabMenu

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

the class EditVoDetailsTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit VO name");
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setText(vo.getName());
    nameTextBox.getTextBox().setMaxLength(128);
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setOk();
                return true;
            } else {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
        }
    };
    nameTextBox.setValidator(nameValidator);
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes of VO name");
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            VirtualOrganization v = JsonUtils.clone(vo).cast();
            v.setName(nameTextBox.getTextBox().getText().trim());
            UpdateVo request = new UpdateVo(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
            request.updateVo(v);
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    // Add some standard form options
    layout.setHTML(0, 0, "Short name:");
    layout.setHTML(0, 1, vo.getShortName());
    layout.setHTML(1, 0, "Name:");
    layout.setWidget(1, 1, nameTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(saveButton);
    menu.addWidget(cancelButton);
    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) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) UpdateVo(cz.metacentrum.perun.webgui.json.vosManager.UpdateVo) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 82 with TabMenu

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

the class VoApplicationFormSettingsTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "application form");
    // HORIZONTAL MENU
    final TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveApplicationFormSettings());
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewAppFormItem());
    final CustomButton emailButton = new CustomButton(ButtonTranslation.INSTANCE.emailNotificationsButton() + "…", ButtonTranslation.INSTANCE.emailNotifications(), SmallIcons.INSTANCE.emailIcon());
    final CustomButton copyButton = new CustomButton(ButtonTranslation.INSTANCE.copyFromVoButton() + "…", ButtonTranslation.INSTANCE.copyFromVo(), SmallIcons.INSTANCE.copyIcon());
    final CustomButton previewButton = TabMenu.getPredefinedButton(ButtonType.PREVIEW, true, ButtonTranslation.INSTANCE.previewAppForm());
    // request
    final GetFormItems itemsRequest = new GetFormItems(PerunEntity.VIRTUAL_ORGANIZATION, vo.getId(), true, null, new JsonCallbackEvents() {

        @Override
        public void onError(PerunError error) {
            // DISABLE BUTTONS
            save.setEnabled(false);
            addButton.setEnabled(false);
            emailButton.setEnabled(false);
            copyButton.setEnabled(false);
            previewButton.setEnabled(false);
        }
    });
    sourceList = itemsRequest.getList();
    // refresh table events
    final JsonCallbackEvents refreshEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            itemsRequest.prepareSettings(sourceList);
        }
    };
    menu.addWidget(UiElements.getRefreshButton(this));
    // save button
    menu.addWidget(save);
    if (!session.isVoAdmin(voId))
        save.setEnabled(false);
    save.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            UpdateFormItems request = new UpdateFormItems(PerunEntity.VIRTUAL_ORGANIZATION, voId, JsonCallbackEvents.disableButtonEvents(save, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    itemsRequest.retrieveData();
                }
            }));
            // reset item ordnum to correct state defined by list
            // keep counter
            int counter = 0;
            // process
            for (int i = 0; i < itemsRequest.getList().size(); i++) {
                // if not for deletion
                if (!itemsRequest.getList().get(i).isForDelete()) {
                    // set
                    itemsRequest.getList().get(i).setOrdnum(counter);
                    counter++;
                }
            }
            // send request
            request.updateFormItems(itemsRequest.getList());
        }
    });
    // add button
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateFormItemTabItem(sourceList, refreshEvents));
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(addButton);
    copyButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CopyFormTabItem(vo.getId(), 0));
        }
    });
    if (!session.isVoAdmin(voId))
        copyButton.setEnabled(false);
    menu.addWidget(copyButton);
    if (!session.isVoAdmin(voId))
        previewButton.setEnabled(false);
    menu.addWidget(previewButton);
    // AUTO APPROVAL + NOTIFICATIONS
    // auto-approval widget already defined
    GetApplicationForm form = new GetApplicationForm(PerunEntity.VIRTUAL_ORGANIZATION, voId, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            final ApplicationForm form = jso.cast();
            previewButton.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    session.getTabManager().addTab(new PreviewFormTabItem(form, sourceList), true);
                }
            });
        }
    });
    form.setHidden(true);
    form.retrieveData();
    menu.addWidget(form.getApprovalWidget());
    emailButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new MailsTabItem(voId, 0));
        }
    });
    if (!session.isVoAdmin(voId))
        emailButton.setEnabled(false);
    menu.addWidget(emailButton);
    // load elements
    itemsRequest.retrieveData();
    // wrap table to the scroll panel
    ScrollPanel sp = new ScrollPanel(itemsRequest.getContents());
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 100, this);
    // add scroll table to the main panel
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PreviewFormTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.PreviewFormTabItem) GetApplicationForm(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationForm) UpdateFormItems(cz.metacentrum.perun.webgui.json.registrarManager.UpdateFormItems) GetFormItems(cz.metacentrum.perun.webgui.json.registrarManager.GetFormItems) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.CreateFormItemTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetApplicationForm(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationForm) MailsTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.MailsTabItem) CopyFormTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.CopyFormTabItem)

Example 83 with TabMenu

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

the class CreateCategoryTabItem method draw.

public Widget draw() {
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    final CustomButton addCategory = TabMenu.getPredefinedButton(ButtonType.ADD, "Add category");
    menu.addWidget(addCategory);
    FlexTable table = new FlexTable();
    table.setStyleName("inputFormFlexTable");
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox rankTextBox = new ExtendedTextBox();
    final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
            nameTextBox.setOk();
            return true;
        }
    };
    final ExtendedTextBox.TextBoxValidator validator2 = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (rankTextBox.getTextBox().getText().trim().isEmpty()) {
                rankTextBox.setError("Rank value can't be empty.");
                return false;
            } else {
                try {
                    Double.parseDouble(rankTextBox.getTextBox().getText().trim());
                } catch (Exception e) {
                    rankTextBox.setError("Value must be in like: 0.5, 1.0 etc.");
                    return false;
                }
            }
            rankTextBox.setOk();
            return true;
        }
    };
    nameTextBox.setValidator(validator);
    rankTextBox.setValidator(validator2);
    final TabItem tab = this;
    addCategory.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (validator.validateTextBox() && validator2.validateTextBox()) {
                CreateCategory request = new CreateCategory(JsonCallbackEvents.closeTabDisableButtonEvents(addCategory, tab));
                request.createCategory(nameTextBox.getTextBox().getText().trim(), Double.parseDouble(rankTextBox.getTextBox().getText().trim()));
            }
        }
    });
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    vp.add(table);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    table.setHTML(0, 0, "Name:");
    table.setWidget(0, 1, nameTextBox);
    table.setHTML(1, 0, "Rank:");
    table.setWidget(1, 1, rankTextBox);
    for (int i = 0; i < table.getRowCount(); i++) {
        table.getFlexCellFormatter().setStyleName(i, 0, "itemName");
    }
    table.setHTML(2, 1, "Values like: 0.0 , 0.5 , 1.2 , etc.");
    table.getFlexCellFormatter().setStyleName(2, 1, "inputFormInlineComment");
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) CreateCategory(cz.metacentrum.perun.webgui.json.cabinetManager.CreateCategory)

Example 84 with TabMenu

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

the class CreateThanksTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // CALLBACK
    final GetOwners owners = new GetOwners();
    // MENU
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // add button
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add acknowledgement for selected owner(s)");
    final TabItem tab = this;
    // click handler
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ArrayList<Owner> list = owners.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    final String name = list.get(i).getName();
                    // add name events
                    JsonCallbackEvents thanksEvents = new JsonCallbackEvents() {

                        public void onFinished(JavaScriptObject jso) {
                            updateAlreadyAdded(name);
                        }
                    };
                    // merge with refresh?
                    if (i == list.size() - 1 && events != null) {
                        thanksEvents = JsonCallbackEvents.mergeEvents(thanksEvents, events);
                    }
                    CreateThanks request = new CreateThanks(publicationId, JsonCallbackEvents.disableButtonEvents(addButton, thanksEvents));
                    request.createThanks(list.get(i).getId());
                    if (i == list.size() - 1) {
                        owners.clearTableSelectedSet();
                    }
                }
            }
        }
    });
    menu.addWidget(addButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // trigger refresh of sub-tab via event
            events.onFinished(null);
            session.getTabManager().closeTab(tab, false);
        }
    }));
    // add already added
    vp.add(alreadyAddedOwners);
    vp.setCellHeight(alreadyAddedOwners, "30px");
    // TABLE
    // show only administrative contacts
    owners.setFilterByType("administrative");
    CellTable<Owner> table = owners.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // resize small tab panel to correct size on screen
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(owners, table, addButton);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Owner(cz.metacentrum.perun.webgui.model.Owner) GetOwners(cz.metacentrum.perun.webgui.json.ownersManager.GetOwners) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) CreateThanks(cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks)

Example 85 with TabMenu

use of cz.metacentrum.perun.webgui.widgets.TabMenu 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)

Aggregations

TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)143 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)124 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)124 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)115 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)99 ArrayList (java.util.ArrayList)89 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)68 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)67 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)48 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)33 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)27 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)27 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)27 PerunError (cz.metacentrum.perun.webgui.model.PerunError)27 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)21 HashMap (java.util.HashMap)20 User (cz.metacentrum.perun.webgui.model.User)18 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)17 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)17 Attribute (cz.metacentrum.perun.webgui.model.Attribute)15