use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring in project che by eclipse.
the class JavaRefactoringRename method createRenameRefactoringDto.
@NotNull
private CreateRenameRefactoring createRenameRefactoringDto(TextEditor editor, boolean isActiveLinkedMode) {
CreateRenameRefactoring dto = dtoFactory.createDto(CreateRenameRefactoring.class);
dto.setOffset(editor.getCursorOffset());
dto.setRefactorLightweight(isActiveLinkedMode);
final VirtualFile file = editor.getEditorInput().getFile();
dto.setPath(JavaUtil.resolveFQN(file));
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
dto.setProjectPath(project.get().getLocation().toString());
}
dto.setType(JAVA_ELEMENT);
return dto;
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring in project che by eclipse.
the class JavaRefactoringRename method createLinkedRenameSession.
private void createLinkedRenameSession() {
final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, true);
Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
createRenamePromise.then(new Operation<RenameRefactoringSession>() {
@Override
public void apply(RenameRefactoringSession session) throws OperationException {
activateLinkedModeIntoEditor(session, textEditor.getDocument());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
isActiveLinkedEditor = false;
showError();
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring in project che by eclipse.
the class JavaRefactoringRename method createRenameSession.
private void createRenameSession() {
final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, false);
Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
createRenamePromise.then(new Operation<RenameRefactoringSession>() {
@Override
public void apply(RenameRefactoringSession session) throws OperationException {
renamePresenter.show(session);
if (mode != null) {
mode.exitLinkedMode(false);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
showError();
}
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring in project che by eclipse.
the class RenamePresenter method createRenameRefactoringDto.
private CreateRenameRefactoring createRenameRefactoringDto(RefactorInfo refactorInfo) {
CreateRenameRefactoring dto = dtoFactory.createDto(CreateRenameRefactoring.class);
dto.setRefactorLightweight(false);
if (refactorInfo == null) {
final VirtualFile file = editorAgent.getActiveEditor().getEditorInput().getFile();
dto.setType(JAVA_ELEMENT);
dto.setPath(JavaUtil.resolveFQN(file));
dto.setOffset(((TextEditor) editorAgent.getActiveEditor()).getCursorOffset());
if (file instanceof Resource) {
final Project project = ((Resource) file).getRelatedProject().get();
dto.setProjectPath(project.getLocation().toString());
}
} else {
final Resource[] resources = refactorInfo.getResources();
checkState(resources != null && resources.length == 1);
final Resource resource = resources[0];
if (resource.getResourceType() == FILE) {
dto.setPath(JavaUtil.resolveFQN(resource));
dto.setType(COMPILATION_UNIT);
} else if (resource instanceof Container) {
dto.setPath(resource.getLocation().toString());
dto.setType(PACKAGE);
}
final Project project = resource.getRelatedProject().get();
dto.setProjectPath(project.getLocation().toString());
}
return dto;
}
use of org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring in project che by eclipse.
the class RenamePresenter method show.
/**
* Show Rename window with the special information.
*
* @param refactorInfo
* information about the rename operation
*/
public void show(RefactorInfo refactorInfo) {
this.refactorInfo = refactorInfo;
final CreateRenameRefactoring createRenameRefactoring = createRenameRefactoringDto(refactorInfo);
Promise<RenameRefactoringSession> createRenamePromise = refactorService.createRenameRefactoring(createRenameRefactoring);
createRenamePromise.then(new Operation<RenameRefactoringSession>() {
@Override
public void apply(RenameRefactoringSession session) throws OperationException {
show(session);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
Aggregations