01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.refactoring.reorg;
11:
12: import org.eclipse.core.runtime.CoreException;
13:
14: import org.eclipse.swt.widgets.Shell;
15:
16: import org.eclipse.ltk.core.refactoring.Refactoring;
17: import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
18:
19: import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
20:
21: import org.eclipse.jdt.internal.ui.refactoring.UserInterfaceStarter;
22:
23: public class RenameUserInterfaceStarter extends UserInterfaceStarter {
24:
25: public boolean activate(Refactoring refactoring, Shell parent,
26: int saveMode) throws CoreException {
27: RenameProcessor processor = (RenameProcessor) refactoring
28: .getAdapter(RenameProcessor.class);
29: Object[] elements = processor.getElements();
30: RenameSelectionState state = elements.length == 1 ? new RenameSelectionState(
31: elements[0])
32: : null;
33: boolean executed = super
34: .activate(refactoring, parent, saveMode);
35: INameUpdating nameUpdating = (INameUpdating) refactoring
36: .getAdapter(INameUpdating.class);
37: if (executed && nameUpdating != null && state != null) {
38: Object newElement = nameUpdating.getNewElement();
39: if (newElement != null) {
40: state.restore(newElement);
41: }
42: }
43: return executed;
44: }
45: }
|