Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkchan2005-11-24 17:31:23 +0000
committerkchan2005-11-24 17:31:23 +0000
commit3543ea78b90beb4ea15474b3649b243366571375 (patch)
tree8a8247e495fec78eb2692b500ec007d640994ebd /bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal
parent9a713be759730d1434957aa1ee78f6578231b0bc (diff)
downloadwebtools.webservices-3543ea78b90beb4ea15474b3649b243366571375.tar.gz
webtools.webservices-3543ea78b90beb4ea15474b3649b243366571375.tar.xz
webtools.webservices-3543ea78b90beb4ea15474b3649b243366571375.zip
[98729] Simplify StatusHandler semantics from DataModelOperations.
Diffstat (limited to 'bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal')
-rw-r--r--bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java
index 13c0fd566..2a68f63ea 100644
--- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java
+++ b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java
@@ -37,9 +37,10 @@ public class CommandFragmentEngine implements CommandManager
private Stack commandStack_;
private FragmentListener undoFragmentListener_;
private FragmentListener nextFragmentListener_;
+ private FragmentListener afterExecuteFragmentListener_;
private FragmentListener peekFragmentListener_;
private DataFlowManager dataManager_;
- private IEnvironment environment_;
+ private IEnvironment environment_;
private IStatus lastStatus_;
/**
@@ -98,6 +99,11 @@ public class CommandFragmentEngine implements CommandManager
nextFragmentListener_ = listener;
}
+ public void setAfterExecuteFragmentListener( FragmentListener listener )
+ {
+ afterExecuteFragmentListener_ = listener;
+ }
+
/**
* Sets the next fragment listener for this engine. This listener will be
* called for each fragment that is traversed in peekForwardToNextStop operation.
@@ -232,7 +238,16 @@ public class CommandFragmentEngine implements CommandManager
{
CommandListEntry topEntry = (CommandListEntry)commandStack_.lastElement();
- // Always undo the top element.
+ if( topEntry.fragmentStopped_ && !topEntry.beforeExecute_ )
+ {
+ // Normally the command at the top of the stack has not been executed. If
+ // it has been execute, it means that we tried to execute and it failed.
+ // The first command in the command stack failed. Therefore, we should
+ // only undo this command.
+ performUndo( topEntry );
+ return topEntry.parentIndex_ == 0;
+ }
+
performUndo( topEntry );
while( topEntry.parentIndex_ != 0 )
@@ -311,7 +326,23 @@ public class CommandFragmentEngine implements CommandManager
lastStatus_ = runCommand( entry, monitor );
- if( lastStatus_.getSeverity() == IStatus.ERROR ) continueNavigate = false;
+ if( afterExecuteFragmentListener_ != null )
+ {
+ continueNavigate = afterExecuteFragmentListener_.notify( entry.fragment_ );
+
+ if( !continueNavigate )
+ {
+ // The after execution listener has indicated that execution should stop.
+ // Therefore, we will upgrade the severity of the last status to ERROR.
+ lastStatus_ = new Status( IStatus.ERROR,
+ lastStatus_.getPlugin(),
+ lastStatus_.getCode(),
+ lastStatus_.getMessage(),
+ lastStatus_.getException() );
+ }
+ }
+
+ if( continueNavigate && lastStatus_.getSeverity() == IStatus.ERROR ) continueNavigate = false;
}
if( !continueNavigate ) entry.fragmentStopped_ = true;
@@ -325,6 +356,11 @@ public class CommandFragmentEngine implements CommandManager
commandStack_.push( entry );
}
+ // Subclasses can do initialization before the execution of a command here
+ protected void initBeforeExecute( AbstractDataModelOperation operation )
+ {
+ }
+
private IStatus runCommand( CommandListEntry entry, IProgressMonitor monitor )
{
CommandFactory factory = entry.fragment_.getCommandFactory();
@@ -342,6 +378,8 @@ public class CommandFragmentEngine implements CommandManager
try
{
+ initBeforeExecute( cmd );
+
environment_.getLog().log(ILog.INFO, "command", 5001, this, "runCommand", "Executing: " + cmd.getClass().getName());
cmd.setEnvironment( environment_ );

Back to the top