Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.FileUpload$FileUploadImpl


    // Add a label
    vPanel.add(new HTML(constants.cwFileUploadSelectFile()));

    // Add a file upload widget
    final FileUpload fileUpload = new FileUpload();
    fileUpload.ensureDebugId("cwFileUpload");
    vPanel.add(fileUpload);

    // Add a button to upload the file
    Button uploadButton = new Button(constants.cwFileUploadButton());
    uploadButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        String filename = fileUpload.getFilename();
        if (filename.length() == 0) {
          Window.alert(constants.cwFileUploadNoFileError());
        } else {
          Window.alert(constants.cwFileUploadSuccessful());
        }
View Full Code Here


        uploadFormPanel.setMethod( FormPanel.METHOD_POST );

        HorizontalPanel panel = new HorizontalPanel();
        uploadFormPanel.setWidget( panel );

        final FileUpload upload = new FileUpload();
        upload.setHeight("30px");
        upload.setName( HTMLFileManagerFields.FILE_UPLOAD_FIELD_NAME_IMPORT );
        panel.add( upload );

        Button ok = new Button( constants.Import() );
        ok.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent sender) {
                doImportFile( uploadFormPanel );
            }

            private void doImportFile(final FormPanel uploadFormPanel) {
                if ( Window.confirm( constants.ImportConfirm() ) ) {
                    LoadingPopup.showMessage( constants.ImportingInProgress() );
                    uploadFormPanel.submit();
                }
            }
        } );

        panel.add(new HTML("   "));

        panel.add( ok );

        uploadFormPanel.addSubmitCompleteHandler( new SubmitCompleteHandler() {

            public void onSubmitComplete(SubmitCompleteEvent event) {
                if ( event.getResults().indexOf( "OK" ) > -1 ) {
                    Window.alert( constants.ImportDone() );
                    History.newItem( " " );
                    Window.Location.reload();
                } else {
                    ErrorPopup.showMessage( constants.ImportFailed() );
                }
                LoadingPopup.close();
            }
        } );

        uploadFormPanel.addSubmitHandler( new SubmitHandler() {

            public void onSubmit(SubmitEvent event) {
                String fileName = upload.getFilename();
                if ( fileName.length() == 0 ) {
                    Window.alert( constants.NoExportFilename() );
                    event.cancel();
                } else {
                    String lowerCaseFileName = fileName.toLowerCase();
View Full Code Here

    public static final String FILE_NAME_FIELD_LABEL = "File";

    public UploadFileDialogForm() {
        setPostURL(SUBMIT_FILE_URL);
        fileUpload = new FileUpload();
        fileUpload.setName("file");
        addWidget(FILE_NAME_FIELD_LABEL, fileUpload);
        fileUpload.setWidth("300px");
        addDialogValidator(new FileNameValidator());
    }
View Full Code Here

    private final FileUpload fileUpload;

    public UploadFileWidget() {
        setPostURL(SUBMIT_FILE_URL);
        fileUpload = new FileUpload();
        fileUpload.setName("file");
        addWidget(FILE_NAME_FIELD_LABEL, fileUpload);
        fileUpload.setWidth(FIELD_WIDTH);
        addDialogValidator(new FileNameValidator());
    }
View Full Code Here

        form = new FormPanel();
        form.setAction( GWT.getModuleBaseURL() + "asset" );
        form.setEncoding( FormPanel.ENCODING_MULTIPART );
        form.setMethod( FormPanel.METHOD_POST );

        FileUpload up = new FileUpload();
        up.setName( HTMLFileManagerFields.UPLOAD_FIELD_NAME_ATTACH );
        HorizontalPanel fields = new HorizontalPanel();
        fields.add( getHiddenField( HTMLFileManagerFields.FORM_FIELD_UUID,
                                    uuid ) );

        Button ok = new Button( constants.Upload() );
View Full Code Here

        panel.setStyleName("list--no-bullets");

        loadingIcon = new Image(resources.spinner());
        loadingIcon.setVisible(false);

        upload = new FileUpload();
        upload.setName("uploadFileElement");

        merge = new CheckBox("Merge?");
        merge.setValue(true);
View Full Code Here

        VerticalPanel panel = new VerticalPanel();
        panel.getElement().setAttribute("style", "width:100%");
        form.setWidget(panel);

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


        final HTML errorMessages = new HTML("Please chose a file!");
        errorMessages.setStyleName("error-panel");
        errorMessages.setVisible(false);
        panel.add(errorMessages);

        // Add a 'submit' button.


        ClickHandler cancelHandler = new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                window.hide();
            }
        };

        ClickHandler submitHandler = new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

                errorMessages.setVisible(false);

                // verify form
                String filename = upload.getFilename();

                if(tabs.getTabBar().getSelectedTab()==1)
                {
                    // unmanaged content
                    if(unmanagedForm.validate().hasErrors())
                    {
                        return;
                    }
                    else
                    {
                        wizard.onCreateUnmanaged(unmanagedForm.getUpdatedEntity());
                    }
                }
                else if(filename!=null && !filename.equals(""))
                {
                    loading = Feedback.loading(
                            Console.CONSTANTS.common_label_plaseWait(),
                            Console.CONSTANTS.common_label_requestProcessed(),
                            new Feedback.LoadingCallback() {
                                @Override
                                public void onCancel() {

                                }
                            });
                    form.submit();
                }
                else
                {
                    errorMessages.setVisible(true);
                }
            }
        };

        DialogueOptions options = new DialogueOptions(
                Console.CONSTANTS.common_label_next(), submitHandler,
                Console.CONSTANTS.common_label_cancel(), cancelHandler);

        // Add an event handler to the form.
        form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
            @Override
            public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {

                getLoading().hide();


                String html = event.getResults();

                // Step 1: upload content, retrieve hash value
                try {

                    String json = html;

                    try {
                        if(!GWT.isScript()) // TODO: Formpanel weirdness
                            json = html.substring(html.indexOf(">")+1, html.lastIndexOf("<"));
                    } catch (StringIndexOutOfBoundsException e) {
                        // if I get this exception it means I shouldn't strip out the html
                        // this issue still needs more research
                        Log.debug("Failed to strip out HTML.  This should be preferred?");
                    }

                    JSONObject response  = JSONParser.parseLenient(json).isObject();
                    JSONObject result = response.get("result").isObject();
                    String hash= result.get("BYTES_VALUE").isString().stringValue();
                    // step2: assign name and group
                    wizard.onUploadComplete(upload.getFilename(), hash);

                } catch (Exception e) {
                    Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
                }
View Full Code Here

        VerticalPanel panel = new VerticalPanel();
        panel.getElement().setAttribute("style", "width:100%");
        form.setWidget(panel);

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


        final HTML errorMessages = new HTML("Please chose a file!");
        errorMessages.setStyleName("error-panel");
        errorMessages.setVisible(false);
        panel.add(errorMessages);

        // Add a 'submit' button.


        ClickHandler cancelHandler = new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                window.hide();
            }
        };

        ClickHandler submitHandler = new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

                errorMessages.setVisible(false);

                // verify form
                String filename = upload.getFilename();
                if(filename!=null && !filename.equals(""))
                {
                    loading = Feedback.loading(
                            Console.CONSTANTS.common_label_plaseWait(),
                            Console.CONSTANTS.common_label_requestProcessed(),
                            new Feedback.LoadingCallback() {
                                @Override
                                public void onCancel() {

                                }
                            });
                    form.submit();
                }
                else
                {
                    errorMessages.setVisible(true);
                }
            }
        };

        DialogueOptions options = new DialogueOptions(
                Console.CONSTANTS.common_label_next(), submitHandler,
                Console.CONSTANTS.common_label_cancel(), cancelHandler);

        // Add an event handler to the form.
        form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
            @Override
            public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {

                getLoading().hide();


                String html = event.getResults();

                // Step 1: upload content, retrieve hash value
                try {

                    String json = html;

                    try {
                        if(!GWT.isScript()) // TODO: Formpanel weirdness
                            json = html.substring(html.indexOf(">")+1, html.lastIndexOf("<"));
                    } catch (StringIndexOutOfBoundsException e) {
                        // if I get this exception it means I shouldn't strip out the html
                        // this issue still needs more research
                        Log.debug("Failed to strip out HTML.  This should be preferred?");
                    }

                    JSONObject response  = JSONParser.parseLenient(json).isObject();
                    JSONObject result = response.get("result").isObject();
                    String hash= result.get("BYTES_VALUE").isString().stringValue();
                    // step2: assign name and group
                    wizard.onUploadComplete(upload.getFilename(), hash);

                } catch (Exception e) {
                    Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
                }
View Full Code Here

    imageThumbnail.setVisible(false);
    imageDeleteButton.setVisible(false);
  }

  public void clearImageUpload() {
    FileUpload newImage = new FileUpload();
    newImage.setName(image.getName());

    image.removeFromParent();
    uploadPanel.clear();
    uploadPanel.add(newImage);
    newImage.addChangeHandler(uploadChangeHandler);
   
    flag.setText(UploadStatus.NO_CHANGE.name());
   
    image = newImage;
  }
View Full Code Here

      lb.addItem("bar", "barValue");
      lb.addItem("baz", "bazValue");
      panel.add(lb);

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

      // Add an event handler to the form.
      form.addSubmitHandler(new FormPanel.SubmitHandler() {
         public void onSubmit(SubmitEvent event) {
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.FileUpload$FileUploadImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.