Search in sources :

Example 1 with PreviewNode

use of org.eclipse.ltk.internal.ui.refactoring.PreviewNode in project che by eclipse.

the class DtoConverter method toRefactoringPreview.

/**
     * Converts {@link PreviewNode} to {@link RefactoringPreview}.
     */
public static RefactoringPreview toRefactoringPreview(PreviewNode node) {
    RefactoringPreview dto = DtoFactory.newDto(RefactoringPreview.class);
    dto.setId(node.getId());
    dto.setText(node.getText());
    dto.setImage(node.getImageDescriptor().getImage());
    dto.setEnabled(true);
    PreviewNode[] children = node.getChildren();
    if (children != null && children.length > 0) {
        List<RefactoringPreview> list = new ArrayList<>(children.length);
        for (PreviewNode child : children) {
            list.add(toRefactoringPreview(child));
        }
        dto.setChildrens(list);
    }
    return dto;
}
Also used : ArrayList(java.util.ArrayList) PreviewNode(org.eclipse.ltk.internal.ui.refactoring.PreviewNode) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)

Example 2 with PreviewNode

use of org.eclipse.ltk.internal.ui.refactoring.PreviewNode in project che by eclipse.

the class RefactoringManager method getRefactoringPreview.

/**
     * Get refactoring preview tree.
     *
     * @param sessionId
     *         id of the refactoring session
     * @return refactoring preview
     * @throws RefactoringException
     *         when refactoring session not found.
     */
public RefactoringPreview getRefactoringPreview(String sessionId) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(sessionId);
    PreviewNode node = session.getChangePreview();
    return DtoConverter.toRefactoringPreview(node);
}
Also used : MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) PreviewNode(org.eclipse.ltk.internal.ui.refactoring.PreviewNode)

Example 3 with PreviewNode

use of org.eclipse.ltk.internal.ui.refactoring.PreviewNode in project che by eclipse.

the class RefactoringSession method updateChangeEnabled.

public void updateChangeEnabled(String changeId, boolean enabled) throws RefactoringException {
    PreviewNode node = findNode(previewNode, changeId);
    if (node == null) {
        throw new RefactoringException("Can't find refactoring change to update enabled state.");
    }
    node.setEnabled(enabled);
}
Also used : PreviewNode(org.eclipse.ltk.internal.ui.refactoring.PreviewNode) RefactoringException(org.eclipse.che.plugin.java.server.refactoring.RefactoringException)

Example 4 with PreviewNode

use of org.eclipse.ltk.internal.ui.refactoring.PreviewNode in project che by eclipse.

the class RefactoringManager method getChangePreview.

/**
     * generate preview for refactoring change
     *
     * @param change
     *         the refactoring change
     * @return refactoring change preview
     * @throws RefactoringException
     *         when refactoring session or change not found.
     */
public ChangePreview getChangePreview(RefactoringChange change) throws RefactoringException {
    RefactoringSession session = getRefactoringSession(change.getSessionId());
    PreviewNode previewNode = session.getChangePreview(change.getChangeId());
    try {
        ChangePreviewViewerDescriptor descriptor = previewNode.getChangePreviewViewerDescriptor();
        if (descriptor != null) {
            IChangePreviewViewer viewer = descriptor.createViewer();
            if (viewer != null) {
                return previewNode.feedInput(viewer, Collections.EMPTY_LIST);
            }
        }
    } catch (CoreException e) {
        throw new RefactoringException(e.getMessage());
    }
    return null;
}
Also used : ChangePreviewViewerDescriptor(org.eclipse.ltk.internal.ui.refactoring.ChangePreviewViewerDescriptor) CoreException(org.eclipse.core.runtime.CoreException) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) PreviewNode(org.eclipse.ltk.internal.ui.refactoring.PreviewNode) IChangePreviewViewer(org.eclipse.ltk.ui.refactoring.IChangePreviewViewer)

Aggregations

PreviewNode (org.eclipse.ltk.internal.ui.refactoring.PreviewNode)4 RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)2 MoveRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)2 RefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession)2 RenameLinkedModeRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession)2 ReorgRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession)2 ArrayList (java.util.ArrayList)1 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)1 RefactoringException (org.eclipse.che.plugin.java.server.refactoring.RefactoringException)1 CoreException (org.eclipse.core.runtime.CoreException)1 ChangePreviewViewerDescriptor (org.eclipse.ltk.internal.ui.refactoring.ChangePreviewViewerDescriptor)1 IChangePreviewViewer (org.eclipse.ltk.ui.refactoring.IChangePreviewViewer)1