Java Code Examples for org.eclipse.swt.widgets.MessageBox#setMessage()

The following examples show how to use org.eclipse.swt.widgets.MessageBox#setMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HopGitPerspective.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Discard changes to selected unstaged files.
 * Equivalent to <tt>git checkout -- &lt;paths&gt;</tt>
 *
 * @throws Exception
 */
@GuiToolbarElement(
  root = GUI_PLUGIN_FILES_TOOLBAR_PARENT_ID,
  id = FILES_TOOLBAR_ITEM_FILES_DISCARD,
  label = "Discard",
  toolTip = "Discard changes to the selected files"
)
public void discard() throws Exception {
  MessageBox box = new MessageBox( hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  box.setText( "Confirm" );
  box.setMessage( "Are you sure you want to discard changes to the selected " + getSelectedChangedFiles().size() + " files?" );
  int answer = box.open();
  if ( ( answer & SWT.YES ) == 0 ) {
    return;
  }

  List<UIFile> contents = getSelectedChangedFiles();
  for ( UIFile content : contents ) {
    vcs.revertPath( content.getName() );
  }
  refresh();

}
 
Example 2
Source File: ScriptDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private boolean cancel() {
  if ( input.hasChanged() ) {
    MessageBox box = new MessageBox( shell, SWT.YES | SWT.NO | SWT.APPLICATION_MODAL );
    box.setText( BaseMessages.getString( PKG, "ScriptDialog.WarningDialogChanged.Title" ) );
    box.setMessage( BaseMessages.getString( PKG, "ScriptDialog.WarningDialogChanged.Message", Const.CR ) );
    int answer = box.open();

    if ( answer == SWT.NO ) {
      return false;
    }
  }
  transformName = null;
  input.setChanged( changed );
  dispose();
  return true;
}
 
Example 3
Source File: ActionWriteToLogDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setLogMessage( wLogMessage.getText() );
  action.setLogSubject( wLogSubject.getText() );
  if ( wLoglevel.getSelectionIndex() != -1 ) {
    action.setEntryLogLevel( LogLevel.values()[ wLoglevel.getSelectionIndex() ] );
  }
  dispose();
}
 
Example 4
Source File: ActionSNMPTrapDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setPort( wPort.getText() );
  action.setServerName( wServerName.getText() );
  action.setOID( wOID.getText() );
  action.setTimeout( wTimeout.getText() );
  action.setRetry( wTimeout.getText() );
  action.setComString( wComString.getText() );
  action.setMessage( wMessage.getText() );
  action.setTargetType( wTargetType.getText() );
  action.setUser( wUser.getText() );
  action.setPassPhrase( wPassphrase.getText() );
  action.setEngineID( wEngineID.getText() );
  dispose();
}
 
Example 5
Source File: MySQLBulkLoaderDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void getTableName() {
  String connectionName = wConnection.getText();
  if ( StringUtils.isEmpty( connectionName ) ) {
    return;
  }
  DatabaseMeta databaseMeta = pipelineMeta.findDatabase( connectionName );
  if ( databaseMeta != null ) {
    if ( log.isDebug() ) {
      logDebug( BaseMessages.getString( PKG, "MySQLBulkLoaderDialog.Log.LookingAtConnection" ) + databaseMeta.toString() );
    }

    DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, databaseMeta, pipelineMeta.getDatabases() );
    std.setSelectedSchemaAndTable( wSchema.getText(), wTable.getText() );
    if ( std.open() ) {
      wSchema.setText( Const.NVL( std.getSchemaName(), "" ) );
      wTable.setText( Const.NVL( std.getTableName(), "" ) );
    }
  } else {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "MySQLBulkLoaderDialog.InvalidConnection.DialogMessage" ) );
    mb.setText( BaseMessages.getString( PKG, "MySQLBulkLoaderDialog.InvalidConnection.DialogTitle" ) );
    mb.open();
  }
}
 
Example 6
Source File: ActionColumnsExistDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void getTableName() {
  String databaseName = wConnection.getText();
  if ( StringUtils.isNotEmpty( databaseName ) ) {
    DatabaseMeta databaseMeta = workflowMeta.findDatabase( databaseName );
    if ( databaseMeta != null ) {
      DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, databaseMeta, workflowMeta.getDatabases() );
      std.setSelectedSchemaAndTable( wSchemaname.getText(), wTablename.getText() );
      if ( std.open() ) {
        wSchemaname.setText( Const.NVL( std.getSchemaName(), "" ) );
        wTablename.setText( Const.NVL( std.getTableName(), "" ) );
      }
    } else {
      MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
      mb.setMessage( BaseMessages.getString( PKG, "ActionColumnsExist.ConnectionError.DialogMessage" ) );
      mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) );
      mb.open();
    }
  }
}
 
Example 7
Source File: ActionCreateFileDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {

    if ( Utils.isEmpty( wName.getText() ) ) {
      MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
      mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
      mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
      mb.open();
      return;
    }
    action.setName( wName.getText() );
    action.setFilename( wFilename.getText() );
    action.setFailIfFileExists( wAbortExists.getSelection() );
    action.setAddFilenameToResult( wAddFilenameToResult.getSelection() );
    dispose();
  }
 
Example 8
Source File: ActionGetPOPDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private boolean connect() {
  String errordescription = null;
  boolean retval = false;
  if ( mailConn != null && mailConn.isConnected() ) {
    retval = mailConn.isConnected();
  }

  if ( !retval ) {
    String realserver = workflowMeta.environmentSubstitute( wServerName.getText() );
    String realuser = workflowMeta.environmentSubstitute( wUserName.getText() );
    String realpass = action.getRealPassword( workflowMeta.environmentSubstitute( wPassword.getText() ) );
    int realport = Const.toInt( workflowMeta.environmentSubstitute( wPort.getText() ), -1 );
    String realproxyuser = workflowMeta.environmentSubstitute( wProxyUsername.getText() );
    try {
      mailConn =
        new MailConnection(
          LogChannel.UI, MailConnectionMeta.getProtocolFromString(
          wProtocol.getText(), MailConnectionMeta.PROTOCOL_IMAP ), realserver, realport, realuser,
          realpass, wUseSSL.getSelection(), wUseProxy.getSelection(), realproxyuser );
      mailConn.connect();

      retval = true;
    } catch ( Exception e ) {
      errordescription = e.getMessage();
    }
  }

  if ( !retval ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "JobGetPOP.Connected.NOK.ConnectionBad", wServerName.getText() )
      + Const.CR + Const.NVL( errordescription, "" ) );
    mb.setText( BaseMessages.getString( PKG, "JobGetPOP.Connected.Title.Bad" ) );
    mb.open();
  }

  return ( mailConn.isConnected() );

}
 
Example 9
Source File: RssInputDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private boolean checkInputURL( RssInputMeta meta ) {
  if ( wUrlList.nrNonEmpty() < 1 ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "RssInput.Log.UrlMissing" ) );
    mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) );
    mb.open();

    return false;
  } else {
    return true;
  }

}
 
Example 10
Source File: ActionSftpDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void checkRemoteFolder() {
  String changeFtpFolder = workflowMeta.environmentSubstitute( wScpDirectory.getText() );
  if ( !Utils.isEmpty( changeFtpFolder ) ) {
    if ( connectToSftp( true, changeFtpFolder ) ) {
      MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_INFORMATION );
      mb.setMessage( BaseMessages.getString( PKG, "JobSFTP.FolderExists.OK", changeFtpFolder ) + Const.CR );
      mb.setText( BaseMessages.getString( PKG, "JobSFTP.FolderExists.Title.Ok" ) );
      mb.open();
    }
  }
}
 
Example 11
Source File: ActionFtpPutDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setServerName( wServerName.getText() );
  action.setServerPort( wServerPort.getText() );
  action.setUserName( wUserName.getText() );
  action.setPassword( wPassword.getText() );
  action.setRemoteDirectory( wRemoteDirectory.getText() );
  action.setLocalDirectory( wLocalDirectory.getText() );
  action.setWildcard( wWildcard.getText() );
  action.setRemove( wRemove.getSelection() );
  action.setBinaryMode( wBinaryMode.getSelection() );
  action.setTimeout( Const.toInt( wTimeout.getText(), 10000 ) );
  action.setOnlyPuttingNewFiles( wOnlyNew.getSelection() );
  action.setActiveConnection( wActive.getSelection() );
  action.setControlEncoding( wControlEncoding.getText() );

  action.setProxyHost( wProxyHost.getText() );
  action.setProxyPort( wProxyPort.getText() );
  action.setProxyUsername( wProxyUsername.getText() );
  action.setProxyPassword( wProxyPassword.getText() );
  action.setSocksProxyHost( wSocksProxyHost.getText() );
  action.setSocksProxyPort( wSocksProxyPort.getText() );
  action.setSocksProxyUsername( wSocksProxyUsername.getText() );
  action.setSocksProxyPassword( wSocksProxyPassword.getText() );
  dispose();
}
 
Example 12
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
@Override public boolean isCloseable() {
  try {
    // Check if the file is saved. If not, ask for it to be saved.
    //
    if ( workflowMeta.hasChanged() ) {

      MessageBox messageDialog = new MessageBox( hopShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL );
      messageDialog.setText( "Save file?" );
      messageDialog.setMessage( "Do you want to save file '" + buildTabName() + "' before closing?" );
      int answer = messageDialog.open();
      if ( ( answer & SWT.YES ) != 0 ) {
        save();
        return true;
      }
      if ( ( answer & SWT.NO ) != 0 ) {
        // User doesn't want to save but close
        return true;
      }
      return false;
    } else {
      return true;
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopShell(), "Error", "Error preparing file close", e );
  }
  return false;
}
 
Example 13
Source File: ActionFileCompareDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setFilename1( wFilename1.getText() );
  action.setFilename2( wFilename2.getText() );
  action.setAddFilenameToResult( wAddFilenameResult.getSelection() );
  dispose();
}
 
Example 14
Source File: ActionMysqlBulkLoadDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setText( BaseMessages.getString( PKG, "System.TransformActionNameMissing.Title" ) );
    mb.setMessage( BaseMessages.getString( PKG, "System.ActionNameMissing.Msg" ) );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setDatabase( workflowMeta.findDatabase( wConnection.getText() ) );
  action.setSchemaname( wSchemaname.getText() );
  action.setTablename( wTablename.getText() );
  action.setFilename( wFilename.getText() );
  action.setSeparator( wSeparator.getText() );
  action.setEnclosed( wEnclosed.getText() );
  action.setEscaped( wEscaped.getText() );
  action.setLineterminated( wLineterminated.getText() );
  action.setLinestarted( wLinestarted.getText() );
  action.setReplacedata( wReplacedata.getSelection() );
  action.setIgnorelines( wIgnorelines.getText() );
  action.setListattribut( wListattribut.getText() );
  action.prorityvalue = wProrityValue.getSelectionIndex();
  action.setLocalInfile( wLocalInfile.getSelection() );

  action.setAddFileToResult( wAddFileToResult.getSelection() );

  dispose();
}
 
Example 15
Source File: ActionTableExistsDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void getSchemaNames() {
  if ( wSchemaname.isDisposed() ) {
    return;
  }
  DatabaseMeta databaseMeta = workflowMeta.findDatabase( wConnection.getText() );
  if ( databaseMeta != null ) {
    Database database = new Database( loggingObject, databaseMeta );
    database.shareVariablesWith( workflowMeta );
    try {
      database.connect();
      String[] schemas = database.getSchemas();

      if ( null != schemas && schemas.length > 0 ) {
        schemas = Const.sortStrings( schemas );
        EnterSelectionDialog dialog = new EnterSelectionDialog( shell, schemas,
          BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.Title", wConnection.getText() ),
          BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.Message" ) );
        String d = dialog.open();
        if ( d != null ) {
          wSchemaname.setText( Const.NVL( d.toString(), "" ) );
        }

      } else {
        MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
        mb.setMessage( BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.Empty.Message" ) );
        mb.setText( BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.Empty.Title" ) );
        mb.open();
      }
    } catch ( Exception e ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ),
        BaseMessages.getString( PKG, "System.Dialog.AvailableSchemas.ConnectionError" ), e );
    } finally {
      if ( database != null ) {
        database.disconnect();
        database = null;
      }
    }
  }
}
 
Example 16
Source File: DatabaseExplorerDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
public void showCount( String tableName ) {
  GetTableSizeProgressDialog pd = new GetTableSizeProgressDialog( shell, dbMeta, tableName );
  Long size = pd.open();
  if ( size != null ) {
    MessageBox mb = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.OK );
    mb.setMessage( BaseMessages.getString( PKG, "DatabaseExplorerDialog.TableSize.Message", tableName, size.toString() ) );
    mb.setText( BaseMessages.getString( PKG, "DatabaseExplorerDialog.TableSize.Title" ) );
    mb.open();
  }
}
 
Example 17
Source File: ActionFtpDeleteDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private boolean connectToFtp() {
  boolean retval = false;
  String realServername = null;
  try {
    if ( ftpclient == null || !ftpclient.connected() ) {
      // Create ftp client to host:port ...
      ftpclient = new FTPClient();
      realServername = workflowMeta.environmentSubstitute( wServerName.getText() );
      int realPort = Const.toInt( workflowMeta.environmentSubstitute( wPort.getText() ), 21 );
      ftpclient.setRemoteAddr( InetAddress.getByName( realServername ) );
      ftpclient.setRemotePort( realPort );

      if ( !Utils.isEmpty( wProxyHost.getText() ) ) {
        String realProxy_host = workflowMeta.environmentSubstitute( wProxyHost.getText() );
        ftpclient.setRemoteAddr( InetAddress.getByName( realProxy_host ) );

        int port = Const.toInt( workflowMeta.environmentSubstitute( wProxyPort.getText() ), 21 );
        if ( port != 0 ) {
          ftpclient.setRemotePort( port );
        }
      }

      // login to ftp host ...
      ftpclient.connect();
      String realUsername =
        workflowMeta.environmentSubstitute( wUserName.getText() )
          + ( !Utils.isEmpty( wProxyHost.getText() ) ? "@" + realServername : "" )
          + ( !Utils.isEmpty( wProxyUsername.getText() ) ? " "
          + workflowMeta.environmentSubstitute( wProxyUsername.getText() ) : "" );

      String realPassword =
        Utils.resolvePassword( workflowMeta, wPassword.getText() )
          + ( !Utils.isEmpty( wProxyPassword.getText() ) ? " "
          + Utils.resolvePassword( workflowMeta, wProxyPassword.getText() ) : "" );
      // login now ...
      ftpclient.login( realUsername, realPassword );
      pwdFolder = ftpclient.pwd();
    }
    retval = true;
  } catch ( Exception e ) {
    if ( ftpclient != null ) {
      try {
        ftpclient.quit();
      } catch ( Exception ignored ) {
        // We've tried quitting the FTP Client exception
        // nothing else to be done if the FTP Client was already disconnected
      }
      ftpclient = null;
    }
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "JobFTPDelete.ErrorConnect.NOK", realServername,
      e.getMessage() ) + Const.CR );
    mb.setText( BaseMessages.getString( PKG, "JobFTPDelete.ErrorConnect.Title.Bad" ) );
    mb.open();
  }
  return retval;
}
 
Example 18
Source File: DatabaseExplorerDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
public void getDDLForOther( String tableName ) {
  if ( databases != null ) {
    Database db = new Database( dbMeta );
    try {
      db.connect();

      IRowMeta r = db.getTableFields( tableName );

      // Now select the other connection...

      // Only take non-SAP ERP connections....
      List<DatabaseMeta> dbs = new ArrayList<DatabaseMeta>();
      for ( int i = 0; i < databases.size(); i++ ) {
        dbs.add( databases.get( i ) );
      }

      String conn[] = new String[ dbs.size() ];
      for ( int i = 0; i < conn.length; i++ ) {
        conn[ i ] = ( dbs.get( i ) ).getName();
      }

      EnterSelectionDialog esd = new EnterSelectionDialog( shell, conn, BaseMessages.getString( PKG, "DatabaseExplorerDialog.TargetDatabase.Title" ),
        BaseMessages.getString( PKG, "DatabaseExplorerDialog.TargetDatabase.Message" ) );
      String target = esd.open();
      if ( target != null ) {
        DatabaseMeta targetdbi = DatabaseMeta.findDatabase( dbs, target );
        Database targetdb = new Database( targetdbi );

        String sql = targetdb.getCreateTableStatement( tableName, r, null, false, null, true );
        SqlEditor se = new SqlEditor( dbMeta, shell, SWT.NONE, dbMeta, dbcache, sql );
        se.open();
      }
    } catch ( HopDatabaseException dbe ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "Dialog.Error.Header" ),
        BaseMessages.getString( PKG, "DatabaseExplorerDialog.Error.GenDDL" ), dbe );
    } finally {
      db.disconnect();
    }
  } else {
    MessageBox mb = new MessageBox( shell, SWT.NONE | SWT.ICON_INFORMATION );
    mb.setMessage( BaseMessages.getString( PKG, "DatabaseExplorerDialog.NoConnectionsKnown.Message" ) );
    mb.setText( BaseMessages.getString( PKG, "DatabaseExplorerDialog.NoConnectionsKnown.Title" ) );
    mb.open();
  }
}
 
Example 19
Source File: ActionPGPEncryptFilesDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void ok() {
  if ( Utils.isEmpty( wName.getText() ) ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
    mb.setMessage( "Please give this action a name!" );
    mb.setText( "Enter a name" );
    mb.open();
    return;
  }
  action.setName( wName.getText() );
  action.setIncludeSubfolders( wIncludeSubfolders.getSelection() );
  action.setAsciiMode( wasciiMode.getSelection() );
  action.setArgFromPrevious( wPrevious.getSelection() );
  action.setAddresultfilesname( wAddFileToResult.getSelection() );
  action.setDestinationIsAFile( wDestinationIsAFile.getSelection() );
  action.setCreateDestinationFolder( wCreateDestinationFolder.getSelection() );
  action.setNrErrorsLessThan( wNrErrorsLessThan.getText() );

  action.setCreateMoveToFolder( wCreateMoveToFolder.getSelection() );

  if ( wSuccessCondition.getSelectionIndex() == 1 ) {
    action.setSuccessCondition( action.SUCCESS_IF_AT_LEAST_X_FILES_UN_ZIPPED );
  } else if ( wSuccessCondition.getSelectionIndex() == 2 ) {
    action.setSuccessCondition( action.SUCCESS_IF_ERRORS_LESS );
  } else {
    action.setSuccessCondition( action.SUCCESS_IF_NO_ERRORS );
  }

  if ( wIfFileExists.getSelectionIndex() == 1 ) {
    action.setIfFileExists( "overwrite_file" );
  } else if ( wIfFileExists.getSelectionIndex() == 2 ) {
    action.setIfFileExists( "unique_name" );
  } else if ( wIfFileExists.getSelectionIndex() == 3 ) {
    action.setIfFileExists( "delete_file" );
  } else if ( wIfFileExists.getSelectionIndex() == 4 ) {
    action.setIfFileExists( "move_file" );
  } else if ( wIfFileExists.getSelectionIndex() == 5 ) {
    action.setIfFileExists( "fail" );
  } else {
    action.setIfFileExists( "do_nothing" );
  }

  action.setDestinationFolder( wDestinationFolder.getText() );

  action.setGPGLocation( wGpgExe.getText() );

  if ( wIfMovedFileExists.getSelectionIndex() == 1 ) {
    action.setIfMovedFileExists( "overwrite_file" );
  } else if ( wIfMovedFileExists.getSelectionIndex() == 2 ) {
    action.setIfMovedFileExists( "unique_name" );
  } else if ( wIfMovedFileExists.getSelectionIndex() == 3 ) {
    action.setIfMovedFileExists( "fail" );
  } else {
    action.setIfMovedFileExists( "do_nothing" );
  }

  action.setDoNotKeepFolderStructure( wDoNotKeepFolderStructure.getSelection() );

  action.setAddDate( wAddDate.getSelection() );
  action.setAddTime( wAddTime.getSelection() );
  action.setSpecifyFormat( wSpecifyFormat.getSelection() );
  action.setDateTimeFormat( wDateTimeFormat.getText() );
  action.setAddDateBeforeExtension( wAddDateBeforeExtension.getSelection() );

  action.setAddMovedDate( wAddMovedDate.getSelection() );
  action.setAddMovedTime( wAddMovedTime.getSelection() );
  action.setSpecifyMoveFormat( wSpecifyMoveFormat.getSelection() );
  action.setMovedDateTimeFormat( wMovedDateTimeFormat.getText() );
  action.setAddMovedDateBeforeExtension( wAddMovedDateBeforeExtension.getSelection() );

  int nritems = wFields.nrNonEmpty();
  int nr = 0;
  for ( int i = 0; i < nritems; i++ ) {
    String arg = wFields.getNonEmpty( i ).getText( 1 );
    if ( arg != null && arg.length() != 0 ) {
      nr++;
    }
  }
  action.actionType = new int[ nr ];
  action.sourceFileFolder = new String[ nr ];
  action.userId = new String[ nr ];
  action.destinationFileFolder = new String[ nr ];
  action.wildcard = new String[ nr ];
  nr = 0;
  for ( int i = 0; i < nritems; i++ ) {
    String actionName = wFields.getNonEmpty( i ).getText( 1 );
    String source = wFields.getNonEmpty( i ).getText( 2 );
    String wild = wFields.getNonEmpty( i ).getText( 3 );
    String userid = wFields.getNonEmpty( i ).getText( 4 );
    String dest = wFields.getNonEmpty( i ).getText( 5 );

    if ( source != null && source.length() != 0 ) {
      action.actionType[ nr ] = ActionPGPEncryptFiles.getActionTypeByDesc( actionName );
      action.sourceFileFolder[ nr ] = source;
      action.wildcard[ nr ] = wild;
      action.userId[ nr ] = userid;
      action.destinationFileFolder[ nr ] = dest;
      nr++;
    }
  }
  dispose();
}
 
Example 20
Source File: TextFileInputDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void preview() {
  // Create the XML input transform
  TextFileInputMeta oneMeta = new TextFileInputMeta();
  getInfo( oneMeta );

  if ( oneMeta.isAcceptingFilenames() ) {
    MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_INFORMATION );
    mb.setMessage( BaseMessages.getString( PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Message" ) );
    mb.setText( BaseMessages.getString( PKG, "TextFileInputDialog.Dialog.SpecifyASampleFile.Title" ) );
    mb.open();
    return;
  }

  PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewTransformation( pipelineMeta, oneMeta,
    wTransformName.getText() );

  EnterNumberDialog numberDialog =
    new EnterNumberDialog( shell, props.getDefaultPreviewSize(), BaseMessages.getString( PKG,
      "TextFileInputDialog.PreviewSize.DialogTitle" ), BaseMessages.getString( PKG,
      "TextFileInputDialog.PreviewSize.DialogMessage" ) );
  int previewSize = numberDialog.open();
  if ( previewSize > 0 ) {
    PipelinePreviewProgressDialog progressDialog =
      new PipelinePreviewProgressDialog( shell, previewMeta, new String[] { wTransformName.getText() },
        new int[] { previewSize } );
    progressDialog.open();

    Pipeline pipeline = progressDialog.getPipeline();
    String loggingText = progressDialog.getLoggingText();

    if ( !progressDialog.isCancelled() ) {
      if ( pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0 ) {
        EnterTextDialog etd =
          new EnterTextDialog( shell, BaseMessages.getString( PKG, "System.Dialog.PreviewError.Title" ),
            BaseMessages.getString( PKG, "System.Dialog.PreviewError.Message" ), loggingText, true );
        etd.setReadOnly();
        etd.open();
      }
    }

    PreviewRowsDialog prd =
      new PreviewRowsDialog( shell, pipelineMeta, SWT.NONE, wTransformName.getText(), progressDialog
        .getPreviewRowsMeta( wTransformName.getText() ), progressDialog.getPreviewRows( wTransformName.getText() ),
        loggingText );
    prd.open();
  }
}