Search in sources :

Example 1 with FlexCellFormatter

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

the class RegistrarFormItemGenerator method generateComboBox.

/**
	 * Generates the combobox
	 * @return
	 */
private Widget generateComboBox() {
    final ListBox lbox = new ListBox();
    final TextBox textBox = new ExtendedTextBox();
    textBox.setMaxLength(TEXT_BOX_MAX_LENGTH);
    textBox.getElement().setClassName("apptextbox" + counter++);
    setCutCopyPasteHandler("apptextbox" + counter);
    boolean anyValueSelected = false;
    textBox.setWidth(MIN_WIDTH + "px");
    strValueBox = textBox;
    inputChecker = getDefaultInputChecker();
    textBox.setVisible(false);
    // parse options
    String options = getOptions();
    Map<String, String> boxContents = parseSelectionBox(options);
    ArrayList<String> keyList = JsonUtils.setToList(boxContents.keySet());
    //Collections.sort(keyList);
    int i = 0;
    for (String key : keyList) {
        boolean selected = strValue.equals(key);
        lbox.addItem(boxContents.get(key), key);
        lbox.setItemSelected(i, selected);
        if (selected == true) {
            anyValueSelected = true;
        }
        i++;
    }
    // add " - other value - " with previous value as default
    if (strValue == null) {
        strValue = "";
    }
    lbox.addItem("--- other value ---", strValue);
    final int otherValueIndex = i;
    if (!anyValueSelected && !strValue.equals("")) {
        lbox.setItemSelected(otherValueIndex, true);
        textBox.setVisible(true);
    }
    // when changed, update value
    lbox.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String value = lbox.getValue(lbox.getSelectedIndex());
            strValueBox.setValue(value, true);
            // if other value selected, set textbox visible
            textBox.setVisible(lbox.getSelectedIndex() == otherValueIndex);
            if (lbox.getSelectedIndex() == otherValueIndex) {
                textBox.setFocus(true);
                textBox.selectAll();
            }
            // validation
            if (inputChecker.isValid(true)) {
                // is valid AND value not empty
                if (!strValueBox.getText().equals("") || !item.isRequired()) {
                    // default OK?
                    if (inputChecker.useDefaultOkMessage()) {
                        statusCellWrapper.setWidget(new FormInputStatusWidget("OK", Status.OK));
                    }
                } else {
                    // input empty - clear;
                    statusCellWrapper.clear();
                }
            }
        }
    });
    // set default value
    strValueBox.setText(lbox.getValue(lbox.getSelectedIndex()));
    // container
    FlexTable ft = new FlexTable();
    ft.setStyleName("appFormComboBoxTable");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    ft.setWidget(0, 0, lbox);
    ft.setWidget(1, 0, textBox);
    ftf.setWidth(1, 0, MIN_WIDTH + "px");
    return ft;
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)

Example 2 with FlexCellFormatter

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

the class UiElements method getFooter.

/**
	 * Returns the footer widget
	 *
	 * @return widget footer
	 */
public Widget getFooter() {
    FlexTable ft = new FlexTable();
    ft.addStyleName("perunFooter");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    Anchor a = new Anchor("Perun web", PerunWebConstants.INSTANCE.footerPerunLink());
    a.setTarget("_blank");
    Anchor mail = new Anchor(Utils.perunReportEmailAddress(), "mailto:" + Utils.perunReportEmailAddress());
    Anchor lnk = new Anchor("Online help", "https://wiki.metacentrum.cz/wiki/Perun");
    lnk.setTarget("_blank");
    HTML foot = new HTML("<strong>About: </strong>" + a + "<strong>&nbsp;|&nbsp;Support: </strong>" + mail + ", " + lnk);
    ft.setWidget(0, 0, foot);
    ft.setWidget(0, 1, new HTML(PerunWebConstants.INSTANCE.footerPerunCopyright() + " " + JsonUtils.getCurrentYear() + ", version: " + PerunWebConstants.INSTANCE.guiVersion()));
    ft.setWidget(0, 2, new HTML("<strong>" + ButtonTranslation.INSTANCE.settingsButton() + ": </strong>"));
    ftf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
    //ftf.setWidth(0, 0, "40%");
    ftf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
    //ftf.setWidth(0, 1, "35%");
    ftf.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
    ftf.setWidth(0, 2, "15%");
    // toggle languages
    //ft.setWidget(0, 3, getToggleLanguageButton());
    //ftf.setWidth(0, 3, "30px");
    //ftf.setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
    // toggle ids button
    ft.setWidget(0, 3, getExtendedInfoButton());
    ftf.setWidth(0, 3, "30px");
    ftf.setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
    if ("true".equalsIgnoreCase(Location.getParameter("log"))) {
        // toggle log button
        ft.setWidget(0, 4, getToggleLogButton());
        ftf.setWidth(0, 4, "30px");
        ftf.setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_LEFT);
    }
    return ft;
}
Also used : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)

Example 3 with FlexCellFormatter

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

the class CreateMailTabItem method basicInformationTab.

/**
	 * Returns flex table with basic information
	 *
	 * @return
	 */
private Widget basicInformationTab() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("500px", "350px");
    vp.setSpacing(10);
    // layout
    FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    vp.add(ft);
    vp.add(new HTML("&nbsp;"));
    // inputs - filling
    mailTypeListbox.clear();
    for (ApplicationMail.MailType type : ApplicationMail.MailType.values()) {
        mailTypeListbox.addItem(ApplicationMail.getTranslatedMailType(type.toString()), type.toString());
    }
    int initialIndex = 0;
    applicationTypeListbox.clear();
    for (Application.ApplicationType type : Application.ApplicationType.values()) {
        applicationTypeListbox.addItem(Application.getTranslatedType(type.toString()), type.toString());
        if (type.equals(Application.ApplicationType.INITIAL)) {
            initialIndex = applicationTypeListbox.getItemCount() - 1;
        }
    }
    final int initIndex = initialIndex;
    mailTypeListbox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            if (mailTypeListbox.getValue(mailTypeListbox.getSelectedIndex()).equals("USER_INVITE")) {
                applicationTypeListbox.setEnabled(false);
                applicationTypeListbox.setSelectedIndex(initIndex);
            } else {
                applicationTypeListbox.setEnabled(true);
            }
        }
    });
    // basic info
    int row = 0;
    ft.setHTML(row, 0, "E-mail type:");
    ft.setWidget(row, 1, mailTypeListbox);
    ftf.setStyleName(row, 0, "itemName");
    row++;
    ft.setHTML(row, 1, "Selected type of notification (action which trigger sending and who is notified).");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    row++;
    ft.setHTML(row, 0, "Application type: ");
    ft.setWidget(row, 1, applicationTypeListbox);
    ftf.setStyleName(row, 0, "itemName");
    ftf.setWidth(row, 0, "120px");
    row++;
    ft.setHTML(row, 1, "Select which application type will trigger sending.");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    row++;
    sendingEnabledCheckBox.setValue(true);
    ft.setHTML(row, 0, "Sending enabled:");
    ft.setWidget(row, 1, sendingEnabledCheckBox);
    ftf.setStyleName(row, 0, "itemName");
    row++;
    ft.setHTML(row, 1, "If checked, notification will be sent. Un-check it to temporary disable sending.");
    ftf.setStyleName(row, 1, "inputFormInlineComment");
    return vp;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) AddApplicationMail(cz.metacentrum.perun.webgui.json.registrarManager.AddApplicationMail)

Example 4 with FlexCellFormatter

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

the class CreateMailTabItem method messageTab.

/**
	 * Returns message texarea
	 *
	 * @param locale
	 * @return
	 */
private Widget messageTab(String locale) {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("500px", "350px");
    vp.setSpacing(10);
    // layout
    FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");
    FlexCellFormatter ftf = ft.getFlexCellFormatter();
    // inputs
    TextBox tb = new TextBox();
    tb.setWidth("385px");
    messagesSubjects.put(locale, tb);
    TextArea ta = new TextArea();
    ta.setSize("450px", "190px");
    messagesTextAreas.put(locale, ta);
    // adds inputs to the flex table
    ft.setHTML(0, 0, "Subject:");
    ftf.setStyleName(0, 0, "itemName");
    ft.setWidget(0, 1, tb);
    ft.setHTML(1, 0, "Text:");
    ftf.setStyleName(1, 0, "itemName");
    //ftf.setColSpan(1, 0, 2);
    Anchor a = new Anchor("see available tags >>");
    a.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            // select last tab
            tabPanel.selectTab(tabPanel.getWidgetCount() - 1);
        }
    });
    ft.setWidget(1, 1, a);
    ft.setWidget(2, 0, ta);
    ftf.setColSpan(2, 0, 2);
    vp.add(ft);
    vp.add(new HTML("&nbsp;"));
    return vp;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 5 with FlexCellFormatter

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

the class EditFormItemTabItem method itemTextTab.

/**
	 * Returns flex table with settings for the language
	 *
	 * @param locale
	 * @return
	 */
private Widget itemTextTab(String locale) {
    ItemTexts itemTexts = item.getItemTexts(locale);
    if (itemTexts == null) {
        // create empty item texts
        JSONObject itemTextJson = new JSONObject();
        itemTextJson.put("label", new JSONString(""));
        itemTextJson.put("help", new JSONString(""));
        itemTextJson.put("errorMessage", new JSONString(""));
        itemTextJson.put("options", new JSONString(""));
    }
    item.setItemTexts(locale, itemTexts);
    TextArea labelTextBox = new TextArea();
    labelTextBoxes.put(locale, labelTextBox);
    TextArea helpTextBox = new TextArea();
    helpTextBoxes.put(locale, helpTextBox);
    TextArea errorTextBox = new TextArea();
    errorTextBoxes.put(locale, errorTextBox);
    // layout
    final FlexTable ft = new FlexTable();
    ft.setStyleName("inputFormFlexTable");
    ft.setSize("550px", "100%");
    final FlexCellFormatter ftf = ft.getFlexCellFormatter();
    // sizes
    labelTextBox.setWidth("440px");
    helpTextBox.setWidth("440px");
    errorTextBox.setWidth("440px");
    // fill values
    labelTextBox.setText(itemTexts.getLabel());
    helpTextBox.setText(itemTexts.getHelp());
    errorTextBox.setText(itemTexts.getErrorMessage());
    // adding to table
    int row = 0;
    if ("HTML_COMMENT".equals(item.getType()) || "HEADING".equals(item.getType())) {
        Label label = new Label("Content:");
        ft.setWidget(row, 0, label);
        ft.setWidget(row, 1, labelTextBox);
        row++;
        ft.setHTML(row, 1, "HTML formatted content of form item. It spans through all columns to full form width.");
        ftf.setStyleName(row, 1, "inputFormInlineComment");
        row++;
    } else if ("SUBMIT_BUTTON".equals(item.getType()) || "AUTO_SUBMIT_BUTTON".equals(item.getType())) {
        Label label = new Label("Label:");
        ft.setWidget(row, 0, label);
        ft.setWidget(row, 1, labelTextBox);
        row++;
        ft.setHTML(row, 1, "Label displayed on submit button.");
        ftf.setStyleName(row, 1, "inputFormInlineComment");
        row++;
    } else {
        Label label = new Label("Label:");
        ft.setWidget(row, 0, label);
        ft.setWidget(row, 1, labelTextBox);
        row++;
        ft.setHTML(row, 1, "Label displayed to users to identify item on application form. If empty, \"Short name\" from basic settings is used as fallback.");
        ftf.setStyleName(row, 1, "inputFormInlineComment");
        row++;
        Label helpLabel = new Label("Help:");
        ft.setWidget(row, 0, helpLabel);
        ft.setWidget(row, 1, helpTextBox);
        row++;
        ft.setHTML(row, 1, "Help text displayed to user along with input widget.");
        ftf.setStyleName(row, 1, "inputFormInlineComment");
        row++;
        Label errorLabel = new Label("Error:");
        ft.setWidget(row, 0, errorLabel);
        ft.setWidget(row, 1, errorTextBox);
        row++;
        ft.setHTML(row, 1, "Error message displayed to user when enters wrong value.");
        ftf.setStyleName(row, 1, "inputFormInlineComment");
    }
    // style
    for (int i = 0; i < ft.getRowCount(); i++) {
        ftf.setStyleName(i, 0, "itemName");
    }
    // box items table
    final FlexTable boxItemTable = new FlexTable();
    boxItemTable.setStyleName("inputFormFlexTable");
    boxItemTable.setWidth("550px");
    // final layout
    VerticalPanel vp = new VerticalPanel();
    vp.add(ft);
    // values for selection and combobox
    if (Arrays.asList("SELECTIONBOX", "COMBOBOX", "CHECKBOX", "RADIO").contains(item.getType())) {
        final Map<String, String> values = new HashMap<String, String>();
        // parse values from the item
        String options = itemTexts.getOptions();
        if (options != null) {
            // for each value, add key-value
            values.putAll(RegistrarFormItemGenerator.parseSelectionBox(options));
        }
        buildItemsTable(boxItemTable, values, locale);
        vp.add(boxItemTable);
    }
    vp.addStyleName("perun-table");
    // scroll panel
    ScrollPanel sp = new ScrollPanel(vp);
    sp.addStyleName("perun-tableScrollPanel");
    sp.setSize("560px", "100%");
    return sp;
}
Also used : HashMap(java.util.HashMap) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) JSONString(com.google.gwt.json.client.JSONString) JSONObject(com.google.gwt.json.client.JSONObject) JSONString(com.google.gwt.json.client.JSONString)

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