Search in sources :

Example 1 with IConfirmQuery

use of org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery in project eclipse.jdt.ls by eclipse.

the class OverwriteHelper method confirmOverwritting.

private void confirmOverwritting(IReorgQueries reorgQueries) {
    IConfirmQuery overwriteQuery = reorgQueries.createYesYesToAllNoNoToAllQuery(RefactoringCoreMessages.OverwriteHelper_0, true, IReorgQueries.CONFIRM_OVERWRITING);
    IConfirmQuery skipQuery = reorgQueries.createSkipQuery(RefactoringCoreMessages.OverwriteHelper_2, IReorgQueries.CONFIRM_SKIPPING);
    confirmFileOverwritting(overwriteQuery, skipQuery);
    confirmFolderOverwritting(skipQuery);
    confirmCuOverwritting(overwriteQuery);
    confirmPackageFragmentRootOverwritting(skipQuery, overwriteQuery);
    confirmPackageOverwritting(overwriteQuery);
}
Also used : IConfirmQuery(org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery)

Example 2 with IConfirmQuery

use of org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery in project eclipse.jdt.ls by eclipse.

the class MoveHandler method move.

public static WorkspaceEdit move(IResource[] resources, IJavaElement[] javaElements, IReorgDestination destination, boolean updateReferences, IProgressMonitor monitor) throws CoreException {
    IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(resources, javaElements);
    if (policy.canEnable()) {
        JavaMoveProcessor processor = new JavaMoveProcessor(policy);
        Refactoring refactoring = new MoveRefactoring(processor);
        processor.setDestination(destination);
        processor.setUpdateReferences(updateReferences);
        processor.setReorgQueries(new IReorgQueries() {

            @Override
            public IConfirmQuery createSkipQuery(String queryTitle, int queryID) {
                return yesQuery;
            }

            @Override
            public IConfirmQuery createYesNoQuery(String queryTitle, boolean allowCancel, int queryID) {
                return yesQuery;
            }

            @Override
            public IConfirmQuery createYesYesToAllNoNoToAllQuery(String queryTitle, boolean allowCancel, int queryID) {
                return yesQuery;
            }

            private final IConfirmQuery yesQuery = new IConfirmQuery() {

                @Override
                public boolean confirm(String question) throws OperationCanceledException {
                    return true;
                }

                @Override
                public boolean confirm(String question, Object[] elements) throws OperationCanceledException {
                    return true;
                }
            };
        });
        CheckConditionsOperation check = new CheckConditionsOperation(refactoring, CheckConditionsOperation.ALL_CONDITIONS);
        final CreateChangeOperation create = new CreateChangeOperation(check, RefactoringStatus.FATAL);
        create.run(monitor);
        Change change = create.getChange();
        return ChangeUtil.convertToWorkspaceEdit(change);
    }
    return null;
}
Also used : IMovePolicy(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy) Change(org.eclipse.ltk.core.refactoring.Change) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) JavaMoveProcessor(org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.JavaMoveProcessor) CreateChangeOperation(org.eclipse.ltk.core.refactoring.CreateChangeOperation) IReorgQueries(org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries) IConfirmQuery(org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery) CheckConditionsOperation(org.eclipse.ltk.core.refactoring.CheckConditionsOperation) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) MoveRefactoring(org.eclipse.ltk.core.refactoring.participants.MoveRefactoring) MoveInnerToTopRefactoring(org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring)

Aggregations

IConfirmQuery (org.eclipse.jdt.internal.corext.refactoring.reorg.IConfirmQuery)2 IMovePolicy (org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgPolicy.IMovePolicy)1 IReorgQueries (org.eclipse.jdt.internal.corext.refactoring.reorg.IReorgQueries)1 MoveInnerToTopRefactoring (org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring)1 JavaMoveProcessor (org.eclipse.jdt.ls.core.internal.corext.refactoring.reorg.JavaMoveProcessor)1 Change (org.eclipse.ltk.core.refactoring.Change)1 CheckConditionsOperation (org.eclipse.ltk.core.refactoring.CheckConditionsOperation)1 CreateChangeOperation (org.eclipse.ltk.core.refactoring.CreateChangeOperation)1 Refactoring (org.eclipse.ltk.core.refactoring.Refactoring)1 MoveRefactoring (org.eclipse.ltk.core.refactoring.participants.MoveRefactoring)1