Example usage for com.google.gwt.user.client.ui CheckBox setEnabled

List of usage examples for com.google.gwt.user.client.ui CheckBox setEnabled

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

From source file:com.gwtmodel.table.view.grid.GridView.java

License:Apache License

@Override
public void setReadOnly(boolean readOnly) {
    for (int r = 0; r < rowNo; r++) {
        for (int c = 0; c < colNo; c++) {
            Widget w = getW(r, c);/* ww  w.  j a  v a  2  s .  co m*/
            switch (gType.getgType()) {
            case BOOLEAN:
                CheckBox ce = (CheckBox) w;
                ce.setEnabled(!readOnly);
                break;
            case DECIMAL:
                NumerW nw = (NumerW) w;
                IFormLineView i = nw.iF;
                i.setReadOnly(readOnly);
                break;
            }
        }
    }
}

From source file:com.ikon.frontend.client.widget.form.FormManager.java

License:Open Source License

/**
 * drawFormElement//w w w  .  j a  va 2  s . com
 */
private void drawFormElement(int row, final GWTFormElement gwtFormElement, boolean readOnly,
        boolean searchView) {
    final String propertyName = gwtFormElement.getName();

    if (gwtFormElement instanceof GWTButton) {
        final GWTButton gWTButton = (GWTButton) gwtFormElement;

        if (submitForm != null) {
            submitForm.setVisible(false); // Always set form hidden because there's new buttons
        }

        Button transButton = new Button(gWTButton.getLabel());
        String style = Character.toUpperCase(gWTButton.getStyle().charAt(0))
                + gWTButton.getStyle().substring(1);
        transButton.setStyleName("okm-" + style + "Button");
        HTML space = new HTML("&nbsp;");
        submitButtonPanel.add(transButton);
        submitButtonPanel.add(space);
        submitButtonPanel.setCellWidth(space, "5px");

        // Setting submit button
        transButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (gWTButton.getConfirmation() != null && !gWTButton.getConfirmation().equals("")) {
                    Main.get().confirmPopup.setConfirm(ConfirmPopup.CONFIRM_WORKFLOW_ACTION);
                    Main.get().confirmPopup.setConfirmationText(gWTButton.getConfirmation());
                    ValidationButton validationButton = new ValidationButton(gWTButton, singleton);
                    Main.get().confirmPopup.setValue(validationButton);
                    Main.get().confirmPopup.center();
                } else {
                    if (gWTButton.isValidate()) {
                        if (validationProcessor.validate()) {
                            if (gWTButton.getTransition().equals("")) {
                                workflow.setTaskInstanceValues(taskInstance.getId(), null);
                            } else {
                                workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition());
                            }
                            disableAllButtonList();
                        }
                    } else {
                        if (gWTButton.getTransition().equals("")) {
                            workflow.setTaskInstanceValues(taskInstance.getId(), null);
                        } else {
                            workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition());
                        }
                        disableAllButtonList();
                    }
                }
            }
        });

        // Adding button to control list
        if (!buttonControlList.contains(transButton)) {
            buttonControlList.add(transButton);
        }
    } else if (gwtFormElement instanceof GWTTextArea) {
        HorizontalPanel hPanel = new HorizontalPanel();
        TextArea textArea = new TextArea();
        textArea.setEnabled((!readOnly && !((GWTTextArea) gwtFormElement).isReadonly()) || isSearchView); // read only
        hPanel.add(textArea);
        textArea.setStyleName("okm-TextArea");
        textArea.setText(((GWTTextArea) gwtFormElement).getValue());
        textArea.setSize(gwtFormElement.getWidth(), gwtFormElement.getHeight());
        HTML text = new HTML(); // Create a widget for this property
        text.setHTML(((GWTTextArea) gwtFormElement).getValue().replaceAll("\n", "<br>"));
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, text);
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    search.propertyRemoved();
                }
            });

            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (search != null) {
                textArea.addKeyUpHandler(new KeyUpHandler() {
                    @Override
                    public void onKeyUp(KeyUpEvent event) {
                        search.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTInput) {
        final HorizontalPanel hPanel = new HorizontalPanel();
        final TextBox textBox = new TextBox(); // Create a widget for this property
        textBox.setEnabled((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only
        hPanel.add(textBox);
        String value = "";

        if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_TEXT)
                || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK)
                || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) {
            textBox.setText(((GWTInput) gwtFormElement).getValue());
            value = ((GWTInput) gwtFormElement).getValue();
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
            if (((GWTInput) gwtFormElement).getDate() != null) {
                DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                textBox.setText(dtf.format(((GWTInput) gwtFormElement).getDate()));
                value = dtf.format(((GWTInput) gwtFormElement).getDate());
            }
        }

        textBox.setWidth(gwtFormElement.getWidth());
        textBox.setStyleName("okm-Input");
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setHTML(row, 1, value);

        if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
            final PopupPanel calendarPopup = new PopupPanel(true);
            final CalendarWidget calendar = new CalendarWidget();

            calendar.addChangeHandler(new ChangeHandler() {
                @Override
                public void onChange(ChangeEvent event) {
                    calendarPopup.hide();
                    DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                    textBox.setText(dtf.format(calendar.getDate()));
                    ((GWTInput) gwtFormElement).setDate(calendar.getDate());

                    if (search != null) {
                        search.metadataValueChanged();
                    }
                }
            });

            calendarPopup.add(calendar);
            final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar());

            if (readOnly || ((GWTInput) gwtFormElement).isReadonly()) { // read only
                calendarIcon.setResource(OKMBundleResources.INSTANCE.calendarDisabled());
            } else {
                calendarIcon.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(),
                                calendarIcon.getAbsoluteTop() - 2);
                        if (calendar.getDate() != null) {
                            calendar.setNow((Date) calendar.getDate().clone());
                        } else {
                            calendar.setNow(null);
                        }
                        calendarPopup.show();
                    }
                });
            }

            calendarIcon.setStyleName("okm-Hyperlink");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(calendarIcon);
            textBox.setEnabled(false);
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK)) {
            if (!value.equals("")) {
                HorizontalPanel hLinkPanel = new HorizontalPanel();
                Anchor anchor = new Anchor(value, true);
                final String url = value;

                anchor.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Window.open(url, url, "");
                    }
                });

                anchor.setStyleName("okm-Hyperlink");
                String containerName = ((GWTInput) gwtFormElement).getName() + "ContainerName";
                hLinkPanel.add(new HTML("<div id=\"" + containerName + "\"></div>\n"));
                HTML space = new HTML("");
                hLinkPanel.add(space);
                hLinkPanel.add(anchor);
                hLinkPanel.setCellWidth(space, "5px");
                table.setWidget(row, 1, hLinkPanel);
                Util.createLinkClipboardButton(url, containerName);
            } else {
                table.setHTML(row, 1, "");
            }
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) {
            if (!value.equals("")) {
                Anchor anchor = new Anchor();
                final GWTFolder folder = ((GWTInput) gwtFormElement).getFolder();

                // remove first ocurrence
                String path = value.substring(value.indexOf("/", 1) + 1);

                // Looks if must change icon on parent if now has no childs and properties with user security
                // atention
                if (folder.isHasChildren()) {
                    anchor.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", path, "top"));
                } else {
                    anchor.setHTML(Util.imageItemHTML("img/menuitem_empty.gif", path, "top"));
                }

                anchor.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent arg0) {
                        CommonUI.openPath(folder.getPath(), null);
                    }
                });

                anchor.setStyleName("okm-KeyMap-ImageHover");
                table.setWidget(row, 1, anchor);
            } else {
                table.setHTML(row, 1, "");
            }

            Image pathExplorer = new Image(OKMBundleResources.INSTANCE.folderExplorer());
            pathExplorer.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    // when any changes is done is fired search.metadataValueChanged();
                    folderSelectPopup.show(textBox, search);
                }
            });

            pathExplorer.setStyleName("okm-KeyMap-ImageHover");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(pathExplorer);
            hPanel.setCellVerticalAlignment(pathExplorer, HasAlignment.ALIGN_MIDDLE);
            pathExplorer.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only
            textBox.setEnabled(false);
        }

        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView) {
            // Second date input
            if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
                final TextBox textBoxTo = new TextBox();
                textBoxTo.setWidth(gwtFormElement.getWidth());
                textBoxTo.setStyleName("okm-Input");
                hPanel.add(new HTML("&nbsp;&harr;&nbsp;"));
                hPanel.add(textBoxTo);

                if (((GWTInput) gwtFormElement).getDateTo() != null) {
                    DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                    textBoxTo.setText(dtf.format(((GWTInput) gwtFormElement).getDateTo()));
                }

                final PopupPanel calendarPopup = new PopupPanel(true);
                final CalendarWidget calendar = new CalendarWidget();
                calendar.addChangeHandler(new ChangeHandler() {
                    @Override
                    public void onChange(ChangeEvent event) {
                        calendarPopup.hide();
                        DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                        textBoxTo.setText(dtf.format(calendar.getDate()));
                        ((GWTInput) gwtFormElement).setDateTo(calendar.getDate());

                        if (search != null) {
                            search.metadataValueChanged();
                        }
                    }
                });

                calendarPopup.add(calendar);
                final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar());
                calendarIcon.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(),
                                calendarIcon.getAbsoluteTop() - 2);
                        calendarPopup.show();
                    }
                });

                calendarIcon.setStyleName("okm-Hyperlink");
                hPanel.add(Util.hSpace("5"));
                hPanel.add(calendarIcon);
                textBoxTo.setEnabled(false);

                // Clean
                final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon());
                cleanIcon.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        TextBox textBox = (TextBox) hPanel.getWidget(0);
                        textBox.setText("");
                        textBoxTo.setText("");
                        ((GWTInput) gwtFormElement).setDate(null);
                        ((GWTInput) gwtFormElement).setDateTo(null);
                    }
                });
                cleanIcon.setStyleName("okm-Hyperlink");
                hPanel.add(Util.hSpace("5"));
                hPanel.add(cleanIcon);
            }

            // Delete
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    search.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (search != null) {
                textBox.addKeyUpHandler(new KeyUpHandler() {
                    @Override
                    public void onKeyUp(KeyUpEvent event) {
                        search.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            // Clean icon ( case is not readonly )
            final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon());
            cleanIcon.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    TextBox textBox = (TextBox) hPanel.getWidget(0);
                    textBox.setText("");
                    ((GWTInput) gwtFormElement).setDate(null);
                    ((GWTInput) gwtFormElement).setFolder(new GWTFolder());
                }
            });
            cleanIcon.setStyleName("okm-Hyperlink");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(cleanIcon);
            cleanIcon.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly())); // read only

            setRowWordWarp(row, 2, true);
        }

    } else if (gwtFormElement instanceof GWTSuggestBox) {
        HorizontalPanel hPanel = new HorizontalPanel();
        final GWTSuggestBox suggestBox = (GWTSuggestBox) gwtFormElement;
        final TextBox textBox = new TextBox(); // Create a widget for this property
        textBox.setWidth(gwtFormElement.getWidth());
        textBox.setStyleName("okm-Input");
        textBox.setReadOnly(true);
        textBox.setEnabled((!readOnly && !suggestBox.isReadonly()) || isSearchView); // read only 
        final HTML hiddenKey = new HTML("");
        hiddenKey.setVisible(false);

        if (suggestBox.getValue() != null) {
            hiddenKey.setHTML(suggestBox.getValue());
        }

        hPanel.add(textBox);
        hPanel.add(hiddenKey);
        final HTML value = new HTML("");
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, value);
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (textBox.isEnabled()) {
            final Image databaseRecordImage = new Image(OKMBundleResources.INSTANCE.databaseRecord());
            databaseRecordImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    List<String> tables = new ArrayList<String>();
                    if (suggestBox.getTable() != null) {
                        tables.add(suggestBox.getTable());
                    }

                    DatabaseRecord databaseRecord = new DatabaseRecord(hiddenKey, textBox);
                    // when any changes is done is fired search.metadataValueChanged();
                    DatabaseRecordSelectPopup drsPopup = new DatabaseRecordSelectPopup(suggestBox,
                            databaseRecord, search);
                    drsPopup.setWidth("300");
                    drsPopup.setHeight("220");
                    drsPopup.setStyleName("okm-Popup");
                    drsPopup.setPopupPosition(databaseRecordImage.getAbsoluteLeft(),
                            databaseRecordImage.getAbsoluteTop() - 2);
                    drsPopup.show();
                }
            });
            databaseRecordImage.setStyleName("okm-Hyperlink");
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(databaseRecordImage);
        }

        hWidgetProperties.put(propertyName, hPanel);
        if (!suggestBox.getValue().equals("")) {
            textBox.setValue(suggestBox.getText());
            value.setHTML(suggestBox.getText());
            hiddenKey.setHTML(suggestBox.getValue());

            /*List<String> tables = new ArrayList<String>();
                    
            if (suggestBox.getTable() != null) {
               tables.add(suggestBox.getTable());
            }
                    
            String formatedQuery = MessageFormat.format(suggestBox.getValueQuery(), suggestBox.getValue());
            keyValueService.getKeyValues(tables, formatedQuery, new AsyncCallback<List<GWTKeyValue>>() {
               @Override
               public void onSuccess(List<GWTKeyValue> result) {
                  if (!result.isEmpty()) {
             GWTKeyValue keyValue = result.get(0);
             textBox.setValue(keyValue.getValue());
             value.setHTML(keyValue.getValue());
             hiddenKey.setHTML(keyValue.getKey());
                  }
               }
                       
               @Override
               public void onFailure(Throwable caught) {
                  Main.get().showError("getKeyValues", caught);
               }
            }); */
        }

        if (searchView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    search.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);
            textBox.addKeyUpHandler(
                    Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler);
            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTCheckBox) {
        CheckBox checkBox = new CheckBox();
        checkBox.setEnabled((!readOnly && !((GWTCheckBox) gwtFormElement).isReadonly()) || isSearchView); // read only
        checkBox.setValue(((GWTCheckBox) gwtFormElement).getValue());
        hWidgetProperties.put(propertyName, checkBox);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");

        if (checkBox.getValue()) {
            table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.yes()));
        } else {
            table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.no()));
        }

        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    search.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (search != null) {
                checkBox.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        search.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTSelect) {
        final GWTSelect gwtSelect = (GWTSelect) gwtFormElement;

        if (!gwtSelect.getOptionsData().equals("")
                && workflowVarMap.keySet().contains(gwtSelect.getOptionsData())) {
            gwtSelect.setOptions(getOptionsFromVariable(workflowVarMap.get(gwtSelect.getOptionsData())));
        }

        if (gwtSelect.getType().equals(GWTSelect.TYPE_SIMPLE)) {
            String selectedLabel = "";
            HorizontalPanel hPanel = new HorizontalPanel();
            ListBox listBox = new ListBox();
            listBox.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            hPanel.add(listBox);
            listBox.setStyleName("okm-Select");
            listBox.addItem("", ""); // Always we set and empty value

            for (GWTOption option : gwtSelect.getOptions()) {
                listBox.addItem(option.getLabel(), option.getValue());
                if (option.isSelected()) {
                    listBox.setItemSelected(listBox.getItemCount() - 1, true);
                    selectedLabel = option.getLabel();
                }
            }

            hWidgetProperties.put(propertyName, hPanel);

            table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
            table.setHTML(row, 1, selectedLabel);
            table.getCellFormatter().setWidth(row, 1, "100%");

            if (searchView) {
                final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
                removeImage.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        for (int row = 0; row < table.getRowCount(); row++) {
                            if (table.getWidget(row, 2).equals(removeImage)) {
                                table.removeRow(row);
                                break;
                            }
                        }

                        hWidgetProperties.remove(propertyName);
                        hPropertyParams.remove(propertyName);
                        formElementList.remove(gwtFormElement);
                        search.propertyRemoved();
                    }
                });
                removeImage.addStyleName("okm-Hyperlink");
                table.setWidget(row, 2, removeImage);
                table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

                if (search != null) {
                    listBox.addChangeHandler(new ChangeHandler() {
                        @Override
                        public void onChange(ChangeEvent event) {
                            search.metadataValueChanged();
                        }
                    });
                }

                setRowWordWarp(row, 3, true);
            } else {
                setRowWordWarp(row, 2, true);
            }

        } else if (gwtSelect.getType().equals(GWTSelect.TYPE_MULTIPLE)) {
            final HorizontalPanel hPanel = new HorizontalPanel();
            ListBox listMulti = new ListBox();
            listMulti.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            listMulti.setStyleName("okm-Select");
            listMulti.addItem("", ""); // Always we set and empty value

            // Table for values
            FlexTable tableMulti = new FlexTable();

            Button addButton = new Button(Main.i18n("button.add"), new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                    FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                    ListBox listMulti = (ListBox) hPanel.getWidget(2);
                    Button addButton = (Button) hPanel.getWidget(4);

                    if (listMulti.getSelectedIndex() > 0) {
                        final HTML htmlValue = new HTML(listMulti.getValue(listMulti.getSelectedIndex()));
                        int rowTableMulti = tableMulti.getRowCount();
                        Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());

                        removeImage.addClickHandler(new ClickHandler() {
                            @Override
                            public void onClick(ClickEvent event) {
                                Widget sender = (Widget) event.getSource();
                                HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                                FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                                ListBox listMulti = (ListBox) hPanel.getWidget(2);
                                Button addButton = (Button) hPanel.getWidget(4);
                                String value = htmlValue.getText();
                                String optionLabel = "";

                                for (Iterator<GWTOption> itOptions = gwtSelect.getOptions()
                                        .iterator(); itOptions.hasNext();) {
                                    GWTOption option = itOptions.next();
                                    if (option.getValue().equals(htmlValue.getText())) {
                                        optionLabel = option.getLabel();
                                        break;
                                    }
                                }

                                listMulti.addItem(optionLabel, value);
                                listMulti.setVisible(true);
                                addButton.setVisible(true);

                                // Looking for row to delete
                                for (int i = 0; i < tableMulti.getRowCount(); i++) {
                                    if (tableMulti.getWidget(i, 1).equals(sender)) {
                                        tableMulti.removeRow(i);
                                    }
                                }

                                if (search != null) {
                                    search.metadataValueChanged();
                                }
                            }
                        });
                        removeImage.setStyleName("okm-Hyperlink");

                        tableMulti.setWidget(rowTableMulti, 0, htmlValue);
                        tableMulti.setWidget(rowTableMulti, 1, removeImage);
                        tableMulti.setHTML(rowTableMulti, 2,
                                listMulti.getItemText(listMulti.getSelectedIndex()));

                        setRowWordWarp(tableMulti, rowTableMulti, 2, true);
                        listMulti.removeItem(listMulti.getSelectedIndex());
                        htmlValue.setVisible(false);

                        if (listMulti.getItemCount() <= 1) {
                            listMulti.setVisible(false);
                            addButton.setVisible(false);
                        }

                        if (search != null) {
                            search.metadataValueChanged();
                        }
                    }
                }
            });

            addButton.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            addButton.setStyleName("okm-AddButton");

            hPanel.add(tableMulti);
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(listMulti);
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(addButton);
            hPanel.setVisible(true);
            listMulti.setVisible(false);
            addButton.setVisible(false);
            hPanel.setCellVerticalAlignment(tableMulti, VerticalPanel.ALIGN_TOP);
            hPanel.setCellVerticalAlignment(listMulti, VerticalPanel.ALIGN_TOP);
            hPanel.setCellVerticalAlignment(addButton, VerticalPanel.ALIGN_TOP);
            hPanel.setHeight("100%");

            table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
            table.setWidget(row, 1, hPanel);
            table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
            table.getCellFormatter().setVerticalAlignment(row, 1, VerticalPanel.ALIGN_TOP);
            table.getCellFormatter().setWidth(row, 1, "100%");

            for (Iterator<GWTOption> itData = gwtSelect.getOptions().iterator(); itData.hasNext();) {
                final GWTOption option = itData.next();

                // Looks if there's some selected value
                if (option.isSelected()) {
                    int rowTableMulti = tableMulti.getRowCount();
                    HTML htmlValue = new HTML(option.getValue());

                    Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); // read only for this element goes at edit() logic
                    removeImage.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            Widget sender = (Widget) event.getSource();
                            HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                            FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                            ListBox listMulti = (ListBox) hPanel.getWidget(2);
                            Button addButton = (Button) hPanel.getWidget(4);

                            listMulti.addItem(option.getLabel(), option.getValue());
                            listMulti.setVisible(true);
                            addButton.setVisible(true);

                            // Looking for row to delete
                            for (int i = 0; i < tableMulti.getRowCount(); i++) {
                                if (tableMulti.getWidget(i, 1).equals(sender)) {
                                    tableMulti.removeRow(i);
                                }
                            }

                            if (search != null) {
                                search.metadataValueChanged();
                            }
                        }
                    });
                    removeImage.setStyleName("okm-Hyperlink");

                    tableMulti.setWidget(rowTableMulti, 0, htmlValue);
                    tableMulti.setWidget(rowTableMulti, 1, removeImage);
                    tableMulti.setHTML(rowTableMulti, 2, option.getLabel());
                    setRowWordWarp(tableMulti, rowTableMulti, 2, true);
                    htmlValue.setVisible(false);
                    removeImage.setVisible(false);
                } else {
                    listMulti.addItem(option.getLabel(), option.getValue());
                }
            }

            // Save panel
            hWidgetProperties.put(propertyName, hPanel);

            if (searchView) {
                final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
                removeImage.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        for (int row = 0; row < table.getRowCount(); row++) {
                            if (table.getWidget(row, 2).equals(removeImage)) {
                                table.removeRow(row);
                                break;
                            }
                        }

                        hWidgetProperties.remove(propertyName);
                        hPropertyParams.remove(propertyName);
                        formElementList.remove(gwtFormElement);
                        search.propertyRemoved();
                    }
                });
                removeImage.addStyleName("okm-Hyperlink");
                table.setWidget(row, 2, removeImage);
                table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

                // not implemented
                // textBox.addKeyUpHandler(Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler);
                setRowWordWarp(row, 3, true);
            } else {
                setRowWordWarp(row, 2, true);
            }
        }
    } else if (gwtFormElement instanceof GWTUpload) {
        final GWTUpload upload = (GWTUpload) gwtFormElement;
        HorizontalPanel hPanel = new HorizontalPanel();
        FileUpload fileUpload = new FileUpload();
        fileUpload.setStyleName("okm-Input");
        fileUpload.getElement().setAttribute("size", "" + upload.getWidth());
        final Anchor documentLink = new Anchor();

        // Setting document link by uuid
        if (upload.getDocumentUuid() != null && !upload.getDocumentUuid().equals("")) {
            repositoryService.getPathByUUID(upload.getDocumentUuid(), new AsyncCallback<String>() {
                @Override
                public void onSuccess(String result) {
                    documentService.get(result, new AsyncCallback<GWTDocument>() {
                        @Override
                        public void onSuccess(GWTDocument result) {
                            final String docPath = result.getPath();
                            documentLink.setText(result.getName());
                            documentLink.addClickHandler(new ClickHandler() {
                                @Override
                                public void onClick(ClickEvent event) {
                                    String path = docPath.substring(0, docPath.lastIndexOf("/"));
                                    CommonUI.openPath(path, docPath);
                                }
                            });
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            Main.get().showError("getDocument", caught);
                        }
                    });
                }

                @Override
                public void onFailure(Throwable caught) {
                    Main.get().showError("getPathByUUID", caught);
                }
            });
        }

        documentLink.setStyleName("okm-Hyperlink");
        hPanel.add(documentLink);
        hPanel.add(fileUpload);
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, new HTML(""));
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");
        setRowWordWarp(row, 2, true);

        // If folderPath is null must initialize value
        if (upload.getFolderPath() == null || upload.getFolderPath().equals("")
                && upload.getFolderUuid() != null && !upload.getFolderUuid().equals("")) {
            repositoryService.getPathByUUID(upload.getFolderUuid(), new AsyncCallback<String>() {
                @Override
                public void onSuccess(String result) {
                    upload.setFolderPath(result);
                }

                @Override
                public void onFailure(Throwable caught) {
                    Main.get().showError("getPathByUUID", caught);
                }
            });
        }
    } else if (gwtFormElement instanceof GWTText) {
        HorizontalPanel hPanel = new HorizontalPanel();
        HTML title = new HTML("&nbsp;" + ((GWTText) gwtFormElement).getLabel() + "&nbsp;");
        title.setStyleName("okm-NoWrap");
        hPanel.add(Util.hSpace("10"));
        hPanel.add(title);
        hPanel.setCellWidth(title, ((GWTText) gwtFormElement).getWidth());
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
    } else if (gwtFormElement instanceof GWTSeparator) {
        HorizontalPanel hPanel = new HorizontalPanel();
        Image horizontalLine = new Image("img/transparent_pixel.gif");
        horizontalLine.setStyleName("okm-TopPanel-Line-Border");
        horizontalLine.setSize("10", "2px");
        Image horizontalLine2 = new Image("img/transparent_pixel.gif");
        horizontalLine2.setStyleName("okm-TopPanel-Line-Border");
        horizontalLine2.setSize("100%", "2px");
        HTML title = new HTML("&nbsp;" + ((GWTSeparator) gwtFormElement).getLabel() + "&nbsp;");
        title.setStyleName("okm-NoWrap");
        hPanel.add(horizontalLine);
        hPanel.add(title);
        hPanel.add(horizontalLine2);
        hPanel.setCellVerticalAlignment(horizontalLine, HasAlignment.ALIGN_MIDDLE);
        hPanel.setCellVerticalAlignment(horizontalLine2, HasAlignment.ALIGN_MIDDLE);
        hPanel.setCellWidth(horizontalLine2, ((GWTSeparator) gwtFormElement).getWidth());
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
    } else if (gwtFormElement instanceof GWTDownload) {
        HorizontalPanel hPanel = new HorizontalPanel();
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
        GWTDownload download = (GWTDownload) gwtFormElement;
        FlexTable downloadTable = new FlexTable();
        HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>");
        downloadTable.setWidget(0, 0, description);
        downloadTable.getFlexCellFormatter().setColSpan(0, 0, 2);

        for (final GWTNode node : download.getNodes()) {
            int downloadTableRow = downloadTable.getRowCount();
            final Anchor anchor = new Anchor("<b>" + node.getLabel() + "</b>", true);

            if (!node.getUuid().equals("")) {
                repositoryService.getPathByUUID(node.getUuid(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        folderService.isValid(result, new AsyncCallback<Boolean>() {
                            @Override
                            public void onSuccess(Boolean result) {
                                final boolean isFolder = result;
                                anchor.addClickHandler(new ClickHandler() {
                                    @Override
                                    public void onClick(ClickEvent event) {
                                        if (isFolder) {
                                            Util.downloadFileByUUID(node.getUuid(), "export");
                                        } else {
                                            Util.downloadFileByUUID(node.getUuid(), "");
                                        }
                                    }
                                });
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                                Main.get().showError("getPathByUUID", caught);
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getPathByUUID", caught);
                    }
                });
            } else if (!node.getPath().equals("")) {
                repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        final String uuid = result;
                        folderService.isValid(node.getPath(), new AsyncCallback<Boolean>() {
                            @Override
                            public void onSuccess(Boolean result) {
                                final boolean isFolder = result;
                                anchor.addClickHandler(new ClickHandler() {
                                    @Override
                                    public void onClick(ClickEvent event) {
                                        if (isFolder) {
                                            Util.downloadFileByUUID(uuid, "export");
                                        } else {
                                            Util.downloadFileByUUID(uuid, "");
                                        }
                                    }
                                });
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                                Main.get().showError("getPathByUUID", caught);
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getUUIDByPath", caught);
                    }
                });
            }

            anchor.setStyleName("okm-Hyperlink");
            downloadTable.setWidget(downloadTableRow, 0, new HTML("&nbsp;&nbsp;&nbsp;"));
            downloadTable.setWidget(downloadTableRow, 1, anchor);
        }

        hPanel.add(downloadTable);
    } else if (gwtFormElement instanceof GWTPrint) {
        HorizontalPanel hPanel = new HorizontalPanel();
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
        GWTPrint print = (GWTPrint) gwtFormElement;
        FlexTable printTable = new FlexTable();
        HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>");
        printTable.setWidget(0, 0, description);
        printTable.getFlexCellFormatter().setColSpan(0, 0, 2);

        for (final GWTNode node : print.getNodes()) {
            int downloadTableRow = printTable.getRowCount();
            final Button downloadButton = new Button(Main.i18n("button.print"));

            if (!node.getUuid().equals("")) {
                downloadButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Window.alert("Not available");
                    }
                });
            } else if (!node.getPath().equals("")) {
                repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        //final String uuid = result;
                        downloadButton.addClickHandler(new ClickHandler() {
                            @Override
                            public void onClick(ClickEvent event) {
                                Window.alert("Not available");
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getUUIDByPath", caught);
                    }
                });
            }

            downloadButton.setStyleName("okm-DownloadButton");
            printTable.setWidget(downloadTableRow, 0,
                    new HTML("&nbsp;&nbsp;&nbsp;" + node.getLabel() + "&nbsp;&nbsp;"));
            printTable.setWidget(downloadTableRow, 1, downloadButton);
        }

        hPanel.add(printTable);
    }
}

From source file:com.openkm.frontend.client.widget.form.FormManager.java

License:Open Source License

/**
 * drawFormElement// w  w w  .  j  a v  a 2  s  . co m
 */
private void drawFormElement(int row, final GWTFormElement gwtFormElement, boolean readOnly,
        boolean searchView) {
    final String propertyName = gwtFormElement.getName();

    if (gwtFormElement instanceof GWTButton) {
        final GWTButton gWTButton = (GWTButton) gwtFormElement;

        if (submitForm != null) {
            submitForm.setVisible(false); // Always set form hidden because there's new buttons
        }

        Button transButton = new Button(gWTButton.getLabel());
        String style = Character.toUpperCase(gWTButton.getStyle().charAt(0))
                + gWTButton.getStyle().substring(1);
        transButton.setStyleName("okm-" + style + "Button");
        HTML space = new HTML("&nbsp;");
        submitButtonPanel.add(transButton);
        submitButtonPanel.add(space);
        submitButtonPanel.setCellWidth(space, "5px");

        // Setting submit button
        transButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                if (gWTButton.getConfirmation() != null && !gWTButton.getConfirmation().equals("")) {
                    Main.get().confirmPopup.setConfirm(ConfirmPopup.CONFIRM_WORKFLOW_ACTION);
                    Main.get().confirmPopup.setConfirmationText(gWTButton.getConfirmation());
                    ValidationButton validationButton = new ValidationButton(gWTButton, singleton);
                    Main.get().confirmPopup.setValue(validationButton);
                    Main.get().confirmPopup.center();
                } else {
                    if (gWTButton.isValidate()) {
                        if (validationProcessor.validate()) {
                            if (gWTButton.getTransition().equals("")) {
                                workflow.setTaskInstanceValues(taskInstance.getId(), null);
                            } else {
                                workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition());
                            }
                            disableAllButtonList();
                        }
                    } else {
                        if (gWTButton.getTransition().equals("")) {
                            workflow.setTaskInstanceValues(taskInstance.getId(), null);
                        } else {
                            workflow.setTaskInstanceValues(taskInstance.getId(), gWTButton.getTransition());
                        }
                        disableAllButtonList();
                    }
                }
            }
        });

        // Adding button to control list
        if (!buttonControlList.contains(transButton)) {
            buttonControlList.add(transButton);
        }
    } else if (gwtFormElement instanceof GWTTextArea) {
        HorizontalPanel hPanel = new HorizontalPanel();
        TextArea textArea = new TextArea();
        textArea.setEnabled((!readOnly && !((GWTTextArea) gwtFormElement).isReadonly()) || isSearchView); // read only
        hPanel.add(textArea);
        textArea.setStyleName("okm-TextArea");
        textArea.setText(((GWTTextArea) gwtFormElement).getValue());
        textArea.setSize(gwtFormElement.getWidth(), gwtFormElement.getHeight());
        HTML text = new HTML(); // Create a widget for this property
        text.setHTML(((GWTTextArea) gwtFormElement).getValue().replaceAll("\n", "<br>"));
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, text);
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView || isMassiveView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    propertyHandler.propertyRemoved();
                }
            });

            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (propertyHandler != null) {
                textArea.addKeyUpHandler(new KeyUpHandler() {
                    @Override
                    public void onKeyUp(KeyUpEvent event) {
                        propertyHandler.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTInput) {
        final HorizontalPanel hPanel = new HorizontalPanel();
        final TextBox textBox = new TextBox(); // Create a widget for this property
        textBox.setEnabled((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only
        hPanel.add(textBox);
        String value = "";

        if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_TEXT)
                || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK)
                || ((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) {
            textBox.setText(((GWTInput) gwtFormElement).getValue());
            value = ((GWTInput) gwtFormElement).getValue();
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
            if (((GWTInput) gwtFormElement).getDate() != null) {
                DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                textBox.setText(dtf.format(((GWTInput) gwtFormElement).getDate()));
                value = dtf.format(((GWTInput) gwtFormElement).getDate());
            }
        }

        textBox.setWidth(gwtFormElement.getWidth());
        textBox.setStyleName("okm-Input");
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setHTML(row, 1, value);

        if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
            final PopupPanel calendarPopup = new PopupPanel(true);
            final CalendarWidget calendar = new CalendarWidget();

            calendar.addChangeHandler(new ChangeHandler() {
                @Override
                public void onChange(ChangeEvent event) {
                    calendarPopup.hide();
                    DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                    textBox.setText(dtf.format(calendar.getDate()));
                    ((GWTInput) gwtFormElement).setDate(calendar.getDate());

                    if (propertyHandler != null) {
                        propertyHandler.metadataValueChanged();
                    }
                }
            });

            calendarPopup.add(calendar);
            final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar());

            if (readOnly || ((GWTInput) gwtFormElement).isReadonly()) { // read only
                calendarIcon.setResource(OKMBundleResources.INSTANCE.calendarDisabled());
            } else {
                calendarIcon.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(),
                                calendarIcon.getAbsoluteTop() - 2);
                        if (calendar.getDate() != null) {
                            calendar.setNow((Date) calendar.getDate().clone());
                        } else {
                            calendar.setNow(null);
                        }
                        calendarPopup.show();
                    }
                });
            }

            calendarIcon.setStyleName("okm-Hyperlink");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(calendarIcon);
            textBox.setEnabled(false);
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_LINK)) {
            if (!value.equals("")) {
                HorizontalPanel hLinkPanel = new HorizontalPanel();
                Anchor anchor = new Anchor(value, true);
                final String url = value;

                anchor.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Window.open(url, url, "");
                    }
                });

                anchor.setStyleName("okm-Hyperlink");
                String containerName = ((GWTInput) gwtFormElement).getName() + "ContainerName";
                hLinkPanel.add(new HTML("<div id=\"" + containerName + "\"></div>\n"));
                HTML space = new HTML("");
                hLinkPanel.add(space);
                hLinkPanel.add(anchor);
                hLinkPanel.setCellWidth(space, "5px");
                table.setWidget(row, 1, hLinkPanel);
                Util.createClipboardButton(containerName, url);
            } else {
                table.setHTML(row, 1, "");
            }
        } else if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_FOLDER)) {
            if (!value.equals("")) {
                Anchor anchor = new Anchor();
                final GWTFolder folder = ((GWTInput) gwtFormElement).getFolder();

                // remove first ocurrence
                String path = value.substring(value.indexOf("/", 1) + 1);

                // Looks if must change icon on parent if now has no childs and properties with user security
                // atention
                if (folder.isHasChildren()) {
                    anchor.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", path, "top"));
                } else {
                    anchor.setHTML(Util.imageItemHTML("img/menuitem_empty.gif", path, "top"));
                }

                anchor.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent arg0) {
                        CommonUI.openPath(folder.getPath(), null);
                    }
                });

                anchor.setStyleName("okm-KeyMap-ImageHover");
                table.setWidget(row, 1, anchor);
            } else {
                table.setHTML(row, 1, "");
            }

            Image pathExplorer = new Image(OKMBundleResources.INSTANCE.folderExplorer());
            pathExplorer.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    // when any changes is done is fired search.metadataValueChanged();
                    folderSelectPopup.show(textBox, propertyHandler);
                }
            });

            pathExplorer.setStyleName("okm-KeyMap-ImageHover");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(pathExplorer);
            hPanel.setCellVerticalAlignment(pathExplorer, HasAlignment.ALIGN_MIDDLE);
            pathExplorer.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly()) || isSearchView); // read only
            textBox.setEnabled(false);
        }

        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView || isMassiveView) {
            if (searchView) {
                // Second date input
                if (((GWTInput) gwtFormElement).getType().equals(GWTInput.TYPE_DATE)) {
                    final TextBox textBoxTo = new TextBox();
                    textBoxTo.setWidth(gwtFormElement.getWidth());
                    textBoxTo.setStyleName("okm-Input");
                    hPanel.add(new HTML("&nbsp;&harr;&nbsp;"));
                    hPanel.add(textBoxTo);

                    if (((GWTInput) gwtFormElement).getDateTo() != null) {
                        DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                        textBoxTo.setText(dtf.format(((GWTInput) gwtFormElement).getDateTo()));
                    }

                    final PopupPanel calendarPopup = new PopupPanel(true);
                    final CalendarWidget calendar = new CalendarWidget();
                    calendar.addChangeHandler(new ChangeHandler() {
                        @Override
                        public void onChange(ChangeEvent event) {
                            calendarPopup.hide();
                            DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
                            textBoxTo.setText(dtf.format(calendar.getDate()));
                            ((GWTInput) gwtFormElement).setDateTo(calendar.getDate());

                            if (propertyHandler != null) {
                                propertyHandler.metadataValueChanged();
                            }
                        }
                    });

                    calendarPopup.add(calendar);
                    final Image calendarIcon = new Image(OKMBundleResources.INSTANCE.calendar());
                    calendarIcon.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            calendarPopup.setPopupPosition(calendarIcon.getAbsoluteLeft(),
                                    calendarIcon.getAbsoluteTop() - 2);
                            calendarPopup.show();
                        }
                    });

                    calendarIcon.setStyleName("okm-Hyperlink");
                    hPanel.add(Util.hSpace("5"));
                    hPanel.add(calendarIcon);
                    textBoxTo.setEnabled(false);

                    // Clean
                    final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon());
                    cleanIcon.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            TextBox textBox = (TextBox) hPanel.getWidget(0);
                            textBox.setText("");
                            textBoxTo.setText("");
                            ((GWTInput) gwtFormElement).setDate(null);
                            ((GWTInput) gwtFormElement).setDateTo(null);
                        }
                    });
                    cleanIcon.setStyleName("okm-Hyperlink");
                    hPanel.add(Util.hSpace("5"));
                    hPanel.add(cleanIcon);
                }
            }

            // Delete
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    propertyHandler.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (propertyHandler != null) {
                textBox.addKeyUpHandler(new KeyUpHandler() {
                    @Override
                    public void onKeyUp(KeyUpEvent event) {
                        propertyHandler.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            // Clean icon ( case is not readonly )
            final Image cleanIcon = new Image(OKMBundleResources.INSTANCE.cleanIcon());
            cleanIcon.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    TextBox textBox = (TextBox) hPanel.getWidget(0);
                    textBox.setText("");
                    ((GWTInput) gwtFormElement).setDate(null);
                    ((GWTInput) gwtFormElement).setFolder(new GWTFolder());
                }
            });
            cleanIcon.setStyleName("okm-Hyperlink");
            hPanel.add(Util.hSpace("5"));
            hPanel.add(cleanIcon);
            cleanIcon.setVisible((!readOnly && !((GWTInput) gwtFormElement).isReadonly())); // read only

            setRowWordWarp(row, 2, true);
        }

    } else if (gwtFormElement instanceof GWTSuggestBox) {
        HorizontalPanel hPanel = new HorizontalPanel();
        final GWTSuggestBox suggestBox = (GWTSuggestBox) gwtFormElement;
        final TextBox textBox = new TextBox(); // Create a widget for this property
        textBox.setWidth(gwtFormElement.getWidth());
        textBox.setStyleName("okm-Input");
        textBox.setReadOnly(true);
        textBox.setEnabled((!readOnly && !suggestBox.isReadonly()) || isSearchView); // read only 
        final HTML hiddenKey = new HTML("");
        hiddenKey.setVisible(false);

        if (suggestBox.getValue() != null) {
            hiddenKey.setHTML(suggestBox.getValue());
        }

        hPanel.add(textBox);
        hPanel.add(hiddenKey);
        final HTML value = new HTML("");
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, value);
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (textBox.isEnabled()) {
            final Image databaseRecordImage = new Image(OKMBundleResources.INSTANCE.databaseRecord());
            databaseRecordImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    List<String> tables = new ArrayList<String>();
                    if (suggestBox.getTable() != null) {
                        tables.add(suggestBox.getTable());
                    }

                    DatabaseRecord databaseRecord = new DatabaseRecord(hiddenKey, textBox);
                    // when any changes is done is fired search.metadataValueChanged();
                    DatabaseRecordSelectPopup drsPopup = new DatabaseRecordSelectPopup(suggestBox,
                            databaseRecord, propertyHandler);
                    drsPopup.setWidth("300");
                    drsPopup.setHeight("220");
                    drsPopup.setStyleName("okm-Popup");
                    drsPopup.setPopupPosition(databaseRecordImage.getAbsoluteLeft(),
                            databaseRecordImage.getAbsoluteTop() - 2);
                    drsPopup.show();
                }
            });
            databaseRecordImage.setStyleName("okm-Hyperlink");
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(databaseRecordImage);
        }

        hWidgetProperties.put(propertyName, hPanel);
        if (!suggestBox.getValue().equals("")) {
            textBox.setValue(suggestBox.getText());
            value.setHTML(suggestBox.getText());
            hiddenKey.setHTML(suggestBox.getValue());

            /*List<String> tables = new ArrayList<String>();
                    
            if (suggestBox.getTable() != null) {
               tables.add(suggestBox.getTable());
            }
                    
            String formatedQuery = MessageFormat.format(suggestBox.getValueQuery(), suggestBox.getValue());
            keyValueService.getKeyValues(tables, formatedQuery, new AsyncCallback<List<GWTKeyValue>>() {
               @Override
               public void onSuccess(List<GWTKeyValue> result) {
                  if (!result.isEmpty()) {
             GWTKeyValue keyValue = result.get(0);
             textBox.setValue(keyValue.getValue());
             value.setHTML(keyValue.getValue());
             hiddenKey.setHTML(keyValue.getKey());
                  }
               }
                       
               @Override
               public void onFailure(Throwable caught) {
                  Main.get().showError("getKeyValues", caught);
               }
            }); */
        }

        if (searchView || isMassiveView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    propertyHandler.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);
            textBox.addKeyUpHandler(
                    Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler);
            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTCheckBox) {
        CheckBox checkBox = new CheckBox();
        checkBox.setEnabled((!readOnly && !((GWTCheckBox) gwtFormElement).isReadonly()) || isSearchView); // read only
        checkBox.setValue(((GWTCheckBox) gwtFormElement).getValue());
        hWidgetProperties.put(propertyName, checkBox);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");

        if (checkBox.getValue()) {
            table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.yes()));
        } else {
            table.setWidget(row, 1, new Image(OKMBundleResources.INSTANCE.no()));
        }

        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");

        if (searchView || isMassiveView) {
            final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
            removeImage.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2).equals(removeImage)) {
                            table.removeRow(row);
                            break;
                        }
                    }

                    hWidgetProperties.remove(propertyName);
                    hPropertyParams.remove(propertyName);
                    formElementList.remove(gwtFormElement);
                    propertyHandler.propertyRemoved();
                }
            });
            removeImage.addStyleName("okm-Hyperlink");
            table.setWidget(row, 2, removeImage);
            table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

            if (propertyHandler != null) {
                checkBox.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        propertyHandler.metadataValueChanged();
                    }
                });
            }

            setRowWordWarp(row, 3, true);
        } else {
            setRowWordWarp(row, 2, true);
        }
    } else if (gwtFormElement instanceof GWTSelect) {
        final GWTSelect gwtSelect = (GWTSelect) gwtFormElement;

        if (!gwtSelect.getOptionsData().equals("")
                && workflowVarMap.keySet().contains(gwtSelect.getOptionsData())) {
            gwtSelect.setOptions(getOptionsFromVariable(workflowVarMap.get(gwtSelect.getOptionsData())));
        }

        if (gwtSelect.getType().equals(GWTSelect.TYPE_SIMPLE)) {
            String selectedLabel = "";
            HorizontalPanel hPanel = new HorizontalPanel();
            ListBox listBox = new ListBox();
            listBox.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            hPanel.add(listBox);
            listBox.setStyleName("okm-Select");
            listBox.addItem("", ""); // Always we set and empty value

            for (GWTOption option : gwtSelect.getOptions()) {
                listBox.addItem(option.getLabel(), option.getValue());
                if (option.isSelected()) {
                    listBox.setItemSelected(listBox.getItemCount() - 1, true);
                    selectedLabel = option.getLabel();
                }
            }

            // Mark suggested
            if (!gwtSelect.getSuggestion().equals("")) {
                NodeList<Element> nodeList = listBox.getElement().getElementsByTagName("option");
                int count = 1; // 0 is empty value
                for (GWTOption option : gwtSelect.getOptions()) {
                    if (nodeList.getLength() < (count)) {
                        break;
                    }
                    if (option.isSuggested()) {
                        nodeList.getItem(count).setClassName("okm-Option-Suggested");
                    } else {
                        nodeList.getItem(count).setClassName("okm-Option");
                    }
                    count++;
                }
            }

            hWidgetProperties.put(propertyName, hPanel);

            table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
            table.setHTML(row, 1, selectedLabel);
            table.getCellFormatter().setWidth(row, 1, "100%");

            if (searchView || isMassiveView) {
                final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
                removeImage.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        for (int row = 0; row < table.getRowCount(); row++) {
                            if (table.getWidget(row, 2).equals(removeImage)) {
                                table.removeRow(row);
                                break;
                            }
                        }

                        hWidgetProperties.remove(propertyName);
                        hPropertyParams.remove(propertyName);
                        formElementList.remove(gwtFormElement);
                        propertyHandler.propertyRemoved();
                    }
                });
                removeImage.addStyleName("okm-Hyperlink");
                table.setWidget(row, 2, removeImage);
                table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

                if (propertyHandler != null) {
                    listBox.addChangeHandler(new ChangeHandler() {
                        @Override
                        public void onChange(ChangeEvent event) {
                            propertyHandler.metadataValueChanged();
                        }
                    });
                }

                setRowWordWarp(row, 3, true);
            } else {
                setRowWordWarp(row, 2, true);
            }

        } else if (gwtSelect.getType().equals(GWTSelect.TYPE_MULTIPLE)) {
            final HorizontalPanel hPanel = new HorizontalPanel();
            ListBox listMulti = new ListBox();
            listMulti.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            listMulti.setStyleName("okm-Select");
            listMulti.addItem("", ""); // Always we set and empty value

            // Table for values
            FlexTable tableMulti = new FlexTable();

            Button addButton = new Button(Main.i18n("button.add"), new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                    FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                    ListBox listMulti = (ListBox) hPanel.getWidget(2);
                    Button addButton = (Button) hPanel.getWidget(4);

                    if (listMulti.getSelectedIndex() > 0) {
                        final HTML htmlValue = new HTML(listMulti.getValue(listMulti.getSelectedIndex()));
                        int rowTableMulti = tableMulti.getRowCount();
                        Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());

                        removeImage.addClickHandler(new ClickHandler() {
                            @Override
                            public void onClick(ClickEvent event) {
                                Widget sender = (Widget) event.getSource();
                                HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                                FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                                ListBox listMulti = (ListBox) hPanel.getWidget(2);
                                Button addButton = (Button) hPanel.getWidget(4);
                                String value = htmlValue.getText();
                                String optionLabel = "";

                                for (Iterator<GWTOption> itOptions = gwtSelect.getOptions()
                                        .iterator(); itOptions.hasNext();) {
                                    GWTOption option = itOptions.next();
                                    if (option.getValue().equals(htmlValue.getText())) {
                                        optionLabel = option.getLabel();
                                        break;
                                    }
                                }

                                listMulti.addItem(optionLabel, value);
                                listMulti.setVisible(true);
                                addButton.setVisible(true);

                                // Looking for row to delete
                                for (int i = 0; i < tableMulti.getRowCount(); i++) {
                                    if (tableMulti.getWidget(i, 1).equals(sender)) {
                                        tableMulti.removeRow(i);
                                    }
                                }

                                if (propertyHandler != null) {
                                    propertyHandler.metadataValueChanged();
                                }
                            }
                        });
                        removeImage.setStyleName("okm-Hyperlink");

                        tableMulti.setWidget(rowTableMulti, 0, htmlValue);
                        tableMulti.setWidget(rowTableMulti, 1, removeImage);
                        tableMulti.setHTML(rowTableMulti, 2,
                                listMulti.getItemText(listMulti.getSelectedIndex()));

                        setRowWordWarp(tableMulti, rowTableMulti, 2, true);
                        listMulti.removeItem(listMulti.getSelectedIndex());
                        htmlValue.setVisible(false);

                        if (listMulti.getItemCount() <= 1) {
                            listMulti.setVisible(false);
                            addButton.setVisible(false);
                        }

                        if (propertyHandler != null) {
                            propertyHandler.metadataValueChanged();
                        }
                    }
                }
            });

            addButton.setEnabled((!readOnly && !gwtSelect.isReadonly()) || isSearchView); // read only
            addButton.setStyleName("okm-AddButton");

            hPanel.add(tableMulti);
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(listMulti);
            hPanel.add(new HTML("&nbsp;"));
            hPanel.add(addButton);
            hPanel.setVisible(true);
            listMulti.setVisible(false);
            addButton.setVisible(false);
            hPanel.setCellVerticalAlignment(tableMulti, VerticalPanel.ALIGN_TOP);
            hPanel.setCellVerticalAlignment(listMulti, VerticalPanel.ALIGN_TOP);
            hPanel.setCellVerticalAlignment(addButton, VerticalPanel.ALIGN_TOP);
            hPanel.setHeight("100%");

            table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
            table.setWidget(row, 1, hPanel);
            table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
            table.getCellFormatter().setVerticalAlignment(row, 1, VerticalPanel.ALIGN_TOP);
            table.getCellFormatter().setWidth(row, 1, "100%");

            for (Iterator<GWTOption> itData = gwtSelect.getOptions().iterator(); itData.hasNext();) {
                final GWTOption option = itData.next();

                // Looks if there's some selected value
                if (option.isSelected()) {
                    int rowTableMulti = tableMulti.getRowCount();
                    HTML htmlValue = new HTML(option.getValue());

                    Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon()); // read only for this element goes at edit() logic
                    removeImage.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            Widget sender = (Widget) event.getSource();
                            HorizontalPanel hPanel = (HorizontalPanel) hWidgetProperties.get(propertyName);
                            FlexTable tableMulti = (FlexTable) hPanel.getWidget(0);
                            ListBox listMulti = (ListBox) hPanel.getWidget(2);
                            Button addButton = (Button) hPanel.getWidget(4);

                            listMulti.addItem(option.getLabel(), option.getValue());
                            listMulti.setVisible(true);
                            addButton.setVisible(true);

                            // Looking for row to delete
                            for (int i = 0; i < tableMulti.getRowCount(); i++) {
                                if (tableMulti.getWidget(i, 1).equals(sender)) {
                                    tableMulti.removeRow(i);
                                }
                            }

                            if (propertyHandler != null) {
                                propertyHandler.metadataValueChanged();
                            }
                        }
                    });
                    removeImage.setStyleName("okm-Hyperlink");

                    tableMulti.setWidget(rowTableMulti, 0, htmlValue);
                    tableMulti.setWidget(rowTableMulti, 1, removeImage);
                    tableMulti.setHTML(rowTableMulti, 2, option.getLabel());
                    setRowWordWarp(tableMulti, rowTableMulti, 2, true);
                    htmlValue.setVisible(false);
                    removeImage.setVisible(false);
                } else {
                    listMulti.addItem(option.getLabel(), option.getValue());
                }
            }

            // Mark suggested
            if (!gwtSelect.getSuggestion().equals("")) {
                NodeList<Element> nodeList = listMulti.getElement().getElementsByTagName("option");
                int count = 1; // 0 is empty value
                for (GWTOption option : gwtSelect.getOptions()) {
                    // In list only are shown not selected items
                    if (!option.isSelected()) {
                        if (nodeList.getLength() < (count)) {
                            break;
                        }
                        if (option.isSuggested()) {
                            nodeList.getItem(count).setClassName("okm-Option-Suggested");
                        } else {
                            nodeList.getItem(count).setClassName("okm-Option");
                        }
                        count++;
                    }
                }
            }

            // Save panel
            hWidgetProperties.put(propertyName, hPanel);

            if (searchView || isMassiveView) {
                final Image removeImage = new Image(OKMBundleResources.INSTANCE.deleteIcon());
                removeImage.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        for (int row = 0; row < table.getRowCount(); row++) {
                            if (table.getWidget(row, 2).equals(removeImage)) {
                                table.removeRow(row);
                                break;
                            }
                        }

                        hWidgetProperties.remove(propertyName);
                        hPropertyParams.remove(propertyName);
                        formElementList.remove(gwtFormElement);
                        propertyHandler.propertyRemoved();
                    }
                });
                removeImage.addStyleName("okm-Hyperlink");
                table.setWidget(row, 2, removeImage);
                table.getCellFormatter().setVerticalAlignment(row, 2, HasAlignment.ALIGN_TOP);

                // not implemented
                // textBox.addKeyUpHandler(Main.get().mainPanel.search.searchBrowser.searchIn.searchControl.keyUpHandler);
                setRowWordWarp(row, 3, true);
            } else {
                setRowWordWarp(row, 2, true);
            }
        }
    } else if (gwtFormElement instanceof GWTUpload) {
        final GWTUpload upload = (GWTUpload) gwtFormElement;
        HorizontalPanel hPanel = new HorizontalPanel();
        FileUpload fileUpload = new FileUpload();
        fileUpload.setStyleName("okm-Input");
        fileUpload.getElement().setAttribute("size", "" + upload.getWidth());
        final Anchor documentLink = new Anchor();

        // Setting document link by uuid
        if (upload.getDocumentUuid() != null && !upload.getDocumentUuid().equals("")) {
            repositoryService.getPathByUUID(upload.getDocumentUuid(), new AsyncCallback<String>() {
                @Override
                public void onSuccess(String result) {
                    documentService.get(result, new AsyncCallback<GWTDocument>() {
                        @Override
                        public void onSuccess(GWTDocument result) {
                            final String docPath = result.getPath();
                            documentLink.setText(result.getName());
                            documentLink.addClickHandler(new ClickHandler() {
                                @Override
                                public void onClick(ClickEvent event) {
                                    CommonUI.openPath(Util.getParent(docPath), docPath);
                                }
                            });
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            Main.get().showError("getDocument", caught);
                        }
                    });
                }

                @Override
                public void onFailure(Throwable caught) {
                    Main.get().showError("getPathByUUID", caught);
                }
            });
        }

        documentLink.setStyleName("okm-Hyperlink");
        hPanel.add(documentLink);
        hPanel.add(fileUpload);
        hWidgetProperties.put(propertyName, hPanel);
        table.setHTML(row, 0, "<b>" + gwtFormElement.getLabel() + "</b>");
        table.setWidget(row, 1, new HTML(""));
        table.getCellFormatter().setVerticalAlignment(row, 0, VerticalPanel.ALIGN_TOP);
        table.getCellFormatter().setWidth(row, 1, "100%");
        setRowWordWarp(row, 2, true);

        // If folderPath is null must initialize value
        if (upload.getFolderPath() == null || upload.getFolderPath().equals("")
                && upload.getFolderUuid() != null && !upload.getFolderUuid().equals("")) {
            repositoryService.getPathByUUID(upload.getFolderUuid(), new AsyncCallback<String>() {
                @Override
                public void onSuccess(String result) {
                    upload.setFolderPath(result);
                }

                @Override
                public void onFailure(Throwable caught) {
                    Main.get().showError("getPathByUUID", caught);
                }
            });
        }
    } else if (gwtFormElement instanceof GWTText) {
        HorizontalPanel hPanel = new HorizontalPanel();
        HTML title = new HTML("&nbsp;" + ((GWTText) gwtFormElement).getLabel() + "&nbsp;");
        title.setStyleName("okm-NoWrap");
        hPanel.add(Util.hSpace("10"));
        hPanel.add(title);
        hPanel.setCellWidth(title, ((GWTText) gwtFormElement).getWidth());
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
    } else if (gwtFormElement instanceof GWTSeparator) {
        HorizontalPanel hPanel = new HorizontalPanel();
        Image horizontalLine = new Image("img/transparent_pixel.gif");
        horizontalLine.setStyleName("okm-TopPanel-Line-Border");
        horizontalLine.setSize("10", "2px");
        Image horizontalLine2 = new Image("img/transparent_pixel.gif");
        horizontalLine2.setStyleName("okm-TopPanel-Line-Border");
        horizontalLine2.setSize("100%", "2px");
        HTML title = new HTML("&nbsp;" + ((GWTSeparator) gwtFormElement).getLabel() + "&nbsp;");
        title.setStyleName("okm-NoWrap");
        hPanel.add(horizontalLine);
        hPanel.add(title);
        hPanel.add(horizontalLine2);
        hPanel.setCellVerticalAlignment(horizontalLine, HasAlignment.ALIGN_MIDDLE);
        hPanel.setCellVerticalAlignment(horizontalLine2, HasAlignment.ALIGN_MIDDLE);
        hPanel.setCellWidth(horizontalLine2, ((GWTSeparator) gwtFormElement).getWidth());
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
    } else if (gwtFormElement instanceof GWTDownload) {
        HorizontalPanel hPanel = new HorizontalPanel();
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
        GWTDownload download = (GWTDownload) gwtFormElement;
        FlexTable downloadTable = new FlexTable();
        HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>");
        downloadTable.setWidget(0, 0, description);
        downloadTable.getFlexCellFormatter().setColSpan(0, 0, 2);

        for (final GWTNode node : download.getNodes()) {
            int downloadTableRow = downloadTable.getRowCount();
            final Anchor anchor = new Anchor("<b>" + node.getLabel() + "</b>", true);

            if (!node.getUuid().equals("")) {
                repositoryService.getPathByUUID(node.getUuid(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        folderService.isValid(result, new AsyncCallback<Boolean>() {
                            @Override
                            public void onSuccess(Boolean result) {
                                final boolean isFolder = result;
                                anchor.addClickHandler(new ClickHandler() {
                                    @Override
                                    public void onClick(ClickEvent event) {
                                        if (isFolder) {
                                            Util.downloadFileByUUID(node.getUuid(), "export");
                                        } else {
                                            Util.downloadFileByUUID(node.getUuid(), "");
                                        }
                                    }
                                });
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                                Main.get().showError("getPathByUUID", caught);
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getPathByUUID", caught);
                    }
                });
            } else if (!node.getPath().equals("")) {
                repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        final String uuid = result;
                        folderService.isValid(node.getPath(), new AsyncCallback<Boolean>() {
                            @Override
                            public void onSuccess(Boolean result) {
                                final boolean isFolder = result;
                                anchor.addClickHandler(new ClickHandler() {
                                    @Override
                                    public void onClick(ClickEvent event) {
                                        if (isFolder) {
                                            Util.downloadFileByUUID(uuid, "export");
                                        } else {
                                            Util.downloadFileByUUID(uuid, "");
                                        }
                                    }
                                });
                            }

                            @Override
                            public void onFailure(Throwable caught) {
                                Main.get().showError("getPathByUUID", caught);
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getUUIDByPath", caught);
                    }
                });
            }

            anchor.setStyleName("okm-Hyperlink");
            downloadTable.setWidget(downloadTableRow, 0, new HTML("&nbsp;&nbsp;&nbsp;"));
            downloadTable.setWidget(downloadTableRow, 1, anchor);
        }

        hPanel.add(downloadTable);
    } else if (gwtFormElement instanceof GWTPrint) {
        HorizontalPanel hPanel = new HorizontalPanel();
        hWidgetProperties.put(propertyName, hPanel);
        table.setWidget(row, 0, hPanel);
        table.getFlexCellFormatter().setColSpan(row, 0, 2);
        GWTPrint print = (GWTPrint) gwtFormElement;
        FlexTable printTable = new FlexTable();
        HTML description = new HTML("<b>" + gwtFormElement.getLabel() + "</b>");
        printTable.setWidget(0, 0, description);
        printTable.getFlexCellFormatter().setColSpan(0, 0, 2);

        for (final GWTNode node : print.getNodes()) {
            int downloadTableRow = printTable.getRowCount();
            final Button downloadButton = new Button(Main.i18n("button.print"));

            if (!node.getUuid().equals("")) {
                downloadButton.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Util.print(node.getUuid());
                    }
                });
            } else if (!node.getPath().equals("")) {
                repositoryService.getUUIDByPath(node.getPath(), new AsyncCallback<String>() {
                    @Override
                    public void onSuccess(String result) {
                        final String uuid = result;
                        downloadButton.addClickHandler(new ClickHandler() {
                            @Override
                            public void onClick(ClickEvent event) {
                                Util.print(uuid);
                            }
                        });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        Main.get().showError("getUUIDByPath", caught);
                    }
                });
            }

            downloadButton.setStyleName("okm-DownloadButton");
            printTable.setWidget(downloadTableRow, 0,
                    new HTML("&nbsp;&nbsp;&nbsp;" + node.getLabel() + "&nbsp;&nbsp;"));
            printTable.setWidget(downloadTableRow, 1, downloadButton);
        }

        hPanel.add(printTable);
    }
}

From source file:com.phideltcmu.recruiter.client.ui.CategoriesPanel.java

License:Creative Commons License

@Override
public void onCategoriesFetched(CategoriesFetchedEvent event) {
    this.remove(loading);
    VerticalPanel vp = new VerticalPanel();
    vp.add(header);//from w  w w  . j  a va2s .  co m
    vp.add(new InlineHTML("<br><hr><br>"));
    for (final Category c : event.getCategoryList()) {
        final String categoryName = c.getValue();
        CheckBox checkBox = new CheckBox(categoryName);
        checkBox.setEnabled(true);
        checkBox.setValue(defaultCheck);
        checkBooleanMap.put(categoryName, defaultCheck);
        checkMap.put(c.getValue(), checkBox);

        checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
                checkBooleanMap.put(categoryName, !checkBooleanMap.get(categoryName));
            }
        });
        vp.add(checkBox);
    }
    vp.add(new InlineHTML("<br><hr><br>"));
    this.add(vp);
    postFetchFireBus.fireEvent(new CategoriesPanelLoadedEvent(event.getCategoryList()));
}

From source file:com.risevision.ui.client.common.widgets.RolesWidget.java

License:Open Source License

public void setEnabled(boolean enabled) {
    for (CheckBox cb : widgets)
        cb.setEnabled(enabled);
}

From source file:com.square.client.gwt.client.view.personne.physique.creation.PopupCreationPersonneDoublonViewImpl.java

License:Open Source License

/**
 * Construit le tableau de recherche.//from  w ww.  ja v a  2 s.c o m
 * @param listeDoublons la liste des doublons.
 */
private void construireTableauRecherche(List<PersonneDoublonModel> listeDoublons) {
    final List<CheckBox> listeCBSelection = new ArrayList<CheckBox>();
    final HeaderFlexTable<PersonneDoublonModel> ftDoublons = new HeaderFlexTable<PersonneDoublonModel>() {
        @Override
        public Widget[] setHeader() {
            return new Widget[] { new Label(viewConstants.enTeteColonneNom()),
                    new Label(viewConstants.enTeteColonnePrenom()),
                    new Label(viewConstants.enTeteColonneDateNaissance()),
                    new Label(viewConstants.enTeteColonneAdresse()),
                    new Label(viewConstants.enTeteColonneCodePostal()),
                    new Label(viewConstants.enTeteColonneVille()),
                    new Label(viewConstants.enTeteColonneCompoFamiliale()),
                    new Label(viewConstants.enTeteSelection()) };
        }

        @Override
        public void setRow(final PersonneDoublonModel doublon) {
            setWidget(0, new Label(doublon.getNom()));
            setWidget(1, new Label(doublon.getPrenom()));
            setWidget(2, new Label(doublon.getDateNaissance()));
            setWidget(3, new Label(doublon.getAdresse()));
            setWidget(4, new Label(doublon.getCodePostal()));
            setWidget(5, new Label(doublon.getCommune()));
            setWidget(6, new Label(doublon.getCompoFamiliale()));
            final CheckBox cb = new CheckBox();
            cb.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (cb.getValue()) {
                        for (CheckBox checkBox : listeCBSelection) {
                            if (!cb.equals(checkBox)) {
                                checkBox.setEnabled(false);
                            }
                        }
                        idPersonneSelectionnee = doublon.getId();
                        btnRattacher.setEnabled(true);
                    } else {
                        for (CheckBox checkBox : listeCBSelection) {
                            checkBox.setEnabled(true);
                        }
                        idPersonneSelectionnee = null;
                        btnRattacher.setEnabled(false);
                    }
                }
            });
            listeCBSelection.add(cb);
            setWidget(7, cb);
            setCellHorizontalAlignment(7, HasAlignment.ALIGN_CENTER);
        }
    };
    //        ftDoublons.addStyleName(SquareResources.INSTANCE.css().popupTableDoublons());
    //        ftDoublons.getCellFormatter().addStyleName(0, 0, SquareResources.INSTANCE.css().titreColonneTableDoublon());
    //        styleLigne = SquareResources.INSTANCE.css().celluleSombreTableDoublon();
    //        styleLigne = SquareResources.INSTANCE.css().celluleClaireTableDoublon();
    ftDoublons.setWidth(AppControllerConstants.POURCENT_100);
    ftDoublons.setListeObjets(listeDoublons);

    scrollPanel.add(ftDoublons);
}

From source file:com.square.composant.contrat.square.client.view.ContratGarantieViewImpl.java

License:Open Source License

/** Construit le contenu. */
private void construireBlocContenu(GarantieModel garantie) {
    conteneurGlobal = new FlexTable();
    conteneurGlobal.setWidth(ContratsViewImplConstants.POURCENT_100);
    conteneurGlobal.setCellPadding(2);//from ww w.ja  v  a2 s .  c  o m

    // Code tarif
    if (garantie.getCodeTarif() != null) {
        final Label lCodeTarif = new Label(viewConstants.libelleCodeTarif(), false);
        final Label labelCodeTarif = new Label(garantie.getCodeTarif(), false);
        conteneurGlobal.setWidget(0, 0, lCodeTarif);
        conteneurGlobal.setWidget(0, 1, labelCodeTarif);
    }

    // Code gnration
    if (garantie.getCodeGeneration() != null) {
        final Label lCodeGeneration = new Label(viewConstants.libelleCodeGeneration(), false);
        final Label labelCodeGeneration = new Label(garantie.getCodeGeneration(), false);
        conteneurGlobal.setWidget(0, 2, lCodeGeneration);
        conteneurGlobal.setWidget(0, 3, labelCodeGeneration);
    }

    // Garantie Gestion
    if (garantie.getLibelleGarantieGestion() != null) {
        final Label lGarantieGestion = new Label(viewConstants.libelleGarantieGestion(), false);
        final Label labelGarantieGestion = new Label(garantie.getLibelleGarantieGestion(), false);
        conteneurGlobal.setWidget(0, 4, lGarantieGestion);
        conteneurGlobal.setWidget(0, 5, labelGarantieGestion);
    }

    // Produit Gestion
    if (garantie.getLibelleProduitGestion() != null) {
        final Label lProduitGestion = new Label(viewConstants.libelleProduitGestion(), false);
        final Label labelProduitGestion = new Label(garantie.getLibelleProduitGestion(), false);
        conteneurGlobal.setWidget(0, 6, lProduitGestion);
        conteneurGlobal.setWidget(0, 7, labelProduitGestion);
    }

    // Loi Madelin
    final Label lLoiMadelin = new Label(viewConstants.libelleLoiMadelin(), false);
    final CheckBox cbLoiMadelin = new CheckBox();
    cbLoiMadelin.setEnabled(false);
    cbLoiMadelin.setValue(garantie.getLoiMadelin());
    conteneurGlobal.setWidget(1, 0, lLoiMadelin);
    conteneurGlobal.setWidget(1, 1, cbLoiMadelin);

    // Montant souscrit
    if (garantie.getMontantSouscrit() != null) {
        final Label lMontantSouscrit = new Label(viewConstants.libelleMontantSouscrit(), false);
        final Label labelMontantSouscrit = new Label(numberFormat.format(garantie.getMontantSouscrit()), false);
        conteneurGlobal.setWidget(1, 2, lMontantSouscrit);
        conteneurGlobal.setWidget(1, 3, labelMontantSouscrit);
    }

    conteneurGlobal.getColumnFormatter().setWidth(0, "14%");
    conteneurGlobal.getColumnFormatter().setWidth(1, "8%");
    conteneurGlobal.getColumnFormatter().setWidth(2, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(3, "5%");
    conteneurGlobal.getColumnFormatter().setWidth(4, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(5, "24%");
    conteneurGlobal.getColumnFormatter().setWidth(6, "12%");
    conteneurGlobal.getColumnFormatter().setWidth(7, "13%");
}

From source file:com.square.composant.fusion.square.client.view.selection.doublon.SelectionDoublonViewImpl.java

License:Open Source License

/**
 * Met  jour les CheckBoxs du tableau pagin.
 *///ww w .  j  av  a 2  s .c o m
private void majCBTableau() {
    for (int i = 1; i < remotePagingTableDoublons.getFtResultats().getRowCount(); i++) {
        final CheckBox cb = (CheckBox) remotePagingTableDoublons.getFtResultats().getWidget(i, 8);
        if (mapCBSelectionnees.size() < 2 || mapCBSelectionnees.containsValue(cb)) {
            cb.setEnabled(true);
        } else {
            cb.setEnabled(false);
        }
    }
}

From source file:com.square.composant.fusion.square.client.view.selection.doublon.SelectionDoublonViewImpl.java

License:Open Source License

@Override
public void viderSelection() {
    mapCBSelectionnees.clear();//from w w  w. ja va 2  s.c  o m
    for (int i = 1; i < remotePagingTableDoublons.getFtResultats().getRowCount(); i++) {
        if (remotePagingTableDoublons.getFtResultats().getCellCount(i) > 8) {
            final CheckBox cb = (CheckBox) remotePagingTableDoublons.getFtResultats().getWidget(i, 8);
            cb.setEnabled(true);
            cb.setValue(false);
        }
    }
    btnValider.setEnabled(false);
    btnViderSelection.setEnabled(false);
}

From source file:com.square.composant.tarificateur.square.client.view.ligne.devis.LigneDevisViewImpl.java

License:Open Source License

/**
 * Affiche les informations d'une ligne de devis.
 *///w  w w  .j  ava 2s.c o  m
private void afficherInfosLigneDevis(LigneDevisModel ligneDevis, final boolean ligneLiee,
        boolean isLectureSeule, int numLigne) {
    // on rcupre la finalit
    final Long idFinalite = ligneDevis.getFinalite().getIdentifiant() != null
            ? ligneDevis.getFinalite().getIdentifiant()
            : constantesApp.getIdFinaliteEnCours();

    // on rcupre le critre optionnel ou pas du produit
    boolean isProduitOptionnel = true;
    if (ligneLiee && ligneDevis.getProduitOptionnel() != null) {
        isProduitOptionnel = ligneDevis.getProduitOptionnel().booleanValue();
    }

    // calcul du montant mensuel
    final float montantLigneMensuel = calculMontantMensuelLigne(ligneDevis.getMontantTtc().floatValue(),
            ligneDevis.getIdentifiantModePaiement());
    float montantLigneMensuelRemise = 0f;
    if (ligneDevis.getMontantRemise() != null) {
        montantLigneMensuelRemise = calculMontantMensuelLigne(ligneDevis.getMontantRemise().floatValue(),
                ligneDevis.getIdentifiantModePaiement());
    }

    // ajout du montant de la ligne au total sauf si ligne lie obligatoire
    if ((!ligneLiee || isProduitOptionnel) && montantLigneMensuelRemise != montantLigneMensuel) {
        montantTotalLignesGroupees += montantLigneMensuel;
        montantTotalLignesGroupeesRemise += montantLigneMensuelRemise;
    }

    final RadioButton rbLigneAdhesion = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneRefus = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneEnCours = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    final RadioButton rbLigneCorbeille = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne);
    rbLigneAdhesion.setTitle(viewConstants.titreRadioAccepte());
    rbLigneRefus.setTitle(viewConstants.titreRadioRefuse());
    rbLigneEnCours.setTitle(viewConstants.titreRadioEnCours());
    rbLigneCorbeille.setTitle(viewConstants.titreRadioCorbeille());
    rbLigneAdhesion.setEnabled(!isLectureSeule);
    rbLigneRefus.setEnabled(!isLectureSeule);
    rbLigneEnCours.setEnabled(!isLectureSeule);
    rbLigneCorbeille.setEnabled(!isLectureSeule);

    // on coche la finalite suivant le cas
    if (idFinalite.equals(constantesApp.getIdFinaliteAcceptee())) {
        rbLigneAdhesion.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteRefusee())) {
        rbLigneRefus.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteEnCours())) {
        rbLigneEnCours.setValue(Boolean.TRUE);
    } else if (idFinalite.equals(constantesApp.getIdFinaliteCorbeille())) {
        rbLigneCorbeille.setValue(Boolean.TRUE);
    }

    final CheckBox cbImprimerLigne = new CheckBox();
    cbImprimerLigne.setTitle(viewConstants.titreCheckboxSelection());

    mapRbLigneAdhesion.put(ligneDevis.getIdentifiant(), rbLigneAdhesion);
    mapRbLigneRefus.put(ligneDevis.getIdentifiant(), rbLigneRefus);
    mapRbLigneEnAttente.put(ligneDevis.getIdentifiant(), rbLigneEnCours);
    mapRbLigneCorbeille.put(ligneDevis.getIdentifiant(), rbLigneCorbeille);
    mapCbImprimerLigne.put(ligneDevis.getIdentifiant(), cbImprimerLigne);

    if (ligneLiee && !isProduitOptionnel) {
        // produit obligatoire non coch et non dcochable (non affich de toute faon)
        cbImprimerLigne.setValue(Boolean.FALSE);
        cbImprimerLigne.setEnabled(Boolean.FALSE);
    } else if (ligneLiee && isProduitOptionnel) {
        // On slectionne pour impression les produits bonus
        if (ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1())
                || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) {
            cbImprimerLigne.setValue(Boolean.TRUE);
        } else {
            // produit optionnel dcochable
            cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null
                    ? ligneDevis.getSelectionnePourImpression()
                    : Boolean.FALSE);
        }
        cbImprimerLigne.setEnabled(Boolean.TRUE);
    } else if (!ligneLiee) {
        // produit principal dcochable
        cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null
                && ligneDevis.getSelectionnePourImpression().booleanValue());
        cbImprimerLigne.setEnabled(Boolean.TRUE);
    }

    String libelleMontant = "";
    if (montantLigneMensuelRemise != montantLigneMensuel) {
        libelleMontant = numberFormat.format((double) montantLigneMensuel)
                + ComposantTarificateurConstants.ESPACE + viewConstants.symboleMonnaie();
    } else if (montantLigneMensuel != 0f
            && (ligneDevis.getNAAucunTarif() == null || !ligneDevis.getNAAucunTarif())) {
        libelleMontant = viewConstants.libelleOffert();
    }

    final Label lProduit = new Label();
    final Label lPrenomNomBeneficiaire = new Label();
    final HTML lCriteresProduit = new HTML();
    final Label lDateEffet = new Label();
    final Label lMontant = new Label();
    lDateEffet.setWordWrap(false);
    lMontant.setWordWrap(false);

    final String libelleProduit = ligneDevis.getLibelleProduit();

    lProduit.setText(libelleProduit);

    //limite le nombre de caractres
    final String nomPrenom = ligneDevis.getPrenomNomBeneficiaire();
    String nomPrenomLimite = nomPrenom;
    if (nomPrenom.length() > viewConstants.nbMaxCaracteresNomPrenom()) { //limite si superieur a la constante
        nomPrenomLimite = nomPrenomLimite.substring(0, viewConstants.nbMaxCaracteresNomPrenom()) + "...";
    }
    lPrenomNomBeneficiaire.setText(nomPrenomLimite);
    lPrenomNomBeneficiaire.setTitle(nomPrenom);

    lCriteresProduit.setHTML(getLibelleCriteresProduit(ligneDevis));
    lDateEffet.setText(ligneDevis.getDateEffet());
    lMontant.setText(libelleMontant);

    tableauLignesDevis.setWidget(numLigne, 0, lProduit);
    tableauLignesDevis.setWidget(numLigne, 1, lPrenomNomBeneficiaire);
    tableauLignesDevis.setWidget(numLigne, 2, lCriteresProduit);
    tableauLignesDevis.setWidget(numLigne, 3, lDateEffet);
    tableauLignesDevis.setWidget(numLigne, 4, lMontant);
    tableauLignesDevis.setWidget(numLigne, 5, rbLigneAdhesion);
    tableauLignesDevis.setWidget(numLigne, 6, rbLigneRefus);
    tableauLignesDevis.setWidget(numLigne, 7, rbLigneCorbeille);
    tableauLignesDevis.setWidget(numLigne, 8, rbLigneEnCours);
    tableauLignesDevis.setWidget(numLigne, 9, cbImprimerLigne);

    // mise en forme du tableau
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 0, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 1, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 2, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 3, HasAlignment.ALIGN_LEFT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 4, HasAlignment.ALIGN_RIGHT);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 5, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 6, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 7, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 8, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 9, HasAlignment.ALIGN_CENTER);
    tableauLignesDevis.getRowFormatter().setVerticalAlign(numLigne, HasAlignment.ALIGN_TOP);
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 0,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 1,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 3,
            ComposantTarificateur.RESOURCES.css().important());
    tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 4,
            ComposantTarificateur.RESOURCES.css().important());

    // Mise en forme spciale pour les lignes associes  des produits sans tarifs
    if (ligneDevis.getNAAucunTarif() != null && ligneDevis.getNAAucunTarif().booleanValue()) {
        tableauLignesDevis.getRowFormatter().addStyleName(numLigne,
                ComposantTarificateur.RESOURCES.css().produitSansTarif());
    }

    // si c'est une ligne liee dont le produit est obligatoire, ou si il s'agit d'un produit bonus
    if ((ligneLiee && !isProduitOptionnel)
            || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1())
            || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) {
        rbLigneAdhesion.setEnabled(false);
        rbLigneRefus.setEnabled(false);
        rbLigneEnCours.setEnabled(false);
        rbLigneCorbeille.setEnabled(false);
        // on cache la ligne
        tableauLignesDevis.getRowFormatter().setVisible(numLigne, false);
    }
}