Skip to content

Instantly share code, notes, and snippets.

@gastaldi
Last active December 29, 2015 03:09
Show Gist options
  • Select an option

  • Save gastaldi/7606068 to your computer and use it in GitHub Desktop.

Select an option

Save gastaldi/7606068 to your computer and use it in GitHub Desktop.
/**
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.addon.ui.controller;
import java.util.List;
import org.jboss.forge.addon.ui.UICommand;
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.forge.addon.ui.wizard.UIWizardStep;
/**
* A Controller for a specific {@link UICommand}
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public interface CommandController
{
/**
* Returns the original {@link UICommand}
*/
public UICommand getOriginalCommand();
/**
* Returns the current {@link UICommand} based on the navigation
*/
public UICommand getCurrentCommand();
/**
* Is it possible to navigate to the next page ?
*
*/
public boolean canFlipToNextPage();
/**
* Is it possible to navigate to the previous page ?
*
*/
public boolean canFlipToPreviousPage();
/**
* Is the wizard allowed to finish?
*/
public boolean canFinish();
/**
* Navigate to the next page. Throws {@link IllegalStateException} if navigation is not possible
*/
public void next() throws IllegalStateException;
/**
* Navigate to the previous visited page
*/
public void previous() throws IllegalStateException;
/**
* Lets the controller know that some value in the Wizard was modified, so it should invalidate subsequent pages.
*/
public void valueChanged();
/**
* Finish clicked
*
* @return A list of results, in order, from the executed {@link UIWizardStep} instances.
* @throws Exception if anything wrong happens
*/
public List<Result> finish() throws Exception;
}
/**
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.addon.ui.controller;
import org.jboss.forge.addon.ui.UICommand;
import org.jboss.forge.addon.ui.context.UIContext;
/**
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public class CommandControllerFactory
{
public CommandController create(Class<? extends UICommand> command, UIContext context)
{
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment