Search in sources :

Example 21 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class EditExecServiceTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit ExecService");
    VerticalPanel vp = new VerticalPanel();
    final CheckBox enabled = new CheckBox();
    enabled.setText("Enabled / Disabled");
    enabled.setValue(execService.isEnabled());
    final ExtendedTextBox delay = new ExtendedTextBox();
    delay.getTextBox().setText("" + execService.getDefaultDelay());
    final ExtendedTextBox.TextBoxValidator delayValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!JsonUtils.checkParseInt(delay.getTextBox().getText().trim())) {
                delay.setError("Delay must be a number (time in minutes) !");
                return false;
            } else {
                delay.setOk();
                return true;
            }
        }
    };
    delay.setValidator(delayValidator);
    final ExtendedTextBox scriptPath = new ExtendedTextBox();
    scriptPath.getTextBox().setValue(execService.getScriptPath());
    final ExtendedTextBox.TextBoxValidator scriptValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (scriptPath.getTextBox().getText().trim().isEmpty()) {
                scriptPath.setError("Script path can't be empty !");
                return false;
            } else {
                scriptPath.setOk();
                return true;
            }
        }
    };
    scriptPath.setValidator(scriptValidator);
    // 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 ExecService");
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!scriptValidator.validateTextBox() && !delayValidator.validateTextBox())
                return;
            ExecService es = JsonUtils.clone(execService).cast();
            es.setEnabled(enabled.getValue());
            es.setDefaultDelay(Integer.parseInt(delay.getTextBox().getValue().trim()));
            es.setScriptPath(scriptPath.getTextBox().getValue().trim());
            UpdateExecService request = new UpdateExecService(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
            request.updateExecService(es);
        }
    });
    // 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, "Enabled:");
    layout.setWidget(0, 1, enabled);
    layout.setHTML(1, 0, "Script path:");
    layout.setWidget(1, 1, scriptPath);
    layout.setHTML(2, 0, "Delay:");
    layout.setWidget(2, 1, delay);
    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 : UpdateExecService(cz.metacentrum.perun.webgui.json.generalServiceManager.UpdateExecService) ExecService(cz.metacentrum.perun.webgui.model.ExecService) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) 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) UpdateExecService(cz.metacentrum.perun.webgui.json.generalServiceManager.UpdateExecService) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 22 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class AddUserExtSourceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add ext. identity");
    VerticalPanel vp = new VerticalPanel();
    // get available ext sources
    final ListBoxWithObjects<ExtSource> extSourcesDropDown = new ListBoxWithObjects<ExtSource>();
    final TextBox externalLogin = new TextBox();
    final TextBox loaTextBox = new TextBox();
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add external identity to user");
    // fill listbox
    JsonCallbackEvents fillEvent = new JsonCallbackEvents() {

        @Override
        public void onError(PerunError error) {
            extSourcesDropDown.clear();
            extSourcesDropDown.addItem("Error while loading");
            callDone = false;
        }

        @Override
        public void onFinished(JavaScriptObject jso) {
            extSourcesDropDown.clear();
            ArrayList<ExtSource> list = JsonUtils.jsoAsList(jso);
            list = new TableSorter<ExtSource>().sortByName(list);
            if (list == null || list.isEmpty()) {
                extSourcesDropDown.addItem("No external sources available");
                return;
            }
            for (ExtSource ex : list) {
                extSourcesDropDown.addItem(ex);
            }
            callDone = true;
            if (!externalLogin.getText().isEmpty() && !extSourcesDropDown.isEmpty() && JsonUtils.checkParseInt(loaTextBox.getText()) && callDone) {
                addButton.setEnabled(true);
            }
        }

        @Override
        public void onLoadingStart() {
            extSourcesDropDown.clear();
            extSourcesDropDown.addItem("Loading...");
            callDone = false;
        }
    };
    // callback
    final GetExtSources extSources = new GetExtSources(fillEvent);
    extSources.retrieveData();
    // create layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    layout.setHTML(0, 0, "External login:");
    layout.setWidget(0, 1, externalLogin);
    layout.setHTML(1, 0, "External source:");
    layout.setWidget(1, 1, extSourcesDropDown);
    layout.setHTML(2, 0, "Level of Assurance:");
    layout.setWidget(2, 1, loaTextBox);
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.setStyleName(i, 0, "itemName");
    }
    cellFormatter.setStyleName(3, 1, "inputFormInlineComment");
    layout.setHTML(3, 1, "0 - not verified = default</br>1 - verified email</br>2 - verified identity</br>3 - verified identity, strict password strength");
    TabMenu menu = new TabMenu();
    // close tab events
    final JsonCallbackEvents addExtSrcEvents = JsonCallbackEvents.closeTabDisableButtonEvents(addButton, this);
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ExtSource selected = extSourcesDropDown.getObjectAt(extSourcesDropDown.getSelectedIndex());
            String login = externalLogin.getText();
            AddUserExtSource request = new AddUserExtSource(addExtSrcEvents);
            int loa = 0;
            if (JsonUtils.checkParseInt(loaTextBox.getText())) {
                loa = Integer.parseInt(loaTextBox.getText());
            } else {
                JsonUtils.cantParseIntConfirm("Level of Assurance", loaTextBox.getText());
                return;
            }
            request.addUserExtSource(userId, login.trim(), selected, loa);
        }
    });
    addButton.setEnabled(false);
    menu.addWidget(addButton);
    final TabItem tab = this;
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().closeTab(tab);
        }
    }));
    KeyUpHandler handler = new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (!externalLogin.getText().isEmpty() && !extSourcesDropDown.isEmpty() && JsonUtils.checkParseInt(loaTextBox.getText()) && callDone) {
                addButton.setEnabled(true);
            } else {
                addButton.setEnabled(false);
            }
        }
    };
    externalLogin.addKeyUpHandler(handler);
    loaTextBox.addKeyUpHandler(handler);
    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) GetExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetExtSources) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) AddUserExtSource(cz.metacentrum.perun.webgui.json.usersManager.AddUserExtSource) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddUserExtSource(cz.metacentrum.perun.webgui.json.usersManager.AddUserExtSource) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 23 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class CreateSecurityTeamTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox descriptionTextBox = 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.createSecurityTeam());
    createButton.addClickHandler(new ClickHandler() {

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

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new SecTeam must be editable by user in GUI, because it is already in PERUN
                    SecurityTeam team = jso.cast();
                    session.addEditableSecurityTeam(team.getId());
                }
            }));
            request.createSecurityTeam(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.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, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    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) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 24 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project perun by CESNET.

the class EditSecurityTeamDetailsTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit Security Team");
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setText(team.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);
    final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
    descriptionTextBox.getTextBox().setText(team.getDescription());
    // 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 Security team name");
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            SecurityTeam team2 = JsonUtils.clone(team).cast();
            team2.setName(nameTextBox.getTextBox().getText().trim());
            team2.setDescription(descriptionTextBox.getTextBox().getText().trim());
            UpdateSecurityTeam request = new UpdateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
            request.updateSecurityTeam(team2);
        }
    });
    // 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, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    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 : UpdateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) UpdateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) 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 25 with FlexCellFormatter

use of com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter in project gerrit by GerritCodeReview.

the class ProjectsTable method insert.

protected void insert(final int row, final ProjectInfo k) {
    table.insertRow(row);
    applyDataRowStyle(row);
    final FlexCellFormatter fmt = table.getFlexCellFormatter();
    fmt.addStyleName(row, C_STATE, Gerrit.RESOURCES.css().iconCell());
    fmt.addStyleName(row, C_NAME, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, C_NAME, Gerrit.RESOURCES.css().projectNameColumn());
    fmt.addStyleName(row, C_DESCRIPTION, Gerrit.RESOURCES.css().dataCell());
    populate(row, k);
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)

Aggregations

FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)25 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)25 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)19 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)19 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)17 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)10 RegistrarFormItemGenerator (cz.metacentrum.perun.webgui.client.applicationresources.RegistrarFormItemGenerator)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)5 JSONString (com.google.gwt.json.client.JSONString)3 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)3 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)3 ArrayList (java.util.ArrayList)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 ImageResource (com.google.gwt.resources.client.ImageResource)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 Image (com.google.gwt.user.client.ui.Image)2