Search in sources :

Example 1 with ReorgDestination

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.

the class MoveRefactoringSessionTest method testPreviewChanges.

@Test
public void testPreviewChanges() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    manager.setRefactoringDestination(destination);
    MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
    settings.setUpdateReferences(true);
    settings.setSessionId(sessionId);
    manager.setMoveSettings(settings);
    manager.createChange(sessionId);
    RefactoringPreview change = manager.getRefactoringPreview(sessionId);
    RefactoringChange change1 = new DtoServerImpls.ChangeEnabledStateImpl();
    change1.setSessionId(sessionId);
    change1.setChangeId(change.getChildrens().get(0).getId());
    ChangePreview preview = manager.getChangePreview(change1);
    assertThat(preview).isNotNull();
    assertThat(preview.getFileName()).isNotNull().isNotEmpty();
    assertThat(preview.getOldContent()).isNotNull().isNotEmpty();
    assertThat(preview.getNewContent()).isNotNull().isNotEmpty();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringChange(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange) ChangePreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 2 with ReorgDestination

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.

the class MoveRefactoringSessionTest method testCtrateMoveChanges.

@Test
public void testCtrateMoveChanges() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    manager.setRefactoringDestination(destination);
    MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
    settings.setUpdateReferences(true);
    settings.setSessionId(sessionId);
    manager.setMoveSettings(settings);
    ChangeCreationResult change = manager.createChange(sessionId);
    assertThat(change).isNotNull();
    assertThat(change.isCanShowPreviewPage()).isTrue();
    assertThat(change.getStatus().getSeverity()).isEqualTo(RefactoringStatus.OK);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 3 with ReorgDestination

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.

the class MovePresenter method setMoveDestinationPath.

/** {@inheritDoc} */
@Override
public void setMoveDestinationPath(String path, String projectPath) {
    ReorgDestination destination = dtoFactory.createDto(ReorgDestination.class);
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    destination.setSessionId(refactoringSessionId);
    destination.setProjectPath(projectPath);
    destination.setDestination(path);
    Promise<RefactoringStatus> promise = refactorService.setDestination(destination);
    promise.then(new Operation<RefactoringStatus>() {

        @Override
        public void apply(RefactoringStatus arg) throws OperationException {
            view.setEnableAcceptButton(true);
            view.setEnablePreviewButton(true);
            switch(arg.getSeverity()) {
                case INFO:
                    view.showStatusMessage(arg);
                    break;
                case WARNING:
                    view.showStatusMessage(arg);
                    break;
                case ERROR:
                    showErrorMessage(arg);
                    break;
                case FATAL:
                    showErrorMessage(arg);
                    break;
                case OK:
                default:
                    view.clearStatusMessage();
                    break;
            }
        }
    });
}
Also used : RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 4 with ReorgDestination

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.

the class MoveRefactoringSessionTest method testSetMoveDestination.

@Test
public void testSetMoveDestination() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    RefactoringStatus status = manager.setRefactoringDestination(destination);
    assertThat(status).isNotNull();
    assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 5 with ReorgDestination

use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination in project che by eclipse.

the class MoveRefactoringSessionTest method testApplyMove.

@Test
public void testApplyMove() throws Exception {
    IType type = fProject.findType("p.A");
    ICompilationUnit unit = type.getCompilationUnit();
    String sessionId = manager.createMoveRefactoringSession(new IJavaElement[] { unit });
    ReorgDestination destination = new DtoServerImpls.ReorgDestinationImpl();
    destination.setSessionId(sessionId);
    destination.setProjectPath(RefactoringTestSetup.getProject().getPath().toOSString());
    destination.setDestination(p1.getPath().toOSString());
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    manager.setRefactoringDestination(destination);
    MoveSettings settings = new DtoServerImpls.MoveSettingsImpl();
    settings.setUpdateReferences(true);
    settings.setSessionId(sessionId);
    manager.setMoveSettings(settings);
    manager.createChange(sessionId);
    RefactoringStatus status = manager.applyRefactoring(sessionId);
    assertThat(status).isNotNull();
    assertThat(status.getSeverity()).isEqualTo(RefactoringStatus.OK);
    IType movedType = fProject.findType("p1.A");
    assertThat(movedType).isNotNull();
    assertThat(movedType.exists()).isTrue();
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) MoveSettings(org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Aggregations

ReorgDestination (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination)6 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)5 IType (org.eclipse.jdt.core.IType)5 Test (org.junit.Test)5 MoveSettings (org.eclipse.che.ide.ext.java.shared.dto.refactoring.MoveSettings)4 RefactoringStatus (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus)3 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)2 OperationException (org.eclipse.che.api.promises.client.OperationException)1 ChangeCreationResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult)1 ChangePreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview)1 RefactoringChange (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringChange)1