Search in sources :

Example 1 with IPackageFragment

use of org.eclipse.wst.jsdt.core.IPackageFragment 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)

Example 2 with IPackageFragment

use of org.eclipse.wst.jsdt.core.IPackageFragment in project webtools.sourceediting by eclipse.

the class JSPTypeMoveParticipant method createChange.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor)
	 */
public Change createChange(IProgressMonitor pm) throws CoreException {
    if (pm != null && pm.isCanceled()) {
        return null;
    }
    CompositeChange multiChange = null;
    Object dest = getArguments().getDestination();
    if (dest instanceof IPackageFragment) {
        Change[] changes = JSPTypeMoveChange.createChangesFor(fType, ((IPackageFragment) dest).getElementName());
        if (changes.length > 0) {
            multiChange = new CompositeChange(JsUIMessages.JSP_changes, changes);
        }
    }
    return multiChange;
}
Also used : IPackageFragment(org.eclipse.wst.jsdt.core.IPackageFragment) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange)

Aggregations

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