Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cc4f9ccc7a83be6386add9e603861d307b8dca46 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*******************************************************************************
 * Copyright (c) 2005, 2006 Wind River Systems, Inc. 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Markus Schorn - initial API and implementation 
 *******************************************************************************/

package org.eclipse.cdt.ui.refactoring.actions;

import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.window.IShellProvider;

import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;

import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactory;

/**
 * Launches a rename refactoring.
 */          
public class CRenameAction extends RefactoringAction {
    
    public CRenameAction() {
        super(Messages.CRenameAction_label); 
    }
    
	@Override
	public void run(IShellProvider shellProvider, ICElement elem) {
        CRefactory.getInstance().rename(shellProvider.getShell(), elem);
	}

	@Override
	public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
		CRefactory.getInstance().rename(shellProvider.getShell(), wc, s);
	}

    @Override
	public void updateSelection(ICElement elem) {
    	super.updateSelection(elem);
    	if (elem == null || elem instanceof IInclude || elem instanceof ITranslationUnit) {
    		setEnabled(false);
    	}
    	else {
    		setEnabled(true);
    	}
    }
}

Back to the top