~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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  
 
8
 *  
 
9
 * Contributors: 
 
10
 * Institute for Software - initial API and implementation
 
11
 *******************************************************************************/
 
12
package org.eclipse.cdt.ui.refactoring.actions;
 
13
 
 
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;
 
18
 
 
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;
 
23
 
 
24
import org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoringRunner;
 
25
 
 
26
/**
 
27
 * Launches a HideMethod refacoring
 
28
 * @author Guido Zgraggen IFS
 
29
 * 
 
30
 * @noextend This class is not intended to be subclassed by clients.
 
31
 */
 
32
public class HideMethodAction extends RefactoringAction {
 
33
    
 
34
    public HideMethodAction() {
 
35
        super(Messages.HideMethodAction_label); 
 
36
    }
 
37
    
 
38
        @Override
 
39
        public void run(IShellProvider shellProvider, ICElement elem) {
 
40
                if (elem instanceof ISourceReference) {
 
41
                        new HideMethodRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run();
 
42
                }
 
43
        }
 
44
 
 
45
        @Override
 
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();
 
52
                }
 
53
        }
 
54
 
 
55
    @Override
 
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) {
 
61
                setEnabled(false);
 
62
        }
 
63
    }
 
64
}