Java Code Examples for org.eclipse.swt.SWT#ICON_ERROR
The following examples show how to use
org.eclipse.swt.SWT#ICON_ERROR .
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: ManagerUtils.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
/** * Publish a DownloadManager on our Tracker. * <P> * Doesn't require SWT Thread */ public static void publish( Core core, DownloadManager dm) { if (dm == null) { return; } TOTorrent torrent = dm.getTorrent(); if (torrent == null) { return; } try { core.getTrackerHost().publishTorrent(torrent); } catch (TRHostException e) { MessageBoxShell mb = new MessageBoxShell( SWT.ICON_ERROR | SWT.OK, MessageText.getString("MyTorrentsView.menu.host.error.title"), MessageText.getString("MyTorrentsView.menu.host.error.message").concat( "\n").concat(e.toString())); mb.open(null); } }
Example 2
Source File: JobEntryMysqlBulkLoadDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void getTableName() { // New class: SelectTableDialog int connr = wConnection.getSelectionIndex(); if ( connr >= 0 ) { DatabaseMeta inf = jobMeta.getDatabase( connr ); DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, inf, jobMeta.getDatabases() ); std.setSelectedSchemaAndTable( wSchemaname.getText(), wTablename.getText() ); if ( std.open() ) { wTablename.setText( Const.NVL( std.getTableName(), "" ) ); } } else { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "JobMysqlBulkLoad.ConnectionError2.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); } }
Example 3
Source File: ActionWaitForSqlDialog.java From hop with Apache License 2.0 | 6 votes |
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() ) { wTablename.setText( Const.NVL( std.getTableName(), "" ) ); } } else { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "ActionWaitForSQL.ConnectionError2.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); } } }
Example 4
Source File: OraBulkLoaderDialog.java From hop with Apache License 2.0 | 6 votes |
private void ok() { if ( Utils.isEmpty( wTransformName.getText() ) ) { return; } // Get the information for the dialog into the input structure. getInfo( input ); if ( input.getDatabaseMeta() == null ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "OraBulkLoaderDialog.InvalidConnection.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "OraBulkLoaderDialog.InvalidConnection.DialogTitle" ) ); mb.open(); } dispose(); }
Example 5
Source File: JobEntryColumnsExistDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void getTableName() { // New class: SelectTableDialog int connr = wConnection.getSelectionIndex(); if ( connr >= 0 ) { DatabaseMeta inf = jobMeta.getDatabase( connr ); DatabaseExplorerDialog std = new DatabaseExplorerDialog( shell, SWT.NONE, inf, jobMeta.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, "JobEntryColumnsExist.ConnectionError.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); } }
Example 6
Source File: LucidDBStreamingLoaderDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void ok() { if ( Utils.isEmpty( wStepname.getText() ) ) { return; } // Get the information for the dialog into the input structure. getInfo( input ); if ( input.getDatabaseMeta() == null ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb .setMessage( BaseMessages .getString( PKG, "LucidDBStreamingLoaderDialog.InvalidConnection.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "LucidDBStreamingLoaderDialog.InvalidConnection.DialogTitle" ) ); mb.open(); } dispose(); }
Example 7
Source File: DimensionLookupDialog.java From hop with Apache License 2.0 | 6 votes |
private void ok() { if ( Utils.isEmpty( wTransformName.getText() ) ) { return; } getInfo( input ); transformName = wTransformName.getText(); // return value if ( input.getDatabaseMeta() == null ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "DimensionLookupDialog.InvalidConnection.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "DimensionLookupDialog.InvalidConnection.DialogTitle" ) ); mb.open(); return; } dispose(); }
Example 8
Source File: MailInputDialog.java From hop with Apache License 2.0 | 5 votes |
private boolean connect() { String errordescription = null; boolean retval = false; if ( mailConn != null && mailConn.isConnected() ) { retval = mailConn.isConnected(); } if ( !retval ) { String realserver = pipelineMeta.environmentSubstitute( wServerName.getText() ); String realuser = pipelineMeta.environmentSubstitute( wUserName.getText() ); String realpass = Utils.resolvePassword( pipelineMeta, wPassword.getText() ); String realProxyUsername = pipelineMeta.environmentSubstitute( wProxyUsername.getText() ); int realport = Const.toInt( pipelineMeta.environmentSubstitute( wPort.getText() ), -1 ); try { mailConn = new MailConnection( LogChannel.UI, MailConnectionMeta.getProtocolFromString( wProtocol.getText(), MailConnectionMeta.PROTOCOL_IMAP ), realserver, realport, realuser, realpass, wUseSSL.getSelection(), wUseProxy.getSelection(), realProxyUsername ); 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, "MailInput.Connected.NOK.ConnectionBad", wServerName.getText() ) + Const.CR + Const.NVL( errordescription, "" ) ); mb.setText( BaseMessages.getString( PKG, "MailInput.Connected.Title.Bad" ) ); mb.open(); } return ( mailConn.isConnected() ); }
Example 9
Source File: XMLInputDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private boolean checkInputPositionsFilled( XMLInputMeta meta ) { if ( meta.getInputPosition() == null || meta.getInputPosition().length < 1 ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "XMLInputDialog.SpecifyRepeatingElement.DialogMessage" ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); return false; } else { return true; } }
Example 10
Source File: BeamHelper.java From kettle-beam with Apache License 2.0 | 5 votes |
public void createFileDefinition() { MetaStoreFactory<FileDefinition> factory = new MetaStoreFactory<>( FileDefinition.class, spoon.getMetaStore(), PentahoDefaults.NAMESPACE ); FileDefinition fileDefinition = new FileDefinition(); fileDefinition.setName( "My File Definition" ); boolean ok = false; while ( !ok ) { FileDefinitionDialog dialog = new FileDefinitionDialog( spoon.getShell(), fileDefinition ); if ( dialog.open() ) { // write to metastore... try { if ( factory.loadElement( fileDefinition.getName() ) != null ) { MessageBox box = new MessageBox( spoon.getShell(), SWT.YES | SWT.NO | SWT.ICON_ERROR ); box.setText( BaseMessages.getString( PKG, "BeamHelper.Error.FileDefintionExists.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "BeamHelper.Error.FileDefintionExists.Message" ) ); int answer = box.open(); if ( ( answer & SWT.YES ) != 0 ) { factory.saveElement( fileDefinition ); ok = true; } } else { factory.saveElement( fileDefinition ); ok = true; } } catch ( Exception exception ) { new ErrorDialog( spoon.getShell(), BaseMessages.getString( PKG, "BeamHelper.Error.ErrorSavingDefinition.Title" ), BaseMessages.getString( PKG, "BeamHelper.Error.ErrorSavingDefinition.Message" ), exception ); return; } } else { // Cancel return; } } }
Example 11
Source File: JobEntryFTPSPUTDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setServerName( wServerName.getText() ); jobEntry.setServerPort( wServerPort.getText() ); jobEntry.setUserName( wUserName.getText() ); jobEntry.setPassword( wPassword.getText() ); jobEntry.setRemoteDirectory( wRemoteDirectory.getText() ); jobEntry.setLocalDirectory( wLocalDirectory.getText() ); jobEntry.setWildcard( wWildcard.getText() ); jobEntry.setRemove( wRemove.getSelection() ); jobEntry.setBinaryMode( wBinaryMode.getSelection() ); jobEntry.setTimeout( Const.toInt( wTimeout.getText(), 10000 ) ); jobEntry.setOnlyPuttingNewFiles( wOnlyNew.getSelection() ); jobEntry.setActiveConnection( wActive.getSelection() ); jobEntry.setProxyHost( wProxyHost.getText() ); jobEntry.setProxyPort( wProxyPort.getText() ); jobEntry.setProxyUsername( wProxyUsername.getText() ); jobEntry.setProxyPassword( wProxyPassword.getText() ); jobEntry.setConnectionType( FTPSConnection.getConnectionTypeByDesc( wConnectionType.getText() ) ); dispose(); }
Example 12
Source File: JobEntrySFTPPUTDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setServerName( wServerName.getText() ); jobEntry.setServerPort( wServerPort.getText() ); jobEntry.setUserName( wUserName.getText() ); jobEntry.setPassword( wPassword.getText() ); jobEntry.setScpDirectory( wScpDirectory.getText() ); jobEntry.setLocalDirectory( wLocalDirectory.getText() ); jobEntry.setWildcard( wWildcard.getText() ); jobEntry.setCopyPrevious( wgetPrevious.getSelection() ); jobEntry.setCopyPreviousFiles( wgetPreviousFiles.getSelection() ); jobEntry.setAddFilenameResut( wAddFilenameToResult.getSelection() ); jobEntry.setUseKeyFile( wusePublicKey.getSelection() ); jobEntry.setKeyFilename( wKeyFilename.getText() ); jobEntry.setKeyPassPhrase( wkeyfilePass.getText() ); jobEntry.setCompression( wCompression.getText() ); jobEntry.setProxyType( wProxyType.getText() ); jobEntry.setProxyHost( wProxyHost.getText() ); jobEntry.setProxyPort( wProxyPort.getText() ); jobEntry.setProxyUsername( wProxyUsername.getText() ); jobEntry.setProxyPassword( wProxyPassword.getText() ); jobEntry.setCreateRemoteFolder( wCreateRemoteFolder.getSelection() ); jobEntry.setAfterFTPS( JobEntrySFTPPUT.getAfterSFTPPutByDesc( wAfterFTPPut.getText() ) ); jobEntry.setCreateDestinationFolder( wCreateDestinationFolder.getSelection() ); jobEntry.setDestinationFolder( wDestinationFolder.getText() ); jobEntry.setSuccessWhenNoFile( wSuccessWhenNoFile.getSelection() ); dispose(); }
Example 13
Source File: JobEntryTalendJobExecDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setFilename( wFilename.getText() ); jobEntry.setClassName( wClassName.getText() ); dispose(); }
Example 14
Source File: JobEntryCreateFileDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setFilename( wFilename.getText() ); jobEntry.setFailIfFileExists( wAbortExists.getSelection() ); jobEntry.setAddFilenameToResult( wAddFilenameToResult.getSelection() ); dispose(); }
Example 15
Source File: DimensionLookupDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void getSchemaNames() { DatabaseMeta databaseMeta = transMeta.findDatabase( wConnection.getText() ); if ( databaseMeta != null ) { Database database = new Database( loggingObject, databaseMeta ); 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, "DimensionLookupDialog.AvailableSchemas.Title", wConnection.getText() ), BaseMessages .getString( PKG, "DimensionLookupDialog.AvailableSchemas.Message", wConnection.getText() ) ); String d = dialog.open(); if ( d != null ) { wSchema.setText( Const.NVL( d, "" ) ); setTableFieldCombo(); } } else { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "DimensionLookupDialog.NoSchema.Error" ) ); mb.setText( BaseMessages.getString( PKG, "DimensionLookupDialog.GetSchemas.Error" ) ); mb.open(); } } catch ( Exception e ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages .getString( PKG, "DimensionLookupDialog.ErrorGettingSchemas" ), e ); } finally { database.disconnect(); } } }
Example 16
Source File: JobEntrySSH2GETDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setServerName( wServerName.getText() ); jobEntry.setUserName( wUserName.getText() ); jobEntry.setPassword( wPassword.getText() ); jobEntry.setServerPort( wServerPort.getText() ); jobEntry.setFtpDirectory( wFtpDirectory.getText() ); jobEntry.setlocalDirectory( wLocalDirectory.getText() ); jobEntry.setWildcard( wWildcard.getText() ); jobEntry.setOnlyGettingNewFiles( wOnlyNew.getSelection() ); jobEntry.setUseHTTPProxy( wuseHTTPProxy.getSelection() ); jobEntry.setHTTPProxyHost( wHTTPProxyHost.getText() ); jobEntry.setHTTPProxyPort( wHTTPProxyPort.getText() ); jobEntry.setHTTPProxyUsername( wHTTPProxyUsername.getText() ); jobEntry.setHTTPProxyPassword( wHTTPProxyPassword.getText() ); jobEntry.setUsePublicKey( wusePublicKey.getSelection() ); jobEntry.setKeyFilename( wKeyFilename.getText() ); jobEntry.setKeyFilePass( wkeyfilePass.getText() ); jobEntry.setUseBasicAuthentication( wuseBasicAuthentication.getSelection() ); if ( wAfterFTPPut.getSelectionIndex() == 1 ) { jobEntry.setAfterFTPPut( "delete_file" ); } else if ( wAfterFTPPut.getSelectionIndex() == 2 ) { jobEntry.setAfterFTPPut( "move_file" ); } else { jobEntry.setAfterFTPPut( "do_nothing" ); } jobEntry.setDestinationFolder( wDestinationFolder.getText() ); jobEntry.setCreateDestinationFolder( wCreateDestinationFolder.getSelection() ); jobEntry.setCacheHostKey( wcacheHostKey.getSelection() ); jobEntry.setTimeout( Const.toInt( wTimeout.getText(), 0 ) ); jobEntry.setCreateTargetFolder( wcreateTargetFolder.getSelection() ); jobEntry.setIncludeSubFolders( wincludeSubFolders.getSelection() ); dispose(); }
Example 17
Source File: ActionEvalFilesMetricsDialog.java From hop with Apache License 2.0 | 4 votes |
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.setResultFilenamesWildcard( wResultFilenamesWildcard.getText() ); action.setResultFieldFile( wResultFieldFile.getText() ); action.setResultFieldWildcard( wResultFieldWildcard.getText() ); action.setResultFieldIncludeSubfolders( wResultFieldIncludeSubFolders.getText() ); action.sourceFiles = ActionEvalFilesMetrics.getSourceFilesByDesc( wSourceFiles.getText() ); action.evaluationType = ActionEvalFilesMetrics.getEvaluationTypeByDesc( wEvaluationType.getText() ); action.scale = ActionEvalFilesMetrics.getScaleByDesc( wScale.getText() ); action.setSuccessConditionType( ActionEvalFilesMetrics.getSuccessNumberConditionByDesc( wSuccessNumberCondition.getText() ) ); action.setCompareValue( wCompareValue.getText() ); action.setMinValue( wMinValue.getText() ); action.setMaxValue( wMaxValue.getText() ); 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++; } } String[] sourceFileFolder = new String[ nr ]; String[] sourceWildcard = new String[ nr ]; String[] sourceIncludeSubfolders = new String[ nr ]; nr = 0; for ( int i = 0; i < nritems; i++ ) { String source = wFields.getNonEmpty( i ).getText( 1 ); String wild = wFields.getNonEmpty( i ).getText( 2 ); String includeSubFolders = wFields.getNonEmpty( i ).getText( 3 ); if ( source != null && source.length() != 0 ) { sourceFileFolder[ nr ] = source; sourceWildcard[ nr ] = wild; sourceIncludeSubfolders[ nr ] = ActionEvalFilesMetrics.getIncludeSubFolders( includeSubFolders ); nr++; } } action.setSourceFileFolder( sourceFileFolder ); action.setSourceWildcard( sourceWildcard ); action.setSourceIncludeSubfolders( sourceIncludeSubfolders ); dispose(); }
Example 18
Source File: JobEntryXMLWellFormedDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void ok() { if ( Utils.isEmpty( wName.getText() ) ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setText( BaseMessages.getString( PKG, "System.StepJobEntryNameMissing.Title" ) ); mb.setMessage( BaseMessages.getString( PKG, "System.JobEntryNameMissing.Msg" ) ); mb.open(); return; } jobEntry.setName( wName.getText() ); jobEntry.setIncludeSubfolders( wIncludeSubfolders.getSelection() ); jobEntry.setArgFromPrevious( wPrevious.getSelection() ); jobEntry.setNrErrorsLessThan( wNrErrorsLessThan.getText() ); if ( wSuccessCondition.getSelectionIndex() == 1 ) { jobEntry.setSuccessCondition( JobEntryXMLWellFormed.SUCCESS_IF_AT_LEAST_X_FILES_WELL_FORMED ); } else if ( wSuccessCondition.getSelectionIndex() == 2 ) { jobEntry.setSuccessCondition( JobEntryXMLWellFormed.SUCCESS_IF_BAD_FORMED_FILES_LESS ); } else { jobEntry.setSuccessCondition( JobEntryXMLWellFormed.SUCCESS_IF_NO_ERRORS ); } if ( wAddFilenameToResult.getSelectionIndex() == 1 ) { jobEntry.setResultFilenames( JobEntryXMLWellFormed.ADD_WELL_FORMED_FILES_ONLY ); } else if ( wAddFilenameToResult.getSelectionIndex() == 2 ) { jobEntry.setResultFilenames( JobEntryXMLWellFormed.ADD_BAD_FORMED_FILES_ONLY ); } else { jobEntry.setResultFilenames( JobEntryXMLWellFormed.ADD_ALL_FILENAMES ); } 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++; } } String[] source_filefolder = new String[nr]; String[] wildcard = new String[nr]; nr = 0; for ( int i = 0; i < nritems; i++ ) { String source = wFields.getNonEmpty( i ).getText( 1 ); String wild = wFields.getNonEmpty( i ).getText( 2 ); if ( source != null && source.length() != 0 ) { source_filefolder[nr] = source; wildcard[nr] = wild; nr++; } } jobEntry.setSourceFileFolders( source_filefolder ); jobEntry.setSourceWildcards( wildcard ); dispose(); }
Example 19
Source File: ActionFtpPutDialog.java From hop with Apache License 2.0 | 4 votes |
private boolean connectToFtp(boolean checkfolder, String remoteFoldername ) { 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( wServerPort.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(); } if ( checkfolder ) { if ( pwdFolder != null ) { ftpclient.chdir( pwdFolder ); } // move to spool dir ... if ( !Utils.isEmpty( remoteFoldername ) ) { String realFtpDirectory = workflowMeta.environmentSubstitute( remoteFoldername ); ftpclient.chdir( realFtpDirectory ); } } retval = true; } catch ( Exception e ) { if ( ftpclient != null ) { try { ftpclient.quit(); } catch ( Exception ignored ) { // We've tried quitting the FTP Client exception // nothing else can 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, "JobFTPPUT.ErrorConnect.NOK", realServername, e.getMessage() ) + Const.CR ); mb.setText( BaseMessages.getString( PKG, "JobFTPPUT.ErrorConnect.Title.Bad" ) ); mb.open(); } return retval; }
Example 20
Source File: RegexEvalHelperDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void testValue( int index, boolean testRegEx, String regExString ) { String realScript = regExString; if ( realScript == null ) { realScript = transmeta.environmentSubstitute( wRegExScript.getText() ); } if ( Utils.isEmpty( realScript ) ) { if ( testRegEx ) { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); mb.setMessage( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Message" ) ); mb.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.EnterScript.Title" ) ); mb.open(); } return; } String realValue = null; Text control = null; switch ( index ) { case 1: realValue = Const.NVL( transmeta.environmentSubstitute( wValue1.getText() ), "" ); control = wValue1; break; case 2: realValue = Const.NVL( transmeta.environmentSubstitute( wValue2.getText() ), "" ); control = wValue2; break; case 3: realValue = Const.NVL( transmeta.environmentSubstitute( wValue3.getText() ), "" ); control = wValue3; break; case 4: realValue = Const.NVL( transmeta.environmentSubstitute( wValueGroup.getText() ), "" ); control = wValueGroup; break; default: break; } try { Pattern p; if ( isCanonicalEqualityFlagSet() ) { p = Pattern.compile( regexoptions + realScript, Pattern.CANON_EQ ); } else { p = Pattern.compile( regexoptions + realScript ); } Matcher m = p.matcher( realValue ); boolean ismatch = m.matches(); if ( ismatch ) { control.setBackground( guiresource.getColorGreen() ); } else { control.setBackground( guiresource.getColorRed() ); } if ( index == 4 ) { wGroups.removeAll(); int nrFields = m.groupCount(); int nr = 0; for ( int i = 1; i <= nrFields; i++ ) { if ( m.group( i ) == null ) { wGroups.add( "" ); } else { wGroups.add( m.group( i ) ); } nr++; } wlGroups.setText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.FieldsGroup", nr ) ); } wRegExScriptCompile.setForeground( guiresource.getColorBlue() ); wRegExScriptCompile.setText( BaseMessages .getString( PKG, "RegexEvalHelperDialog.ScriptSuccessfullyCompiled" ) ); wRegExScriptCompile.setToolTipText( "" ); } catch ( Exception e ) { if ( !errorDisplayed ) { wRegExScriptCompile.setForeground( guiresource.getColorRed() ); wRegExScriptCompile.setText( e.getMessage() ); wRegExScriptCompile.setToolTipText( BaseMessages.getString( PKG, "RegexEvalHelperDialog.ErrorCompiling.Message" ) + Const.CR + e.toString() ); this.errorDisplayed = true; } } }