use of org.eclipse.jdt.internal.corext.refactoring.tagging.IDelegateUpdating in project che by eclipse.
the class RenameSession method setSettings.
public void setSettings(RenameSettings settings) {
IDelegateUpdating delegateUpdating = (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
if (delegateUpdating != null && delegateUpdating.canEnableDelegateUpdating()) {
delegateUpdating.setDelegateUpdating(settings.isDelegateUpdating());
delegateUpdating.setDeprecateDelegates(settings.isDeprecateDelegates());
}
IQualifiedNameUpdating nameUpdating = (IQualifiedNameUpdating) refactoring.getAdapter(IQualifiedNameUpdating.class);
if (nameUpdating != null && nameUpdating.canEnableQualifiedNameUpdating()) {
nameUpdating.setUpdateQualifiedNames(settings.isUpdateQualifiedNames());
if (settings.isUpdateQualifiedNames()) {
nameUpdating.setFilePatterns(settings.getFilePatterns());
}
}
IReferenceUpdating referenceUpdating = (IReferenceUpdating) refactoring.getAdapter(IReferenceUpdating.class);
if (referenceUpdating != null) {
referenceUpdating.setUpdateReferences(settings.isUpdateReferences());
}
IRenameSubpackages renameSubpackages = (IRenameSubpackages) refactoring.getAdapter(IRenameSubpackages.class);
if (renameSubpackages != null) {
renameSubpackages.setRenameSubpackages(settings.isUpdateSubpackages());
}
ISimilarDeclarationUpdating similarDeclarationUpdating = (ISimilarDeclarationUpdating) refactoring.getAdapter(ISimilarDeclarationUpdating.class);
if (similarDeclarationUpdating != null) {
similarDeclarationUpdating.setUpdateSimilarDeclarations(settings.isUpdateSimilarDeclarations());
if (settings.isUpdateSimilarDeclarations()) {
similarDeclarationUpdating.setMatchStrategy(settings.getMachStrategy());
}
}
ITextUpdating textUpdating = (ITextUpdating) refactoring.getAdapter(ITextUpdating.class);
if (textUpdating != null && textUpdating.canEnableTextUpdating()) {
textUpdating.setUpdateTextualMatches(settings.isUpdateTextualMatches());
}
}
use of org.eclipse.jdt.internal.corext.refactoring.tagging.IDelegateUpdating in project che by eclipse.
the class JDTRefactoringDescriptorComment method initializeInferredSettings.
/**
* Initializes the inferred settings.
*
* @param object
* the refactoring object
*/
private void initializeInferredSettings(final Object object) {
if (object instanceof INameUpdating) {
final INameUpdating updating = (INameUpdating) object;
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_original_element_pattern, JavaElementLabels.getTextLabel(updating.getElements()[0], JavaElementLabels.ALL_FULLY_QUALIFIED)));
try {
final Object element = updating.getNewElement();
if (element != null)
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_renamed_element_pattern, JavaElementLabels.getTextLabel(element, JavaElementLabels.ALL_FULLY_QUALIFIED)));
else {
final String newLabel = BasicElementLabels.getJavaElementName(updating.getCurrentElementName());
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_renamed_element_pattern, newLabel));
}
} catch (CoreException exception) {
JavaPlugin.log(exception);
}
} else if (object instanceof RefactoringProcessor) {
final RefactoringProcessor processor = (RefactoringProcessor) object;
final Object[] elements = processor.getElements();
if (elements != null) {
if (elements.length == 1 && elements[0] != null)
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_original_element_pattern, JavaElementLabels.getTextLabel(elements[0], JavaElementLabels.ALL_FULLY_QUALIFIED)));
else if (elements.length > 1) {
final StringBuffer buffer = new StringBuffer(128);
buffer.append(RefactoringCoreMessages.JavaRefactoringDescriptor_original_elements);
for (int index = 0; index < elements.length; index++) {
if (elements[index] != null) {
buffer.append(LINE_DELIMITER);
buffer.append(ELEMENT_DELIMITER);
buffer.append(JavaElementLabels.getTextLabel(elements[index], JavaElementLabels.ALL_FULLY_QUALIFIED));
} else {
buffer.append(LINE_DELIMITER);
buffer.append(ELEMENT_DELIMITER);
buffer.append(RefactoringCoreMessages.JavaRefactoringDescriptor_not_available);
}
}
fSettings.add(buffer.toString());
}
}
} else if (object instanceof IReorgPolicy) {
final IReorgPolicy policy = (IReorgPolicy) object;
Object destination = policy.getJavaElementDestination();
if (destination != null)
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptorComment_destination_pattern, JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED)));
else {
destination = policy.getResourceDestination();
if (destination != null)
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptorComment_destination_pattern, JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED)));
}
final List<IAdaptable> list = new ArrayList<IAdaptable>();
list.addAll(Arrays.asList(policy.getJavaElements()));
list.addAll(Arrays.asList(policy.getResources()));
final Object[] elements = list.toArray();
if (elements != null) {
if (elements.length == 1 && elements[0] != null)
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_original_element_pattern, JavaElementLabels.getTextLabel(elements[0], JavaElementLabels.ALL_FULLY_QUALIFIED)));
else if (elements.length > 1) {
final StringBuffer buffer = new StringBuffer(128);
buffer.append(RefactoringCoreMessages.JavaRefactoringDescriptor_original_elements);
for (int index = 0; index < elements.length; index++) {
if (elements[index] != null) {
buffer.append(LINE_DELIMITER);
buffer.append(ELEMENT_DELIMITER);
buffer.append(JavaElementLabels.getTextLabel(elements[index], JavaElementLabels.ALL_FULLY_QUALIFIED));
} else {
buffer.append(LINE_DELIMITER);
buffer.append(ELEMENT_DELIMITER);
buffer.append(RefactoringCoreMessages.JavaRefactoringDescriptor_not_available);
}
}
fSettings.add(buffer.toString());
}
}
if (object instanceof IMovePolicy) {
final IMovePolicy extended = (IMovePolicy) object;
if (extended.isTextualMove())
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptorComment_textual_move_only);
}
}
if (object instanceof IReferenceUpdating) {
final IReferenceUpdating updating = (IReferenceUpdating) object;
if (updating.getUpdateReferences())
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_update_references);
}
if (object instanceof ISimilarDeclarationUpdating) {
final ISimilarDeclarationUpdating updating = (ISimilarDeclarationUpdating) object;
if (updating.canEnableSimilarDeclarationUpdating() && updating.getUpdateSimilarDeclarations()) {
final int strategy = updating.getMatchStrategy();
if (strategy == RenamingNameSuggestor.STRATEGY_EXACT)
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_rename_similar);
else if (strategy == RenamingNameSuggestor.STRATEGY_EMBEDDED)
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_rename_similar_embedded);
else if (strategy == RenamingNameSuggestor.STRATEGY_SUFFIX)
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_rename_similar_suffix);
}
}
if (object instanceof IQualifiedNameUpdating) {
final IQualifiedNameUpdating updating = (IQualifiedNameUpdating) object;
if (updating.canEnableQualifiedNameUpdating() && updating.getUpdateQualifiedNames()) {
final String patterns = updating.getFilePatterns();
if (//$NON-NLS-1$
patterns != null && !"".equals(patterns))
fSettings.add(Messages.format(RefactoringCoreMessages.JavaRefactoringDescriptor_qualified_names_pattern, BasicElementLabels.getFilePattern(patterns.trim())));
else
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_qualified_names);
}
}
if (object instanceof ITextUpdating) {
final ITextUpdating updating = (ITextUpdating) object;
if (updating.canEnableTextUpdating())
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_textual_occurrences);
}
if (object instanceof IDelegateUpdating) {
final IDelegateUpdating updating = (IDelegateUpdating) object;
if (updating.canEnableDelegateUpdating() && updating.getDelegateUpdating()) {
if (updating.getDeprecateDelegates())
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_keep_original_deprecated);
else
fSettings.add(RefactoringCoreMessages.JavaRefactoringDescriptor_keep_original);
}
}
}
Aggregations