KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > reorg > RenameUserInterfaceStarter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.refactoring.reorg;
12
13
14 import org.eclipse.core.runtime.CoreException;
15
16 import org.eclipse.swt.widgets.Shell;
17
18 import org.eclipse.ltk.core.refactoring.Refactoring;
19 import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
20
21 import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
22
23 import org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter;
24
25 public class RenameUserInterfaceStarter extends UserInterfaceStarter {
26     
27     public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
28         RenameProcessor processor= (RenameProcessor)refactoring.getAdapter(RenameProcessor.class);
29         Object JavaDoc[] elements= processor.getElements();
30         RenameSelectionState state= elements.length == 1 ? new RenameSelectionState(elements[0]) : null;
31         boolean executed= super.activate(refactoring, parent, saveMode);
32         INameUpdating nameUpdating= (INameUpdating)refactoring.getAdapter(INameUpdating.class);
33         if (executed && nameUpdating != null && state != null) {
34             Object JavaDoc newElement= nameUpdating.getNewElement();
35             if (newElement != null) {
36                 state.restore(newElement);
37             }
38         }
39         return executed;
40     }
41 }
42
Popular Tags