Search in sources :

Example 1 with RenameSupport

use of org.eclipse.wst.jsdt.ui.refactoring.RenameSupport in project webtools.sourceediting by eclipse.

the class JSPRenameElementActionDelegate method run.

public void run(IAction action) {
    IJavaScriptElement element = getSelectedElement();
    if (element != null) {
        RenameSupport renameSupport = null;
        try {
            switch(element.getElementType()) {
                case IJavaScriptElement.TYPE:
                    renameSupport = RenameSupport.create((IType) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
                    break;
                case IJavaScriptElement.METHOD:
                    renameSupport = RenameSupport.create((IFunction) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
                    break;
                case IJavaScriptElement.PACKAGE_FRAGMENT:
                    renameSupport = RenameSupport.create((IPackageFragment) element, element.getElementName(), RenameSupport.UPDATE_REFERENCES);
                    break;
            }
            if (renameSupport != null) {
                renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
                PlatformStatusLineUtil.clearStatusLine();
            }
        } catch (CoreException e) {
            Logger.logException(e);
        }
    } else {
        PlatformStatusLineUtil.displayErrorMessage(JsUIMessages.JSPRenameElementAction_0);
        PlatformStatusLineUtil.addOneTimeClearListener();
    }
}
Also used : IPackageFragment(org.eclipse.wst.jsdt.core.IPackageFragment) CoreException(org.eclipse.core.runtime.CoreException) IJavaScriptElement(org.eclipse.wst.jsdt.core.IJavaScriptElement) IFunction(org.eclipse.wst.jsdt.core.IFunction) RenameSupport(org.eclipse.wst.jsdt.ui.refactoring.RenameSupport) IType(org.eclipse.wst.jsdt.core.IType)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 IFunction (org.eclipse.wst.jsdt.core.IFunction)1 IJavaScriptElement (org.eclipse.wst.jsdt.core.IJavaScriptElement)1 IPackageFragment (org.eclipse.wst.jsdt.core.IPackageFragment)1 IType (org.eclipse.wst.jsdt.core.IType)1 RenameSupport (org.eclipse.wst.jsdt.ui.refactoring.RenameSupport)1