Example usage for com.google.gwt.user.client.ui ListBox setName

List of usage examples for com.google.gwt.user.client.ui ListBox setName

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui ListBox setName.

Prototype

public void setName(String name) 

Source Link

Usage

From source file:com.ephesoft.dcma.gwt.admin.bm.client.presenter.plugin.EditPluginPresenter.java

License:Open Source License

/**
 * To set properties.//from   www  . ja  va 2 s  . c  o m
 */
public void setProperties() {
    ListBox hocrToPdfListBox = null;
    ListBox createMultipagePdfOptimizationSwitchListBox = null;
    ListBox tabbedPdfOptimizationSwitchListBox = null;
    docFieldWidgets = new ArrayList<EditableWidgetStorage>();
    int row = 0;
    Collection<BatchClassPluginConfigDTO> values = controller.getSelectedPlugin().getBatchClassPluginConfigs();
    if (values != null) {
        for (final BatchClassPluginConfigDTO batchClassPluginConfig : values) {
            view.formatRow(row);
            view.addWidget(row, 0,
                    new Label(batchClassPluginConfig.getDescription() + BatchClassManagementConstants.COLON));

            if (batchClassPluginConfig.isMandatory()) {
                view.addWidgetStar(row, 1);
            }
            if (batchClassPluginConfig.getSampleValue() != null
                    && !batchClassPluginConfig.getSampleValue().isEmpty()) {
                if (batchClassPluginConfig.getSampleValue().size() > 1) {
                    // Create a listBox
                    if (batchClassPluginConfig.isMultivalue()) {
                        // Create a multiple select list box
                        List<String> sampleValueList = batchClassPluginConfig.getSampleValue();
                        int max_visible_item_count = MAX_VISIBLE_ITEM_COUNT;
                        if (sampleValueList.size() < MAX_VISIBLE_ITEM_COUNT) {
                            max_visible_item_count = sampleValueList.size();
                        }
                        ListBox fieldValue = view.addMultipleSelectListBox(row, sampleValueList,
                                max_visible_item_count, batchClassPluginConfig.getValue());
                        view.addWidget(row, 2, fieldValue);
                        docFieldWidgets.add(new EditableWidgetStorage(fieldValue));
                    } else {
                        // Create a drop down
                        final ListBox fieldValue = view.addDropDown(row,
                                batchClassPluginConfig.getSampleValue(), batchClassPluginConfig.getValue());
                        fieldValue.setName(batchClassPluginConfig.getPluginConfig().getFieldName());
                        if (batchClassPluginConfig.getPluginConfig().getFieldName()
                                .equalsIgnoreCase(PluginNameConstants.EXPORT_PLUGIN_TYPE_DESC)) {
                            hocrToPdfListBox = fieldValue;
                            fieldValue.addChangeHandler(new ChangeHandler() {

                                @Override
                                public void onChange(ChangeEvent arg0) {
                                    enableHocrToPdfProps(fieldValue);
                                }
                            });
                        }
                        if (batchClassPluginConfig.getPluginConfig().getFieldName().equalsIgnoreCase(
                                PluginNameConstants.CREATE_MULTIPAGE_PDF_OPTIMIZATION_SWITCH)) {
                            createMultipagePdfOptimizationSwitchListBox = fieldValue;
                            fieldValue.addChangeHandler(new ChangeHandler() {

                                @Override
                                public void onChange(ChangeEvent arg0) {
                                    enableCreateMultipageOptimizationProps(fieldValue);
                                }
                            });
                        }
                        if (batchClassPluginConfig.getPluginConfig().getFieldName()
                                .equalsIgnoreCase(PluginNameConstants.TABBED_PDF_OPTIMIZATION_SWITCH)) {
                            createMultipagePdfOptimizationSwitchListBox = fieldValue;
                            fieldValue.addChangeHandler(new ChangeHandler() {

                                @Override
                                public void onChange(ChangeEvent arg0) {
                                    enableTabbedPdfOptimizationProps(fieldValue);
                                }
                            });
                        }
                        view.addWidget(row, 2, fieldValue);
                        EditableWidgetStorage editableWidgetStorage = new EditableWidgetStorage(fieldValue);
                        editableWidgetStorage.setValidatable(Boolean.FALSE);
                        docFieldWidgets.add(editableWidgetStorage);
                    }
                } else {
                    // Create a read only text box
                    ValidatableWidget<TextBox> validatableTextBox = view.addTextBox(row, batchClassPluginConfig,
                            true);
                    view.addWidget(row, 2, validatableTextBox.getWidget());
                    EditableWidgetStorage editableWidgetStorage = new EditableWidgetStorage(validatableTextBox);
                    editableWidgetStorage.setValidatable(Boolean.FALSE);
                    docFieldWidgets.add(editableWidgetStorage);
                }
            } else {
                // Create a text box
                ValidatableWidget<TextBox> validatableTextBox = view.addTextBox(row, batchClassPluginConfig,
                        false);
                view.addWidget(row, 2, validatableTextBox.getWidget());
                EditableWidgetStorage editableWidgetStorage = new EditableWidgetStorage(validatableTextBox);
                if (batchClassPluginConfig.isMandatory()) {
                    editableWidgetStorage.setMandatory(true);
                }
                docFieldWidgets.add(editableWidgetStorage);
            }
            row++;
        }
        row++;
        // view.addButtons(row);
    }
    enableHocrToPdfProps(hocrToPdfListBox);
    enableCreateMultipageOptimizationProps(createMultipagePdfOptimizationSwitchListBox);
    enableTabbedPdfOptimizationProps(tabbedPdfOptimizationSwitchListBox);
}

From source file:com.ephesoft.dcma.gwt.core.client.util.GWTListBoxControl.java

License:Open Source License

public static ValidatableWidget<ListBox> createGWTListControl(String type, String actualValue,
        final String fieldName, List<String> regexPatterns, List<String> values) {

    ListBox optionList = new ListBox();
    ValidatableWidget<ListBox> optionListWidget = new ValidatableWidget<ListBox>(optionList);
    if (regexPatterns != null && !regexPatterns.isEmpty()) {
        optionListWidget.addValidator(new ListBoxPatternValidator(optionList, regexPatterns));
    }/*w  w  w .  ja va  2  s.  c om*/
    optionList.setName(fieldName != null ? fieldName : "");
    String item = "";
    int selectedIndex = -1;
    for (int itemIndex = 0; itemIndex < values.size(); itemIndex++) {
        item = values.get(itemIndex).trim();
        if (!item.isEmpty()) {
            optionList.addItem(item);
            if (!actualValue.trim().isEmpty() && item.equalsIgnoreCase(actualValue)) {
                selectedIndex = itemIndex;
            }
        }
    }

    if (selectedIndex > -1) {
        optionList.getElement().setAttribute("isActualValueFound", Boolean.TRUE.toString());
        optionList.setSelectedIndex(selectedIndex);
    } else {
        optionList.getElement().setAttribute("isActualValueFound", Boolean.FALSE.toString());
    }

    return optionListWidget;
}

From source file:com.google.gwt.examples.FormPanelExample.java

License:Apache License

public void onModuleLoad() {
    // Create a FormPanel and point it at a service.
    final FormPanel form = new FormPanel();
    form.setAction("/myFormHandler");

    // Because we're going to add a FileUpload widget, we'll need to set the
    // form to use the POST method, and multipart MIME encoding.
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    form.setWidget(panel);//from w  ww  .j a va2  s  .c om

    // Create a TextBox, giving it a name so that it will be submitted.
    final TextBox tb = new TextBox();
    tb.setName("textBoxFormElement");
    panel.add(tb);

    // Create a ListBox, giving it a name and some values to be associated with
    // its options.
    ListBox lb = new ListBox();
    lb.setName("listBoxFormElement");
    lb.addItem("foo", "fooValue");
    lb.addItem("bar", "barValue");
    lb.addItem("baz", "bazValue");
    panel.add(lb);

    // Create a FileUpload widget.
    FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    panel.add(upload);

    // Add a 'submit' button.
    panel.add(new Button("Submit", new ClickHandler() {
        public void onClick(ClickEvent event) {
            form.submit();
        }
    }));

    // Add an event handler to the form.
    form.addSubmitHandler(new FormPanel.SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            // This event is fired just before the form is submitted. We can take
            // this opportunity to perform validation.
            if (tb.getText().length() == 0) {
                Window.alert("The text box must not be empty");
                event.cancel();
            }
        }
    });
    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            // When the form submission is successfully completed, this event is
            // fired. Assuming the service returned a response of type text/html,
            // we can get the result text here (see the FormPanel documentation for
            // further explanation).
            Window.alert(event.getResults());
        }
    });

    RootPanel.get().add(form);
}

From source file:com.google.gwt.sample.stockwatcher.client.SitePage.java

private static void setControlTypeLBChangeHandlers(final ListBox lb) {
    lb.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent evenet) {
            lb.setEnabled(false);/* w w  w . ja v  a 2 s  .c o  m*/

            Utility.newRequestObj().actuatorSetControlType(lb.getTitle(), lb.getSelectedItemText(),
                    new AsyncCallback<String>() {
                        public void onFailure(Throwable caught) {
                            lb.setSelectedIndex(Integer.parseInt(lb.getName()));
                            lb.setEnabled(true);
                        }

                        public void onSuccess(String result) {
                            lb.setName(String.valueOf(lb.getSelectedIndex()));
                            lb.setEnabled(true);
                        }
                    });
        }
    });
}

From source file:com.siderakis.demo.client.FullFormDemo.java

License:Apache License

public FullFormDemo() {

    // Create a UploadFormPanel and point it at a service.
    final UploadFormPanel form = new UploadFormPanel();
    form.setAction(UPLOAD_ACTION_URL);
    form.setWidget(panel);/*from w w w.j av a2s. c  o m*/

    // Create a standard FileUpload.
    panel.add(new Label("Single File:"));
    final FileUpload upload = new FileUpload();
    upload.setName("singleUploadFormElement");
    panel.add(upload);

    // Create a TextBox, giving it a name so that it will be submitted.
    panel.add(new Label("Textbox:"));
    final TextBox tb = new TextBox();
    tb.setName("textBoxFormElement");
    panel.add(tb);

    // Create a ListBox, giving it a name and some values to be associated
    // with its options.
    panel.add(new Label("Listbox:"));
    final ListBox lb = new ListBox();
    lb.setName("listBoxFormElement");
    lb.addItem("foo", "fooValue");
    lb.addItem("bar", "barValue");
    lb.addItem("baz", "bazValue");
    panel.add(lb);

    // Add a 'submit' button.
    panel.add(new Button("Submit", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            form.submit();
        }
    }));

    // Create a SimpleProgressBar, add it to the panel. Also set it as the
    // status display for the form.
    final SimpleProgressBar simpleProgressBar = new SimpleProgressBar();
    panel.add(simpleProgressBar);

    form.setStatusDisplay(simpleProgressBar);

    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(final SubmitCompleteEvent event) {
            // TODO reset the form.
        }
    });
    outer.add(form);
    addSourceCodeLink("FullFormDemo");
}

From source file:gov.nist.appvet.gwt.client.gui.dialog.ReportUploadDialogBox.java

License:Open Source License

public ReportUploadDialogBox(String username, String sessionId, String appid, String servletURL,
        String[] availableToolNames, final String[] availableToolIDs) {
    super(false, true);

    setWidth("100%");
    setAnimationEnabled(false);/*from   ww  w.ja  va 2  s  .  c  o  m*/

    final VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    this.setWidget(dialogVPanel);
    dialogVPanel.setSize("", "");
    this.servletURL = servletURL;

    final SimplePanel simplePanel = new SimplePanel();
    simplePanel.setStyleName("reportUploadPanel");
    dialogVPanel.add(simplePanel);
    dialogVPanel.setCellVerticalAlignment(simplePanel, HasVerticalAlignment.ALIGN_MIDDLE);
    dialogVPanel.setCellHorizontalAlignment(simplePanel, HasHorizontalAlignment.ALIGN_CENTER);
    simplePanel.setSize("", "");
    uploadReportForm = new FormPanel();
    simplePanel.setWidget(uploadReportForm);
    uploadReportForm.setSize("", "");
    uploadReportForm.setAction(servletURL);
    uploadReportForm.setMethod(FormPanel.METHOD_POST);
    uploadReportForm.setEncoding(FormPanel.ENCODING_MULTIPART);

    final VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    uploadReportForm.setWidget(verticalPanel);
    verticalPanel.setSize("", "");

    final Hidden hiddenAppid = new Hidden();
    hiddenAppid.setName("appid");
    hiddenAppid.setValue(appid);
    verticalPanel.add(hiddenAppid);

    final Hidden hiddenUsername = new Hidden();
    hiddenUsername.setName("username");
    hiddenUsername.setValue(username);
    verticalPanel.add(hiddenUsername);

    final Hidden hiddenSessionId = new Hidden();
    hiddenSessionId.setName("sessionid");
    hiddenSessionId.setValue(sessionId);
    verticalPanel.add(hiddenSessionId);

    //      final Hidden hiddenAnalyst = new Hidden();
    //      hiddenAnalyst.setName("analyst");
    //      hiddenAnalyst.setValue(username);
    //      verticalPanel.add(hiddenAnalyst);

    final Hidden hiddenCommand = new Hidden();
    hiddenCommand.setValue("SUBMIT_REPORT");
    hiddenCommand.setName("command");
    verticalPanel.add(hiddenCommand);

    hiddenToolID = new Hidden();
    hiddenToolID.setName("toolid");
    verticalPanel.add(hiddenToolID);

    final Grid grid = new Grid(5, 2);
    grid.setCellPadding(5);
    grid.setStyleName("grid");
    verticalPanel.add(grid);
    grid.setHeight("210px");
    verticalPanel.setCellVerticalAlignment(grid, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellHorizontalAlignment(grid, HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setCellWidth(grid, "100%");

    final Label labelAnalyst = new Label("Analyst: ");
    labelAnalyst.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    labelAnalyst.setStyleName("reportUploadLabel");
    grid.setWidget(0, 0, labelAnalyst);
    labelAnalyst.setWidth("");

    final TextBox analystTextBox = new TextBox();
    analystTextBox.setAlignment(TextAlignment.LEFT);
    analystTextBox.setText(username);
    analystTextBox.setEnabled(true);
    analystTextBox.setReadOnly(true);
    grid.setWidget(0, 1, analystTextBox);
    grid.getCellFormatter().setHeight(0, 1, "18px");
    grid.getCellFormatter().setWidth(0, 1, "300px");
    grid.getCellFormatter().setStyleName(0, 1, "reportUploadWidget");
    analystTextBox.setSize("220px", "18px");

    final Label appIdLabel = new Label("App ID: ");
    appIdLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    grid.setWidget(1, 0, appIdLabel);
    grid.getCellFormatter().setWidth(1, 0, "300px");
    grid.getCellFormatter().setHeight(1, 1, "18px");
    grid.getCellFormatter().setWidth(1, 1, "300px");

    final TextBox appIdTextBox = new TextBox();
    appIdTextBox.setAlignment(TextAlignment.LEFT);
    appIdTextBox.setText(appid);
    appIdTextBox.setEnabled(true);
    appIdTextBox.setReadOnly(true);
    grid.setWidget(1, 1, appIdTextBox);
    grid.getCellFormatter().setStyleName(1, 1, "reportUploadWidget");
    appIdTextBox.setSize("220px", "18px");

    final Label toolNameLabel = new Label("Tool: ");
    toolNameLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    grid.setWidget(2, 0, toolNameLabel);
    toolNameLabel.setWidth("90px");
    grid.getCellFormatter().setWidth(2, 1, "300px");
    toolNamesComboBox = new ListBox();

    grid.setWidget(2, 1, toolNamesComboBox);
    grid.getCellFormatter().setHeight(2, 1, "18px");
    grid.getCellFormatter().setStyleName(2, 1, "reportUploadWidget");
    toolNamesComboBox.setSize("231px", "22px");

    final Label lblReport = new Label("Report: ");
    lblReport.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    grid.setWidget(3, 0, lblReport);
    grid.getCellFormatter().setWidth(3, 1, "300px");
    fileUpload = new FileUpload();
    fileUpload.setName("fileupload");
    grid.setWidget(3, 1, fileUpload);
    grid.getCellFormatter().setHeight(3, 1, "18px");
    grid.getCellFormatter().setStyleName(3, 1, "reportUploadWidget");
    fileUpload.setSize("189px", "22px");

    final Label riskLabel = new Label("Risk: ");
    riskLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    grid.setWidget(4, 0, riskLabel);
    grid.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    grid.getCellFormatter().setWidth(4, 1, "300px");
    grid.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    grid.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
    grid.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    grid.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    grid.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT);
    grid.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
    grid.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
    grid.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_MIDDLE);

    ListBox toolRiskComboBox = new ListBox();
    toolRiskComboBox.setName("toolrisk");
    toolRiskComboBox.addItem("PASS");
    toolRiskComboBox.addItem("WARNING");
    toolRiskComboBox.addItem("FAIL");
    grid.setWidget(4, 1, toolRiskComboBox);
    grid.getCellFormatter().setHeight(4, 1, "18px");
    grid.getCellFormatter().setStyleName(4, 1, "reportUploadWidget");
    toolRiskComboBox.setSize("231px", "22px");
    grid.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    grid.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
    grid.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    statusLabel = new Label("");
    statusLabel.setStyleName("submissionRequirementsLabel");
    verticalPanel.add(statusLabel);
    verticalPanel.setCellWidth(statusLabel, "100%");
    verticalPanel.setCellVerticalAlignment(statusLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.setCellHorizontalAlignment(statusLabel, HasHorizontalAlignment.ALIGN_CENTER);
    statusLabel.setHeight("20px");

    final HorizontalPanel horizontalButtonPanel = new HorizontalPanel();
    horizontalButtonPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalButtonPanel.setStyleName("reportUploadButtonPanel");
    dialogVPanel.add(horizontalButtonPanel);
    dialogVPanel.setCellVerticalAlignment(horizontalButtonPanel, HasVerticalAlignment.ALIGN_MIDDLE);
    dialogVPanel.setCellHorizontalAlignment(horizontalButtonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    dialogVPanel.setCellWidth(horizontalButtonPanel, "100%");
    horizontalButtonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    horizontalButtonPanel.setSize("210px", "");
    cancelButton = new PushButton("Cancel");
    cancelButton.setHTML("Cancel");
    horizontalButtonPanel.add(cancelButton);
    cancelButton.setSize("70px", "18px");
    horizontalButtonPanel.setCellVerticalAlignment(cancelButton, HasVerticalAlignment.ALIGN_MIDDLE);
    horizontalButtonPanel.setCellHorizontalAlignment(cancelButton, HasHorizontalAlignment.ALIGN_CENTER);
    submitButton = new PushButton("Submit");
    horizontalButtonPanel.add(submitButton);
    horizontalButtonPanel.setCellHorizontalAlignment(submitButton, HasHorizontalAlignment.ALIGN_CENTER);
    horizontalButtonPanel.setCellVerticalAlignment(submitButton, HasVerticalAlignment.ALIGN_MIDDLE);
    submitButton.setSize("70px", "18px");
    verticalPanel.setCellWidth(horizontalButtonPanel, "100%");

    submitButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // Set toolid first
            int selectedToolNameIndex = toolNamesComboBox.getSelectedIndex();
            String toolID = availableToolIDs[selectedToolNameIndex];
            hiddenToolID.setValue(toolID);

            uploadReportForm.submit();
        }

    });

    for (final String availableTool : availableToolNames) {
        final String toolName = availableTool;
        if ((toolName != null) && !toolName.isEmpty()) {
            toolNamesComboBox.addItem(availableTool);
        }
    }
}

From source file:it.fub.jardin.client.widget.JardinSelectColumnsForChartPopUp.java

License:Open Source License

/**
 * Create a new Detail Area for Impianti printing all available fields
 *///from  w w  w .ja  va 2  s .com
public JardinSelectColumnsForChartPopUp(final JardinGrid grid, final String ct) {

    this.grid = grid;

    /* Impostazione caratteristiche di Window */
    this.setMinHeight(210);
    // this.setMinWidth(1000);
    this.setPlain(true);
    this.setTitle("Selezione le colonne");
    this.setLayout(new FitLayout());

    this.resultset = grid.getResultset();

    /* Creazione FormPanel */
    this.formPanel = new FormPanel();
    this.formPanel.setBodyBorder(false);
    this.formPanel.setHeaderVisible(false);
    this.formPanel.setScrollMode(Scroll.AUTO);

    final ListBox lbTitle = new ListBox();
    lbTitle.setVisibleItemCount(1);
    lbTitle.setName("title");
    lbTitle.setTitle("Colonna titolo");

    final ListBox lbValue = new ListBox();
    lbValue.setVisibleItemCount(1);
    lbValue.setName("value");
    lbValue.setTitle("Colonna valore");

    /* Recupero le informazioni sui campi */
    BaseModelData fieldsInfo = new BaseModelData();
    for (ResultsetField field : this.resultset.getFields()) {
        fieldsInfo.set(field.getName(), field.getType());
        // System.out.println(field.getType());
    }

    ColumnModel cm = this.grid.getColumnModel();
    for (int i = 0; i < cm.getColumnCount(); i++) {
        if (!(cm.getColumn(i).isHidden())) {
            lbTitle.addItem(cm.getColumn(i).getId());
            if ((fieldsInfo.get(cm.getColumn(i).getId()).toString().compareToIgnoreCase("int") == 0)
                    || (fieldsInfo.get(cm.getColumn(i).getId()).toString().compareToIgnoreCase("real") == 0)) {
                lbValue.addItem(cm.getColumn(i).getId());
            }
        }
    }
    // formPanel.addText("Verranno visualizzate solo le prime 50 righe.<br /><br />");
    this.formPanel.addText("Colonna titolo:<br />");
    this.formPanel.add(lbTitle);
    this.formPanel.addText("<br />Colonna valore:<br />");
    this.formPanel.add(lbValue);
    this.formPanel.addText("<br />");
    this.button = new Button("Crea grafico");
    this.formPanel.add(this.button);

    this.button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            ArrayList<String> dataToChart = new ArrayList<String>();
            dataToChart.add(ct);
            dataToChart.add("" + JardinSelectColumnsForChartPopUp.this.resultset.getId());
            dataToChart.add(lbTitle.getValue(lbTitle.getSelectedIndex()));
            dataToChart.add(lbValue.getValue(lbValue.getSelectedIndex()));
            Dispatcher.forwardEvent(EventList.ShowChart, dataToChart);
            //
            JardinSelectColumnsForChartPopUp.this.removeAll();
            JardinSelectColumnsForChartPopUp.this.hide();
        }
    });

    this.add(this.formPanel);

}

From source file:org.nuxeo.ecm.platform.annotations.gwt.client.view.NewAnnotationPopup.java

License:Apache License

public NewAnnotationPopup(final Element element, final AnnotationController controller,
        final boolean removeOnCancel, final String annotationType, final String annotationName) {
    this.controller = controller;
    this.element = element;
    this.removeOnCancel = removeOnCancel;

    GWT.log("creating new annotation pop up", null);
    int scroll = Document.get().getBody().getScrollTop();
    controller.setFrameScrollFromTop(scroll);
    dockPanel.setStyleName("annotationsNewAnnotationPopup");

    dockPanel.add(verticalPanel, DockPanel.NORTH);
    dockPanel.add(annotationTextArea, DockPanel.CENTER);
    dockPanel.add(flowPanel, DockPanel.SOUTH);

    if (annotationName != null) {
        selectedAnnotationType = annotationName;
        // Add into the view
        verticalPanel.add(new Label(selectedAnnotationType));

        Map<String, String[]> fields = controller.getWebConfiguration().getAnnotationDefinition(annotationName)
                .getFields();//from   w w w  .  j ava2  s.  com
        for (String fieldName : fields.keySet()) {
            ListBox fieldListBox = new ListBox();
            fieldListBox.setName(fieldName);
            for (String choice : fields.get(fieldName)) {
                fieldListBox.addItem(choice);
            }
            fieldListBoxes.add(fieldListBox);

            // Add into the view
            verticalPanel.add(fieldListBox);
        }
    } else {
        WebConfiguration webConf = controller.getWebConfiguration();
        List<AnnotationDefinition> annotationDefs = webConf
                .getAnnotationDefinitions(new TypeFilter(annotationType));
        if (annotationDefs.size() == 1) {
            selectedAnnotationType = annotationDefs.get(0).getName();
            String label = selectedAnnotationType;
            // If this is the default annotation (Comment), internationalize the
            // title
            if (label.equals(AnnotationConstant.COMMENT_ANNOTATION_NAME)) {
                TranslationConstants translationContants = GWT.create(TranslationConstants.class);
                label = translationContants.comment();
            }

            // Add into the view
            verticalPanel.add(new Label(label));
        } else {
            for (AnnotationDefinition annotationDef : annotationDefs) {
                listBox.addItem(annotationDef.getName());
            }

            // Add into the view
            verticalPanel.add(listBox);
        }

    }

    TranslationConstants translationContants = GWT.create(TranslationConstants.class);
    submit = new Button(translationContants.submit());
    submit.setEnabled(false);
    flowPanel.add(submit);
    cancel = new Button(translationContants.cancel());
    flowPanel.add(cancel);
    submit.addClickListener(new CommitListener(element, annotationName));

    cancel.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            cancel();
        }
    });

    this.add(dockPanel);
}

From source file:org.overlord.gadgets.web.client.widgets.Portlet.java

License:Open Source License

private Widget createSelectBox(String name, String defaultVal, List<String> options) {
    ListBox listBox = new ListBox(false);
    listBox.setName(name);
    listBox.getElement().setId(name);/*from  ww  w. ja  va 2  s . c om*/
    for (String option : options) {
        listBox.addItem(option);
    }
    if (options.size() == 0) {
        listBox.addItem(" ");
    }
    int index = 0;
    for (int i = 0; i < options.size(); i++) {
        if (options.get(i).equals(defaultVal)) {
            index = i;
        }
    }
    listBox.setSelectedIndex(index);
    return listBox;
}

From source file:org.overlord.sramp.ui.client.widgets.ArtifactUploadForm.java

License:Apache License

/**
 * Constructor./*from  w ww. j  a va 2 s  . c  om*/
 * @param url
 */
public ArtifactUploadForm(String url) {
    ILocalizationService i18n = Services.getServices().getService(ILocalizationService.class);

    this.setAction(url);
    this.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.
    VerticalPanel vpanel = new VerticalPanel();

    final ListBox artifactType = new ListBox();
    final Button submitButton = new Button(i18n.translate("widgets.artifact-upload.submit"));

    // Populate the type list box with options
    artifactType.setName("artifactType");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.please-choose"), "");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.choice.doc"), "Document");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.choice.xml"), "XmlDocument");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.choice.xsd"), "XsdDocument");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.choice.wsdl"), "WsdlDocument");
    artifactType.addItem(i18n.translate("widgets.artifact-upload.choice.policy"), "PolicyDocument");
    artifactType.setSelectedIndex(0);

    // Configure the file upload widget
    upload.getElement().setClassName("file");
    upload.setName("artifact");

    // Hook into the submit button
    submitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            submit();
        }
    });
    submitButton.setEnabled(false);

    // Add all the widgets to the form.
    vpanel.add(upload);
    vpanel.add(artifactType);
    vpanel.add(submitButton);

    // Create a change handler that will enable/disable the Submit button.
    ChangeHandler changeHandler = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            boolean validSelection = !"".equals(artifactType.getValue(artifactType.getSelectedIndex()));
            boolean validFile = upload.getFilename() != null && upload.getFilename().trim().length() > 0;
            submitButton.setEnabled(validSelection && validFile);
        }
    };
    upload.addChangeHandler(changeHandler);
    upload.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            String filename = upload.getFilename().toLowerCase();
            if (filename.endsWith(".xml")) {
                artifactType.setSelectedIndex(2);
            } else if (filename.endsWith(".xsd")) {
                artifactType.setSelectedIndex(3);
            } else if (filename.endsWith(".wsdl")) {
                artifactType.setSelectedIndex(4);
            } else if (filename.endsWith(".wspolicy")) {
                artifactType.setSelectedIndex(5);
            } else {
                artifactType.setSelectedIndex(1);
            }
            submitButton.setEnabled(true);
        }
    });
    artifactType.addChangeHandler(changeHandler);

    setWidget(vpanel);
}