Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

Introduction

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

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

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

License:Open Source License

/**
 * drawFormElement/*w  ww  .j a v a2  s.  c  o  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(" ");
        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.SearchPanel.java

License:Creative Commons License

public SearchPanel() {
    privateEventBus.addHandler(SearchCompletedEvent.TYPE, this);
    this.setHeight("100%");
    this.setWidth("100%");
    this.setStyleName("cent");
    this.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);

    this.add(new InlineHTML("<br>"));

    FlexTable layout = new FlexTable();
    layout.setCellSpacing(6);/* w ww  . jav  a  2 s .c  om*/
    FlexTable.FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();

    layout.setHTML(0, 0, "Find a person");
    cellFormatter.setColSpan(0, 0, 2);
    cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);

    layout.setHTML(1, 0, "Search Text");
    layout.setWidget(1, 1, searchField);

    layout.setWidget(2, 0, searchButton);
    cellFormatter.setColSpan(2, 0, 2);
    cellFormatter.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);

    searchButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            searchingPopup.center();
            DynamicRecruiter.RECRUIT_SERVICE.search(searchField.getText(),
                    new SearchDirectoryHandler(privateEventBus));
            noResults.setVisible(false);
        }
    });

    DecoratorPanel infoPanel = new DecoratorPanel();
    infoPanel.setWidget(layout);
    this.add(infoPanel);
    this.add(new InlineHTML("<br>"));
    this.add(addConfirmation);
    this.add(new InlineHTML("<br><br>"));
    this.add(table);

    noResults.setStyleName("gwt-Label-red");
    this.add(noResults);
    this.table.setVisible(false);
    this.noResults.setVisible(false);
    this.searchField.addKeyPressHandler(new SearchSubmitHandler());
}

From source file:com.qualogy.qafe.gwt.client.component.QPagingScrollTableOperation.java

License:Apache License

/**
 * Constructor.//from   w  w  w .  j  a  v a  2s . com
 *
 * @param table
 *            the table being affected
 * @param images
 *            the images to use
 */
// CHECKSTYLE.OFF: CyclomaticComplexity
public QPagingScrollTableOperation(final QPagingScrollTable table, ScrollTableOperationImages images) {
    this.table = table;
    if (this.table instanceof QPagingScrollTable) {
        ((QPagingScrollTable) this.table).setScrollTableOperations(this);
    }

    // Create the main widget
    HorizontalPanel hPanel = new HorizontalPanel();
    initWidget(hPanel);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    setStyleName(DEFAULT_STYLENAME);

    // Create the paging image buttons
    createPageButtons(images);

    // Create the error label
    errorLabel = new HTML();
    errorLabel.setStylePrimaryName("errorMessage");

    // Add the widgets to the panel
    hPanel.add(createSpacer());
    if (hasAddControl(table)) {
        hPanel.add(addImage);
        hPanel.add(createSpacer());
    }
    if (hasDeleteControl(table)) {
        hPanel.add(deleteImage);
        hPanel.add(createSpacer());
    }

    if (isEditableDatagrid(table) || hasDeleteControl(table) || hasAddControl(table)) {
        if (saveDatagrid(table)) {
            hPanel.add(saveImage);
            hPanel.add(createSpacer());
        }
        if (refreshDatagrid(table)) {
            hPanel.add(refreshImage);
            hPanel.add(createSpacer());
        }
        if (cancelDatagrid(table)) {
            hPanel.add(cancelImage);
            hPanel.add(createSpacer());
        }
    }

    hPanel.add(errorLabel);

    if (table.getSource().getImportEnabled() != null && table.getSource().getImportEnabled().booleanValue()) {
        final DisclosurePanel importPanel = new DisclosurePanel("Upload data");
        hPanel.add(importPanel);
        final FormPanel formPanel = new FormPanel();

        formPanel.setAction(GWT.getModuleBaseURL() + "/rpc.datagridupload");
        formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
        formPanel.setMethod(FormPanel.METHOD_POST);

        FileUpload fileUploadComponent = new FileUpload();
        fileUploadComponent.setName("uploadElement");

        Button uploadButtonComponent = new Button("Upload");
        uploadButtonComponent.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                formPanel.submit();
            }
        });

        CheckBox isFirstLineHeader = new CheckBox("Is first row header ?");
        isFirstLineHeader.setName("isFirstLineHeader");
        isFirstLineHeader.setTitle(
                "Check wheter or not the first line of the uploaded file is a header/column definition");
        HorizontalPanel hp = new HorizontalPanel();

        Label label = new Label("Delimeter");
        final TextBox delimiter = new TextBox();
        delimiter.setValue(",");
        delimiter.setTitle("Insert the delimeter (can be any value, as long it's length 1)");
        delimiter.setName("delimiter");
        delimiter.setWidth("15px");
        hp.setSpacing(10);
        hp.add(label);
        hp.add(delimiter);

        Grid gridPanel = new Grid(2, 4);
        gridPanel.setWidget(0, 0, fileUploadComponent);
        gridPanel.setWidget(0, 1, uploadButtonComponent);
        gridPanel.setWidget(1, 0, isFirstLineHeader);
        gridPanel.setWidget(1, 1, hp);

        formPanel.add(gridPanel);

        formPanel.addSubmitHandler(new FormPanel.SubmitHandler() {

            public void onSubmit(SubmitEvent event) {
                // This event is fired just before the form is submitted. We can
                // take
                // this opportunity to perform validation.
                if (delimiter.getText().length() == 0 || delimiter.getText().length() > 1) {
                    ClientApplicationContext.getInstance().log("Ooops...Delimeter invalid",
                            "Make sure there is valid delimeter value.One character only (current value ='"
                                    + delimiter.getText() + "'",
                            true);
                    event.cancel();
                }
            }

        });

        formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

            public void onSubmitComplete(SubmitCompleteEvent event) {
                String uuId = event.getResults();
                if (uuId != null && uuId.indexOf("=") > 0) {
                    uuId = uuId.substring(uuId.indexOf("=") + 1);
                    processData(uuId);
                    importPanel.setOpen(false);
                } else {
                    ClientApplicationContext.getInstance().log("Upload failed", event.getResults(), true);
                }
            }
        });
        importPanel.add(formPanel);
    }

    if (table.getSource() != null && table.getSource().getExport() != null
            && table.getSource().getExport().booleanValue()) {

        createExportLabelsAndImages();

        final DisclosurePanel exportPanel = new DisclosurePanel("Export");
        String[] labels = getExportLabels(table.getSource().getExportFormats());
        Image[] exportImages = getExportImages(labels);

        FlexTable gridExportPanel = new FlexTable();
        hPanel.add(exportPanel);
        exportPanel.add(gridExportPanel);
        final Frame frame = new Frame();
        frame.setHeight("0");
        frame.setWidth("0");
        frame.setVisible(false);
        final String moduleRelativeURL = GWT.getModuleBaseURL() + "/rpc.export";
        gridExportPanel.setWidget(0, 0, frame);

        final CheckBox generateColumnHeaderBox = new CheckBox("Generate Column Header");
        gridExportPanel.getFlexCellFormatter().setColSpan(1, 1, 7);
        gridExportPanel.setWidget(2, 1, generateColumnHeaderBox);
        gridExportPanel.getFlexCellFormatter().setColSpan(2, 1, 6);

        for (int i = 0; i < labels.length; i++) {

            exportImages[i].setStylePrimaryName("datagridexportlabel");
            exportImages[i].setTitle(labels[i]);
            gridExportPanel.setWidget(0, i + 1, exportImages[i]);

            exportImages[i].addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (event.getSource() instanceof Image) {
                        Image image = (Image) (event.getSource());
                        final String exportCode = image.getTitle();
                        RPCServiceAsync service = MainFactoryActions.createService();
                        AsyncCallback<?> callback = new AsyncCallback<Object>() {
                            public void onSuccess(Object result) {
                                String uuid = (String) result;
                                // set frame
                                frame.setUrl(moduleRelativeURL + "?uuid=" + uuid);
                                ClientApplicationContext.getInstance().setBusy(false);
                            }

                            public void onFailure(Throwable caught) {

                                ClientApplicationContext.getInstance().log("Export failed",
                                        "Export failed for " + exportCode + " ", true, true, caught);
                                ClientApplicationContext.getInstance().setBusy(false);
                                FunctionsExecutor.setProcessedBuiltIn(true);
                            }
                        };
                        List<DataContainerGVO> dList = new ArrayList<DataContainerGVO>();
                        // following loop is to maintain the order of rows while exporting.
                        for (int i = 0; i < (table.getAbsoluteLastRowIndex() + 1); i++) {
                            dList.add(table.getRowValue(i));
                        }
                        service.prepareForExport(dList, exportCode, null,
                                generateColumnHeaderBox.getValue().booleanValue(), callback);
                    }
                }
            });
        }
    }
}

From source file:com.qualogy.qafe.gwt.client.factory.MainFactory.java

License:Apache License

public static void createTryMeWindow(String subwindow) {

    final WindowPanel w = new WindowPanel("Try me!");

    w.setResizable(true);//w  ww .  jav a2  s  .  c o m

    w.setAnimationEnabled(true);
    w.setSize("800px", "500px");

    VerticalPanel verticalPanel = new VerticalPanel();
    final ScrollLayoutPanel vp = new ScrollLayoutPanel();
    vp.setAlwaysShowScrollBars(false);
    vp.setWidth("800px");
    vp.setHeight("500px");
    w.setWidget(verticalPanel);
    // vp.setSpacing(5);
    // vp.setWidth("100%");
    final TabPanel tabPanel = new TabPanel();
    tabPanel.setAnimationEnabled(true);
    tabPanel.setWidth("580px");
    tabPanel.setHeight("500px");

    DockPanel dockPanel = new DockPanel();
    dockPanel.setWidth("580px");
    dockPanel.setHeight("500px");
    tabPanel.add(dockPanel, "Insert code!");
    final TextArea textArea = new TextArea();
    textArea.setVisibleLines(30);
    textArea.setHeight("auto");
    textArea.setWidth("580px");
    DOM.setElementAttribute(textArea.getElement(), "font-size", "10pt");

    dockPanel.add(textArea, DockPanel.CENTER);
    final MenuBar menu = new MenuBar();
    MenuBar renderMenu = new MenuBar(true);
    w.addResizeHandler(new ResizeHandler() {

        public void onResize(ResizeEvent event) {
            int height = event.getHeight();
            int width = event.getWidth();

            if (w.getWidget() != null) {
                w.setHeight((height) + "px");
                w.setWidth((width) + "px");
                vp.setHeight((height - 20) + "px");
                vp.setWidth((width - 20) + "px");
                tabPanel.setHeight((height - 20) + "px");
                tabPanel.setWidth((width - 20) + "px");
                menu.setWidth((width) + "px");
                textArea.setWidth((width - 20) + "px");
            }

        }
    });

    MenuItem gwtMenuItem = new MenuItem("GWT output", new Command() {

        public void execute() {
            String xml = textArea.getText();
            if (xml == null || xml.length() == 0) {
                MessageBox.error("Try me:Error", "There is no input");
            } else {
                MainFactoryActions.processUIXml(xml);
            }

        }
    });
    MenuItem flexMenuItem = new MenuItem("Flex output", new Command() {

        public void execute() {
            String xml = textArea.getText();
            if (xml == null || xml.length() == 0) {
                MessageBox.error("Try me:Error", "There is no input");
            } else {
                MainFactoryActions.processUIXmlFlex(xml);
            }

        }
    });

    renderMenu.addItem(gwtMenuItem);
    renderMenu.addItem(flexMenuItem);

    MenuBar codeMenu = new MenuBar(true);

    MenuItem clearXmlInput = new MenuItem("Clear", new Command() {

        public void execute() {
            textArea.setText("");

        }
    });

    MenuItem createHeaderButton = new MenuItem("Create Header", new Command() {

        public void execute() {
            final String headerText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                    + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n"
                    + "  <!-- PLEASE ENTER YOUR CODE HERE --> \n" + "</application-mapping> \n";

            textArea.setText(headerText);

        }
    });

    MenuItem createSampleAppButton = new MenuItem("Create Sample Application", new Command() {

        public void execute() {
            final String sampleText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                    + "<application-mapping xmlns=\"http://qafe.com/schema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://qafe.com/schema http://www.qafe.com/schema/2.2/application-mapping.xsd\"> \n"
                    + "<presentation-tier>\n" + "  <view>\n"
                    + "    <window id=\"window1\" displayname=\"Hello World\" width=\"200\" height=\"200\">\n"
                    + "      <rootpanel id=\"myRootPanel\">   \n" + "        <verticallayout>\n\n"
                    + "          <!-- PLEASE ENTER HERE YOUR CODE -->\n\n"
                    + "          <label id=\"mylabel\" displayname=\"Hello World\" />\n\n"
                    + "        </verticallayout>\n" + "      </rootpanel>\n" + "    </window>\n" + " </view>\n"
                    + "</presentation-tier>\n" +

                    "</application-mapping> \n";

            textArea.setText(sampleText);

        }
    });

    codeMenu.addItem(clearXmlInput);
    codeMenu.addItem(createHeaderButton);
    codeMenu.addItem(createSampleAppButton);

    menu.addItem("Render", renderMenu);
    menu.addItem("Code", codeMenu);

    if (menu != null) {
        verticalPanel.add(menu);
    }
    verticalPanel.add(vp);

    // w.setWidget(tabPanel);

    /*
     * FMB Upload
     */
    final FormPanel fmbForm = new FormPanel();
    fmbForm.setAction(GWT.getModuleBaseURL() + "/rpc.fmbupload");

    // Because we're going to add a FileUpload widget, we'll need to set the
    // form to use the POST method, and multipart MIME encoding.
    fmbForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    fmbForm.setMethod(FormPanel.METHOD_POST);
    // Create a panel to hold all of the form widgets.
    VerticalPanel panelFmbUpload = new VerticalPanel();
    panelFmbUpload.setWidth("580px");
    panelFmbUpload.setHeight("500px");
    // panelFmbUpload.setHeight("100%");

    final FileUpload fmbFile = new FileUpload();
    final TextBox emailBox = new TextBox();
    final TextBox phoneBox = new TextBox();
    fmbFile.setName("fmbUploadElement");

    // Add an event handler to the form.
    fmbForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {

            if (event.getResults() != null) {
                if (event.getResults().startsWith("Conversion failed")) {
                    ClientApplicationContext.getInstance().log("Conversion failed",
                            "The file doesn't seem to be a valid Oracle Forms file. If you still want it to be converted for demo purpose, you can also send it to info@qafe.com",
                            true);

                } else if (event.getResults().startsWith("UUID")) {

                    String[] split = event.getResults().split("=");
                    if (split.length == 2) {
                        String uuid = split[1];
                        MainFactoryActions.processUIByUUID(uuid, textArea);
                        MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]",
                                "The message was sent by " + emailBox.getText() + " with optional phonenr: "
                                        + phoneBox.getText());
                        tabPanel.selectTab(0);
                    }
                } else {
                    // firefox workaround
                    String[] split = event.getResults().split("=");
                    if (split.length == 2) {
                        String uuid = split[1];

                        uuid = uuid.replaceAll("</pre>", "");
                        MainFactoryActions.processUIByUUID(uuid, textArea);
                        MainFactoryActions.notify("FMB uploaded with filename [" + fmbFile.getFilename() + "]",
                                "The message was sent by " + emailBox.getText() + " with optional phonenr: "
                                        + phoneBox.getText());
                        tabPanel.selectTab(0);
                    } else {
                        ClientApplicationContext.getInstance().log(event.getResults());
                    }
                }

            } else {
                ClientApplicationContext.getInstance().log(
                        "The Forms Conversion process could not handle this file. Please check the file.",
                        "Check whether or not this file is an FMB (not an FMX)", true);
            }
        }
    });

    FlexTable tempFmbPanel = new FlexTable();
    tempFmbPanel.setWidget(0, 1, fmbFile);
    tempFmbPanel.setWidget(0, 0, new Label("Input for FMB"));

    tempFmbPanel.setWidget(1, 0, new HTML(
            "<p>Note: the FMB you are uploading is only for <span style=\"color:red;\">demo</span> purpose.</p>"
                    + "<p>FMB's can have external dependencies like <span style=\"color:red;\">PLL, OLB's, images</span>,etc. Since they are <span style=\"color:red;\">not</span> included in the upload, the output might not appear correct.</p>"
                    + "<p>For a more detailed conversion of your FMB's please contact us at <span style=\"color:red;\">info@qafe.com </span></p> <p/>"
                    + "<p>Please fill in the information below, so that we can contact you for more information</p> "));
    tempFmbPanel.getFlexCellFormatter().setColSpan(1, 0, 2);

    tempFmbPanel.setWidget(2, 0, new Label("E-mail: (required)"));

    emailBox.setName("fmbEmail");
    emailBox.addBlurHandler(new BlurHandler() {

        public void onBlur(BlurEvent event) {
            String textValue = ((TextBoxBase) event.getSource()).getText();
            if (textValue != null) {
                if (textValue.replaceFirst(TextFieldGVO.REGEXP_TYPE_EMAIL_VALUE, "").length() > 0) {
                    ClientApplicationContext.getInstance().log("Email validation error",
                            TextFieldGVO.TYPE_EMAIL_DEFAULT_MESSAGE, true);
                }
            }

        }
    });
    tempFmbPanel.setWidget(2, 1, emailBox);

    tempFmbPanel.setWidget(3, 0, new Label("Phonenr:"));

    phoneBox.setName("fmbPhone");
    phoneBox.addBlurHandler(new BlurHandler() {

        public void onBlur(BlurEvent event) {

        }
    });
    tempFmbPanel.setWidget(3, 1, phoneBox);

    fmbForm.add(tempFmbPanel);

    panelFmbUpload.add(fmbForm);
    // Add a 'submit' button.
    panelFmbUpload.add(new Button("Generate", new ClickHandler() {

        public void onClick(ClickEvent event) {
            fmbForm.submit();

        }
    }));
    // Add an event handler to the form.
    fmbForm.addSubmitHandler(new FormPanel.SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            // This event is fired just before the form is submitted. We can take
            // this opportunity to perform validation.
            if (emailBox.getText().length() == 0) {
                ClientApplicationContext.getInstance().log("Email validation error",
                        "Please fill in your email address", true);
                event.cancel();
            } else if (fmbFile.getFilename() == null || fmbFile.getFilename().length() == 0) {
                ClientApplicationContext.getInstance().log("Uploaded file validation error",
                        "There is no file selected. Please select one to continue", true);
                event.cancel();
            }
        }
    });

    tabPanel.add(panelFmbUpload, "Forms Conversion");

    vp.add(tabPanel);
    w.center();
    if (QAFEKeywordsGVO.SYSTEM_MENUITEM_TRYME_FORMS.equals(subwindow)) {
        tabPanel.selectTab(1);

    } else {
        tabPanel.selectTab(0);
    }
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.PanelRenderer.java

License:Apache License

public UIObject render(ComponentGVO component, String uuid, String parent, String context) {
    UIObject panel = null;/*ww w  .  ja v a2s . com*/
    if (component != null) {
        if (component instanceof PanelGVO) {
            final ComponentGVO finalComponentGVO = component;
            final String finalUuid = uuid;
            final String finalParent = parent;
            final PanelGVO root = (PanelGVO) component;
            LayoutGVO layout = root.getLayout();
            if (layout instanceof AutoLayoutGVO) {
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new FlexTable() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new FlexTable();
                }
                panel.setTitle(component.getTooltip());
                AutoLayoutGVO autoLayoutGVO = (AutoLayoutGVO) layout;
                int columns = autoLayoutGVO.getCols() != null ? autoLayoutGVO.getCols().intValue() : 1;
                UIObject[] children = renderChildComponents(layout.getComponents(), uuid, parent, context);

                if (children != null) {
                    int nrOfRows = (children.length / columns) + 1;

                    for (int i = 0; i < nrOfRows; i++) {
                        for (int j = 0; j < columns; j++) {
                            int element = (i * columns) + j;
                            if (element < children.length) {
                                if (children[element] != null) {
                                    if (children[element] instanceof Widget) {
                                        ((FlexTable) panel).setWidget(i, j, (Widget) children[element]);
                                    }
                                }
                            }
                        }
                    }
                }
            } else if (layout instanceof AbsoluteLayoutGVO) {
                AbsoluteLayoutGVO absoluteLayout = (AbsoluteLayoutGVO) layout;
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new AbsolutePanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new AbsolutePanel();
                }
                AbsolutePanel absolutePanel = (AbsolutePanel) panel;
                ElementGVO[] elementGVOs = absoluteLayout.getElements();
                if (elementGVOs != null) {
                    for (int i = 0; i < elementGVOs.length; i++) {
                        UIObject uiObject = super.renderChildComponent(elementGVOs[i].getComponent(), uuid,
                                parent, context);
                        if (uiObject instanceof Widget) {
                            absolutePanel.add((Widget) uiObject, elementGVOs[i].getX(), elementGVOs[i].getY());
                        }
                    }
                }
            } else if (layout instanceof GridLayoutGVO) {
                GridLayoutGVO gridLayout = (GridLayoutGVO) layout;
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new FlexTable() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new FlexTable();
                }
                ElementGVO[] elementGVOs = gridLayout.getElements();
                if (elementGVOs != null) {
                    int maxX = 0;
                    int maxY = 0;
                    for (int i = 0; i < elementGVOs.length; i++) {
                        if (maxX < elementGVOs[i].getX()) {
                            maxX = elementGVOs[i].getX();
                        }
                        if (maxY < elementGVOs[i].getY()) {
                            maxY = elementGVOs[i].getY();
                        }
                    }
                    RendererHelper.addMenu(component, panel, uuid, parent);
                    FlexTable flexTable = (FlexTable) panel;
                    flexTable.setTitle(root.getTooltip());
                    for (int i = 0; i < elementGVOs.length; i++) {
                        UIObject uiObject = super.renderChildComponent(elementGVOs[i].getComponent(), uuid,
                                parent, context);
                        if (uiObject instanceof Widget) {
                            flexTable.setWidget(elementGVOs[i].getY(), elementGVOs[i].getX(),
                                    (Widget) uiObject);
                            if (elementGVOs[i].getStyleClass() != null
                                    && elementGVOs[i].getStyleClass().length() > 0) {
                                flexTable.getFlexCellFormatter().setStyleName(elementGVOs[i].getY(),
                                        elementGVOs[i].getX(), elementGVOs[i].getStyleClass());
                            }
                            Element gvoElement = flexTable.getFlexCellFormatter()
                                    .getElement(elementGVOs[i].getY(), elementGVOs[i].getX());
                            RendererHelper.setStyleForElement(gvoElement, elementGVOs[i].getStyleProperties());
                            if (elementGVOs[i].getGridwidth() > 0) {
                                flexTable.getFlexCellFormatter().setColSpan(elementGVOs[i].getY(),
                                        elementGVOs[i].getX(), elementGVOs[i].getGridwidth());
                            }
                            if (elementGVOs[i].getGridheight() > 0) {
                                flexTable.getFlexCellFormatter().setRowSpan(elementGVOs[i].getY(),
                                        elementGVOs[i].getX(), elementGVOs[i].getGridheight());
                            }
                        }
                    }
                }
            } else if (layout instanceof HorizontalLayoutGVO) {
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new HorizontalPanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new HorizontalPanel();
                }
                performCommonTasks(root, panel, uuid, parent);
            } else if (layout instanceof VerticalLayoutGVO) {
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new VerticalPanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new VerticalPanel();
                }
                performCommonTasks(root, panel, uuid, parent);
            } else if (layout instanceof AbsoluteLayoutGVO) {
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new DockPanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new DockPanel();
                }
                performCommonTasks(root, (Panel) panel, uuid, parent);
            } else if (layout instanceof BorderLayoutGVO) {
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    panel = new DockPanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    panel = new DockPanel();
                }
                DockPanel dockPanel = (DockPanel) panel;
                dockPanel.setHorizontalAlignment(DockPanel.ALIGN_CENTER);
                dockPanel.setSpacing(3);
                BorderLayoutGVO borderLayoutGVO = (BorderLayoutGVO) layout;
                if (borderLayoutGVO.getNorth() != null) {
                    dockPanel.add(
                            (Widget) renderChildComponent(borderLayoutGVO.getNorth(), uuid, parent, context),
                            DockPanel.NORTH);
                }
                if (borderLayoutGVO.getSouth() != null) {
                    dockPanel.add(
                            (Widget) renderChildComponent(borderLayoutGVO.getSouth(), uuid, parent, context),
                            DockPanel.SOUTH);
                }
                if (borderLayoutGVO.getEast() != null) {
                    dockPanel.add(
                            (Widget) renderChildComponent(borderLayoutGVO.getEast(), uuid, parent, context),
                            DockPanel.EAST);
                }
                if (borderLayoutGVO.getWest() != null) {
                    dockPanel.add(
                            (Widget) renderChildComponent(borderLayoutGVO.getWest(), uuid, parent, context),
                            DockPanel.WEST);
                }
                if (borderLayoutGVO.getCenter() != null) {
                    dockPanel.add(
                            (Widget) renderChildComponent(borderLayoutGVO.getCenter(), uuid, parent, context),
                            DockPanel.CENTER);
                }

            }
            if (root.getConcurrentModificationEnabled() && (root.getFieldName() != null)
                    && !root.getFieldName().isEmpty()) {
                addChecksum(panel);
            }
            if (root.getFieldName() != null && root.getFieldName().length() > 0
                    && root.getShowdatacontrol() != null && root.getShowdatacontrol().booleanValue()) {
                DockPanel dockPanel = null;
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    dockPanel = new DockPanel() {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    dockPanel = new DockPanel();
                }
                dockPanel.add(createDataPanelToolBar(root, uuid, parent), DockPanel.NORTH);
                dockPanel.add((Widget) panel, DockPanel.NORTH);
                panel = dockPanel;
            }
            if (root.getDisclosure()) {
                DisclosurePanel disclosurePanel = new DisclosurePanel(root.getTitle());
                disclosurePanel.setAnimationEnabled(true);
                disclosurePanel.add((Widget) panel);
                panel = disclosurePanel;
            } else if (root.getTitle() != null && root.getTitle().length() > 0) {
                CaptionPanel titledPanel = null;
                if (root.getMenu() != null && !(component instanceof RootPanelGVO)) {
                    titledPanel = new CaptionPanel(root.getTitle()) {
                        @Override
                        public void onBrowserEvent(Event event) {
                            if (event.getTypeInt() == Event.ONCONTEXTMENU) {
                                DOM.eventPreventDefault(event);
                                applyContextMenu(event, finalComponentGVO, finalUuid, finalParent);
                            }
                            super.onBrowserEvent(event);
                        }

                        @Override
                        protected void setElement(Element elem) {
                            super.setElement(elem);
                            sinkEvents(Event.ONCONTEXTMENU);
                        }
                    };
                } else {
                    titledPanel = new CaptionPanel(root.getTitle());
                }
                titledPanel.add((Widget) panel);
                panel = titledPanel;
            }

            RendererHelper.fillIn(component, panel, uuid, parent, context);
        }
    }
    return panel;
}

From source file:com.square.client.gwt.client.composant.onglet.scroll.DoubleTabPanelScroll.java

License:Open Source License

/**
 * Creates an empty tab panel./*  w  w  w  . j a v a 2  s. c o m*/
 * @param nbOngletsStatiques nombre d'onglets statiques
 * @param width largeur du scrollPanel, en units CSS (e.g. "10px", "1em")
 */
public DoubleTabPanelScroll(int nbOngletsStatiques, int width) {
    this.nbOngletsStatiques = nbOngletsStatiques;
    dynamicTabBar = new ExtendedTabBar();
    staticTabBar = new ExtendedTabBar();
    tabBar = new ExtendedDoubleTabBar(staticTabBar, dynamicTabBar, nbOngletsStatiques);
    deck = new TabbedDeckPanel(tabBar);
    scrollPanel = new ExtendedScrollPanel(dynamicTabBar, width);
    scrollPanel.addStyleName(SquareResources.INSTANCE.css().scrollPanel());
    final VerticalPanel panel = new VerticalPanel();

    final FlexTable panelTabBars = new FlexTable();
    panelTabBars.getFlexCellFormatter().addStyleName(0, 0, SquareResources.INSTANCE.css().ongletsStatiques());
    panelTabBars.addStyleName(SquareResources.INSTANCE.css().barreOnglets());
    panelTabBars.setWidget(0, 0, staticTabBar);
    panelTabBars.setCellPadding(0);
    panelTabBars.setCellSpacing(0);

    panelTabBars.setWidget(0, 1, scrollPanel);
    panelTabBars.getFlexCellFormatter().addStyleName(0, 1, SquareResources.INSTANCE.css().ongletsDynamiques());
    panelTabBars.getFlexCellFormatter().setHorizontalAlignment(0, 1, HorizontalPanel.ALIGN_LEFT);

    panel.add(panelTabBars);
    panel.add(deck);
    panel.setCellHeight(deck, "100%");

    final int idxDecalage = nbOngletsStatiques;
    dynamicTabBar.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            staticTabBar.selectTab(-1);
            scrollPanel.ensureVisible((UIObject) (dynamicTabBar.getTab(event.getSelectedItem())));
            scrollPanel.refreshScrollButtons();
            deck.showWidget(event.getSelectedItem() + idxDecalage);
            fireSelectionEvent(event.getSelectedItem() + idxDecalage);
        }
    });

    dynamicTabBar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            fireBeforeSelectionEvent(event.getItem() + idxDecalage);
        }
    });

    staticTabBar.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            dynamicTabBar.selectTab(-1);
            deck.showWidget(event.getSelectedItem());
            fireSelectionEvent(event.getSelectedItem());
        }
    });
    staticTabBar.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            fireBeforeSelectionEvent(event.getItem());
        }
    });
    initWidget(panel);
    setStyleName("gwt-TabPanel");
    deck.setStyleName("gwt-TabPanelBottom");
    // Add a11y role "tabpanel"
    Accessibility.setRole(deck.getElement(), Accessibility.ROLE_TABPANEL);
}

From source file:com.square.client.gwt.client.view.action.creation.ActionCreationViewImpl.java

License:Open Source License

/** Construction du bloc de planification. */
private void construireBlocPlanification() {
    final SuggestListBoxSingleProperties<IdentifiantLibelleGwt> slbIdentifiantLibelleProperties = new SuggestListBoxSingleProperties<IdentifiantLibelleGwt>() {
        @Override/*w  ww  .  j  a  v  a2 s . co  m*/
        public String getSelectSuggestRenderer(IdentifiantLibelleGwt row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleGwt row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    final Label labelAFaire = new Label(viewConstants.labelAFaire(), false);
    cdbDateAction = new DecoratedCalendrierDateBox(true);
    cdbDateAction.ensureDebugId(viewDebugIdConstants.debugIdCdbDateAction());
    aidecdbDateAction = new AideComposant(AideComposantConstants.AIDE_ACTION_CREATION_DATE, isAdmin);
    // listComposantAide.add(aidecdbDateAction);
    ajouterAideComposant(aidecdbDateAction);
    final Label labelDebut = new Label(viewConstants.labelDebut(), false);
    tbfHeureAction = new DecoratedTextBoxFormat("NN:NN");
    tbfHeureAction.ensureDebugId(viewDebugIdConstants.debugIdTbfHeureAction());
    tbfHeureAction.addStyleName(SquareResources.INSTANCE.css().heureDate());
    aideTbfHeureAction = new AideComposant(AideComposantConstants.AIDE_ACTION_CREATION_HEURE, isAdmin);
    HorizontalPanel panelHeure = new HorizontalPanel();
    panelHeure.setSpacing(5);
    panelHeure.add(tbfHeureAction);
    panelHeure.add(aideTbfHeureAction);
    panelHeure.setCellVerticalAlignment(aideTbfHeureAction, HasAlignment.ALIGN_MIDDLE);
    ajouterAideComposant(aideTbfHeureAction);
    final Label labelDuree = new Label(viewConstants.labelDuree(), false);
    slbDuree = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    slbDuree.ensureDebugId(viewDebugIdConstants.debugIdSlbDuree());
    slbDuree.setWidth(ActionCreationViewImplConstants.LARGEUR_SLB_DUREE);
    aideSlbDuree = new AideComposant(100014L, isAdmin);
    ajouterAideComposant(aideSlbDuree);

    // Constuction de la priorite
    final Label lpriorite = new Label(viewConstants.priorite());
    slbPriorite = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    slbPriorite.ensureDebugId(viewDebugIdConstants.debugIdSlbPriorite());
    aideSlbPriorite = new AideComposant(AideComposantConstants.AIDE_ACTION_CREATION_PRIORITE, isAdmin);
    HorizontalPanel panelPriorite = new HorizontalPanel();
    panelPriorite.setSpacing(5);
    panelPriorite.add(slbPriorite);
    panelPriorite.add(aideSlbPriorite);
    ajouterAideComposant(aideSlbPriorite);

    final CaptionPanel captionPanel = new CaptionPanel(viewConstants.libellePanelPlanification());
    final FlexTable flexTable = new FlexTable();
    flexTable.setWidth(AppControllerConstants.POURCENT_100);
    flexTable.setCellSpacing(3);
    flexTable.setWidget(0, 0, labelAFaire);
    flexTable.setWidget(0, 1,
            construireBlocIcone(cdbDateAction, "ActionCreationDto.dateAction", aidecdbDateAction));
    flexTable.setWidget(0, 2, labelDebut);
    flexTable.setWidget(0, 3, panelHeure);
    flexTable.setWidget(0, 4, labelDuree);
    flexTable.setWidget(0, 5, construireBlocIcone(slbDuree, "ActionCreationDto.idDuree", aideSlbDuree));
    flexTable.setWidget(1, 0, lpriorite);
    flexTable.setWidget(1, 1, panelPriorite);
    flexTable.getFlexCellFormatter().setColSpan(1, 1, 5);
    flexTable.getRowFormatter().setVerticalAlign(0, HasAlignment.ALIGN_MIDDLE);
    flexTable.getRowFormatter().setVerticalAlign(1, HasAlignment.ALIGN_MIDDLE);
    flexTable.getColumnFormatter().setWidth(0, ActionCreationViewImplConstants.LARGEUR_COL_LIBELLE);

    captionPanel.add(flexTable);
    conteneurGlobal.add(captionPanel);
}

From source file:com.square.client.gwt.client.view.personne.action.PersonneActionContenuViewImpl.java

License:Open Source License

private void constructionAction() {
    final CaptionPanel captionAction = new CaptionPanel(constants.titreAction());

    final SuggestListBoxSingleProperties<IdentifiantLibelleGwt> properties = new SuggestListBoxSingleProperties<IdentifiantLibelleGwt>() {
        @Override//from  w  w  w. j a v a 2  s.  com
        public String getSelectSuggestRenderer(IdentifiantLibelleGwt row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleGwt row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    // Construction partie nature, rsultat
    final FlexTable ftNatureResultat = new FlexTable();
    ftNatureResultat.setWidth(AppControllerConstants.POURCENT_100);
    ftNatureResultat.getColumnFormatter().setWidth(0, "15%");
    ftNatureResultat.getColumnFormatter().setWidth(1, "35%");
    ftNatureResultat.getColumnFormatter().setWidth(2, "15%");
    ftNatureResultat.getColumnFormatter().setWidth(3, "35%");
    ftNatureResultat.setCellSpacing(5);

    // Nature
    slbNatureContact = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(properties);
    slbNatureContact.ensureDebugId(viewDebudIdConstants.debugIdSlbsNatureContactAction());
    aideslbNatureContact = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_NATURE_CONTACT,
            isAdmin);
    ajouterAideComposant(aideslbNatureContact);
    slbNatureResultat = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(properties);
    slbNatureResultat.ensureDebugId(viewDebudIdConstants.debugIdSlbsNatureResultatAction());
    aideslbNatureResultat = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_NATURE_RESULTAT,
            isAdmin);
    ajouterAideComposant(aideslbNatureResultat);
    // aideslbNatureContact = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_NATURE_CONTACT, isAdmin);
    // ajouterAideComposant(aideslbNatureContact);
    final HorizontalPanel hpNatureContact = new HorizontalPanel();
    hpNatureContact.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hpNatureContact.add(slbNatureContact);
    hpNatureContact
            .add(iconeErreurChampManager.createInstance("ActionModificationDto.nature", slbNatureContact));
    hpNatureContact.add(aideslbNatureContact);
    hpNatureContact.setSpacing(2);
    lEtat = new Label("");
    panelEtat = new HorizontalPanel();
    panelEtat.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panelEtat.add(slbNatureResultat);
    panelEtat.add(
            iconeErreurChampManager.createInstance("ActionModificationDto.natureResultat", slbNatureResultat));
    panelEtat.add(aideslbNatureResultat);
    panelEtat.setSpacing(2);

    // Opportunit
    final Label ltitreOpportunite = new Label(constants.libelleOpportunite());
    lOpportunite = new Hyperlink();
    lOpportunite.setStyleName("lienSquare");
    aidelOpportunite = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_OPPORTUNITE, isAdmin);
    ajouterAideComposant(aidelOpportunite);
    final HorizontalPanel panelLink = new HorizontalPanel();
    panelLink.add(lOpportunite);
    panelLink.add(aidelOpportunite);
    panelLink.setCellVerticalAlignment(aidelOpportunite, HasVerticalAlignment.ALIGN_MIDDLE);
    panelLink.setCellVerticalAlignment(lOpportunite, HasVerticalAlignment.ALIGN_MIDDLE);
    panelLink.setSpacing(10);
    // Statut de l'action
    final HorizontalPanel panelStatut = new HorizontalPanel();
    panelStatut.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    panelStatut.setSpacing(2);
    final Label libelleStatut = new Label(constants.libelleStatut());
    slbStatut = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(properties);
    slbStatut.ensureDebugId(viewDebudIdConstants.debugIdSlbStatut());
    aideslbStatut = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_STATUT, isAdmin);
    ajouterAideComposant(aideslbStatut);
    panelStatut.add(slbStatut);
    panelStatut.add(iconeErreurChampManager.createInstance("ActionModificationDto.statut", slbStatut));
    panelStatut.add(aideslbStatut);

    // Rsultat de l'action
    slbsResultatAction = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(properties);
    slbsResultatAction.ensureDebugId(viewDebudIdConstants.debugIdSlbsResultatAction());
    aideslbsResultatAction = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_RESULTAT_ACTION,
            isAdmin);
    ajouterAideComposant(aideslbsResultatAction);
    final HorizontalPanel panelResultatAction = new HorizontalPanel();
    panelResultatAction.add(slbsResultatAction);
    panelResultatAction.add(aideslbsResultatAction);
    panelResultatAction.setSpacing(10);

    final Label libelleResultat = new Label(constants.libelleResultat());

    // Construction zone de text pour l'historique des actions prcdentes
    htmlHistorique = new HTML();
    htmlHistorique.ensureDebugId(viewDebudIdConstants.debugIdTaHistorique());
    htmlHistorique.setWidth(AppControllerConstants.POURCENT_100);
    aidehtmlHistorique = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_HISTORIQUE, isAdmin);
    ajouterAideComposant(aidehtmlHistorique);

    final ScrollPanel conteneurHistorique = new ScrollPanel();
    conteneurHistorique.setStylePrimaryName(SquareResources.INSTANCE.css().historiqueAction());
    conteneurHistorique.setWidth(AppControllerConstants.POURCENT_100);
    conteneurHistorique.setHeight("100px");
    conteneurHistorique.add(htmlHistorique);

    // Zone de texte
    rtaDescriptif = new RichTextArea();
    rtaDescriptif.ensureDebugId(viewDebudIdConstants.debugIdRtaDescriptif());
    rttToolbar = new RichTextToolbar(rtaDescriptif, RichTextToolbar.BOLD, RichTextToolbar.ITALIC,
            RichTextToolbar.UNDERLINE);
    rttToolbar.ensureDebugId(viewDebudIdConstants.debugIdRttToolbar());
    rtpCommmentaire = new RichTextPanel(rttToolbar, rtaDescriptif);
    rtpCommmentaire.ensureDebugId(viewDebudIdConstants.debugIdRtpCommmentaire());
    rttToolbar.setWidth(AppControllerConstants.POURCENT_100);
    rtpCommmentaire.setWidth(AppControllerConstants.POURCENT_100);
    aidertpCommentaire = new AideComposant(AideComposantConstants.AIDE_PERSONNE_ACTION_COMMENTAIRE, isAdmin);
    ajouterAideComposant(aidertpCommentaire);

    ftNatureResultat.setWidget(0, 0, new Label(constants.libelleNatureAction()));
    ftNatureResultat.setWidget(0, 1, hpNatureContact);
    ftNatureResultat.setWidget(0, 2, lEtat);
    ftNatureResultat.setWidget(0, 3, panelEtat);
    ftNatureResultat.setWidget(1, 0, ltitreOpportunite);
    ftNatureResultat.setWidget(1, 1, panelLink);
    ftNatureResultat.setWidget(2, 0, libelleStatut);
    ftNatureResultat.setWidget(2, 1, panelStatut);
    ftNatureResultat.setWidget(3, 0, libelleResultat);
    ftNatureResultat.setWidget(3, 1, panelResultatAction);
    ftNatureResultat.setWidget(4, 0, new Label(constants.notes()));
    ftNatureResultat.getFlexCellFormatter().setColSpan(4, 0, 4);
    ftNatureResultat.setWidget(5, 0, aidehtmlHistorique);
    ftNatureResultat.setWidget(6, 0, conteneurHistorique);
    ftNatureResultat.getFlexCellFormatter().setColSpan(6, 0, 4);
    ftNatureResultat.setWidget(7, 0, aidertpCommentaire);
    ftNatureResultat.setWidget(8, 0, rtpCommmentaire);
    ftNatureResultat.getFlexCellFormatter().setColSpan(8, 0, 4);

    captionAction.add(ftNatureResultat);
    flexTable.setWidget(3, 0, captionAction);
    flexTable.getFlexCellFormatter().setColSpan(3, 0, 2);
}

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

License:Open Source License

/**
 * Construit le bloc des criteres de recherche.
 *//* ww  w .  j  ava2  s.  c o  m*/
private void construireBlocChefFamille() {
    final Label lCivilite = new Label(viewConstants.civilite(), false);
    final Label lNom = new Label(viewConstants.nom(), false);
    final Label lDateNaissance = new Label(viewConstants.dateNaissance(), false);
    final Label lEmail = new Label(viewConstants.email(), false);
    final Label lTelephone = new Label(viewConstants.telephone(), false);
    final Label lProfession = new Label(viewConstants.profession(), false);

    slbIdentifiantLibelleProperties = new SuggestListBoxSingleProperties<IdentifiantLibelleGwt>() {
        @Override
        public String getSelectSuggestRenderer(IdentifiantLibelleGwt row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleGwt row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    slbIdentifiantLibelleBooleanProperties = new SuggestListBoxSingleProperties<IdentifiantLibelleBooleanModel>() {
        @Override
        public String getSelectSuggestRenderer(IdentifiantLibelleBooleanModel row) {
            return row == null ? "" : row.getLibelle();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(IdentifiantLibelleBooleanModel row) {
            return new String[] { row == null ? "" : row.getLibelle() };
        }
    };

    slbCivilite = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    slbCivilite.ensureDebugId(viewDebugIdConstants.debugIdSlbCivilite());
    aideslbCivilite = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_CIVILITE,
            isAdmin);
    ajouterAideComposant(aideslbCivilite);

    tbNom = new DecoratedTextBoxFormat("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
    tbNom.ensureDebugId(viewDebugIdConstants.debugIdTbNom());
    aidetbNom = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_NOM, isAdmin);
    ajouterAideComposant(aidetbNom);

    tbPrenom = new DecoratedTextBoxFormat("AAAAAAAAAAAAAAAAAAAAAAAAA");
    tbPrenom.ensureDebugId(viewDebugIdConstants.debugIdTbPrenom());
    aidetbPrenom = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_PRENOM, isAdmin);
    ajouterAideComposant(aidetbPrenom);

    cdbDateNaissance = new DecoratedCalendrierDateBox(true);
    cdbDateNaissance.ensureDebugId(viewDebugIdConstants.debugIdCdbDateNaissance());
    aidecdbDateNaissance = new AideComposant(
            AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_DATE_NAISSANCE, isAdmin);
    ajouterAideComposant(aidecdbDateNaissance);
    tbEmail = new DecoratedTextBox();
    tbEmail.setMaxLength(PersonnePhysiqueCreationViewImplConstants.MAX_LENGTH_TB_EMAIL);
    tbEmail.ensureDebugId(viewDebugIdConstants.debugIdTbEmail());
    aidetbEmail = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_EMAIL, isAdmin);
    ajouterAideComposant(aidetbEmail);

    tbTelephone = new DecoratedTextBoxFormat(PersonnePhysiqueCreationViewImplConstants.FORMAT_TELEPHONE_DEFAUT);
    tbTelephone.ensureDebugId(viewDebugIdConstants.debugIdTbTelephone());
    aidetbTelephone = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_TELEPHONE,
            isAdmin);
    ajouterAideComposant(aidetbTelephone);

    tbTelephonePortable = new DecoratedTextBoxFormat(
            PersonnePhysiqueCreationViewImplConstants.FORMAT_TELEPHONE_DEFAUT);
    tbTelephonePortable.ensureDebugId(viewDebugIdConstants.debugIdTbTelephonePortable());
    aidetbTelephonePortable = new AideComposant(
            AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_TELEPHONE_PORTABLE, isAdmin);
    ajouterAideComposant(aidetbTelephonePortable);

    slbNatureTelephone = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(
            slbIdentifiantLibelleProperties);
    slbNatureTelephone.ensureDebugId(viewDebugIdConstants.debugIdSlbNatureTelephone());
    aideslbNatureTelephone = new AideComposant(
            AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_NATURE_TELEPHONE, isAdmin);
    ajouterAideComposant(aideslbNatureTelephone);

    slbNatureTelephonePortable = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(
            slbIdentifiantLibelleProperties);
    slbNatureTelephonePortable.ensureDebugId(viewDebugIdConstants.debugIdSlbNatureTelephonePortable());
    aideslbNatureTelephonePortable = new AideComposant(
            AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_NATURE_TELEPHONE_PORTABLE, isAdmin);
    ajouterAideComposant(aideslbNatureTelephonePortable);

    slbProfession = new DecoratedSuggestListBoxSingle<IdentifiantLibelleBooleanModel>(
            slbIdentifiantLibelleBooleanProperties);
    slbProfession.ensureDebugId(viewDebugIdConstants.debugIdSlbProfession());
    aideslbProfession = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_CREATION_PROFESSION,
            isAdmin);
    ajouterAideComposant(aideslbProfession);

    imgFlagPaysTelephone = new Image(SquareResources.INSTANCE.flagFr());
    imgFlagPaysTelephone.ensureDebugId(viewDebugIdConstants.debugIdImgFlagPaysTelephone());
    imgFlagPaysTelephone.addStyleName(SquareResources.INSTANCE.css().imgDrapeau());
    imgFlagPaysTelephonePortable = new Image(SquareResources.INSTANCE.flagFr());
    imgFlagPaysTelephonePortable.ensureDebugId(viewDebugIdConstants.debugIdImgFlagPaysTelephonePortable());
    imgFlagPaysTelephonePortable.addStyleName(SquareResources.INSTANCE.css().imgDrapeau());

    final CaptionPanel fieldSetPanel = new CaptionPanel(viewConstants.titreChefDeFamille());

    final FlexTable flexTable = new FlexTable();
    flexTable.setWidth(AppControllerConstants.POURCENT_100);
    int row = 0;
    final int spacing = 3;

    final HorizontalPanel ligneCivilite = new HorizontalPanel();
    ligneCivilite.setSpacing(spacing);
    ligneCivilite.add(construireBlocIcone(slbCivilite, "PersonneDto.civilite", aideslbCivilite));
    flexTable.setWidget(row, 0, lCivilite);
    flexTable.setWidget(row++, 1, ligneCivilite);

    final HorizontalPanel ligneNom = new HorizontalPanel();
    ligneNom.setSpacing(spacing);
    ligneNom.add(construireBlocIcone(tbNom, "PersonneDto.nom", aidetbNom));
    ligneNom.add(construireBlocIcone(tbPrenom, "PersonneDto.prenom", aidetbPrenom));
    flexTable.setWidget(row, 0, lNom);
    flexTable.setWidget(row++, 1, ligneNom);

    final HorizontalPanel ligneDateNaissance = new HorizontalPanel();
    ligneDateNaissance.setSpacing(spacing);
    ligneDateNaissance
            .add(construireBlocIcone(cdbDateNaissance, "PersonneDto.dateNaissance", aidecdbDateNaissance));
    flexTable.setWidget(row, 0, lDateNaissance);
    flexTable.setWidget(row++, 1, ligneDateNaissance);

    pWarningDoublon = new HorizontalPanel();
    pWarningDoublon.setVisible(false);
    pWarningDoublon.setSpacing(2);
    final Image imgWarning = new Image(SmatisResources.INSTANCE.imgWarning());
    pWarningDoublon.add(imgWarning);
    final Label lWarningDoublon = new Label(viewConstants.warningDoublons());
    lWarningDoublon.ensureDebugId(viewDebugIdConstants.debugIdLWarningDoublon());
    lWarningDoublon.addStyleName(SquareResources.INSTANCE.css().labelReclamation());
    pWarningDoublon.add(lWarningDoublon);
    flexTable.setWidget(row, 0, pWarningDoublon);
    flexTable.getFlexCellFormatter().setColSpan(row++, 0, 2);

    final HorizontalPanel ligneEmail = new HorizontalPanel();
    ligneEmail.setSpacing(spacing);
    ligneEmail.add(construireBlocIcone(tbEmail, "EmailDto.adresse", aidetbEmail));
    flexTable.setWidget(row, 0, lEmail);
    flexTable.setWidget(row++, 1, ligneEmail);

    final HorizontalPanel ligneTelephone = new HorizontalPanel();
    ligneTelephone.setSpacing(spacing);
    ligneTelephone.add(construireBlocIcone(tbTelephone, "TelephoneDto.numero.0", aidetbTelephone));
    ligneTelephone
            .add(construireBlocIcone(slbNatureTelephone, "TelephoneDto.nature.0", aideslbNatureTelephone));
    ligneTelephone.add(imgFlagPaysTelephone);
    flexTable.setWidget(row, 0, lTelephone);
    flexTable.setWidget(row++, 1, ligneTelephone);

    final HorizontalPanel ligneTelephonePortable = new HorizontalPanel();
    ligneTelephonePortable.setSpacing(spacing);
    ligneTelephonePortable
            .add(construireBlocIcone(tbTelephonePortable, "TelephoneDto.numero.1", aidetbTelephonePortable));
    ligneTelephonePortable.add(construireBlocIcone(slbNatureTelephonePortable, "TelephoneDto.nature.1",
            aideslbNatureTelephonePortable));
    ligneTelephonePortable.add(imgFlagPaysTelephonePortable);
    flexTable.setWidget(row, 0, new Label(""));
    flexTable.setWidget(row++, 1, ligneTelephonePortable);

    final HorizontalPanel ligneProfession = new HorizontalPanel();
    ligneProfession.setSpacing(spacing);
    ligneProfession.add(construireBlocIcone(slbProfession, "PersonneDto.profession", aideslbProfession));
    flexTable.setWidget(row, 0, lProfession);
    flexTable.setWidget(row++, 1, ligneProfession);

    fieldSetPanel.add(flexTable);
    conteneur.add(fieldSetPanel);
}

From source file:com.square.client.gwt.client.view.personne.physique.gestion.GestionPersonnePhysiqueViewImpl.java

License:Open Source License

private Widget construireBlocInfosSup(
        SuggestListBoxSingleProperties<IdentifiantLibelleGwt> slbIdentifiantLibelleProperties,
        SuggestListBoxSingleProperties<IdentifiantLibelleBooleanModel> slbIdentifiantLibelleBooleanProperties) {
    libDecede = new Label("", false);
    libDecede.ensureDebugId(constantsDebugId.debugIdLbGDecede());
    lbGnumeroRo = new Label("", false);
    lbGnumeroRo.ensureDebugId(constantsDebugId.debugIdLbGnumeroRo());
    lbGstatut = new Label("", false);
    lbGstatut.ensureDebugId(constantsDebugId.debugIdLbGstatut());
    libGregime = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    aidelibGregime = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_GESTION_REGIME, isAdmin);
    ajouterAideComposant(aidelibGregime);
    libGregime.ensureDebugId(constantsDebugId.debugIdLibGregime());
    libGsegment = new DecoratedSuggestListBoxSingle<IdentifiantLibelleGwt>(slbIdentifiantLibelleProperties);
    libGsegment.ensureDebugId(constantsDebugId.debugIdLibGsegment());
    libGsegment.setEnabled(false);/*from  w  w w  .j  a v  a  2  s.com*/
    aidelibGsegment = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_GESTION_SEGMENT, isAdmin);
    ajouterAideComposant(aidelibGsegment);
    final SuggestListBoxSingleProperties<CaisseSimpleModel> slbCaisseProperties = new SuggestListBoxSingleProperties<CaisseSimpleModel>() {

        @Override
        public String getSelectSuggestRenderer(CaisseSimpleModel row) {
            return row == null || row.getId().equals(constants.IDENTIFIANT_NC) ? ""
                    : row.getCode() + "." + row.getCentre() + "." + row.getNom();
        }

        @Override
        public String[] getResultColumnsRenderer() {
            return new String[] {};
        }

        @Override
        public String[] getResultRowsRenderer(CaisseSimpleModel row) {
            return new String[] { row == null || row.getId().equals(constants.IDENTIFIANT_NC) ? ""
                    : row.getCode() + "." + row.getCentre() + "." + row.getNom() };
        }
    };
    libGcaisse = new DecoratedSuggestListBoxSingle<CaisseSimpleModel>(slbCaisseProperties);
    libGcaisse.ensureDebugId(constantsDebugId.debugIdLibGcaisse());
    aidelibGcaisse = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_GESTION_CAISSE, isAdmin);
    ajouterAideComposant(aidelibGcaisse);
    libGprofession = new DecoratedSuggestListBoxSingle<IdentifiantLibelleBooleanModel>(
            slbIdentifiantLibelleBooleanProperties);
    libGprofession.ensureDebugId(constantsDebugId.debugIdLibGprofession());
    aidelibGprofession = new AideComposant(AideComposantConstants.AIDE_PERSONNE_PHYSIQUE_GESTION_PROFESSION,
            isAdmin);
    ajouterAideComposant(aidelibGprofession);

    final FlexTable flexTable = new FlexTable();
    flexTable.setWidth(AppControllerConstants.POURCENT_100);
    flexTable.setCellSpacing(5);
    flexTable.setWidget(0, 0, libDecede);
    flexTable.setWidget(1, 0, new Label(constants.lbGnumeroRo(), false));
    flexTable.setWidget(1, 1, lbGnumeroRo);
    flexTable.setWidget(1, 2, new Label(constants.lbGstatut(), false));
    flexTable.setWidget(1, 3, lbGstatut);
    flexTable.setWidget(2, 0, new Label(constants.lbGregime(), false));
    flexTable.setWidget(2, 1,
            construireBlocIcone(libGregime, "PersonneDto.infoSante.caisseRegime", aidelibGregime));
    flexTable.setWidget(2, 2, new Label(constants.lbGsegment(), false));
    flexTable.setWidget(2, 3, construireBlocIcone(libGsegment, "PersonneDto.segment", aidelibGsegment));
    flexTable.setWidget(3, 0, new Label(constants.lbGcaisse(), false));
    flexTable.setWidget(3, 1, construireBlocIcone(libGcaisse, "PersonneDto.infoSante.caisse", aidelibGcaisse));
    flexTable.setWidget(3, 2, new Label(constants.lbGprofession(), false));
    flexTable.setWidget(3, 3,
            construireBlocIcone(libGprofession, "PersonneDto.profession", aidelibGprofession));
    flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    flexTable.getRowFormatter().setVerticalAlign(2, HasVerticalAlignment.ALIGN_MIDDLE);
    flexTable.getColumnFormatter().setWidth(0, LARGEUR_COL_LIBELLE_0);
    flexTable.getColumnFormatter().setWidth(1, LARGEUR_COL_CHAMP_1);
    flexTable.getColumnFormatter().setWidth(2, LARGEUR_COL_LIBELLE_2);
    flexTable.getColumnFormatter().setWidth(3, LARGEUR_COL_CHAMP_3);

    final CaptionPanel captionPanel = new CaptionPanel(constants.lbGinformationSup());
    captionPanel.add(flexTable);
    return captionPanel;
}