org.eclipse.cdt.internal.ui.actions
Class SelectionConverter

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.actions.SelectionConverter

public class SelectionConverter
extends java.lang.Object


Constructor Summary
SelectionConverter()
           
 
Method Summary
static org.eclipse.jface.viewers.IStructuredSelection allResources(org.eclipse.jface.viewers.IStructuredSelection selection, int resourceMask)
          Returns the selection adapted to IResource.
static boolean allResourcesAreOfType(org.eclipse.jface.viewers.IStructuredSelection selection, int resourceMask)
           
static boolean canOperateOn(CEditor editor)
           
static org.eclipse.cdt.core.model.ICElement[] codeResolve(CEditor editor)
           
static org.eclipse.cdt.core.model.ICElement codeResolve(CEditor editor, org.eclipse.swt.widgets.Shell shell, java.lang.String title, java.lang.String message)
          Converts the text selection provided by the given editor a Java element by asking the user if code reolve returned more than one result.
static org.eclipse.cdt.core.model.ICElement[] codeResolve(org.eclipse.cdt.core.model.ICElement input, org.eclipse.jface.text.ITextSelection selection)
           
static org.eclipse.cdt.core.model.ICElement[] codeResolveOrInput(CEditor editor)
          Converts the text selection provided by the given editor into an array of C elements.
static org.eclipse.cdt.core.model.ICElement[] codeResolveOrInputHandled(CEditor editor, org.eclipse.swt.widgets.Shell shell, java.lang.String title)
           
static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToCElements(org.eclipse.jface.viewers.ISelection s)
          Converts objects of a structured selection to c elements if possible.
static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToCElements(org.eclipse.jface.viewers.ISelection s, boolean keepNonCElements)
          Converts objects of a structured selection to c elements if possible.
static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToResources(org.eclipse.jface.viewers.ISelection s)
           
static org.eclipse.cdt.core.model.ICElement getElementAtOffset(org.eclipse.cdt.core.model.ICElement input, org.eclipse.jface.text.ITextSelection selection)
           
static org.eclipse.cdt.core.model.ICElement getElementAtOffset(org.eclipse.ui.texteditor.ITextEditor editor)
           
static org.eclipse.cdt.core.model.ICElement[] getElementsAtOffset(org.eclipse.cdt.core.model.ICElement input, org.eclipse.jface.text.ITextSelection selection)
           
static org.eclipse.cdt.core.model.ICElement[] getElementsAtOffset(org.eclipse.ui.texteditor.ITextEditor editor)
           
static org.eclipse.cdt.core.model.ICElement getInput(org.eclipse.ui.texteditor.ITextEditor editor)
           
static org.eclipse.jface.viewers.IStructuredSelection getStructuredSelection(org.eclipse.ui.IWorkbenchPart part)
          Converts the selection provided by the given part into a structured selection.
static boolean resourceIsType(org.eclipse.core.resources.IResource resource, int resourceMask)
          Returns whether the type of the given resource is among the specified resource types.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionConverter

public SelectionConverter()
Method Detail

getStructuredSelection

public static org.eclipse.jface.viewers.IStructuredSelection getStructuredSelection(org.eclipse.ui.IWorkbenchPart part)
                                                                             throws org.eclipse.cdt.core.model.CModelException
Converts the selection provided by the given part into a structured selection. The following conversion rules are used:

Throws:
org.eclipse.cdt.core.model.CModelException

convertSelectionToCElements

public static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToCElements(org.eclipse.jface.viewers.ISelection s)
Converts objects of a structured selection to c elements if possible. This is a convenience method, fully equivalent to convertSelectionToCElements(s, false).

Parameters:
s - The structured selection
Returns:
The converted selection

convertSelectionToCElements

public static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToCElements(org.eclipse.jface.viewers.ISelection s,
                                                                                         boolean keepNonCElements)
Converts objects of a structured selection to c elements if possible.

Parameters:
s - The structured selection
keepNonCElements - Whether to keep objects in selection if they cannot be converted
Returns:
The converted selection

convertSelectionToResources

public static org.eclipse.jface.viewers.IStructuredSelection convertSelectionToResources(org.eclipse.jface.viewers.ISelection s)

allResourcesAreOfType

public static boolean allResourcesAreOfType(org.eclipse.jface.viewers.IStructuredSelection selection,
                                            int resourceMask)

allResources

public static org.eclipse.jface.viewers.IStructuredSelection allResources(org.eclipse.jface.viewers.IStructuredSelection selection,
                                                                          int resourceMask)
Returns the selection adapted to IResource. Returns null if any of the entries are not adaptable.

Parameters:
selection - the selection
resourceMask - resource mask formed by bitwise OR of resource type constants (defined on IResource)
Returns:
IStructuredSelection or null if any of the entries are not adaptable.
See Also:
IResource.getType()

getElementAtOffset

public static org.eclipse.cdt.core.model.ICElement getElementAtOffset(org.eclipse.ui.texteditor.ITextEditor editor)
                                                               throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

getElementsAtOffset

public static org.eclipse.cdt.core.model.ICElement[] getElementsAtOffset(org.eclipse.ui.texteditor.ITextEditor editor)
                                                                  throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

getElementAtOffset

public static org.eclipse.cdt.core.model.ICElement getElementAtOffset(org.eclipse.cdt.core.model.ICElement input,
                                                                      org.eclipse.jface.text.ITextSelection selection)
                                                               throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

getElementsAtOffset

public static org.eclipse.cdt.core.model.ICElement[] getElementsAtOffset(org.eclipse.cdt.core.model.ICElement input,
                                                                         org.eclipse.jface.text.ITextSelection selection)
                                                                  throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

getInput

public static org.eclipse.cdt.core.model.ICElement getInput(org.eclipse.ui.texteditor.ITextEditor editor)

resourceIsType

public static boolean resourceIsType(org.eclipse.core.resources.IResource resource,
                                     int resourceMask)
Returns whether the type of the given resource is among the specified resource types.

Parameters:
resource - the resource
resourceMask - resource mask formed by bitwise OR of resource type constants (defined on IResource)
Returns:
true if the resources has a matching type, and false otherwise
See Also:
IResource.getType()

codeResolve

public static org.eclipse.cdt.core.model.ICElement[] codeResolve(CEditor editor)
                                                          throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

codeResolve

public static org.eclipse.cdt.core.model.ICElement[] codeResolve(org.eclipse.cdt.core.model.ICElement input,
                                                                 org.eclipse.jface.text.ITextSelection selection)
                                                          throws org.eclipse.cdt.core.model.CModelException
Throws:
org.eclipse.cdt.core.model.CModelException

codeResolve

public static org.eclipse.cdt.core.model.ICElement codeResolve(CEditor editor,
                                                               org.eclipse.swt.widgets.Shell shell,
                                                               java.lang.String title,
                                                               java.lang.String message)
                                                        throws org.eclipse.cdt.core.model.CModelException
Converts the text selection provided by the given editor a Java element by asking the user if code reolve returned more than one result. If the selection doesn't cover a Java element null is returned.

Throws:
org.eclipse.cdt.core.model.CModelException

codeResolveOrInput

public static org.eclipse.cdt.core.model.ICElement[] codeResolveOrInput(CEditor editor)
                                                                 throws org.eclipse.cdt.core.model.CModelException
Converts the text selection provided by the given editor into an array of C elements. If the selection doesn't cover a C element and the selection's length is greater than 0 the method returns the editor's input element.

Throws:
org.eclipse.cdt.core.model.CModelException

codeResolveOrInputHandled

public static org.eclipse.cdt.core.model.ICElement[] codeResolveOrInputHandled(CEditor editor,
                                                                               org.eclipse.swt.widgets.Shell shell,
                                                                               java.lang.String title)

canOperateOn

public static boolean canOperateOn(CEditor editor)