use of org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType in project che by eclipse.
the class MoveViewImpl method show.
/** {@inheritDoc} */
@Override
public void show(RefactorInfo refactorInfo) {
MoveType moveType = refactorInfo.getMoveType();
RefactoredItemType refactoredItemType = refactorInfo.getRefactoredItemType();
treePanelToHide.setVisible(REFACTOR_MENU.equals(moveType));
patternsPanelToHide.setVisible(COMPILATION_UNIT.equals(refactoredItemType));
Resource[] selectedItems = refactorInfo.getResources();
int selectionSize = selectedItems.length;
boolean isMultiSelection = selectionSize > 1;
classNameUR.setText(isMultiSelection ? locale.multiSelectionReferences(selectionSize) : selectedItems[0].getName());
className.setText(isMultiSelection ? locale.multiSelectionDestination(selectionSize) : selectedItems[0].getName());
show();
}
use of org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType in project che by eclipse.
the class RenameRefactoringAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
if (editorInFocus) {
final EditorPartPresenter editorPart = editorAgent.getActiveEditor();
if (editorPart == null || !(editorPart instanceof TextEditor)) {
return;
}
javaRefactoringRename.refactor((TextEditor) editorPart);
} else {
final Resource[] resources = appContext.getResources();
if (resources == null || resources.length > 1) {
return;
}
final Resource resource = resources[0];
final Optional<Project> project = resource.getRelatedProject();
if (!JavaUtil.isJavaProject(project.get())) {
return;
}
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent() || resource.getLocation().equals(srcFolder.get().getLocation())) {
return;
}
RefactoredItemType renamedItemType = null;
if (resource.getResourceType() == FILE && isJavaFile((File) resource)) {
renamedItemType = COMPILATION_UNIT;
} else if (resource instanceof Container) {
renamedItemType = PACKAGE;
}
if (renamedItemType == null) {
return;
}
renamePresenter.show(RefactorInfo.of(renamedItemType, resources));
}
}
Aggregations