Search in sources :

Example 11 with TabMenu

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

the class AssignTagTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add tag");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId());
    final CellTable<ResourceTag> table = tags.getTable();
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedTagsToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<ResourceTag> tagsToAssign = tags.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(tagsToAssign)) {
                for (int i = 0; i < tagsToAssign.size(); i++) {
                    if (i != tagsToAssign.size() - 1) {
                        // call json normaly
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.disableButtonEvents(assignButton));
                        request.assignResourceTag(tagsToAssign.get(i));
                    } else {
                        // last change - call json with update
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
                        request.assignResourceTag(tagsToAssign.get(i));
                    }
                }
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            tags.filterTable(text);
            // if single group, select
            if (tags.getList().size() == 1) {
                table.getSelectionModel().setSelected(tags.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(tags, table, assignButton);
    tags.retrieveData();
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) 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) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 12 with TabMenu

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

the class MembershipExpirationTabItem method draw.

public Widget draw() {
    this.titleWidget.setText("Set membership expiration");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("350px", "100%");
    final FlexTable layout = new FlexTable();
    layout.setSize("100%", "100%");
    layout.setStyleName("inputFormFlexTable");
    layout.setHTML(0, 0, "Current expiration:");
    layout.getFlexCellFormatter().setStyleName(0, 0, "itemName");
    layout.setHTML(0, 1, member.getStatus());
    final Attribute expire = member.getAttribute("urn:perun:member:attribute-def:def:membershipExpiration");
    String expirationValue = null;
    if (expire != null && !"null".equalsIgnoreCase(expire.getValue())) {
        layout.setHTML(0, 1, expire.getValue());
        expirationValue = expire.getValue().substring(0, ((expire.getValue().length() > 10) ? 9 : expire.getValue().length() - 1));
    } else {
        layout.setHTML(0, 1, "<i>never</i>");
    }
    layout.setHTML(1, 0, "New expiration:");
    layout.getFlexCellFormatter().setStyleName(1, 0, "itemName");
    final CustomButton changeButton = new CustomButton("Save", "Save changes in membership expiration date", SmallIcons.INSTANCE.diskIcon());
    final DatePicker picker = new DatePicker();
    picker.setWidth("100%");
    layout.getFlexCellFormatter().setColSpan(2, 0, 2);
    layout.setWidget(2, 0, picker);
    picker.addValueChangeHandler(new ValueChangeHandler<Date>() {

        @Override
        public void onValueChange(ValueChangeEvent<Date> dateValueChangeEvent) {
            layout.setHTML(1, 1, DateTimeFormat.getFormat("yyyy-MM-dd").format(picker.getValue()));
            changeButton.setEnabled(true);
            changeOrNever = true;
        }
    });
    try {
        // set values if possible
        picker.setCurrentMonth(DateTimeFormat.getFormat("yyyy-MM-dd").parse(expirationValue));
        picker.setValue(DateTimeFormat.getFormat("yyyy-MM-dd").parse(expirationValue));
    } catch (Exception ex) {
        // if not parseable, display current date
        picker.setCurrentMonth(new Date());
        picker.setValue(new Date());
    }
    Anchor anchor = new Anchor("Set expiration to 'never'");
    anchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            layout.setHTML(1, 1, "<i>never</i>");
            changeOrNever = false;
            changeButton.setEnabled(true);
        }
    });
    layout.setWidget(3, 0, anchor);
    layout.getFlexCellFormatter().setColSpan(3, 0, 2);
    layout.getFlexCellFormatter().getElement(3, 0).setAttribute("style", "text-align: right;");
    TabMenu menu = new TabMenu();
    final TabItem tab = this;
    // by default false
    changeButton.setEnabled(false);
    changeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (changeOrNever) {
                expire.setValueAsString(DateTimeFormat.getFormat("yyyy-MM-dd").format(picker.getValue()));
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("member", member.getId());
                SetAttributes request = new SetAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(changeButton, tab));
                ArrayList<Attribute> list = new ArrayList<Attribute>();
                list.add(expire);
                request.setAttributes(ids, list);
            } else {
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("member", member.getId());
                RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(changeButton, tab));
                ArrayList<Attribute> list = new ArrayList<Attribute>();
                list.add(expire);
                request.removeAttributes(ids, list);
            }
        }
    });
    menu.addWidget(changeButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, ButtonTranslation.INSTANCE.cancelButton(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : Attribute(cz.metacentrum.perun.webgui.model.Attribute) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) ArrayList(java.util.ArrayList) Date(java.util.Date) 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) DatePicker(com.google.gwt.user.datepicker.client.DatePicker) HashMap(java.util.HashMap) Map(java.util.Map) RemoveAttributes(cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)

Example 13 with TabMenu

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

the class AuditLogTabItem method draw.

public Widget draw() {
    // page main tab
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // number of messages
    final TextBox tb = new TextBox();
    tb.setText(String.valueOf(count));
    tb.setWidth("100px");
    // menu panel
    TabMenu menu = new TabMenu();
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    CustomButton refreshButton = TabMenu.getPredefinedButton(ButtonType.REFRESH, ButtonTranslation.INSTANCE.refreshAuditMessages());
    // retrieve messages
    final GetAuditMessagesByCount call = new GetAuditMessagesByCount(JsonCallbackEvents.disableButtonEvents(refreshButton));
    call.setCount(count);
    CellTable<AuditMessage> table = call.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    mainTab.add(sp);
    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);
    // refresh button action
    refreshButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (JsonUtils.checkParseInt(tb.getText())) {
                call.clearTable();
                count = Integer.parseInt(tb.getText());
                call.setCount(count);
                call.retrieveData();
            } else {
                JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
            }
        }
    });
    menu.addWidget(refreshButton);
    // enter key = refresh on count text box
    tb.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (JsonUtils.checkParseInt(tb.getText())) {
                    call.clearTable();
                    count = Integer.parseInt(tb.getText());
                    call.setCount(count);
                    call.retrieveData();
                } else {
                    JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
                }
            }
        }
    });
    // add textbox into menu
    menu.addWidget(new HTML("<strong>Number of messages: </strong>"));
    menu.addWidget(tb);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAuditMessagesByCount(cz.metacentrum.perun.webgui.json.auditMessagesManager.GetAuditMessagesByCount) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 14 with TabMenu

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

the class CreateOwnerTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // textboxes which set the class data when updated
    final ExtendedTextBox ownerNameTextBox = new ExtendedTextBox();
    final ExtendedTextBox ownerContactTextBox = new ExtendedTextBox();
    final ListBox ownerType = new ListBox();
    ownerType.addItem(ObjectTranslation.INSTANCE.ownerTypeAdministrative(), "administrative");
    ownerType.addItem(ObjectTranslation.INSTANCE.ownerTypeTechnical(), "technical");
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

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

        @Override
        public boolean validateTextBox() {
            if (ownerContactTextBox.getTextBox().getText().trim().isEmpty()) {
                ownerContactTextBox.setError("Contact can't be empty.");
                return false;
            }
            ownerContactTextBox.setOk();
            return true;
        }
    };
    ownerNameTextBox.setValidator(nameValidator);
    ownerContactTextBox.setValidator(contactValidator);
    // layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, ownerNameTextBox);
    layout.setHTML(1, 0, "Contact:");
    layout.setWidget(1, 1, ownerContactTextBox);
    layout.setHTML(2, 0, "Type:");
    layout.setWidget(2, 1, ownerType);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    // buttons
    TabMenu menu = new TabMenu();
    final TabItem tab = this;
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createOwner());
    createButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (nameValidator.validateTextBox() && contactValidator.validateTextBox()) {
                CreateOwner request = new CreateOwner(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
                request.createOwner(ownerNameTextBox.getTextBox().getText().trim(), ownerContactTextBox.getTextBox().getText().trim(), ownerType.getValue(ownerType.getSelectedIndex()));
            }
        }
    });
    menu.addWidget(createButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateOwner(cz.metacentrum.perun.webgui.json.ownersManager.CreateOwner) 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)

Example 15 with TabMenu

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

the class ExtSourcesTabItem method draw.

public Widget draw() {
    // create main panel for content
    VerticalPanel mainPage = new VerticalPanel();
    mainPage.setWidth("100%");
    // create new instance for jsonCall getExtSources
    final GetExtSources getExtSources = new GetExtSources();
    getExtSources.setCheckable(false);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addFilterWidget(new ExtendedSuggestBox(getExtSources.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            getExtSources.filterTable(text);
        }
    }, "Filter external sources by name or type");
    final CustomButton loadButton = new CustomButton("Load ext sources", "Load ext sources definitions from a local file.", SmallIcons.INSTANCE.worldIcon());
    loadButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            LoadExtSourcesDefinitions loadCall = new LoadExtSourcesDefinitions(JsonCallbackEvents.disableButtonEvents(loadButton, JsonCallbackEvents.refreshTableEvents(getExtSources)));
            loadCall.retrieveData();
        }
    });
    menu.addWidget(loadButton);
    // get CellTable from jsonCall
    CellTable<ExtSource> extSourcesTable = getExtSources.getTable();
    extSourcesTable.setStyleName("perun-table");
    ScrollPanel scrollTable = new ScrollPanel(extSourcesTable);
    scrollTable.addStyleName("perun-tableScrollPanel");
    // put page into scroll panel
    mainPage.add(menu);
    mainPage.setCellHeight(menu, "30px");
    mainPage.add(scrollTable);
    session.getUiElements().resizePerunTable(scrollTable, 350, this);
    this.contentWidget.setWidget(mainPage);
    return getWidget();
}
Also used : PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) GetExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetExtSources) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) LoadExtSourcesDefinitions(cz.metacentrum.perun.webgui.json.extSourcesManager.LoadExtSourcesDefinitions) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource)

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