class CopyOrMoveToWorkspaceSubItem extends BasicItem implements NodesManipulator {

    private final Workspace workspace;
    private final boolean canExecute;
    private final int type;
    private final int position;
    private final boolean copy;

    /**
     * Constructor with copy or move settings
     *
     * @param workspace  Workspace to copy or move, or null to use new workspace
     * @param canExecute canExecute
     * @param type       type
     * @param position   position
     * @param copy       True to copy, false to move
     */
    public CopyOrMoveToWorkspaceSubItem(Workspace workspace, boolean canExecute, int type, int position, boolean copy) {
        this.workspace = workspace;
        this.canExecute = canExecute;
        this.type = type;
        this.position = position;
        this.copy = copy;
    }

    @Override
    public void setup(Node[] nodes, Node clickedNode) {
        this.nodes = nodes;
    }

    @Override
    public void execute() {
        if (copy) {
            copyToWorkspace(workspace);
        } else {
            moveToWorkspace(workspace);
        }
    }

    @Override
    public String getName() {
        if (workspace != null) {
            return workspace.getLookup().lookup(WorkspaceInformation.class).getName();
        } else {
            return NbBundle.getMessage(CopyOrMoveToWorkspaceSubItem.class,
                copy ? "GraphContextMenu_CopyToWorkspace_NewWorkspace" :
                    "GraphContextMenu_MoveToWorkspace_NewWorkspace");
        }
    }

    @Override
    public boolean canExecute() {
        return canExecute;
    }

    @Override
    public int getType() {
        return type;
    }

    @Override
    public int getPosition() {
        return position;
    }

    @Override
    public Icon getIcon() {
        return null;
    }

    public boolean copyToWorkspace(Workspace workspace) {<FILL_FUNCTION_BODY>}

    public void moveToWorkspace(Workspace workspace) {
        if (copyToWorkspace(workspace)) {
            delete();
        }
    }

    public void delete() {
        Graph g = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
        g.removeAllNodes(Arrays.asList(nodes));
    }
}

        ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);

        Workspace currentWorkspace = projectController.getCurrentWorkspace();
        GraphModel currentGraphModel = graphController.getGraphModel(currentWorkspace);

        GraphModel targetGraphModel;
        if (workspace == null) {
            workspace = projectController.newWorkspace(currentWorkspace.getProject());
            targetGraphModel = graphController.getGraphModel(workspace);

            targetGraphModel.setConfiguration(currentGraphModel.getConfiguration());
            targetGraphModel.setTimeFormat(currentGraphModel.getTimeFormat());
            targetGraphModel.setTimeZone(currentGraphModel.getTimeZone());
        } else {
            targetGraphModel = graphController.getGraphModel(workspace);
        }

        currentGraphModel.getGraph().readLock();
        try {
            targetGraphModel.bridge().copyNodes(nodes);
            Graph targetGraph = targetGraphModel.getGraph();

            Graph visibleCurrentGraph = currentGraphModel.getGraphVisible();
            List<Edge> edgesToRemove = new ArrayList<>();
            for (Edge edge : targetGraph.getEdges()) {
                if (!visibleCurrentGraph.hasEdge(edge.getId())) {
                    edgesToRemove.add(edge);
                }
            }

            if (!edgesToRemove.isEmpty()) {
                targetGraph.removeAllEdges(edgesToRemove);
            }

            return true;
        } catch (Exception e) {
            String error = NbBundle.getMessage(CopyOrMoveToWorkspace.class,
                "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible");
            String title = NbBundle.getMessage(CopyOrMoveToWorkspace.class,
                "GraphContextMenu_CopyOrMoveToWorkspace_ConfigurationNotCompatible_Title");
            JOptionPane.showMessageDialog(null, error, title, JOptionPane.ERROR_MESSAGE);
            return false;
        } finally {
            currentGraphModel.getGraph().readUnlockAll();
        }
    
<methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,public void setup(Graph, Node[]) <variables>protected Graph graph,protected Node[] nodes