Search in sources :

Example 1 with RenameRefactoring

use of org.yakindu.sct.refactoring.refactor.impl.RenameRefactoring in project statecharts by Yakindu.

the class RenameElementHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    NamedElement element = refactoring.getContextObject();
    if (element != null) {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        InputDialog dialog = new InputDialog(window.getShell(), "Rename..", "Please enter new name:", element.getName(), new NameUniquenessValidator(element));
        if (dialog.open() == Window.OK) {
            String newName = dialog.getValue();
            if (newName != null) {
                ((RenameRefactoring) refactoring).setNewName(newName);
                refactoring.execute();
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) InputDialog(org.eclipse.jface.dialogs.InputDialog) RenameRefactoring(org.yakindu.sct.refactoring.refactor.impl.RenameRefactoring) NamedElement(org.yakindu.base.base.NamedElement)

Aggregations

InputDialog (org.eclipse.jface.dialogs.InputDialog)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 NamedElement (org.yakindu.base.base.NamedElement)1 RenameRefactoring (org.yakindu.sct.refactoring.refactor.impl.RenameRefactoring)1