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;
}
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);
}
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);
}
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;
}
Aggregations