Example usage for com.google.gwt.user.client.ui Hidden wrap

List of usage examples for com.google.gwt.user.client.ui Hidden wrap

Introduction

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

Prototype

public static Hidden wrap(Element element) 

Source Link

Document

Creates a Hidden widget that wraps an existing <input type='hidden'> element.

Usage

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped */
public static Widget elementToWidget(Element e, String typ) {
    Widget result = null;// w w w .j  av a  2 s.c  o m
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped  */
public static Widget elementToWidget(String elementName, String typ) {
    Widget result = null;/*from   w ww. jav a2 s .c  o  m*/
    Element e = DOM.getElementById(elementName);
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:fr.gael.dhus.gwt.client.page.UploadPage.java

License:Open Source License

private static void init() {
    showUpload();//  w  w w .  ja  v  a  2 s .co m

    uploadProductFile = FileUpload.wrap(RootPanel.get("upload_productFile").getElement());
    final Hidden collectionsField = Hidden.wrap(RootPanel.get("upload_collections").getElement());
    uploadButton = RootPanel.get("upload_uploadButton");
    url = TextBox.wrap(RootPanel.get("upload_url").getElement());
    username = TextBox.wrap(RootPanel.get("upload_username").getElement());
    pattern = TextBox.wrap(RootPanel.get("upload_pattern").getElement());
    patternResult = RootPanel.get("upload_patternResult");
    password = PasswordTextBox.wrap(RootPanel.get("upload_password").getElement());
    scanButton = RootPanel.get("upload_scanButton");
    stopButton = RootPanel.get("upload_stopButton");
    addButton = RootPanel.get("upload_addButton");
    cancelButton = RootPanel.get("upload_cancelButton");
    deleteButton = RootPanel.get("upload_deleteButton");
    saveButton = RootPanel.get("upload_saveButton");
    status = RootPanel.get("upload_status");
    refreshButton = RootPanel.get("upload_refreshButton");
    scannerInfos = RootPanel.get("upload_scannerInfos");

    uploadForm = new FormPanel();
    uploadForm.setAction(GWT.getHostPageBaseURL() + "/api/upload");
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);

    uploadForm.setWidget(RootPanel.get("upload_form"));
    RootPanel.get("upload_product").add(uploadForm);

    selectedCollections = new ArrayList<Long>();

    uploadButton.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (uploadButton.getElement().getClassName().contains("disabled")) {
                return;
            }

            String filename = uploadProductFile.getFilename();
            if (filename.length() == 0) {
                Window.alert("No file selected!");
            } else {
                DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "wait");
                String collections = "";

                if (selectedCollections != null && !selectedCollections.isEmpty()) {
                    for (Long cId : selectedCollections) {
                        collections += cId + ",";
                    }
                    collections = collections.substring(0, collections.length() - 1);
                }

                collectionsField.setValue(collections);

                uploadForm.submit();
                setState(State.UPLOADING);
            }
        }
    }, ClickEvent.getType());

    uploadForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            RegExp regexp = RegExp.compile(".*HTTP Status ([0-9]+).*");

            Integer errCode = null;
            try {
                errCode = new Integer(regexp.exec(event.getResults()).getGroup(1));
            } catch (Exception e) {
            }

            if (errCode == null) {
                Window.alert("Your product has been successfully uploaded.");
            } else {
                switch (errCode) {
                case 400:
                    Window.alert("Your request is missing a product file to upload.");
                    break;
                case 403:
                    Window.alert("You are not allowed to upload a file on Sentinel Data Hub.");
                    break;
                case 406:
                    Window.alert("Your product was not added. It can not be read by the system.");
                    break;
                case 415:
                    Window.alert("Request contents type is not supported by the servlet.");
                    break;
                case 500:
                    Window.alert("An error occurred while creating the file.");
                    break;
                default:
                    Window.alert("There was an untraceable error while uploading your product.");
                    break;
                }
            }

            DOM.setStyleAttribute(RootPanel.getBodyElement(), "cursor", "default");
            setState(State.DEFAULT);
        }
    });

    addButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (addButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            uploadService.addFileScanner(url.getValue(), username.getValue(), password.getValue(),
                    pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Long>() {

                        @Override
                        public void _onFailure(Throwable caught) {
                            Window.alert("There was an error during adding '" + url.getValue()
                                    + "' to your file scanners.\n" + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Long result) {
                            setState(State.ADDING_FILESCANNER);
                            setState(State.DEFAULT);
                        }

                    });
        }
    }, ClickEvent.getType());

    scanButton.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (scanButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            if (state == State.EDIT_FILESCANNER && editedScannerId != null) {
                uploadService.updateFileScanner(new Long(editedScannerId.longValue()), url.getValue(),
                        username.getValue(), password.getValue(), pattern.getValue(), selectedCollections,
                        new AccessDeniedRedirectionCallback<Void>() {
                            @Override
                            public void _onFailure(Throwable caught) {
                                Window.alert("There was an error during adding '" + url.getValue()
                                        + "' to your file scanners.\n" + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Void scanId) {
                                //                        final String sUrl = url.getValue();
                                setState(State.DEFAULT);
                                uploadService.processScan(new Long(editedScannerId.longValue()),
                                        new AccessDeniedRedirectionCallback<Void>() {
                                            @Override
                                            public void _onFailure(Throwable caught) {
                                            }

                                            @Override
                                            public void onSuccess(Void result) {
                                            }
                                        });
                            }
                        });
            } else {
                uploadService.addFileScanner(url.getValue(), username.getValue(), password.getValue(),
                        pattern.getValue(), selectedCollections, new AccessDeniedRedirectionCallback<Long>() {
                            @Override
                            public void _onFailure(Throwable caught) {
                                Window.alert("There was an error during adding '" + url.getValue()
                                        + "' to your file scanners.\n" + caught.getMessage());
                            }

                            @Override
                            public void onSuccess(Long scanId) {
                                //                     final String sUrl = url.getValue();
                                setState(State.ADDING_FILESCANNER);
                                setState(State.DEFAULT);
                                uploadService.processScan(scanId, new AccessDeniedRedirectionCallback<Void>() {
                                    @Override
                                    public void _onFailure(Throwable caught) {
                                    }

                                    @Override
                                    public void onSuccess(Void result) {
                                    }
                                });
                            }
                        });
            }
        }
    }, ClickEvent.getType());

    stopButton.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (stopButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            uploadService.stopScan(new Long(editedScannerId.longValue()),
                    new AccessDeniedRedirectionCallback<Void>() {
                        @Override
                        public void _onFailure(Throwable caught) {
                        }

                        @Override
                        public void onSuccess(Void result) {
                            setState(State.ADDING_FILESCANNER);
                            setState(State.DEFAULT);
                        }
                    });
        }
    }, ClickEvent.getType());

    cancelButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (cancelButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            setDefaultState();
        }
    }, ClickEvent.getType());

    refreshButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (refreshButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            refreshScanners();
        }
    }, ClickEvent.getType());

    deleteButton.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (deleteButton.getElement().getClassName().contains("disabled") && editedScannerId != null) {
                return;
            }
            removeScanner(editedScannerId);
        }
    }, ClickEvent.getType());

    saveButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (saveButton.getElement().getClassName().contains("disabled")) {
                return;
            }
            uploadService.updateFileScanner(new Long(editedScannerId), url.getValue(), username.getValue(),
                    password.getValue(), pattern.getValue(), selectedCollections,
                    new AccessDeniedRedirectionCallback<Void>() {

                        @Override
                        public void _onFailure(Throwable caught) {
                            Window.alert("There was an error while updating your file scanner.\n"
                                    + caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            setDefaultState();
                        }

                    });
        }
    }, ClickEvent.getType());

    refresh();
}

From source file:jsupload.client.Upload.java

License:Apache License

/**
 * adds a javascript DOM element to the upload form at the specified position
 *///from w  w w  . jav  a2 s  . co  m
public void addElement(Element e, int index) {
    Widget w = null;
    if (e.getTagName().toLowerCase().equals("input") && e.getAttribute("type").toLowerCase().equals("hidden")) {
        if (!Document.get().getBody().isOrHasChild(e)) {
            Document.get().getBody().appendChild(e);
        }
        w = Hidden.wrap(e);
    } else {
        w = new HTML();
        DOM.appendChild(w.getElement(), e);
    }
    uploader.add(w, index);
}

From source file:org.glimpse.client.Aggregator.java

License:Open Source License

public static String getHiddenValue(String id) {
    Element elm = DOM.getElementById(id);
    if (elm == null) {
        return null;
    }/*from  w ww .  j ava  2s. c  om*/
    final Hidden hidden = Hidden.wrap(elm);

    return (hidden != null) ? hidden.getValue() : null;
}

From source file:org.unitime.timetable.gwt.client.instructor.InstructorAvailabilityWidget.java

License:Apache License

public void insert(final RootPanel panel) {
    RPC.execute(InstructorAvailabilityRequest.load(null), new AsyncCallback<InstructorAvailabilityModel>() {
        @Override/*from   ww  w. j  a  va2 s  .c o m*/
        public void onFailure(Throwable caught) {
            UniTimeNotifications.error(caught);
        }

        @Override
        public void onSuccess(final InstructorAvailabilityModel model) {
            if (panel.getElement().getFirstChildElement() != null) {
                iPattern = Hidden.wrap(panel.getElement().getFirstChildElement());
                model.setPattern(iPattern.getValue());

                addValueChangeHandler(new ValueChangeHandler<RoomInterface.RoomSharingModel>() {
                    @Override
                    public void onValueChange(ValueChangeEvent<RoomSharingModel> event) {
                        iPattern.setValue(event.getValue().toString());
                    }
                });
                iEditable = true;
            } else {
                String pattern = panel.getElement().getInnerText().trim();
                panel.getElement().setInnerText(null);
                model.setPattern(pattern);
                iEditable = false;
            }

            setModel(model);

            panel.add(InstructorAvailabilityWidget.this);
            panel.setVisible(true);
        }
    });
}

From source file:org.unitime.timetable.gwt.client.rooms.PeriodPreferencesWidget.java

License:Apache License

public void insert(final RootPanel panel) {
    String pattern = null;/*from   ww w . j a  va2  s  . c o  m*/
    if (panel.getElement().getFirstChildElement() != null) {
        pattern = Hidden.wrap(panel.getElement().getFirstChildElement()).getValue();
    } else {
        pattern = panel.getElement().getInnerText().trim();
    }
    final Long examTypeId = Long.valueOf(pattern.substring(0, pattern.indexOf(':')));
    ;
    RPC.execute(RoomInterface.PeriodPreferenceRequest.loadForExam(null, examTypeId),
            new AsyncCallback<PeriodPreferenceModel>() {
                @Override
                public void onFailure(Throwable caught) {
                    UniTimeNotifications.error(caught);
                }

                @Override
                public void onSuccess(final PeriodPreferenceModel model) {
                    if (panel.getElement().getFirstChildElement() != null) {
                        final Hidden pattern = Hidden.wrap(panel.getElement().getFirstChildElement());
                        model.setPattern(pattern.getValue());

                        addValueChangeHandler(new ValueChangeHandler<PeriodPreferenceModel>() {
                            @Override
                            public void onValueChange(ValueChangeEvent<PeriodPreferenceModel> event) {
                                pattern.setValue(event.getValue().getPattern());
                            }
                        });
                        iEditable = true;
                    } else {
                        String pattern = panel.getElement().getInnerText().trim();
                        panel.getElement().setInnerText(null);
                        model.setPattern(pattern);
                        iEditable = false;
                    }

                    setModel(model);

                    panel.add(PeriodPreferencesWidget.this);
                    panel.setVisible(true);
                }
            });
}

From source file:org.unitime.timetable.gwt.client.sectioning.CourseDetailsWidget.java

License:Apache License

public void insert(final RootPanel panel) {
    String command = panel.getElement().getInnerText().trim();
    panel.getElement().setInnerText(null);

    panel.add(this);
    panel.setVisible(true);/*from  w ww . jav  a  2s .  co m*/

    try {
        reload(new CourseDetailsRpcRequest(Long.parseLong(command)));
    } catch (NumberFormatException e) {
        Element subjectElement = DOM.getElementById(command.split(",")[0]);
        Element courseElement = DOM.getElementById(command.split(",")[1]);
        if ("select".equalsIgnoreCase(subjectElement.getTagName())) {
            final ListBox subjectId = ListBox.wrap(subjectElement);
            final TextBox courseNumber = TextBox.wrap(courseElement);
            courseNumber.addValueChangeHandler(new ValueChangeHandler<String>() {
                @Override
                public void onValueChange(ValueChangeEvent<String> event) {
                    if (subjectId.getSelectedIndex() >= 0 && !courseNumber.getValue().isEmpty()) {
                        try {
                            reload(new CourseDetailsRpcRequest(
                                    Long.valueOf(subjectId.getValue(subjectId.getSelectedIndex())),
                                    courseNumber.getValue()));
                        } catch (NumberFormatException e) {
                        }
                    }
                }
            });
            if (subjectId.getSelectedIndex() >= 0 && !courseNumber.getValue().isEmpty()) {
                try {
                    reload(new CourseDetailsRpcRequest(
                            Long.valueOf(subjectId.getValue(subjectId.getSelectedIndex())),
                            courseNumber.getValue()));
                } catch (NumberFormatException f) {
                }
            }
        } else if ("input".equalsIgnoreCase(courseElement.getTagName())) {
            final Hidden subjectId = Hidden.wrap(subjectElement);
            final TextBox courseNumber = TextBox.wrap(courseElement);
            courseNumber.addValueChangeHandler(new ValueChangeHandler<String>() {
                @Override
                public void onValueChange(ValueChangeEvent<String> event) {
                    if (!courseNumber.getValue().isEmpty()) {
                        try {
                            reload(new CourseDetailsRpcRequest(Long.valueOf(subjectId.getValue()),
                                    courseNumber.getValue()));
                        } catch (NumberFormatException e) {
                        }
                    }
                }
            });
            if (!courseNumber.getValue().isEmpty()) {
                try {
                    reload(new CourseDetailsRpcRequest(Long.valueOf(subjectId.getValue()),
                            courseNumber.getValue()));
                } catch (NumberFormatException f) {
                }
            }
        } else {
            final Hidden subjectId = Hidden.wrap(subjectElement);
            final Hidden courseNumber = Hidden.wrap(courseElement);
            reload(new CourseDetailsRpcRequest(Long.valueOf(subjectId.getValue()), courseNumber.getValue()));
        }
    }
}

From source file:org.unitime.timetable.gwt.client.widgets.CourseNumbersSuggestBox.java

License:Apache License

private String getConfiguration() {
    String conf = iConfiguration;
    for (MatchResult matcher = iRegExp.exec(conf); matcher != null; matcher = iRegExp.exec(conf)) {
        Element element = DOM.getElementById(matcher.getGroup(1));
        String value = "";
        if ("select".equalsIgnoreCase(element.getTagName())) {
            ListBox list = ListBox.wrap(element);
            for (int i = 0; i < list.getItemCount(); i++) {
                if (list.isItemSelected(i))
                    value += (value.isEmpty() ? "" : ",") + list.getValue(i);
            }/*  w w w . j a v  a 2  s  .c o m*/
        } else if ("input".equalsIgnoreCase(element.getTagName())) {
            TextBox text = TextBox.wrap(element);
            value = text.getText();
        } else {
            Hidden hidden = Hidden.wrap(element);
            value = hidden.getValue();
        }
        conf = conf.replace("${" + matcher.getGroup(1) + "}", value);
    }
    return conf;
}