// Path: src/net/bitpot/railways/gui/RoutesCopyProvider.java
// public abstract class RoutesCopyProvider extends TextCopyProvider {
// 
//     private final Route[] routes;
// 
//     public RoutesCopyProvider(Route[] routes) {
//         this.routes = routes;
//     }
// 
//     /**
//      * Returns route value that should be copied to clipboard.
//      * @param route Route which value should be copied to clipboard (route name in this
//      *              implementation).
//      * @return String to copy
//      */
//     public abstract String getCopyValue(Route route);
// 
//     @Nullable
//     @Override
//     public Collection<String> getTextLinesToCopy() {
//         if (routes == null)
//             return null;
// 
//         List<String> copyLines = new ArrayList<>(routes.length);
// 
//         for (Route route : routes) {
//             copyLines.add(getCopyValue(route));
//         }
// 
//         return copyLines;
//     }
// }
// 
// Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
// 
//     private final Module module;
//     private final RequestMethod requestMethod;
//     private final String path;
//     private final String routeName;
// 
//     @Nullable
//     private RailsEngine myParentEngine = null;
// 
//     // Cached path and action text chunks.
//     private List<TextChunk> pathChunks = null;
//     private List<TextChunk> actionChunks = null;
// 
// 
//     public Route(@Nullable Module module, RequestMethod requestMethod, String path,
//                  String name) {
//         this.module = module;
// 
//         this.requestMethod = requestMethod;
//         this.path = path;
//         this.routeName = name;
//     }
// 
// 
//     /**
//      * Returns module the route belongs to.
//      * @return Route module
//      */
//     public Module getModule() {
//         return module;
//     }
// 
// 
//     @NotNull
//     public RequestMethod getRequestMethod() {
//         return requestMethod;
//     }
// 
// 
//     /**
//      * Returns displayable text for route action in short format. Short format
//      * is used in routes table.
//      *
//      * @return Displayable text for route action, ex. "users#create"
//      */
//     public String getActionTitle() {
//         return getQualifiedActionTitle();
//     }
// 
// 
//     /**
//      * Returns qualified name for route action.
//      *
//      * @return Displayable text for route action, ex. "UsersController#create"
//      */
//     public String getQualifiedActionTitle() {
//         return "";
//     }
// 
// 
//     /**
//      * Returns displayable name for navigation list.
//      *
//      * @return Display name of current route.
//      */
//     @Nullable
//     @Override
//     public String getName() {
//         return path;
//     }
// 
// 
//     @Nullable
//     @Override
//     public ItemPresentation getPresentation() {
//         final Route route = this;
// 
//         return new ItemPresentation() {
//             @Nullable
//             @Override
//             public String getPresentableText() {
//                 return path;
//             }
// 
// 
//             @Nullable
//             @Override
//             public String getLocationString() {
//                 return getActionTitle();
//             }
// 
// 
//             @Nullable
//             @Override
//             public Icon getIcon(boolean unused) {
//                 return route.getRequestMethod().getIcon();
//             }
//         };
//     }
// 
// 
//     @Override
//     public void navigate(boolean requestFocus) {
//         // This method should be overridden in subclasses that support navigation.
//     }
// 
// 
//     @Override
//     public boolean canNavigate() {
//         return false;
//     }
// 
// 
//     @Override
//     public boolean canNavigateToSource() {
//         return canNavigate();
//     }
// 
// 
//     public String getPath() {
//         return path;
//     }
// 
//     public String getPathWithMethod() {
//         String path = RailwaysUtils.stripRequestFormat(getPath());
// 
//         if (getRequestMethod() == RequestMethods.ANY)
//             return path;
// 
//         return String.format("%s %s", getRequestMethod().getName(), path);
//     }
// 
// 
//     public List<TextChunk> getPathChunks() {
//         if (pathChunks == null)
//             pathChunks = RoutePathParser.getInstance().parse(getPath());
// 
//         return pathChunks;
//     }
// 
// 
//     public List<TextChunk> getActionChunks() {
//         if (actionChunks == null)
//             actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
// 
//         return actionChunks;
//     }
// 
// 
//     public String getRouteName() {
//         if (getParentEngine() != null)
//             return getParentEngine().getNamespace() + "." + routeName;
// 
//         return routeName;
//     }
// 
// 
//     /**
//      * Checks route action status and sets isActionDeclarationFound flag.
//      *
//      * @param app Rails application which will be checked for controller action.
//      */
//     public void updateActionStatus(RailsApp app) {
//         // Should be overridden in subclasses if an update is required.
//     }
// 
// 
//     @Nullable
//     public RailsEngine getParentEngine() {
//         return myParentEngine;
//     }
// 
//     public void setParentEngine(RailsEngine parentEngine) {
//         myParentEngine = parentEngine;
//     }
// 
// 
//     public Icon getActionIcon() {
//         return RailwaysIcons.NODE_UNKNOWN;
//     }
// }


import com.intellij.ide.CopyProvider;
import com.intellij.openapi.actionSystem.*;
import net.bitpot.railways.gui.RoutesCopyProvider;
import net.bitpot.railways.models.Route;
package net.bitpot.railways.actions;


/**
 * Provides functionality to copy route data from selected items. Requires
 * data context to implement DataProvider interface and provide data for
 * SELECTED_ITEMS and SELECTED_ITEM keys.
 */
public abstract class CopyRouteActionBase extends AnAction {

    /**
     * Should return from route a string to be copied.
     * @param route Route which data will be copied.
     * @return A string to be copied.
     */
    abstract public String getRouteValue(Route route);

    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        DataContext ctx = anActionEvent.getDataContext();

        Route[] routes = (Route[])PlatformDataKeys.SELECTED_ITEMS.getData(ctx);

// Path: src/net/bitpot/railways/gui/RoutesCopyProvider.java
// public abstract class RoutesCopyProvider extends TextCopyProvider {
// 
//     private final Route[] routes;
// 
//     public RoutesCopyProvider(Route[] routes) {
//         this.routes = routes;
//     }
// 
//     /**
//      * Returns route value that should be copied to clipboard.
//      * @param route Route which value should be copied to clipboard (route name in this
//      *              implementation).
//      * @return String to copy
//      */
//     public abstract String getCopyValue(Route route);
// 
//     @Nullable
//     @Override
//     public Collection<String> getTextLinesToCopy() {
//         if (routes == null)
//             return null;
// 
//         List<String> copyLines = new ArrayList<>(routes.length);
// 
//         for (Route route : routes) {
//             copyLines.add(getCopyValue(route));
//         }
// 
//         return copyLines;
//     }
// }
// 
// Path: src/net/bitpot/railways/models/Route.java
// public class Route implements NavigationItem {
// 
//     private final Module module;
//     private final RequestMethod requestMethod;
//     private final String path;
//     private final String routeName;
// 
//     @Nullable
//     private RailsEngine myParentEngine = null;
// 
//     // Cached path and action text chunks.
//     private List<TextChunk> pathChunks = null;
//     private List<TextChunk> actionChunks = null;
// 
// 
//     public Route(@Nullable Module module, RequestMethod requestMethod, String path,
//                  String name) {
//         this.module = module;
// 
//         this.requestMethod = requestMethod;
//         this.path = path;
//         this.routeName = name;
//     }
// 
// 
//     /**
//      * Returns module the route belongs to.
//      * @return Route module
//      */
//     public Module getModule() {
//         return module;
//     }
// 
// 
//     @NotNull
//     public RequestMethod getRequestMethod() {
//         return requestMethod;
//     }
// 
// 
//     /**
//      * Returns displayable text for route action in short format. Short format
//      * is used in routes table.
//      *
//      * @return Displayable text for route action, ex. "users#create"
//      */
//     public String getActionTitle() {
//         return getQualifiedActionTitle();
//     }
// 
// 
//     /**
//      * Returns qualified name for route action.
//      *
//      * @return Displayable text for route action, ex. "UsersController#create"
//      */
//     public String getQualifiedActionTitle() {
//         return "";
//     }
// 
// 
//     /**
//      * Returns displayable name for navigation list.
//      *
//      * @return Display name of current route.
//      */
//     @Nullable
//     @Override
//     public String getName() {
//         return path;
//     }
// 
// 
//     @Nullable
//     @Override
//     public ItemPresentation getPresentation() {
//         final Route route = this;
// 
//         return new ItemPresentation() {
//             @Nullable
//             @Override
//             public String getPresentableText() {
//                 return path;
//             }
// 
// 
//             @Nullable
//             @Override
//             public String getLocationString() {
//                 return getActionTitle();
//             }
// 
// 
//             @Nullable
//             @Override
//             public Icon getIcon(boolean unused) {
//                 return route.getRequestMethod().getIcon();
//             }
//         };
//     }
// 
// 
//     @Override
//     public void navigate(boolean requestFocus) {
//         // This method should be overridden in subclasses that support navigation.
//     }
// 
// 
//     @Override
//     public boolean canNavigate() {
//         return false;
//     }
// 
// 
//     @Override
//     public boolean canNavigateToSource() {
//         return canNavigate();
//     }
// 
// 
//     public String getPath() {
//         return path;
//     }
// 
//     public String getPathWithMethod() {
//         String path = RailwaysUtils.stripRequestFormat(getPath());
// 
//         if (getRequestMethod() == RequestMethods.ANY)
//             return path;
// 
//         return String.format("%s %s", getRequestMethod().getName(), path);
//     }
// 
// 
//     public List<TextChunk> getPathChunks() {
//         if (pathChunks == null)
//             pathChunks = RoutePathParser.getInstance().parse(getPath());
// 
//         return pathChunks;
//     }
// 
// 
//     public List<TextChunk> getActionChunks() {
//         if (actionChunks == null)
//             actionChunks = RouteActionParser.getInstance().parse(getActionTitle());
// 
//         return actionChunks;
//     }
// 
// 
//     public String getRouteName() {
//         if (getParentEngine() != null)
//             return getParentEngine().getNamespace() + "." + routeName;
// 
//         return routeName;
//     }
// 
// 
//     /**
//      * Checks route action status and sets isActionDeclarationFound flag.
//      *
//      * @param app Rails application which will be checked for controller action.
//      */
//     public void updateActionStatus(RailsApp app) {
//         // Should be overridden in subclasses if an update is required.
//     }
// 
// 
//     @Nullable
//     public RailsEngine getParentEngine() {
//         return myParentEngine;
//     }
// 
//     public void setParentEngine(RailsEngine parentEngine) {
//         myParentEngine = parentEngine;
//     }
// 
// 
//     public Icon getActionIcon() {
//         return RailwaysIcons.NODE_UNKNOWN;
//     }
// }


// Path: src/net/bitpot/railways/actions/CopyRouteActionBase.java
import com.intellij.ide.CopyProvider;
import com.intellij.openapi.actionSystem.*;
import net.bitpot.railways.gui.RoutesCopyProvider;
import net.bitpot.railways.models.Route;

package net.bitpot.railways.actions;


/**
 * Provides functionality to copy route data from selected items. Requires
 * data context to implement DataProvider interface and provide data for
 * SELECTED_ITEMS and SELECTED_ITEM keys.
 */
public abstract class CopyRouteActionBase extends AnAction {

    /**
     * Should return from route a string to be copied.
     * @param route Route which data will be copied.
     * @return A string to be copied.
     */
    abstract public String getRouteValue(Route route);

    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        DataContext ctx = anActionEvent.getDataContext();

        Route[] routes = (Route[])PlatformDataKeys.SELECTED_ITEMS.getData(ctx);

        CopyProvider provider = new RoutesCopyProvider(routes) {