Package org.pentaho.mantle.client.events

Examples of org.pentaho.mantle.client.events.SolutionFolderActionEvent


      performOperation( true );
    }
  }

  protected void performOperation( boolean feedback ) {
    final SolutionFolderActionEvent event = new SolutionFolderActionEvent();
    event.setAction( this.getClass().getName() );

    final TextBox folderNameTextBox = new TextBox();
    folderNameTextBox.setTabIndex( 1 );
    folderNameTextBox.setVisibleLength( 40 );

    VerticalPanel vp = new VerticalPanel();
    vp.add( new Label( Messages.getString( "newFolderName" ) ) ); //$NON-NLS-1$
    vp.add( folderNameTextBox );
    final PromptDialogBox newFolderDialog =
        new PromptDialogBox(
            Messages.getString( "newFolder" ), Messages.getString( "ok" ), Messages.getString( "cancel" ), false, true, vp ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    newFolderDialog.setFocusWidget( folderNameTextBox );
    folderNameTextBox.setFocus( true );

    final IDialogCallback callback = new IDialogCallback() {

      public void cancelPressed() {
        newFolderDialog.hide();
      }

      public void okPressed() {

        if ( !NameUtils.isValidFolderName( folderNameTextBox.getText() ) ) {
          event.setMessage( Messages.getString( "containsIllegalCharacters", folderNameTextBox.getText() ) );
          EventBusUtil.EVENT_BUS.fireEvent( event );
          return;
        }

        solutionPath = parentFolder.getPath() + "/" + URL.encodePathSegment( folderNameTextBox.getText() );

        String createDirUrl = contextURL + "api/repo/dirs/" + SolutionBrowserPanel.pathToId( solutionPath ); //$NON-NLS-1$
        RequestBuilder createDirRequestBuilder = new RequestBuilder( RequestBuilder.PUT, createDirUrl );

        try {
          createDirRequestBuilder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
          createDirRequestBuilder.sendRequest( "", new RequestCallback() {

            @Override
            public void onError( Request createFolderRequest, Throwable exception ) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox(
                      Messages.getString( "error" ), Messages.getString( "couldNotCreateFolder", folderNameTextBox.getText() ), //$NON-NLS-1$ //$NON-NLS-2$
                      false, false, true );
              dialogBox.center();
              event.setMessage( Messages.getString( "couldNotCreateFolder", folderNameTextBox.getText() ) );
              EventBusUtil.EVENT_BUS.fireEvent( event );
            }

            @Override
            public void onResponseReceived( Request createFolderRequest, Response createFolderResponse ) {
              if ( createFolderResponse.getStatusText().equalsIgnoreCase( "OK" ) ) { //$NON-NLS-1$
                NewFolderCommand.this.callback.onHandle( solutionPath );
                new RefreshRepositoryCommand().execute( false );
                event.setMessage( "Success" );
                FileChooserDialog.setIsDirty( Boolean.TRUE );
                setBrowseRepoDirty( Boolean.TRUE );
                EventBusUtil.EVENT_BUS.fireEvent( event );
              } else {
                event.setMessage(
                    StringUtils.isEmpty( createFolderResponse.getText() )
                        || Messages.getString( createFolderResponse.getText() ) == null
                        ? Messages.getString( "couldNotCreateFolder", folderNameTextBox.getText() ) //$NON-NLS-1$
                        : Messages.getString( createFolderResponse.getText(), folderNameTextBox.getText() )
                );
                EventBusUtil.EVENT_BUS.fireEvent( event );

              }
            }

          } );
        } catch ( RequestException e ) {
          Window.alert( e.getLocalizedMessage() );
          event.setMessage( e.getLocalizedMessage() );
          EventBusUtil.EVENT_BUS.fireEvent( event );
        }

      }
    };
View Full Code Here


    }
  }

  protected void performOperation( boolean feedback ) {

    final SolutionFolderActionEvent event = new SolutionFolderActionEvent();
    event.setAction( this.getClass().getName() );

    final String filesList = repositoryFile.getId();
    final String folderName = repositoryFile.getTitle() == null ? repositoryFile.getName() : repositoryFile.getTitle();
    final HTML messageTextBox =
        new HTML( Messages.getString( "moveToTrashQuestionFolder", escapeHtmlEntities( folderName ) ) );
    final PromptDialogBox folderDeleteWarningDialogBox =
        new PromptDialogBox( Messages.getString( "moveToTrash" ), Messages.getString( "yesMoveToTrash" ), Messages
            .getString( "no" ), true, true );
    folderDeleteWarningDialogBox.setContent( messageTextBox );

    final IDialogCallback callback = new IDialogCallback() {

      public void cancelPressed() {
        folderDeleteWarningDialogBox.hide();
      }

      public void okPressed() {
        String deleteFilesURL = contextURL + "api/repo/files/delete"; //$NON-NLS-1$
        RequestBuilder deleteFilesRequestBuilder = new RequestBuilder( RequestBuilder.PUT, deleteFilesURL );
        deleteFilesRequestBuilder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
        deleteFilesRequestBuilder.setHeader( "Content-Type", "text/plain" ); //$NON-NLS-1$//$NON-NLS-2$
        try {
          deleteFilesRequestBuilder.sendRequest( filesList, new RequestCallback() {

            @Override
            public void onError( Request request, Throwable exception ) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "couldNotDeleteFolder" ), //$NON-NLS-1$ //$NON-NLS-2$
                      false, false, true );
              dialogBox.center();
              event.setMessage( Messages.getString( "couldNotDeleteFolder" ) );
              EventBusUtil.EVENT_BUS.fireEvent( event );
            }

            @Override
            public void onResponseReceived( Request request, Response response ) {
              if ( response.getStatusCode() == 200 ) {
                new RefreshRepositoryCommand().execute( false );
                event.setMessage( "Success" );
                FileChooserDialog.setIsDirty( Boolean.TRUE );
                setBrowseRepoDirty( Boolean.TRUE );
                EventBusUtil.EVENT_BUS.fireEvent( event );
              } else {
                MessageDialogBox dialogBox =
                    new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "couldNotDeleteFolder" ), //$NON-NLS-1$ //$NON-NLS-2$
                        false, false, true );
                dialogBox.center();
                event.setMessage( Messages.getString( "couldNotDeleteFolder" ) );
                EventBusUtil.EVENT_BUS.fireEvent( event );
              }
            }

          } );
        } catch ( RequestException e ) {
          MessageDialogBox dialogBox =
              new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "couldNotDeleteFolder" ), //$NON-NLS-1$ //$NON-NLS-2$
                  false, false, true );
          dialogBox.center();
          event.setMessage( Messages.getString( "couldNotDeleteFolder" ) );
          EventBusUtil.EVENT_BUS.fireEvent( event );
        }
      }
    };
    folderDeleteWarningDialogBox.setCallback( callback );
View Full Code Here

TOP

Related Classes of org.pentaho.mantle.client.events.SolutionFolderActionEvent

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.