Java Code Examples for org.eclipse.ltk.core.refactoring.Refactoring#getAdapter()

The following examples show how to use org.eclipse.ltk.core.refactoring.Refactoring#getAdapter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenameUserInterfaceStarter.java    From typescript.java with MIT License 5 votes vote down vote up
public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
		RenameProcessor processor = (RenameProcessor) refactoring.getAdapter(RenameProcessor.class);
		Object[] elements = processor.getElements();
		RenameSelectionState state = null;//elements.length == 1 ? new RenameSelectionState(elements[0]) : null;
		boolean executed = super.activate(refactoring, parent, saveMode);
		TypeScriptRenameProcessor nameUpdating = (TypeScriptRenameProcessor) refactoring
				.getAdapter(TypeScriptRenameProcessor.class);
		if (executed && nameUpdating != null && state != null) {
//			Object newElement = nameUpdating.getNewElement();
//			if (newElement != null) {
//				state.restore(newElement);
//			}
		}
		return executed;
	}
 
Example 2
Source File: DelegateUIHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Button generateDeprecateDelegateCheckbox(Composite parent, Refactoring refactoring) {
	final IDelegateUpdating updating= (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
	if (updating == null || !updating.canEnableDelegateUpdating())
		return null;
	final Button button= createCheckbox(parent, getDeprecateDelegateCheckBoxTitle(), loadDeprecateDelegateSetting(updating));
	updating.setDeprecateDelegates(button.getSelection());
	button.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			updating.setDeprecateDelegates(button.getSelection());
		}
	});
	return button;
}
 
Example 3
Source File: DelegateUIHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Button generateLeaveDelegateCheckbox(Composite parent, Refactoring refactoring, boolean plural) {
	final IDelegateUpdating updating= (IDelegateUpdating) refactoring.getAdapter(IDelegateUpdating.class);
	if (updating == null || !updating.canEnableDelegateUpdating())
		return null;
	final Button button= createCheckbox(parent, updating.getDelegateUpdatingTitle(plural), loadLeaveDelegateSetting(updating));
	updating.setDelegateUpdating(button.getSelection());
	button.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(SelectionEvent e) {
			updating.setDelegateUpdating(button.getSelection());
		}
	});
	return button;
}
 
Example 4
Source File: RenameUserInterfaceStarter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
	RenameProcessor processor= (RenameProcessor)refactoring.getAdapter(RenameProcessor.class);
	Object[] elements= processor.getElements();
	RenameSelectionState state= elements.length == 1 ? new RenameSelectionState(elements[0]) : null;
	boolean executed= super.activate(refactoring, parent, saveMode);
	INameUpdating nameUpdating= (INameUpdating)refactoring.getAdapter(INameUpdating.class);
	if (executed && nameUpdating != null && state != null) {
		Object newElement= nameUpdating.getNewElement();
		if (newElement != null) {
			state.restore(newElement);
		}
	}
	return executed;
}
 
Example 5
Source File: RenameMethodUserInterfaceStarter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
	RenameVirtualMethodProcessor processor= (RenameVirtualMethodProcessor)refactoring.getAdapter(RenameVirtualMethodProcessor.class);
	if (processor != null) {
		RefactoringStatus status= processor.checkInitialConditions(new NullProgressMonitor());
		if (!status.hasFatalError()) {
			IMethod method= processor.getMethod();
			if (!method.equals(processor.getOriginalMethod())) {
				String message= null;
				if (method.getDeclaringType().isInterface()) {
					message= Messages.format(
						RefactoringCoreMessages.MethodChecks_implements,
						new String[]{
							JavaElementUtil.createMethodSignature(method),
							JavaElementLabels.getElementLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
				} else {
					message= Messages.format(
						RefactoringCoreMessages.MethodChecks_overrides,
						new String[]{
							JavaElementUtil.createMethodSignature(method),
							JavaElementLabels.getElementLabel(method.getDeclaringType(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
				}
				message= Messages.format(
					ReorgMessages.RenameMethodUserInterfaceStarter_message,
					message);
				if (!MessageDialog.openQuestion(parent,
						ReorgMessages.RenameMethodUserInterfaceStarter_name,
						message)) {
					return false;
				}
			}
		}
	}
	return super.activate(refactoring, parent, saveMode);
}
 
Example 6
Source File: RenameInputWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateForcePreview() {
	boolean forcePreview= false;
	Refactoring refactoring= getRefactoring();
	ITextUpdating tu= (ITextUpdating) refactoring.getAdapter(ITextUpdating.class);
	IQualifiedNameUpdating qu= (IQualifiedNameUpdating)refactoring.getAdapter(IQualifiedNameUpdating.class);
	if (tu != null) {
		forcePreview= tu.getUpdateTextualMatches();
	}
	if (qu != null) {
		forcePreview |= qu.getUpdateQualifiedNames();
	}
	getRefactoringWizard().setForcePreviewReview(forcePreview);
}
 
Example 7
Source File: DeleteWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public DeleteWizard(Refactoring refactoring) {
	super(refactoring, DIALOG_BASED_USER_INTERFACE);
	setDefaultPageTitle(RefactoringMessages.DeleteWizard_1);
	fProcessor= (JavaDeleteProcessor) refactoring.getAdapter(JavaDeleteProcessor.class);
	fProcessor.setQueries(new ReorgQueries(this));
}