Package org.pentaho.mantle.client.events

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


    }
  }

  public void performOperation() {

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

    if ( getRepositoryFile() != null ) {
      final RepositoryFile item = getRepositoryFile();

      // Checking if the user has access to manage permissions
      String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId( item.getPath() )
          + "/canAccess?permissions=" + MANAGE_ACLS; //$NON-NLS-1$ //$NON-NLS-2$
      RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url );
      try {
        builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
        builder.sendRequest( null, new RequestCallback() {

          public void onError( Request request, Throwable exception ) {
            FilePropertiesDialog dialog =
                new FilePropertiesDialog( item, new PentahoTabPanel(), null, getActiveTab(), false );
            dialog.showTab( getActiveTab() );
            dialog.center();

            event.setMessage( exception.getMessage() );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }

          public void onResponseReceived( Request request, Response response ) {
            FilePropertiesDialog dialog =
                new FilePropertiesDialog( item, new PentahoTabPanel(), null, getActiveTab(), Boolean
                    .parseBoolean( response.getText() ) );
            dialog.showTab( getActiveTab() );
            dialog.center();

            event.setMessage( "Success" );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }
        } );
      } catch ( RequestException e ) {
        FilePropertiesDialog dialog =
            new FilePropertiesDialog( item, new PentahoTabPanel(), null, getActiveTab(), false );
        dialog.showTab( getActiveTab() );
        dialog.center();

        event.setMessage( e.getMessage() );
        EventBusUtil.EVENT_BUS.fireEvent( event );
      }
    }
  }
View Full Code Here


* (non-Javadoc)
*
* @see com.google.gwt.user.client.Command#execute()
*/
  protected void performOperation( boolean feedback ) {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();

    event.setAction( this.getClass().getName() );
    VerticalPanel vp = new VerticalPanel();
    String deleteMessage;
    final PromptDialogBox deleteConfirmDialog;

    if ( mode.equals( "purge" ) ) {
      deleteMessage = Messages.getString( "deleteAllQuestion" );
      deleteConfirmDialog =
          new PromptDialogBox(
              Messages.getString( "emptyTrash" ), Messages.getString( "yesEmptyTrash" ), Messages.getString( "no" ), false, true, vp ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    } else {
      if ( MULTIPLE_DELETE_TYPE.equals( type ) ) {
        deleteMessage = Messages.getString( "deleteMultiQuestion" );
      } else {
        deleteMessage = Messages.getString( "deleteQuestion", type );
      }
      deleteConfirmDialog =
          new PromptDialogBox(
              Messages.getString( "permDelete" ), Messages.getString( "yesPermDelete" ), Messages.getString( "no" ), false, true, vp ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    vp.add( new HTML( deleteMessage ) ); //$NON-NLS-1$

    final IDialogCallback callback = new IDialogCallback() {

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

      public void okPressed() {
        String temp = "";

        // Add js file list
        temp = temp + fileList;

        // remove trailing ","
        temp = temp.substring( 0, temp.length() - 1 );

        final String filesList = temp;

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

            @Override
            public void onError( Request request, Throwable exception ) {
              MessageDialogBox dialogBox =
                  new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "couldNotDeleteFile" ), //$NON-NLS-1$ //$NON-NLS-2$
                      false, false, true );
              dialogBox.center();
              event.setMessage( Messages.getString( "couldNotDeleteFile" ) );
              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 {

                event.setMessage( Messages.getString( "couldNotDeleteFile" ) );
                EventBusUtil.EVENT_BUS.fireEvent( event );
              }
            }

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

      performOperation( true );
    }
  }

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

    String temp = "";
    String names = "";
    //Convert to a comma delimted list for rest call
    for ( SolutionBrowserFile file : filesToDelete ) {
View Full Code Here

    }
  }

  public void performOperation() {

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

    if ( selectedList != null && selectedList.size() == 1 ) {
      final RepositoryFile item = selectedList.get( 0 );

      // Checking if the user has access to manage permissions
      String url =
          contextURL
              + "api/repo/files/" + SolutionBrowserPanel.pathToId( item.getPath() ) + "/canAccess?permissions=" + MANAGE_ACLS; //$NON-NLS-1$ //$NON-NLS-2$
      RequestBuilder builder = new RequestBuilder( RequestBuilder.GET, url );
      try {
        builder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
        builder.sendRequest( null, new RequestCallback() {

          public void onError( Request request, Throwable exception ) {
            FilePropertiesDialog dialog =
                new FilePropertiesDialog( item, new PentahoTabPanel(), null, defaultTab, false );
            dialog.showTab( defaultTab );
            dialog.center();

            event.setMessage( exception.getMessage() );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }

          public void onResponseReceived( Request request, Response response ) {
            FilePropertiesDialog dialog =
                new FilePropertiesDialog( item, new PentahoTabPanel(), null, defaultTab, Boolean.parseBoolean( response
                    .getText() ) );
            dialog.showTab( FilePropertiesDialog.Tabs.PERMISSION );
            dialog.center();

            event.setMessage( "Success" );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }
        } );
      } catch ( RequestException e ) {
        FilePropertiesDialog dialog = new FilePropertiesDialog( item, new PentahoTabPanel(), null, defaultTab, false );
        dialog.showTab( FilePropertiesDialog.Tabs.PERMISSION );
        dialog.center();

        event.setMessage( e.getMessage() );
        EventBusUtil.EVENT_BUS.fireEvent( event );
      }

    }
  }
View Full Code Here

   *
   * @see com.google.gwt.user.client.Command#execute()
   */
  @Override
  public void execute() {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction( this.getClass().getName() );
    String temp = "";

    if ( repositoryFiles != null ) {
      for ( RepositoryFile repoFile : repositoryFiles ) {
        temp += repoFile.getId() + ","; //$NON-NLS-1$
      }
    }

    // Add file names from js
    temp = temp + fileList;

    // remove trailing ","
    temp = temp.substring( 0, temp.length() - 1 );

    final String filesList = temp;

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

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

        @Override
        public void onResponseReceived( Request request, Response response ) {
          if ( response.getStatusCode() == 200 ) {
            new RefreshRepositoryCommand().execute( false );
            event.setMessage( "Success" );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          } else {
            MessageDialogBox dialogBox =
                new MessageDialogBox(
                    Messages.getString( "cannotRestore" ), Messages.getString( "couldNotRestoreItem", type ), //$NON-NLS-1$ //$NON-NLS-2$
                    false, false, true, Messages.getString( "close" ) );
            dialogBox.center();
            event.setMessage( "Success" );
            FileChooserDialog.setIsDirty( Boolean.TRUE );
            setBrowseRepoDirty( Boolean.TRUE );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }
        }
      } );
    } catch ( RequestException e ) {
      MessageDialogBox dialogBox =
          new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "restoreError" ), //$NON-NLS-1$ //$NON-NLS-2$
              false, false, true );
      dialogBox.center();
      event.setMessage( Messages.getString( "restoreError" ) );
      EventBusUtil.EVENT_BUS.fireEvent( event );
    }
  }
View Full Code Here

    }
  }-*/;

  private static void showScheduleDialog( final String fileNameWithPath ) {

    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction( ScheduleHelper.class.getName() );
    try {

      final String url = GWT.getHostPageBaseURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$
      RequestBuilder requestBuilder = new RequestBuilder( RequestBuilder.GET, url );
      requestBuilder.setHeader( "accept", "text/plain" );
      requestBuilder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
      requestBuilder.sendRequest( null, new RequestCallback() {

        public void onError( Request request, Throwable caught ) {
          MantleLoginDialog.performLogin( new AsyncCallback<Boolean>() {

            public void onFailure( Throwable caught ) {
            }

            public void onSuccess( Boolean result ) {
              showScheduleDialog( fileNameWithPath );
            }

          } );
        }

        public void onResponseReceived( Request request, Response response ) {
          String moduleBaseURL = GWT.getModuleBaseURL();
          String moduleName = GWT.getModuleName();
          final String contextURL = moduleBaseURL.substring( 0, moduleBaseURL.lastIndexOf( moduleName ) );

          RequestBuilder emailValidRequest =
              new RequestBuilder( RequestBuilder.GET, contextURL + "api/emailconfig/isValid" );
          emailValidRequest.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
          emailValidRequest.setHeader( "accept", "text/plain" );
          try {
            emailValidRequest.sendRequest( null, new RequestCallback() {

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

              public void onResponseReceived( Request request, Response response ) {
                if ( response.getStatusCode() == Response.SC_OK ) {
                  final boolean isEmailConfValid = Boolean.parseBoolean( response.getText() );

                  NewScheduleDialog dialog = new NewScheduleDialog( fileNameWithPath, null, isEmailConfValid );
                  dialog.center();

                  event.setMessage( "Open" );
                  EventBusUtil.EVENT_BUS.fireEvent( event );
                }
              }
            } );
          } catch ( RequestException e ) {
            MessageDialogBox dialogBox =
                new MessageDialogBox( Messages.getString( "error" ), e.toString(), false, false, true ); //$NON-NLS-1$
            dialogBox.center();
            event.setMessage( e.getLocalizedMessage() );
            EventBusUtil.EVENT_BUS.fireEvent( event );
          }
        }

      } );
    } catch ( RequestException e ) {
      Window.alert( e.getMessage() );
      event.setMessage( e.getLocalizedMessage() );
      EventBusUtil.EVENT_BUS.fireEvent( event );
    }
  }
View Full Code Here

    String contextURL = moduleBaseURL.substring( 0, moduleBaseURL.lastIndexOf( moduleName ) );
    String exportURL =
        contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId( path ) + "/download?withManifest=true";
    Window.open( exportURL, "_new", "" );

    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction( this.getClass().getName() );
    event.setMessage( "Success" );
    EventBusUtil.EVENT_BUS.fireEvent( event );
  }
View Full Code Here

TOP

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

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.