Skip to content

Commit

Permalink
[BACKLOG-3806] When deleting a step, focus should be set to the "Yes"
Browse files Browse the repository at this point in the history
button
  • Loading branch information
e-cuellar committed Jul 28, 2015
1 parent da1a45b commit 0752892
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 85 deletions.
11 changes: 10 additions & 1 deletion engine/src/org/pentaho/di/job/JobMeta.java
Expand Up @@ -1355,7 +1355,11 @@ public void addJobEntry( int p, JobEntryCopy si ) {
* the hi
*/
public void addJobHop( int p, JobHopMeta hi ) {
jobhops.add( p, hi );
try {
jobhops.add( p, hi );
} catch ( IndexOutOfBoundsException e ) {
jobhops.add( hi );
}
changedHops = true;
}

Expand Down Expand Up @@ -2834,4 +2838,9 @@ public List<LogTableInterface> getExtraLogTables() {
public void setExtraLogTables( List<LogTableInterface> extraLogTables ) {
this.extraLogTables = extraLogTables;
}

public boolean containsJobCopy( JobEntryCopy jobCopy ) {
return jobcopies.contains( jobCopy );
}

}
10 changes: 9 additions & 1 deletion engine/src/org/pentaho/di/trans/TransMeta.java
Expand Up @@ -825,7 +825,11 @@ public void addStep( int p, StepMeta stepMeta ) {
* The hop to be added.
*/
public void addTransHop( int p, TransHopMeta hi ) {
hops.add( p, hi );
try {
hops.add( p, hi );
} catch ( IndexOutOfBoundsException e ) {
hops.add( hi );
}
changed_hops = true;
}

Expand Down Expand Up @@ -6200,4 +6204,8 @@ public void notifyAllListeners( StepMeta oldMeta, StepMeta newMeta ) {
listener.onStepChange( this, oldMeta, newMeta );
}
}

public boolean containsStepMeta( StepMeta stepMeta ) {
return steps.contains( stepMeta );
}
}
32 changes: 26 additions & 6 deletions ui/src/org/pentaho/di/ui/spoon/Spoon.java
Expand Up @@ -193,6 +193,7 @@
import org.pentaho.di.imp.ImportRules;
import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobExecutionConfiguration;
import org.pentaho.di.job.JobHopMeta;
import org.pentaho.di.job.JobMeta;
import org.pentaho.di.job.entries.job.JobEntryJob;
import org.pentaho.di.job.entries.trans.JobEntryTrans;
Expand Down Expand Up @@ -1493,17 +1494,13 @@ public void cut() {
List<StepMeta> stepMetas = transMeta.getSelectedSteps();
if ( stepMetas != null && stepMetas.size() > 0 ) {
copySteps();
for ( StepMeta stepMeta : stepMetas ) {
delStep( transMeta, stepMeta );
}
delSteps( transMeta, stepMetas.toArray( new StepMeta[stepMetas.size()] ) );
}
} else if ( jobActive ) {
List<JobEntryCopy> jobEntryCopies = jobMeta.getSelectedEntries();
if ( jobEntryCopies != null && jobEntryCopies.size() > 0 ) {
copyJobentries();
for ( JobEntryCopy jobEntryCopy : jobEntryCopies ) {
deleteJobEntryCopies( jobMeta, jobEntryCopy );
}
deleteJobEntryCopies( jobMeta, jobEntryCopies.toArray( new JobEntryCopy[jobEntryCopies.size()] ) );
}
}
}
Expand Down Expand Up @@ -7186,9 +7183,24 @@ public void undoAction( UndoInterface undoInterface ) {

if ( undoInterface instanceof TransMeta ) {
delegates.trans.undoTransformationAction( (TransMeta) undoInterface, ta );
if ( ta.getType() == TransAction.TYPE_ACTION_DELETE_STEP ) {
setUndoMenu( undoInterface ); // something changed: change the menu
ta = undoInterface.previousUndo();
if ( ta != null && ta.getType() == TransAction.TYPE_ACTION_DELETE_HOP ) {
delegates.trans.undoTransformationAction( (TransMeta) undoInterface, ta );
}
}

}
if ( undoInterface instanceof JobMeta ) {
delegates.jobs.undoJobAction( (JobMeta) undoInterface, ta );
if ( ta.getType() == TransAction.TYPE_ACTION_DELETE_JOB_ENTRY ) {
setUndoMenu( undoInterface ); // something changed: change the menu
ta = undoInterface.previousUndo();
if ( ta != null && ta.getType() == TransAction.TYPE_ACTION_DELETE_JOB_HOP ) {
delegates.jobs.undoJobAction( (JobMeta) undoInterface, ta );
}
}
}

// Put what we undo in focus
Expand Down Expand Up @@ -8514,6 +8526,10 @@ public void editJobEntry( JobMeta jobMeta, JobEntryCopy je ) {
delegates.jobs.editJobEntry( jobMeta, je );
}

public void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy[] jobEntry ) {
delegates.jobs.deleteJobEntryCopies( jobMeta, jobEntry );
}

public void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy jobEntry ) {
delegates.jobs.deleteJobEntryCopies( jobMeta, jobEntry );
}
Expand Down Expand Up @@ -8670,6 +8686,10 @@ public void dupeStep( TransMeta transMeta, StepMeta stepMeta ) {
delegates.steps.dupeStep( transMeta, stepMeta );
}

public void delSteps( TransMeta transformation, StepMeta[] steps ) {
delegates.steps.delSteps( transformation, steps );
}

public void delStep( TransMeta transMeta, StepMeta stepMeta ) {
delegates.steps.delStep( transMeta, stepMeta );
}
Expand Down
79 changes: 48 additions & 31 deletions ui/src/org/pentaho/di/ui/spoon/delegates/SpoonJobDelegate.java
Expand Up @@ -284,44 +284,61 @@ public void editJobEntry( JobMeta jobMeta, JobEntryCopy je ) {
}
}
}

public void deleteJobEntryCopies( JobMeta job, JobEntryCopy[] jobEntries ) {

// Hops belonging to the deleting jobEntries are placed in a single transaction and removed.
List<JobHopMeta> jobHops = new ArrayList<JobHopMeta>();
int[] hopIndexes = new int[job.nrJobHops()];
int hopIndex = 0;
main: for ( int i = job.nrJobHops() - 1; i >= 0; i-- ) {
JobHopMeta hi = job.getJobHop( i );
for ( int j = 0; j < jobEntries.length; j++ ) {
if ( hi.getFromEntry().equals( jobEntries[j] ) || hi.getToEntry().equals( jobEntries[j] ) ) {
int idx = job.indexOfJobHop( hi );
jobHops.add( (JobHopMeta) hi.clone() );
hopIndexes[hopIndex] = idx;
job.removeJobHop( idx );
spoon.refreshTree();
continue main;
}
}
hopIndex++;
}
JobHopMeta[] hops = jobHops.toArray( new JobHopMeta[ jobHops.size()] );
spoon.addUndoDelete( job, hops, hopIndexes );

//Deleting jobEntries are placed all in a single transaction and removed.
int[] positions = new int[jobEntries.length];
for ( int i = 0; i < jobEntries.length; i++ ) {
int pos = job.indexOfJobEntry( jobEntries[i] );
job.removeJobEntry( pos );
positions[i] = pos;
}
spoon.addUndoDelete( job, jobEntries, positions );

spoon.refreshTree();
spoon.refreshGraph();
}

public void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy jobEntry ) {
String name = jobEntry.getName();
// TODO Show warning "Are you sure? This operation can't be undone." +
// clear undo buffer.

// First delete all the hops using entry with name:
JobHopMeta[] hi = jobMeta.getAllJobHopsUsing( name );
if ( hi.length > 0 ) {
int[] hix = new int[hi.length];
for ( int i = 0; i < hi.length; i++ ) {
hix[i] = jobMeta.indexOfJobHop( hi[i] );
}

spoon.addUndoDelete( jobMeta, hi, hix );
for ( int i = hix.length - 1; i >= 0; i-- ) {
jobMeta.removeJobHop( hix[i] );
for ( int i = jobMeta.nrJobHops() - 1; i >= 0; i-- ) {
JobHopMeta hi = jobMeta.getJobHop( i );
if ( hi.getFromEntry().equals( jobEntry ) || hi.getToEntry().equals( jobEntry ) ) {
int idx = jobMeta.indexOfJobHop( hi );
spoon.addUndoDelete( jobMeta, new JobHopMeta[] { (JobHopMeta) hi.clone() }, new int[] { idx } );
jobMeta.removeJobHop( idx );
spoon.refreshTree();
}
}

// Then delete all the entries with name:
JobEntryCopy[] je = jobMeta.getAllJobGraphEntries( name );
int[] jex = new int[je.length];
for ( int i = 0; i < je.length; i++ ) {
jex[i] = jobMeta.indexOfJobEntry( je[i] );
}
int pos = jobMeta.indexOfJobEntry( jobEntry );
jobMeta.removeJobEntry( pos );
spoon.addUndoDelete( jobMeta, new JobEntryCopy[] { jobEntry }, new int[] { pos } );

if ( je.length > 0 ) {
spoon.addUndoDelete( jobMeta, je, jex );
}
for ( int i = jex.length - 1; i >= 0; i-- ) {
jobMeta.removeJobEntry( jex[i] );
}

jobMeta.clearUndo();
spoon.setUndoMenu( jobMeta );
spoon.refreshGraph();
spoon.refreshTree();
spoon.refreshGraph();
}

public void dupeJobEntry( JobMeta jobMeta, JobEntryCopy jobEntry ) {
Expand Down Expand Up @@ -1190,7 +1207,7 @@ public void undoJobAction( JobMeta jobMeta, TransAction transAction ) {
//

// We delete an entry : undo this...
case TransAction.TYPE_ACTION_DELETE_STEP:
case TransAction.TYPE_ACTION_DELETE_JOB_ENTRY:
// un-Delete the entry at correct location: re-insert
JobEntryCopy[] ce = (JobEntryCopy[]) transAction.getCurrent();
idx = transAction.getCurrentIndex();
Expand Down
39 changes: 38 additions & 1 deletion ui/src/org/pentaho/di/ui/spoon/delegates/SpoonStepsDelegate.java
Expand Up @@ -24,6 +24,7 @@

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -197,6 +198,42 @@ public String editStep( TransMeta transMeta, StepMeta stepMeta ) {
return stepname;
}

public void delSteps( TransMeta transformation, StepMeta[] steps ) {

// Hops belonging to the deleting steps are placed in a single transaction and removed.
List<TransHopMeta> transHops = new ArrayList<TransHopMeta>();
int[] hopIndexes = new int[transformation.nrTransHops()];
int hopIndex = 0;
main: for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) {
TransHopMeta hi = transformation.getTransHop( i );
for ( int j = 0; j < steps.length; j++ ) {
if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) {
int idx = transformation.indexOfTransHop( hi );
transHops.add( (TransHopMeta) hi.clone() );
hopIndexes[hopIndex] = idx;
transformation.removeTransHop( idx );
spoon.refreshTree();
continue main;
}
}
hopIndex++;
}
TransHopMeta[] hops = transHops.toArray( new TransHopMeta[ transHops.size()] );
spoon.addUndoDelete( transformation, hops, hopIndexes );

// Deleting steps are placed all in a single transaction and removed.
int[] positions = new int[steps.length];
for ( int i = 0; i < steps.length; i++ ) {
int pos = transformation.indexOfStep( steps[i] );
transformation.removeStep( pos );
positions[i] = pos;
}
spoon.addUndoDelete( transformation, steps, positions );

spoon.refreshTree();
spoon.refreshGraph();
}

public void delStep( TransMeta transMeta, StepMeta stepMeta ) {
spoon.getLog().logDebug(
toString(), BaseMessages.getString( PKG, "Spoon.Log.DeleteStep" ) + stepMeta.getName() ); // "Delete
Expand All @@ -221,7 +258,7 @@ public void delStep( TransMeta transMeta, StepMeta stepMeta ) {

spoon.refreshTree();
spoon.refreshGraph();
}
}

public StepDialogInterface getStepDialog( StepMetaInterface stepMeta, TransMeta transMeta, String stepName ) throws KettleException {
String dialogClassName = stepMeta.getDialogClassName();
Expand Down
23 changes: 2 additions & 21 deletions ui/src/org/pentaho/di/ui/spoon/job/JobGraph.java
Expand Up @@ -154,7 +154,6 @@
import org.pentaho.di.ui.spoon.TabMapEntry.ObjectType;
import org.pentaho.di.ui.spoon.XulSpoonResourceBundle;
import org.pentaho.di.ui.spoon.XulSpoonSettingsManager;
import org.pentaho.di.ui.spoon.dialog.DeleteMessageBox;
import org.pentaho.di.ui.spoon.dialog.NotePadDialog;
import org.pentaho.di.ui.spoon.trans.DelayListener;
import org.pentaho.di.ui.spoon.trans.DelayTimer;
Expand Down Expand Up @@ -1546,26 +1545,8 @@ public void delSelected() {
return;
}

// Load the list of steps
//
List<String> stepList = new ArrayList<String>();
for ( int i = 0; i < copies.size(); ++i ) {
stepList.add( copies.get( i ).toString() );
}

// Display the delete confirmation message box
MessageBox mb =
new DeleteMessageBox(
shell, BaseMessages.getString( PKG, "Spoon.Dialog.DeletionConfirm.Message" ), stepList );
int answer = mb.open();
if ( answer == SWT.YES ) {
// Perform the delete
for ( int i = 0; i < copies.size(); i++ ) {
spoon.deleteJobEntryCopies( jobMeta, copies.get( i ) );
}
spoon.refreshTree();
spoon.refreshGraph();
}
JobEntryCopy[] jobEntries = copies.toArray( new JobEntryCopy[copies.size()] );
spoon.deleteJobEntryCopies( jobMeta, jobEntries );
}

public void clearSettings() {
Expand Down
26 changes: 2 additions & 24 deletions ui/src/org/pentaho/di/ui/spoon/trans/TransGraph.java
Expand Up @@ -185,7 +185,6 @@
import org.pentaho.di.ui.spoon.TabItemInterface;
import org.pentaho.di.ui.spoon.XulSpoonResourceBundle;
import org.pentaho.di.ui.spoon.XulSpoonSettingsManager;
import org.pentaho.di.ui.spoon.dialog.DeleteMessageBox;
import org.pentaho.di.ui.spoon.dialog.EnterPreviewRowsDialog;
import org.pentaho.di.ui.spoon.dialog.NotePadDialog;
import org.pentaho.di.ui.spoon.dialog.SearchFieldsProgressDialog;
Expand Down Expand Up @@ -2886,29 +2885,8 @@ public void delSelected( StepMeta stMeta ) {
return;
}

// Get the list of steps that would be deleted
List<String> stepList = new ArrayList<String>();
for ( int i = transMeta.nrSteps() - 1; i >= 0; i-- ) {
StepMeta stepMeta = transMeta.getStep( i );
if ( stepMeta.isSelected() || ( stMeta != null && stMeta.equals( stepMeta ) ) ) {
stepList.add( stepMeta.getName() );
}
}

// Create and display the delete confirmation dialog
MessageBox mb =
new DeleteMessageBox( shell, BaseMessages.getString( PKG, "TransGraph.Dialog.Warning.DeleteSteps.Message" ),
stepList );
int result = mb.open();
if ( result == SWT.YES ) {
// Delete the steps
for ( int i = transMeta.nrSteps() - 1; i >= 0; i-- ) {
StepMeta stepMeta = transMeta.getStep( i );
if ( stepMeta.isSelected() || ( stMeta != null && stMeta.equals( stepMeta ) ) ) {
spoon.delStep( transMeta, stepMeta );
}
}
}
StepMeta[] steps = selection.toArray( new StepMeta[selection.size()] );
spoon.delSteps( transMeta, steps );
}

public void editDescription( StepMeta stepMeta ) {
Expand Down

0 comments on commit 0752892

Please sign in to comment.