Search in sources :

Example 16 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class TabPanelForTabItems method runOnSelectEvent.

/**
	 * When selected tab, draw and resize it
	 *
	 * @param i
	 */
protected void runOnSelectEvent(int i) {
    // run resize commands for parent tab
    if (parentTab != null) {
        UiElements.runResizeCommands(parentTab);
    } else {
        UiElements.runResizeCommands();
    }
    // selected tab
    setLastTabId(i, false);
    // check size
    if ((innerTabs.size() < (i + 1)) || (innerTabsSimplePanels.size() < (i + 1))) {
        return;
    }
    // if widget not drawn - draw
    SimplePanel sp = innerTabsSimplePanels.get(i);
    TabItem tab = innerTabs.get(i);
    // check null
    if (sp == null || tab == null) {
        return;
    }
    // if widget null, call draw
    if (sp.getWidget() == null) {
        sp.setWidget(tab.draw());
    }
    UiElements.runResizeCommands(tab);
}
Also used : TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 17 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class VosSelectTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // Get vos request
    final GetVos getVos = new GetVos();
    getVos.setCheckable(false);
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    if (session.isVoAdmin()) {
        // do not display to VO observer
        tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
            }
        }));
    }
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            getVos.filterTable(text);
        }
    }, buttonTranslation.filterVo());
    tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    tabMenu.addWidget(new HTML("<strong>Please select VO you want to manage.</strong>"));
    final TabItem tab = this;
    // get the table with custom onclick
    CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, VirtualOrganization virtualOrganization2) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
            session.getTabManager().closeTab(tab, false);
        }
    });
    // 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 the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 18 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class CreateVoResourceTagTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    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 createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createResourceTag());
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            CreateResourceTag request = new CreateResourceTag(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
            request.createResourceTag(nameTextBox.getTextBox().getText().trim(), voId);
        }
    });
    // 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, "Tag name:");
    layout.setWidget(0, 1, nameTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(createButton);
    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) CreateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.CreateResourceTag) 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 19 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class CreateVoTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox shortNameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setMaxLength(128);
    shortNameTextBox.getTextBox().setMaxLength(32);
    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;
            }
        }
    };
    final ExtendedTextBox.TextBoxValidator shortNameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (shortNameTextBox.getTextBox().getText().trim().isEmpty()) {
                shortNameTextBox.setError("Short name can't be empty.");
            } else if (!shortNameTextBox.getTextBox().getText().trim().matches(Utils.VO_SHORT_NAME_MATCHER)) {
                shortNameTextBox.setError("Short name can contain only letters, numbers, dash and underscore.");
            } else {
                shortNameTextBox.setOk();
                return true;
            }
            return false;
        }
    };
    nameTextBox.setValidator(nameValidator);
    shortNameTextBox.setValidator(shortNameValidator);
    // 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 createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createVo());
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            if (!shortNameValidator.validateTextBox())
                return;
            CreateVo request = new CreateVo(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new VO must be editable by user in GUI, because it is already in PERUN
                    VirtualOrganization vo = jso.cast();
                    session.addEditableVo(vo.getId());
                }
            }));
            request.createVo(nameTextBox.getTextBox().getText().trim(), shortNameTextBox.getTextBox().getText().trim());
        }
    });
    // 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, "Full name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Short name:");
    layout.setWidget(1, 1, shortNameTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(createButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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) CreateVo(cz.metacentrum.perun.webgui.json.vosManager.CreateVo) 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)

Example 20 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class GetFormItems method prepareErrorSettings.

private void prepareErrorSettings(PerunError error) {
    FlexTable ft = new FlexTable();
    ft.setWidth("100%");
    ft.setCellPadding(8);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();
    ft.addStyleName("borderTable");
    ft.setHTML(0, 0, "<strong>Short name</strong>");
    ft.setHTML(0, 1, "<strong>Type</strong>");
    ft.setHTML(0, 2, "<strong>Preview</strong>");
    ft.setHTML(0, 3, "<strong>Edit</strong>");
    fcf.setStyleName(0, 0, "header");
    fcf.setStyleName(0, 1, "header");
    fcf.setStyleName(0, 2, "header");
    fcf.setStyleName(0, 3, "header");
    if (error != null && error.getName().equalsIgnoreCase("FormNotExistsException")) {
        // no form, add create button
        final CustomButton create = new CustomButton("Create empty form", ButtonTranslation.INSTANCE.createEmptyApplicationForm(), SmallIcons.INSTANCE.addIcon());
        create.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                // disable button event with refresh page on finished
                CreateApplicationForm request = new CreateApplicationForm(entity, id, JsonCallbackEvents.disableButtonEvents(create, new JsonCallbackEvents() {

                    private TabItem item = null;

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        if (item != null) {
                            item.draw();
                        }
                    }

                    @Override
                    public void onLoadingStart() {
                        item = session.getTabManager().getActiveTab();
                    }
                }));
                request.createApplicationForm();
            }
        });
        if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && !session.isVoAdmin(id)) {
            create.setEnabled(false);
        } else if (PerunEntity.GROUP.equals(entity) && !session.isGroupAdmin(id) && !session.isVoAdmin(group.getVoId())) {
            create.setEnabled(false);
        }
        loaderImage.setEmptyResultMessage("Application form doesn't exists.");
        loaderImage.loadingFinished();
        ft.setWidget(1, 0, loaderImage);
        ft.getFlexCellFormatter().addStyleName(1, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(1, 0, 4);
        ft.setWidget(2, 0, create);
        ft.getFlexCellFormatter().addStyleName(2, 0, "noBorder");
        ft.getFlexCellFormatter().setColSpan(2, 0, 4);
        ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
        ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    } else {
        // standard error
        ft.setWidget(1, 0, loaderImage);
        fcf.setColSpan(1, 0, 4);
    }
    contents.setWidget(ft);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) CreateFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.CreateFormItemTabItem) EditFormItemTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.EditFormItemTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Aggregations

TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)84 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)76 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)76 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)71 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)68 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)56 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)54 ArrayList (java.util.ArrayList)47 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)30 PerunError (cz.metacentrum.perun.webgui.model.PerunError)21 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)19 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)14 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)13 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)13 User (cz.metacentrum.perun.webgui.model.User)13 Group (cz.metacentrum.perun.webgui.model.Group)11 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)11 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)10 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)10 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)10