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

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


        uploadFormPanel.setMethod( FormPanel.METHOD_POST );

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

        final FileUpload upload = new FileUpload();
        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( 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


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

        // Create a FileUpload widgets.
        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

      panel.setButtonAlign(HorizontalAlignment.CENTER);
      panel.setLabelWidth(75);
      panel.setWidth(390);
      panel.setHeight(80);

      final FileUpload file = new FileUpload();
      file.setName("asyncupload");
      file.setWidth("300px");
      AdapterField adapter = new AdapterField(file);
      adapter.setFieldLabel(Messages.get("fileMenu.label", "File"));
      panel.add(adapter);

      final Window theWindor = this;
      Button btn = new Button(Messages.get("label.cancel", "Cancel"));
      btn.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
          theWindor.hide();
        }
      });
      panel.addButton(btn);

      btn = new Button(Messages.get("label.doImport", "Import"));
      btn.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
          if (file.getFilename() == null || file.getFilename().trim().length() == 0) {
            return;
          }
          try {
            panel.submit();
          } catch (Exception e) {
View Full Code Here

        labelFileUploadDone.setVisible(false);

        Button submitButton = new Button(c.Upload());
        submitButton.setVisible(false);

        final FileUpload fileUpload = new FileUpload();
        fileUpload.setName(Settings.FORM_PARM_UPLOAD_FILE_BASE);
        // The GWT calls this formPanel handler after the formPanel is submitted.
        FormHandlerFile fileFormHandler = new FormHandlerFile(icing);
        fileFormHandler.setFileUpload(fileUpload);
        fileFormHandler.setLabelFileUploadDone(labelFileUploadDone);
        fileFormHandler.setStatusMessage(statusMessage);
        fileFormHandler.setSubmitButton(submitButton);
        fileFormHandler.setNextButton(nextButton);

        /** Invisible parameters to pass */

        final iCingQuery cingQuerySave = new iCingQuery(icing);
        cingQuerySave.action.setValue(Settings.FORM_ACTION_SAVE);
        cingQuerySave.setFormHandler(fileFormHandler); // Override the default one.
        cingQuerySave.formVerticalPanel.add(fileUpload); // will switch between these two.
        cingQuerySave.formVerticalPanel.add(labelFileUploadDone);

        flexTable.setWidget(currentRowIdx, fileIdx, cingQuerySave.formPanel);
        flexTable.setWidget(currentRowIdx, submitIdx, submitButton);

        final ListBox listBox_Program = new ListBox();
        final ListBox listBox_Type = new ListBox();
        final ListBox listBox_Subtype = new ListBox();
        final ListBox listBox_Other = new ListBox();
        final HTML egHtml = new HTML();

        fileFormHandler.setListBox_Program(listBox_Program);
        fileFormHandler.setListBox_Type(listBox_Type);
        fileFormHandler.setListBox_Subtype(listBox_Subtype);
        fileFormHandler.setListBox_Other(listBox_Other);
        fileFormHandler.setEgHtml(egHtml);

        /** Setup the 4 boxes */
        flexTable.setWidget(currentRowIdx, programIdx, listBox_Program);
        listBox_Program.setVisibleItemCount(1);
        ArrayList<String> programList = Classification.getProgramList();
        if (programList == null) { // impossible but modeled for consistency with below boxes.
            listBox_Program.addItem(iCing.STRING_NA);
        } else {
            for (String item : programList) {
                listBox_Program.addItem(item);
            }
        }
        listBox_Program.setItemSelected(0, true);
        if (listBox_Program.getItemCount() == 1) {
            listBox_Program.setEnabled(false);
        }
        listBox_Program.setFocus(true);

        flexTable.setWidget(currentRowIdx, typeIdx, listBox_Type);
        listBox_Type.setVisibleItemCount(1);
        String program = listBox_Program.getValue(listBox_Program.getSelectedIndex());
        ArrayList<String> typeList = Classification.getTypeList(program);
        if (typeList == null) { // impossible but modeled for consistency with below boxes.
            listBox_Type.addItem(iCing.STRING_NA);
        } else {
            for (String item : typeList) {
                listBox_Type.addItem(item);
            }
        }
        listBox_Type.setItemSelected(0, true);
        if (listBox_Type.getItemCount() == 1) {
            listBox_Type.setEnabled(false);
        }

        flexTable.setWidget(currentRowIdx, subTypeIdx, listBox_Subtype);
        listBox_Subtype.setVisibleItemCount(1);
        String type = listBox_Type.getValue(listBox_Type.getSelectedIndex());
        ArrayList<String> subTypeList = Classification.getSubTypeList(program, type);
        if (subTypeList == null || subTypeList.size() == 0) {
            listBox_Subtype.addItem(iCing.STRING_NA);
        } else {
            for (String item : subTypeList) {
                if (item == null) {
                    item = iCing.STRING_NA;
                }
                listBox_Subtype.addItem(item);
            }

        }
        listBox_Subtype.setItemSelected(0, true);
        if (listBox_Subtype.getItemCount() == 1) {
            listBox_Subtype.setEnabled(false);
        }

        flexTable.setWidget(currentRowIdx, otherIdx, listBox_Other);
        listBox_Other.setVisibleItemCount(1);
        String subType = listBox_Subtype.getValue(listBox_Subtype.getSelectedIndex());
        ArrayList<String> otherList = Classification.getOtherList(program, type, subType);
        if (otherList == null || otherList.size() == 0) {
            listBox_Other.addItem(iCing.STRING_NA);
        } else {
            for (String item : otherList) {
                if (item == null) {
                    item = iCing.STRING_NA;
                }
                listBox_Other.addItem(item);
            }
        }
        listBox_Other.setItemSelected(0, true);
        if (listBox_Other.getItemCount() == 1) {
            listBox_Other.setEnabled(false);
        }

        // setup timer to refresh list automatically
        Timer timer = new Timer() {
            public void run() {
                if (fileUpload.getFilename().length() == 0) {
                    return;
                }
                this.cancel();
                cingQuerySave.formPanel.submit();
            }
View Full Code Here

    recreate();
  }
 
 
  private void recreate() {
    upload = new FileUpload();
    upload.setTitle("The path to the ontology in your local system");
    upload.setWidth("300");
    upload.setName("ontologyFile");
   
    contents.clear();
View Full Code Here

    this.callback = callback;

    form = new FormPanel();
    textPackage = new TextBox();
    textVersion = new TextBox();
    fileUpload = new FileUpload();
    vertPanel = new VerticalPanel();

    initWidget(uiBinder.createAndBindUi(this));

    textPackage.setText(packageName);
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("&nbsp;&nbsp;&nbsp;"));

        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

    fileTextBox.setEnabled( false );
   
    //We use an fileNameOverride because FileUpload can only handle US character set reliably.
    final Hidden fileNameOverride = new Hidden( "fileNameOverride" );

    final FileUpload upload = new FileUpload();
    upload.setName( "fileUpload" );
    ChangeHandler fileUploadHandler = new ChangeHandler() {
      @Override
      public void onChange( ChangeEvent event ) {
        fileTextBox.setText( upload.getFilename() );
        if ( !"".equals( importDir.getValue() ) ) {
          //Set the fileNameOverride because the fileUpload object can only reliably transmit US-ASCII
          //character set.  See RFC283 section 2.3 for details
          String fileNameValue = upload.getFilename().replaceAll( "\\\\", "/" );
          fileNameValue = fileNameValue.substring( fileNameValue.lastIndexOf( "/" ) + 1 );
          fileNameOverride.setValue( fileNameValue );
          okButton.setEnabled( true );
        } else {
          okButton.setEnabled( false );
        }
      }
    };
    upload.addChangeHandler( fileUploadHandler );
    upload.setVisible( false );

    HorizontalPanel fileUploadPanel = new HorizontalPanel();
    fileUploadPanel.add( fileTextBox );
    fileUploadPanel.add( new HTML( "&nbsp;" ) );

    Button browseButton = new Button( Messages.getString( "browse" ) + "..." );
    browseButton.setStyleName( "pentaho-button" );
    fileUploadPanel.add( browseButton );
    browseButton.addClickHandler( new ClickHandler() {
      @Override
      public void onClick( ClickEvent event ) {
        setRetainOwnershipState();
        jsClickUpload( upload.getElement() );
      }
    } );

    rootPanel.add( fileUploadPanel );
    rootPanel.add( upload );
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 a 'submit' button.
    panel.add(new Button("Submit", new ClickHandler() {
      public void onClick(ClickEvent event) {
View Full Code Here

    // 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

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.