static boolean canPerformMove()

in kit/src/main/java/com/oracle/javafx/scenebuilder/kit/editor/job/gridpane/GridPaneJobUtils.java [179:248]


    static boolean canPerformMove(
            final EditorController editorController,
            final Position position) {

        boolean result;
        final Selection selection = editorController.getSelection();
        final AbstractSelectionGroup asg = selection.getGroup();

        if (asg instanceof GridSelectionGroup) {
            final GridSelectionGroup gsg = (GridSelectionGroup) asg;
            final FXOMObject gridPane = gsg.getParentObject();
            final Type type = gsg.getType();
            final DesignHierarchyMask mask = new DesignHierarchyMask(gridPane);

            switch (type) {
                case COLUMN:
                    if (position == Position.BEFORE) {
                        result = true;
                        for (int index : gsg.getIndexes()) {
                            // First index column cannot be moved before
                            if (index == 0) {
                                result = false;
                                break;
                            }
                        }
                    } else if (position == Position.AFTER) {
                        result = true;
                        for (int index : gsg.getIndexes()) {
                            // Last index column cannot be moved after
                            if (index == (mask.getColumnsSize() - 1)) {
                                result = false;
                                break;
                            }
                        }
                    } else {
                        result = false;
                    }
                    break;
                case ROW:
                    if (position == Position.ABOVE) {
                        result = true;
                        for (int index : gsg.getIndexes()) {
                            // First index row cannot be moved above
                            if (index == 0) {
                                result = false;
                                break;
                            }
                        }
                    } else if (position == Position.BELOW) {
                        result = true;
                        for (int index : gsg.getIndexes()) {
                            // Last index row cannot be moved below
                            if (index == (mask.getRowsSize() - 1)) {
                                result = false;
                                break;
                            }
                        }
                    } else {
                        result = false;
                    }
                    break;
                default:
                    result = false;
                    assert false;
            }
        } else {
            result = false;
        }
        return result;
    }