1
/*******************************************************************************
2
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
3
* Rapperswil, University of applied sciences and others
4
* All rights reserved. This program and the accompanying materials
5
* are made available under the terms of the Eclipse Public License v1.0
6
* which accompanies this distribution, and is available at
7
* http://www.eclipse.org/legal/epl-v10.html
10
* Institute for Software - initial API and implementation
11
*******************************************************************************/
12
package org.eclipse.cdt.ui.refactoring.actions;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.jface.text.ITextSelection;
17
import org.eclipse.jface.window.IShellProvider;
19
import org.eclipse.cdt.core.model.ICElement;
20
import org.eclipse.cdt.core.model.IMethodDeclaration;
21
import org.eclipse.cdt.core.model.ISourceReference;
22
import org.eclipse.cdt.core.model.IWorkingCopy;
24
import org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoringRunner;
27
* Launches a HideMethod refacoring
28
* @author Guido Zgraggen IFS
30
* @noextend This class is not intended to be subclassed by clients.
32
public class HideMethodAction extends RefactoringAction {
34
public HideMethodAction() {
35
super(Messages.HideMethodAction_label);
39
public void run(IShellProvider shellProvider, ICElement elem) {
40
if (elem instanceof ISourceReference) {
41
new HideMethodRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run();
46
public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
47
IResource res= wc.getResource();
48
if (res instanceof IFile) {
49
new HideMethodRefactoringRunner((IFile) res,
50
fEditor.getSelectionProvider().getSelection(), null,
51
fEditor.getSite().getWorkbenchWindow(), wc.getCProject()).run();
56
public void updateSelection(ICElement elem) {
57
super.updateSelection(elem);
58
if (elem instanceof IMethodDeclaration == false
59
|| elem instanceof ISourceReference == false
60
|| ((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile == false) {