Search in sources :

Example 1 with RefactoredItemType

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();
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) MoveType(org.eclipse.che.ide.ext.java.client.refactoring.move.MoveType) RefactoredItemType(org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType)

Example 2 with RefactoredItemType

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));
    }
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Container(org.eclipse.che.ide.api.resources.Container) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) Resource(org.eclipse.che.ide.api.resources.Resource) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) RefactoredItemType(org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Aggregations

Resource (org.eclipse.che.ide.api.resources.Resource)2 RefactoredItemType (org.eclipse.che.ide.ext.java.client.refactoring.move.RefactoredItemType)2 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Container (org.eclipse.che.ide.api.resources.Container)1 File (org.eclipse.che.ide.api.resources.File)1 Project (org.eclipse.che.ide.api.resources.Project)1 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)1 MoveType (org.eclipse.che.ide.ext.java.client.refactoring.move.MoveType)1