Skip to content

Commit

Permalink
JBIDE-16479: initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Apr 5, 2014
1 parent 3daeb91 commit db266a2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.jboss.tools.forge.ui.ext.cli;

import java.util.Iterator;

import org.jboss.forge.addon.resource.Resource;
import org.jboss.forge.addon.ui.command.AbstractCommandExecutionListener;
import org.jboss.forge.addon.ui.command.UICommand;
import org.jboss.forge.addon.ui.context.UIExecutionContext;
import org.jboss.forge.addon.ui.context.UISelection;
import org.jboss.forge.addon.ui.result.Result;

public class CommandExecutionListenerImpl extends AbstractCommandExecutionListener {

@Override
public void postCommandExecuted(
UICommand command,
UIExecutionContext uiExecutionContext,
Result result) {
UISelection<?> selection = uiExecutionContext.getUIContext().getInitialSelection();
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
if (object instanceof Resource<?>) {
refresh((Resource<?>)object);
}
}
Object object = uiExecutionContext.getUIContext().getSelection();
if (object != null) {
if (object instanceof Resource<?>) {
select((Resource<?>)object);
}
}
}

private void refresh(Resource<?> resource) {
System.out.println("refreshing initial selection: " + resource.getFullyQualifiedName());
}

private void select(Resource<?> resource) {
System.out.println("highlighting final selection: " + resource.getFullyQualifiedName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void start() {
PrintStream out = new PrintStream(stdOut, true);
PrintStream err = new PrintStream(stdErr, true);
handle.initialize(currentDir, getInputStream(), out, err);
handle.addCommandExecutionListener(new CommandExecutionListenerImpl());
}

@Override
Expand Down

0 comments on commit db266a2

Please sign in to comment.