form = new WellForm();
form.setAction( getWebContext() + "/maven2" );
form.setEncoding( FormPanel.ENCODING_MULTIPART );
form.setMethod( FormPanel.METHOD_POST );
final FileUpload up = new FileUpload( new Command() {
@Override
public void execute() {
showUploadingBusy();
form.submit();
}
} );
up.setName( HTMLFileManagerFields.UPLOAD_FIELD_NAME_ATTACH );
form.addSubmitHandler( new Form.SubmitHandler() {
@Override
public void onSubmit( final Form.SubmitEvent event ) {
String fileName = up.getFilename();
if ( fileName == null || "".equals( fileName ) ) {
BusyPopup.close();
Window.alert( M2RepoEditorConstants.INSTANCE.SelectFileUpload() );
event.cancel();
}
}
} );
form.addSubmitCompleteHandler( new Form.SubmitCompleteHandler() {
public void onSubmitComplete( final Form.SubmitCompleteEvent event ) {
if ( "OK".equalsIgnoreCase( event.getResults() ) ) {
BusyPopup.close();
Window.alert( M2RepoEditorConstants.INSTANCE.UploadedSuccessfully() );
hiddenFieldsPanel.setVisible( false );
hiddenArtifactIdField.setText( null );
hiddenGroupIdField.setText( null );
hiddenVersionIdField.setText( null );
searchEvent.fire( new M2RepoSearchEvent() );
up.getElement().setPropertyString( "value", "" );
hide();
} else if ( "NO VALID POM".equalsIgnoreCase( event.getResults() ) ) {
BusyPopup.close();
Window.alert( M2RepoEditorConstants.INSTANCE.InvalidJarNotPom() );
hiddenFieldsPanel.setVisible( true );