Skip to content

Commit

Permalink
[BACKLOG-14795] Add a flag to Abort step to prevent abort with error …
Browse files Browse the repository at this point in the history
…of transformation - ui change (#3611)
  • Loading branch information
AlexanderBuloichik authored and Ben Morrise committed Mar 2, 2017
1 parent 90ccf56 commit 51281be
Showing 1 changed file with 80 additions and 36 deletions.
116 changes: 80 additions & 36 deletions ui/src/org/pentaho/di/ui/trans/steps/abort/AbortDialog.java
Expand Up @@ -2,7 +2,7 @@
* *
* Pentaho Data Integration * Pentaho Data Integration
* *
* Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com * Copyright (C) 2002-2017 by Pentaho : http://www.pentaho.com
* *
******************************************************************************* *******************************************************************************
* *
Expand All @@ -29,6 +29,7 @@
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter; import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.FormLayout;
Expand All @@ -39,16 +40,17 @@
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.util.Utils; import org.pentaho.di.core.util.Utils;
import org.pentaho.di.i18n.BaseMessages; import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.trans.TransMeta; import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.BaseStepMeta; import org.pentaho.di.trans.step.BaseStepMeta;
import org.pentaho.di.trans.step.StepDialogInterface; import org.pentaho.di.trans.step.StepDialogInterface;
import org.pentaho.di.trans.steps.abort.Abort; import org.pentaho.di.trans.steps.abort.Abort;
import org.pentaho.di.trans.steps.abort.AbortMeta; 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.core.widget.TextVar;
import org.pentaho.di.ui.trans.step.BaseStepDialog; import org.pentaho.di.ui.trans.step.BaseStepDialog;
import org.pentaho.di.ui.util.SwtSvgImageUtil;


public class AbortDialog extends BaseStepDialog implements StepDialogInterface { public class AbortDialog extends BaseStepDialog implements StepDialogInterface {
private static Class<?> PKG = Abort.class; // for i18n purposes, needed by Translator2!! private static Class<?> PKG = Abort.class; // for i18n purposes, needed by Translator2!!
Expand All @@ -61,9 +63,11 @@ public class AbortDialog extends BaseStepDialog implements StepDialogInterface {
private TextVar wMessage; private TextVar wMessage;
private FormData fdlMessage, fdMessage; private FormData fdlMessage, fdMessage;


private Label wlAlwaysLogRows;
private Button wAlwaysLogRows; private Button wAlwaysLogRows;
private FormData fdlAlwaysLogRows, fdAlwaysLogRows; private FormData fdAlwaysLogRows;

private Button wAbortWithError;
private FormData fdAbortWithError;


private AbortMeta input; private AbortMeta input;


Expand All @@ -88,42 +92,54 @@ public void modifyText( ModifyEvent e ) {
changed = input.hasChanged(); changed = input.hasChanged();


FormLayout formLayout = new FormLayout(); FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginWidth = 15;
formLayout.marginHeight = Const.FORM_MARGIN; formLayout.marginHeight = 15;


shell.setLayout( formLayout ); shell.setLayout( formLayout );
shell.setText( BaseMessages.getString( PKG, "AbortDialog.Shell.Title" ) ); shell.setText( BaseMessages.getString( PKG, "AbortDialog.Shell.Title" ) );


int middle = props.getMiddlePct(); Label wicon = new Label( shell, SWT.RIGHT );
int margin = Const.MARGIN; 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 // Stepname line
wlStepname = new Label( shell, SWT.RIGHT ); wlStepname = new Label( shell, SWT.RIGHT );
wlStepname.setText( BaseMessages.getString( PKG, "AbortDialog.Stepname.Label" ) ); wlStepname.setText( BaseMessages.getString( PKG, "AbortDialog.Stepname.Label" ) );
props.setLook( wlStepname ); props.setLook( wlStepname );
fdlStepname = new FormData(); fdlStepname = new FormData();
fdlStepname.left = new FormAttachment( 0, 0 ); fdlStepname.left = new FormAttachment( 0, 0 );
fdlStepname.right = new FormAttachment( middle, -margin ); fdlStepname.top = new FormAttachment( 0, 0 );
fdlStepname.top = new FormAttachment( 0, margin );
wlStepname.setLayoutData( fdlStepname ); wlStepname.setLayoutData( fdlStepname );

wStepname = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wStepname = new Text( shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
wStepname.setText( stepname ); wStepname.setText( stepname );
props.setLook( wStepname ); props.setLook( wStepname );
wStepname.addModifyListener( lsMod ); wStepname.addModifyListener( lsMod );
fdStepname = new FormData(); fdStepname = new FormData();
fdStepname.left = new FormAttachment( middle, 0 ); fdStepname.width = 250;
fdStepname.top = new FormAttachment( 0, margin ); fdStepname.left = new FormAttachment( 0, 0 );
fdStepname.right = new FormAttachment( 100, 0 ); fdStepname.top = new FormAttachment( wlStepname, 5 );
wStepname.setLayoutData( fdStepname ); 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 // RowThreshold line
wlRowThreshold = new Label( shell, SWT.RIGHT ); wlRowThreshold = new Label( shell, SWT.RIGHT );
wlRowThreshold.setText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Label" ) ); wlRowThreshold.setText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Label" ) );
props.setLook( wlRowThreshold ); props.setLook( wlRowThreshold );
fdlRowThreshold = new FormData(); fdlRowThreshold = new FormData();
fdlRowThreshold.left = new FormAttachment( 0, 0 ); fdlRowThreshold.left = new FormAttachment( 0, 0 );
fdlRowThreshold.right = new FormAttachment( middle, -margin ); fdlRowThreshold.top = new FormAttachment( spacer, 20 );
fdlRowThreshold.top = new FormAttachment( wStepname, margin );
wlRowThreshold.setLayoutData( fdlRowThreshold ); wlRowThreshold.setLayoutData( fdlRowThreshold );
wRowThreshold = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wRowThreshold = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
wRowThreshold.setText( "" ); wRowThreshold.setText( "" );
Expand All @@ -132,9 +148,9 @@ public void modifyText( ModifyEvent e ) {
wRowThreshold.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Tooltip" ) ); wRowThreshold.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.RowThreshold.Tooltip" ) );
wRowThreshold.addModifyListener( lsMod ); wRowThreshold.addModifyListener( lsMod );
fdRowThreshold = new FormData(); fdRowThreshold = new FormData();
fdRowThreshold.left = new FormAttachment( middle, 0 ); fdRowThreshold.left = new FormAttachment( 0, 0 );
fdRowThreshold.top = new FormAttachment( wStepname, margin ); fdRowThreshold.top = new FormAttachment( wlRowThreshold, 5 );
fdRowThreshold.right = new FormAttachment( 100, 0 ); fdRowThreshold.width = 250;
wRowThreshold.setLayoutData( fdRowThreshold ); wRowThreshold.setLayoutData( fdRowThreshold );


// Message line // Message line
Expand All @@ -143,8 +159,7 @@ public void modifyText( ModifyEvent e ) {
props.setLook( wlMessage ); props.setLook( wlMessage );
fdlMessage = new FormData(); fdlMessage = new FormData();
fdlMessage.left = new FormAttachment( 0, 0 ); fdlMessage.left = new FormAttachment( 0, 0 );
fdlMessage.right = new FormAttachment( middle, -margin ); fdlMessage.top = new FormAttachment( wRowThreshold, 5 );
fdlMessage.top = new FormAttachment( wRowThreshold, margin );
wlMessage.setLayoutData( fdlMessage ); wlMessage.setLayoutData( fdlMessage );
wMessage = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER ); wMessage = new TextVar( transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
wMessage.setText( "" ); wMessage.setText( "" );
Expand All @@ -153,40 +168,61 @@ public void modifyText( ModifyEvent e ) {
wMessage.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AbortMessage.Tooltip" ) ); wMessage.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AbortMessage.Tooltip" ) );
wMessage.addModifyListener( lsMod ); wMessage.addModifyListener( lsMod );
fdMessage = new FormData(); fdMessage = new FormData();
fdMessage.left = new FormAttachment( middle, 0 ); fdMessage.left = new FormAttachment( 0, 0 );
fdMessage.top = new FormAttachment( wRowThreshold, margin ); fdMessage.top = new FormAttachment( wlMessage, 5 );
fdMessage.right = new FormAttachment( 100, 0 ); fdMessage.right = new FormAttachment( 100, 0 );
wMessage.setLayoutData( fdMessage ); 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 = new Button( shell, SWT.CHECK );
wAlwaysLogRows.setText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Label" ) );
props.setLook( wAlwaysLogRows ); props.setLook( wAlwaysLogRows );
wAlwaysLogRows.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Tooltip" ) ); wAlwaysLogRows.setToolTipText( BaseMessages.getString( PKG, "AbortDialog.AlwaysLogRows.Tooltip" ) );
fdAlwaysLogRows = new FormData(); fdAlwaysLogRows = new FormData();
fdAlwaysLogRows.left = new FormAttachment( middle, 0 ); fdAlwaysLogRows.left = new FormAttachment( 0, 0 );
fdAlwaysLogRows.top = new FormAttachment( wMessage, margin ); fdAlwaysLogRows.top = new FormAttachment( wMessage, 5 );
fdAlwaysLogRows.right = new FormAttachment( 100, 0 );
wAlwaysLogRows.setLayoutData( fdAlwaysLogRows ); wAlwaysLogRows.setLayoutData( fdAlwaysLogRows );
wAlwaysLogRows.addSelectionListener( new SelectionAdapter() { wAlwaysLogRows.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) { public void widgetSelected( SelectionEvent e ) {
input.setChanged(); input.setChanged();
} }
} ); } );


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 // Some buttons
wOK = new Button( shell, SWT.PUSH );
wOK.setText( BaseMessages.getString( PKG, "System.Button.OK" ) );
wCancel = new Button( shell, SWT.PUSH ); wCancel = new Button( shell, SWT.PUSH );
wCancel.setText( BaseMessages.getString( PKG, "System.Button.Cancel" ) ); 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 // Add listeners
lsCancel = new Listener() { lsCancel = new Listener() {
Expand All @@ -212,6 +248,7 @@ public void widgetDefaultSelected( SelectionEvent e ) {
wStepname.addSelectionListener( lsDef ); wStepname.addSelectionListener( lsDef );
wRowThreshold.addSelectionListener( lsDef ); wRowThreshold.addSelectionListener( lsDef );
wMessage.addSelectionListener( lsDef ); wMessage.addSelectionListener( lsDef );
wAbortWithError.addSelectionListener( lsDef );


// Detect X or ALT-F4 or something that kills this window... // Detect X or ALT-F4 or something that kills this window...
shell.addShellListener( new ShellAdapter() { shell.addShellListener( new ShellAdapter() {
Expand All @@ -235,6 +272,11 @@ public void shellClosed( ShellEvent e ) {
return stepname; 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. * Copy information from the meta-data input to the dialog fields.
*/ */
Expand All @@ -246,6 +288,7 @@ public void getData() {
wMessage.setText( input.getMessage() ); wMessage.setText( input.getMessage() );
} }
wAlwaysLogRows.setSelection( input.isAlwaysLogRows() ); wAlwaysLogRows.setSelection( input.isAlwaysLogRows() );
wAbortWithError.setSelection( input.isAbortWithError() );


wStepname.selectAll(); wStepname.selectAll();
wStepname.setFocus(); wStepname.setFocus();
Expand All @@ -255,6 +298,7 @@ private void getInfo( AbortMeta in ) {
input.setRowThreshold( wRowThreshold.getText() ); input.setRowThreshold( wRowThreshold.getText() );
input.setMessage( wMessage.getText() ); input.setMessage( wMessage.getText() );
input.setAlwaysLogRows( wAlwaysLogRows.getSelection() ); input.setAlwaysLogRows( wAlwaysLogRows.getSelection() );
input.setAbortWithError( wAbortWithError.getSelection() );
} }


/** /**
Expand Down

0 comments on commit 51281be

Please sign in to comment.