Search in sources :

Example 1 with TabMenu

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

the class UsersApplicationsPage method refresh.

/**
	 * Refresh the page
	 */
private void refresh() {
    bodyContents.clear();
    String user = "";
    if (session.getUser() != null) {
        user = this.session.getUser().getFullNameWithTitles().trim();
    } else {
        PerunPrincipal pp = session.getPerunPrincipal();
        if (!pp.getAdditionInformations("displayName").equals("")) {
            user = pp.getAdditionInformations("displayName");
        } else if (!pp.getAdditionInformations("cn").equals("")) {
            user = pp.getAdditionInformations("cn");
        } else {
            if (pp.getExtSourceType().equals("cz.metacentrum.perun.core.impl.ExtSourceX509")) {
                user = Utils.convertCertCN(pp.getActor());
            } else {
                user = pp.getActor();
            }
        }
    }
    bodyContents.add(new HTML("<h1>" + ApplicationMessages.INSTANCE.applicationsForUser(user) + "</h1>"));
    // callback
    int userId = 0;
    if (session.getUser() != null) {
        userId = session.getUser().getId();
    }
    final GetApplicationsForUserForAppFormGui req = new GetApplicationsForUserForAppFormGui(userId);
    final ListBox listBox = new ListBox();
    req.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<Application> appls = JsonUtils.jsoAsList(jso);
            ArrayList<String> vos = new ArrayList<String>();
            for (Application app : appls) {
                if (!vos.contains(app.getVo().getName())) {
                    vos.add(app.getVo().getName());
                }
            }
            Collections.sort(vos);
            for (String s : vos) {
                listBox.addItem(s);
            }
            if (listBox.getItemCount() > 0) {
                listBox.insertItem(WidgetTranslation.INSTANCE.listboxAll(), 0);
            }
            for (int i = 0; i < listBox.getItemCount(); i++) {
                if (listBox.getItemText(i).equals(ApplicationFormGui.getVo().getName())) {
                    listBox.setSelectedIndex(i);
                    req.filterTable(ApplicationFormGui.getVo().getName());
                    break;
                }
            }
        }

        @Override
        public void onError(PerunError error) {
        }

        @Override
        public void onLoadingStart() {
            listBox.clear();
        }
    });
    req.setCheckable(false);
    listBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            if (listBox.getSelectedIndex() > 0) {
                req.filterTable(listBox.getItemText(listBox.getSelectedIndex()));
            } else {
                // show all
                req.filterTable("");
            }
        }
    });
    final TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.filterByVo() + ":</strong>"));
    tabMenu.addWidget(listBox);
    tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    tabMenu.addWidget(new HTML("<strong>" + ApplicationMessages.INSTANCE.clickOnApplicationToSee() + "</strong>"));
    tabMenu.addStyleName("tabMenu");
    final VerticalPanel applicationsWrapper = new VerticalPanel();
    applicationsWrapper.setSize("100%", "100%");
    applicationsWrapper.add(tabMenu);
    final CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            applicationsWrapper.clear();
            applicationsWrapper.add(backButton);
            applicationsWrapper.add(getApplicationDetailWidget(object));
        }
    });
    appsTable.addStyleName("perun-table");
    applicationsWrapper.add(appsTable);
    backButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            applicationsWrapper.clear();
            applicationsWrapper.add(tabMenu);
            applicationsWrapper.add(appsTable);
        }
    });
    bodyContents.add(applicationsWrapper);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) PerunPrincipal(cz.metacentrum.perun.webgui.model.PerunPrincipal) GetApplicationsForUserForAppFormGui(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUserForAppFormGui) PerunError(cz.metacentrum.perun.webgui.model.PerunError) Application(cz.metacentrum.perun.webgui.model.Application)

Example 2 with TabMenu

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

the class AddMemberToVoTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add member(s)");
    // draw the main tab
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    final TabMenu tabMenu = new TabMenu();
    mainTab.add(tabMenu);
    mainTab.setCellHeight(tabMenu, "30px");
    addCandidatesButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedCandidateToVo());
    inviteCandidatesButton = new CustomButton("Invite selected", SmallIcons.INSTANCE.emailIcon());
    final FindCandidatesOrUsersToAddToVo findAll = new FindCandidatesOrUsersToAddToVo(voId, 0, "");
    final CustomButton searchButton = new CustomButton("Search", SmallIcons.INSTANCE.findIcon());
    final CellTable<Candidate> candidatesTable = findAll.getEmptyTable();
    final ScrollPanel scrollPanel = new ScrollPanel();
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            findAll.searchFor(text);
        }
    }, searchButton);
    searchBox.getTextBox().setText(searchString);
    // search candidate - select if found one
    JsonCallbackEvents selectOneEvent = JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            searchBox.getTextBox().setEnabled(true);
            // check in candidates table
            if (findAll.getList().size() == 1) {
                findAll.setSelected(findAll.getList().get(0));
            }
            tabMenu.addWidget(2, addCandidatesButton);
        }

        @Override
        public void onLoadingStart() {
            searchBox.getTextBox().setEnabled(false);
        }

        @Override
        public void onError(PerunError error) {
            searchBox.getTextBox().setEnabled(true);
        }
    });
    // set event for search
    findAll.setEvents(selectOneEvent);
    tabMenu.addWidget(2, addCandidatesButton);
    tabMenu.addWidget(3, inviteCandidatesButton);
    inviteCandidatesButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // we expect, that candidate is always single
            Candidate candid = findAll.getSelected();
            if (candid != null) {
                if (candid.getObjectType().equalsIgnoreCase("Candidate")) {
                    SendInvitation invite = new SendInvitation(voId, 0);
                    invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteCandidatesButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            findAll.clearTableSelectedSet();
                        }
                    }));
                    invite.inviteUser(candid);
                } else {
                    SendInvitation invite = new SendInvitation(voId, 0);
                    invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteCandidatesButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            findAll.clearTableSelectedSet();
                        }
                    }));
                    User user = candid.cast();
                    invite.inviteUser(user);
                }
            }
        }
    });
    final TabItem tab = this;
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

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

        public void onClick(ClickEvent event) {
            Candidate candidateToBeAdded = findAll.getSelected();
            if (candidateToBeAdded == null) {
                UiElements.cantSaveEmptyListDialogBox(null);
            } else {
                if (candidateToBeAdded.getObjectType().equalsIgnoreCase("Candidate")) {
                    CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addCandidatesButton, new JsonCallbackEvents() {

                        private Candidate saveSelected;

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // put names to already added
                            if (saveSelected != null) {
                                GeneralObject go = saveSelected.cast();
                                alreadyAddedList.add(go);
                            }
                            findAll.clearTableSelectedSet();
                            rebuildAlreadyAddedWidget();
                            // clear search
                            searchBox.getTextBox().setText("");
                        }

                        @Override
                        public void onLoadingStart() {
                            saveSelected = findAll.getSelected();
                        }
                    }));
                    request.createMember(voId, candidateToBeAdded);
                } else {
                    CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addCandidatesButton, new JsonCallbackEvents() {

                        private User saveSelected;

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // put names to already added
                            if (saveSelected != null) {
                                GeneralObject go = saveSelected.cast();
                                alreadyAddedList.add(go);
                                findAll.clearTableSelectedSet();
                                rebuildAlreadyAddedWidget();
                                // clear search
                                searchBox.getTextBox().setText("");
                            }
                        }

                        @Override
                        public void onLoadingStart() {
                            Candidate cand = findAll.getSelected();
                            saveSelected = cand.cast();
                        }
                    }));
                    User user = candidateToBeAdded.cast();
                    request.createMember(voId, user);
                }
            }
        }
    });
    addCandidatesButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findAll, candidatesTable, addCandidatesButton);
    inviteCandidatesButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findAll, candidatesTable, inviteCandidatesButton);
    // tables
    candidatesTable.addStyleName("perun-table");
    scrollPanel.add(candidatesTable);
    scrollPanel.addStyleName("perun-tableScrollPanel");
    // load if stored search string is not empty
    findAll.searchFor(searchString);
    rebuildAlreadyAddedWidget();
    mainTab.add(alreadyAdded);
    // style
    // do not use resizePerunTable() when tab is in overlay - wrong width is calculated
    session.getUiElements().resizeSmallTabPanel(scrollPanel, 350, this);
    // add table to page
    mainTab.add(scrollPanel);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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) CreateMember(cz.metacentrum.perun.webgui.json.membersManager.CreateMember) FindCandidatesOrUsersToAddToVo(cz.metacentrum.perun.webgui.json.vosManager.FindCandidatesOrUsersToAddToVo) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) SendInvitation(cz.metacentrum.perun.webgui.json.registrarManager.SendInvitation)

Example 3 with TabMenu

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

the class MemberAddToGroupTabItem method draw.

public Widget draw() {
    this.titleWidget.setText("Add to group(s)");
    // main widget panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    final GetAllGroups groups = new GetAllGroups(member.getVoId());
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
            if (groups.getList().size() == 1) {
                // select if filtered result is single group
                groups.getSelectionModel().setSelected(groups.getList().get(0), true);
            }
        }
    }, "Filter groups by name");
    final TabItem tab = this;
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add member to selected group(s)");
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ArrayList<Group> list = groups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - should have only one callback to core
                for (int i = 0; i < list.size(); i++) {
                    final Group g = list.get(i);
                    AddMember request = new AddMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            groups.getSelectionModel().setSelected(g, false);
                            alreadyAddedList.add(g);
                            rebuildAlreadyAddedWidget();
                        }
                    }));
                    request.addMemberToGroup(g, member);
                }
            }
        }
    });
    menu.addWidget(addButton);
    addButton.setEnabled(false);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    CellTable<Group> table = groups.getTable();
    JsonUtils.addTableManagedButton(groups, table, addButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    rebuildAlreadyAddedWidget();
    vp.add(alreadyAdded);
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) 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) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMember(cz.metacentrum.perun.webgui.json.groupsManager.AddMember)

Example 4 with TabMenu

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

the class CreateMailTabItem method draw.

public Widget draw() {
    String title = "";
    if (group != null) {
        title = group.getName();
        entity = PerunEntity.GROUP;
        entityId = groupId;
    } else {
        title = vo.getName();
        entity = PerunEntity.VIRTUAL_ORGANIZATION;
        entityId = voId;
    }
    this.titleWidget.setText("Add email notification");
    // languages
    ArrayList<String> languages = new ArrayList<String>();
    if (!Utils.getNativeLanguage().isEmpty()) {
        languages.add(Utils.getNativeLanguage().get(0));
    }
    languages.add(0, "en");
    // vertical panel
    VerticalPanel vp = new VerticalPanel();
    vp.setWidth("500px");
    vp.setHeight("350px");
    // tab panel
    tabPanel.addStyleName("smallTabPanel");
    tabPanel.addStyleName("smallTabPanelWithBorder");
    tabPanel.setHeight("350px");
    // basic settings
    tabPanel.add(basicInformationTab(), "Basic settings");
    // for each locale add tab
    for (String locale : languages) {
        tabPanel.add(messageTab(locale), "Lang: " + locale);
    }
    tabPanel.add(availableTagsTab(), "Available tags");
    // add menu
    final TabItem tab = this;
    TabMenu tabMenu = new TabMenu();
    saveButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createEmailNotificationForApplication(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            String appType = applicationTypeListbox.getValue(applicationTypeListbox.getSelectedIndex());
            String mailType = mailTypeListbox.getValue(mailTypeListbox.getSelectedIndex());
            boolean send = sendingEnabledCheckBox.getValue();
            HashMap<String, MailText> messages = new HashMap<String, MailText>();
            // messages
            for (Map.Entry<String, TextArea> entry : messagesTextAreas.entrySet()) {
                String locale = entry.getKey();
                String subject = messagesSubjects.get(entry.getKey()).getValue();
                String text = entry.getValue().getText();
                MailText mt = MailText.construct(locale, subject, text);
                messages.put(locale, mt);
            }
            // create object
            ApplicationMail appMail = ApplicationMail.construct(appType, form.getId(), mailType, send, messages);
            // request
            AddApplicationMail req = new AddApplicationMail(entity, JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab));
            req.addMail(appMail, entityId);
        }
    });
    tabMenu.addWidget(saveButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    // add tab panel to main panel
    vp.add(tabPanel);
    vp.setCellWidth(tabPanel, "500px");
    vp.setCellHeight(tabPanel, "350px");
    vp.add(tabMenu);
    vp.setCellHeight(tabMenu, "30px");
    vp.setCellHorizontalAlignment(tabMenu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : HashMap(java.util.HashMap) 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) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) HashMap(java.util.HashMap) Map(java.util.Map) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail)

Example 5 with TabMenu

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

the class EditFormItemTabItem method buildItemsTable.

private FlexTable buildItemsTable(final FlexTable boxItemTable, final Map<String, String> values, final String locale) {
    // clear before rebuild
    boxItemTable.clear(true);
    int boxRow = 0;
    // clear options boxes
    final Map<TextBox, TextBox> currentOptions = new HashMap<TextBox, TextBox>();
    optionsBoxes.put(locale, currentOptions);
    boxRow++;
    Label boxContentLabel = new Label(item.getType().substring(0, 1) + item.getType().toLowerCase().substring(1) + " options:");
    boxItemTable.setWidget(boxRow, 0, boxContentLabel);
    boxItemTable.getFlexCellFormatter().setStyleName(boxRow, 0, "itemName");
    boxItemTable.getFlexCellFormatter().setColSpan(boxRow, 0, 4);
    boxRow++;
    HTML comment = new HTML("Define possible options for selection in SELECTIONBOX, COMBOBOX, CHECKBOX, RADIO widget. Empty options are not used.");
    comment.setStyleName("inputFormInlineComment");
    boxItemTable.setWidget(boxRow, 0, comment);
    boxItemTable.getFlexCellFormatter().setColSpan(boxRow, 0, 4);
    boxRow++;
    TabMenu menu = new TabMenu();
    //menu.setWidth("100%");
    boxItemTable.setWidget(boxRow, 0, menu);
    boxItemTable.getFlexCellFormatter().setColSpan(boxRow, 0, 4);
    boxRow++;
    final CustomButton sortButton = new CustomButton("Sort by label (A-Z)", SmallIcons.INSTANCE.sortAscendingIcon());
    menu.addWidget(sortButton);
    final CustomButton sortButton2 = new CustomButton("Sort by label (Z-A)", SmallIcons.INSTANCE.sortDescendingIcon());
    menu.addWidget(sortButton2);
    sortButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // OPTIONS
            Map<TextBox, TextBox> localeTextboxes = optionsBoxes.get(locale);
            Map<String, String> keyValue = new HashMap<String, String>();
            for (Map.Entry<TextBox, TextBox> textBoxes : localeTextboxes.entrySet()) {
                String key = textBoxes.getKey().getText();
                String value = textBoxes.getValue().getText();
                if (key != null && !key.equals("") && value != null && !value.equals("")) {
                    keyValue.put(key.trim(), value.trim());
                }
            }
            List<String> values = new ArrayList<String>(keyValue.values());
            Collections.sort(values, Collator.getNativeComparator());
            Map<String, String> sortedValues = new HashMap<String, String>();
            for (String value : values) {
                for (String key : keyValue.keySet()) {
                    if (Objects.equals(keyValue.get(key), value)) {
                        sortedValues.put(key, keyValue.get(key));
                    }
                }
            }
            buildItemsTable(boxItemTable, sortedValues, locale);
        }
    });
    sortButton2.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // OPTIONS
            Map<TextBox, TextBox> localeTextboxes = optionsBoxes.get(locale);
            Map<String, String> keyValue = new HashMap<String, String>();
            for (Map.Entry<TextBox, TextBox> textBoxes : localeTextboxes.entrySet()) {
                String key = textBoxes.getKey().getText();
                String value = textBoxes.getValue().getText();
                if (key != null && !key.equals("") && value != null && !value.equals("")) {
                    keyValue.put(key.trim(), value.trim());
                }
            }
            List<String> values = new ArrayList<String>(keyValue.values());
            Collections.sort(values, Collections.reverseOrder(Collator.getNativeComparator()));
            Map<String, String> sortedValues = new HashMap<String, String>();
            for (String value : values) {
                for (String key : keyValue.keySet()) {
                    if (Objects.equals(keyValue.get(key), value)) {
                        sortedValues.put(key, keyValue.get(key));
                    }
                }
            }
            buildItemsTable(boxItemTable, sortedValues, locale);
        }
    });
    // for each add new row
    for (Map.Entry<String, String> entry : values.entrySet()) {
        final TextBox keyTextBox = new TextBox();
        final TextBox valueTextBox = new TextBox();
        currentOptions.put(keyTextBox, valueTextBox);
        keyTextBox.setText(entry.getKey());
        valueTextBox.setText(entry.getValue());
        boxItemTable.setHTML(boxRow, 0, "Value:");
        boxItemTable.getFlexCellFormatter().setStyleName(boxRow, 0, "itemName");
        boxItemTable.setWidget(boxRow, 1, keyTextBox);
        boxItemTable.setHTML(boxRow, 2, "Label:");
        boxItemTable.getFlexCellFormatter().setStyleName(boxRow, 2, "itemName");
        boxItemTable.setWidget(boxRow, 3, valueTextBox);
        boxRow++;
    }
    // button for adding new
    CustomButton addNewButton = new CustomButton(ButtonTranslation.INSTANCE.addButton(), ButtonTranslation.INSTANCE.addNewSelectionBoxItem(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            final int r = boxItemTable.getRowCount();
            final TextBox keyTextBox = new TextBox();
            final TextBox valueTextBox = new TextBox();
            currentOptions.put(keyTextBox, valueTextBox);
            boxItemTable.insertRow(r - 1);
            boxItemTable.setHTML(r - 1, 0, "Value:");
            boxItemTable.getFlexCellFormatter().setStyleName(r - 1, 0, "itemName");
            boxItemTable.setWidget(r - 1, 1, keyTextBox);
            boxItemTable.setHTML(r - 1, 2, "Label:");
            boxItemTable.getFlexCellFormatter().setStyleName(r - 1, 2, "itemName");
            boxItemTable.setWidget(r - 1, 3, valueTextBox);
            UiElements.runResizeCommands(tab);
        }
    });
    boxItemTable.setWidget(boxRow, 0, addNewButton);
    boxItemTable.getFlexCellFormatter().setColSpan(boxRow, 0, 2);
    return boxItemTable;
}
Also used : HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) JSONString(com.google.gwt.json.client.JSONString) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

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