diff --git a/ui/src/org/pentaho/di/ui/trans/steps/abort/AbortDialog.java b/ui/src/org/pentaho/di/ui/trans/steps/abort/AbortDialog.java index 8ac921966d61..8cecbe8cba43 100644 --- a/ui/src/org/pentaho/di/ui/trans/steps/abort/AbortDialog.java +++ b/ui/src/org/pentaho/di/ui/trans/steps/abort/AbortDialog.java @@ -2,7 +2,7 @@ * * Pentaho Data Integration * - * Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com + * Copyright (C) 2002-2017 by Pentaho : http://www.pentaho.com * ******************************************************************************* * @@ -29,6 +29,7 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.ShellAdapter; import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; @@ -39,7 +40,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.pentaho.di.core.Const; import org.pentaho.di.core.util.Utils; import org.pentaho.di.i18n.BaseMessages; import org.pentaho.di.trans.TransMeta; @@ -47,8 +47,10 @@ import org.pentaho.di.trans.step.StepDialogInterface; import org.pentaho.di.trans.steps.abort.Abort; import org.pentaho.di.trans.steps.abort.AbortMeta; +import org.pentaho.di.ui.core.ConstUI; import org.pentaho.di.ui.core.widget.TextVar; import org.pentaho.di.ui.trans.step.BaseStepDialog; +import org.pentaho.di.ui.util.SwtSvgImageUtil; public class AbortDialog extends BaseStepDialog implements StepDialogInterface { private static Class PKG = Abort.class; // for i18n purposes, needed by Translator2!! @@ -61,9 +63,11 @@ public class AbortDialog extends BaseStepDialog implements StepDialogInterface { private TextVar wMessage; private FormData fdlMessage, fdMessage; - private Label wlAlwaysLogRows; private Button wAlwaysLogRows; - private FormData fdlAlwaysLogRows, fdAlwaysLogRows; + private FormData fdAlwaysLogRows; + + private Button wAbortWithError; + private FormData fdAbortWithError; private AbortMeta input; @@ -88,14 +92,19 @@ public void modifyText( ModifyEvent e ) { changed = input.hasChanged(); FormLayout formLayout = new FormLayout(); - formLayout.marginWidth = Const.FORM_MARGIN; - formLayout.marginHeight = Const.FORM_MARGIN; + formLayout.marginWidth = 15; + formLayout.marginHeight = 15; shell.setLayout( formLayout ); shell.setText( BaseMessages.getString( PKG, "AbortDialog.Shell.Title" ) ); - int middle = props.getMiddlePct(); - int margin = Const.MARGIN; + Label wicon = new Label( shell, SWT.RIGHT ); + wicon.setImage( getImage() ); + FormData fdlicon = new FormData(); + fdlicon.top = new FormAttachment( 0, 0 ); + fdlicon.right = new FormAttachment( 100, 0 ); + wicon.setLayoutData( fdlicon ); + props.setLook( wicon ); // Stepname line wlStepname = new Label( shell, SWT.RIGHT ); @@ -103,27 +112,34 @@ public void modifyText( ModifyEvent e ) { props.setLook( wlStepname ); fdlStepname = new FormData(); fdlStepname.left = new FormAttachment( 0, 0 ); - fdlStepname.right = new FormAttachment( middle, -margin ); - fdlStepname.top = new FormAttachment( 0, margin ); + fdlStepname.top = new FormAttachment( 0, 0 ); wlStepname.setLayoutData( fdlStepname ); + wStepname = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wStepname.setText( stepname ); props.setLook( wStepname ); wStepname.addModifyListener( lsMod ); fdStepname = new FormData(); - fdStepname.left = new FormAttachment( middle, 0 ); - fdStepname.top = new FormAttachment( 0, margin ); - fdStepname.right = new FormAttachment( 100, 0 ); + fdStepname.width = 250; + fdStepname.left = new FormAttachment( 0, 0 ); + fdStepname.top = new FormAttachment( wlStepname, 5 ); wStepname.setLayoutData( fdStepname ); + Label spacer = new Label( shell, SWT.HORIZONTAL | SWT.SEPARATOR ); + FormData fdSpacer = new FormData(); + fdSpacer.height = 1; + fdSpacer.left = new FormAttachment( 0, 0 ); + fdSpacer.top = new FormAttachment( wStepname, 15 ); + fdSpacer.right = new FormAttachment( 100, 0 ); + spacer.setLayoutData( fdSpacer ); + // RowThreshold line wlRowThreshold = new Label( shell, SWT.RIGHT ); wlRowThreshold.setText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Label" ) ); props.setLook( wlRowThreshold ); fdlRowThreshold = new FormData(); fdlRowThreshold.left = new FormAttachment( 0, 0 ); - fdlRowThreshold.right = new FormAttachment( middle, -margin ); - fdlRowThreshold.top = new FormAttachment( wStepname, margin ); + fdlRowThreshold.top = new FormAttachment( spacer, 20 ); wlRowThreshold.setLayoutData( fdlRowThreshold ); wRowThreshold = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wRowThreshold.setText( "" ); @@ -132,9 +148,9 @@ public void modifyText( ModifyEvent e ) { wRowThreshold.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Tooltip" ) ); wRowThreshold.addModifyListener( lsMod ); fdRowThreshold = new FormData(); - fdRowThreshold.left = new FormAttachment( middle, 0 ); - fdRowThreshold.top = new FormAttachment( wStepname, margin ); - fdRowThreshold.right = new FormAttachment( 100, 0 ); + fdRowThreshold.left = new FormAttachment( 0, 0 ); + fdRowThreshold.top = new FormAttachment( wlRowThreshold, 5 ); + fdRowThreshold.width = 250; wRowThreshold.setLayoutData( fdRowThreshold ); // Message line @@ -143,8 +159,7 @@ public void modifyText( ModifyEvent e ) { props.setLook( wlMessage ); fdlMessage = new FormData(); fdlMessage.left = new FormAttachment( 0, 0 ); - fdlMessage.right = new FormAttachment( middle, -margin ); - fdlMessage.top = new FormAttachment( wRowThreshold, margin ); + fdlMessage.top = new FormAttachment( wRowThreshold, 5 ); wlMessage.setLayoutData( fdlMessage ); wMessage = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wMessage.setText( "" ); @@ -153,26 +168,18 @@ public void modifyText( ModifyEvent e ) { wMessage.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AbortMessage.Tooltip" ) ); wMessage.addModifyListener( lsMod ); fdMessage = new FormData(); - fdMessage.left = new FormAttachment( middle, 0 ); - fdMessage.top = new FormAttachment( wRowThreshold, margin ); + fdMessage.left = new FormAttachment( 0, 0 ); + fdMessage.top = new FormAttachment( wlMessage, 5 ); fdMessage.right = new FormAttachment( 100, 0 ); wMessage.setLayoutData( fdMessage ); - wlAlwaysLogRows = new Label( shell, SWT.RIGHT ); - wlAlwaysLogRows.setText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Label" ) ); - props.setLook( wlAlwaysLogRows ); - fdlAlwaysLogRows = new FormData(); - fdlAlwaysLogRows.left = new FormAttachment( 0, 0 ); - fdlAlwaysLogRows.top = new FormAttachment( wMessage, margin ); - fdlAlwaysLogRows.right = new FormAttachment( middle, -margin ); - wlAlwaysLogRows.setLayoutData( fdlAlwaysLogRows ); wAlwaysLogRows = new Button( shell, SWT.CHECK ); + wAlwaysLogRows.setText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Label" ) ); props.setLook( wAlwaysLogRows ); wAlwaysLogRows.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Tooltip" ) ); fdAlwaysLogRows = new FormData(); - fdAlwaysLogRows.left = new FormAttachment( middle, 0 ); - fdAlwaysLogRows.top = new FormAttachment( wMessage, margin ); - fdAlwaysLogRows.right = new FormAttachment( 100, 0 ); + fdAlwaysLogRows.left = new FormAttachment( 0, 0 ); + fdAlwaysLogRows.top = new FormAttachment( wMessage, 5 ); wAlwaysLogRows.setLayoutData( fdAlwaysLogRows ); wAlwaysLogRows.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { @@ -180,13 +187,42 @@ public void widgetSelected( SelectionEvent e ) { } } ); + wAbortWithError = new Button( shell, SWT.CHECK ); + wAbortWithError.setText( BaseMessages.getString( PKG, "AbortDialog.AbortWithError.Label" ) ); + props.setLook( wAbortWithError ); + wAbortWithError.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AbortWithError.Tooltip" ) ); + fdAbortWithError = new FormData(); + fdAbortWithError.left = new FormAttachment( 0, 0 ); + fdAbortWithError.top = new FormAttachment( wAlwaysLogRows, 5 ); + wAbortWithError.setLayoutData( fdAbortWithError ); + wAbortWithError.addSelectionListener( new SelectionAdapter() { + public void widgetSelected( SelectionEvent e ) { + input.setChanged(); + } + } ); + // Some buttons - wOK = new Button( shell, SWT.PUSH ); - wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) ); wCancel = new Button( shell, SWT.PUSH ); wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) ); + FormData fdCancel = new FormData(); + fdCancel.right = new FormAttachment( 100, 0 ); + fdCancel.bottom = new FormAttachment( 100, 0 ); + wCancel.setLayoutData( fdCancel ); - setButtonPositions( new Button[] { wOK, wCancel }, margin, wAlwaysLogRows ); + wOK = new Button( shell, SWT.PUSH ); + wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) ); + FormData fdOk = new FormData(); + fdOk.right = new FormAttachment( wCancel, -5 ); + fdOk.bottom = new FormAttachment( 100, 0 ); + wOK.setLayoutData( fdOk ); + + Label hSpacer = new Label( shell, SWT.HORIZONTAL | SWT.SEPARATOR ); + FormData fdhSpacer = new FormData(); + fdhSpacer.height = 1; + fdhSpacer.left = new FormAttachment( 0, 0 ); + fdhSpacer.bottom = new FormAttachment( wCancel, -15 ); + fdhSpacer.right = new FormAttachment( 100, 0 ); + hSpacer.setLayoutData( fdhSpacer ); // Add listeners lsCancel = new Listener() { @@ -212,6 +248,7 @@ public void widgetDefaultSelected( SelectionEvent e ) { wStepname.addSelectionListener( lsDef ); wRowThreshold.addSelectionListener( lsDef ); wMessage.addSelectionListener( lsDef ); + wAbortWithError.addSelectionListener( lsDef ); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { @@ -235,6 +272,11 @@ public void shellClosed( ShellEvent e ) { return stepname; } + private Image getImage() { + return SwtSvgImageUtil.getImage( shell.getDisplay(), getClass().getClassLoader(), "ABR.svg", ConstUI.ICON_SIZE, + ConstUI.ICON_SIZE ); + } + /** * Copy information from the meta-data input to the dialog fields. */ @@ -246,6 +288,7 @@ public void getData() { wMessage.setText( input.getMessage() ); } wAlwaysLogRows.setSelection( input.isAlwaysLogRows() ); + wAbortWithError.setSelection( input.isAbortWithError() ); wStepname.selectAll(); wStepname.setFocus(); @@ -255,6 +298,7 @@ private void getInfo( AbortMeta in ) { input.setRowThreshold( wRowThreshold.getText() ); input.setMessage( wMessage.getText() ); input.setAlwaysLogRows( wAlwaysLogRows.getSelection() ); + input.setAbortWithError( wAbortWithError.getSelection() ); } /**