Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.port80.eclipse.jdt.method
Class MethodView  view MethodView download MethodView.java

java.lang.Object
  extended byorg.eclipse.ui.part.WorkbenchPart
      extended byorg.eclipse.ui.part.ViewPart
          extended bycom.port80.eclipse.jdt.method.MethodView
All Implemented Interfaces:
java.util.EventListener, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.jface.util.IPropertyChangeListener, org.eclipse.ui.ISelectionListener, org.eclipse.ui.IViewPart, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.swt.events.KeyListener, org.eclipse.swt.internal.SWTEventListener

public class MethodView
extends org.eclipse.ui.part.ViewPart
implements org.eclipse.swt.events.KeyListener, org.eclipse.ui.ISelectionListener, org.eclipse.jface.util.IPropertyChangeListener

Show methods of a type including methods inherited from super classes. This is similar to the Outline view except that it shows only methods and it shows non-private methods from the super classes even though they are not overriden. So user can knows what methods are available. This sample class demonstrates how to plug-in a new workbench view. The view shows data obtained from the model. The sample creates a dummy model on the fly, but a real implementation would connect to the model available either in this or another plug-in (e.g. the workspace). The view is connected to the model using a content provider.

The view uses a label provider to define how model objects should be presented in the view. Each view can present the same model objects using different labels and icons, if needed. Alternatively, a single label provider can be shared between views in order to ensure that objects of the same type are presented in the same way everywhere.


Field Summary
private  org.eclipse.swt.dnd.Clipboard clipboard
           
private  org.eclipse.jdt.core.IType currentType
           
private static boolean DEBUG
           
private  org.eclipse.jface.action.Action fActionAbout
           
private  org.eclipse.jface.action.Action fActionAnnotate
           
private  org.eclipse.jface.action.Action fActionCopy
           
private  org.eclipse.jface.action.Action fActionHeader
           
private  org.eclipse.jface.action.Action fActionRefresh
           
private  org.eclipse.jface.action.Action fActionShowAll
           
private  org.eclipse.jface.action.Action fActionShowDefault
           
(package private)  com.port80.eclipse.jdt.actions.ShowInEditorAction fActionShowInEditor
           
private  org.eclipse.jface.action.Action fActionShowProtected
           
private  org.eclipse.jface.action.Action fActionShowPublic
           
private  com.port80.eclipse.util.IncrementalFindTreeTarget findTarget
           
private  int fShowLevel
           
private  boolean fSupressSelectionLinking
           
private  org.eclipse.jface.viewers.TreeViewer fViewer
           
private static java.lang.String ID
           
private static java.lang.String NAME
           
private  org.eclipse.ui.IPartListener partListener
           
private  MethodViewContentProvider provider
           
private  com.port80.eclipse.jdt.util.JavaElementTypeComparator typeComparator
           
private static java.lang.String VERSION
           
 
Fields inherited from class org.eclipse.ui.part.ViewPart
 
Fields inherited from class org.eclipse.ui.part.WorkbenchPart
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
MethodView()
          The constructor.
 
Method Summary
private  void adjustInputAndSetSelection(org.eclipse.jdt.core.IJavaElement je)
          Update view input and selection to the specified Java element.
(package private)  void annotateAction()
           
 void beginSession(boolean forward)
           
private  void contributeToActionBars()
           
(package private)  void copyAction()
           
 void createPartControl(org.eclipse.swt.widgets.Composite parent)
          This is a callback that will allow us to create the viewer and initialize it.
private  void disableSyncSelection()
           
 void dispose()
          Disposes of this workbench part.
private  void enableSyncSelection()
           
private  java.lang.String errorMessage(java.lang.String method, org.eclipse.jdt.core.IJavaElement e)
          Return an error message for the given Java element.
(package private)  void fillContextMenu(org.eclipse.jface.action.IMenuManager manager)
           
private  void fillLocalPullDown(org.eclipse.jface.action.IMenuManager manager)
           
private  void fillLocalToolBar(org.eclipse.jface.action.IToolBarManager manager)
           
protected  org.eclipse.jdt.core.IType findInputForElement(org.eclipse.jdt.core.IJavaElement element)
          Converts the given Java element to one which is suitable for this view as input.
protected  org.eclipse.jdt.core.IJavaElement findSelectableElement(org.eclipse.jdt.core.IJavaElement element)
           
private  java.lang.String getSelectedItemText()
           
private  org.eclipse.jface.viewers.IStructuredSelection getSelection()
           
 org.eclipse.jface.viewers.TreeViewer getViewer()
           
 void gotoObject(java.lang.Object a)
           
private  void hookContextMenu()
           
private  void hookDoubleClickAction()
           
private  void hookKeyListener()
          Temporary hack to do the incremental search.
private  void hookPartListener()
          Listen to any part activation and update the method view if an editor part is activated.
 void init(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento)
          Initializes this view with the given view site.
protected  boolean isValidInput(java.lang.Object element)
          Answers if the given element is a valid element for this part.
 void keyPressed(org.eclipse.swt.events.KeyEvent event)
          Sent when a key is pressed on the system keyboard.
 void keyReleased(org.eclipse.swt.events.KeyEvent event)
          Sent when a key is released on the system keyboard.
private  void makeActions()
           
(package private)  boolean methodViewIsOnTop()
           
 void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
          Notification that a property has changed.
(package private)  void refreshAction()
           
 void saveState(org.eclipse.ui.IMemento memento)
          Saves the object state within a memento.
 void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection)
          Notifies this listener that the selection has changed.
 void setFocus()
          Passing the focus request to the viewer's control.
 void setInputElement(org.eclipse.jdt.core.IType type)
           
 void setSelection(org.eclipse.jface.viewers.ISelection selection, boolean reveal)
           
(package private)  void setSelectionFromEditor(org.eclipse.ui.IWorkbenchPart part)
           
(package private)  void showAllAction()
           
(package private)  void showDefaultAction()
           
(package private)  void showMessage(java.lang.String message)
           
(package private)  void showProtectedAction()
           
(package private)  void showPublicAction()
           
 
Methods inherited from class org.eclipse.ui.part.ViewPart
getViewSite, init, setContentDescription, setInitializationData, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

VERSION

private static final java.lang.String VERSION
See Also:
Constant Field Values

ID

private static final java.lang.String ID
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

fViewer

private org.eclipse.jface.viewers.TreeViewer fViewer

provider

private MethodViewContentProvider provider

partListener

private org.eclipse.ui.IPartListener partListener

currentType

private org.eclipse.jdt.core.IType currentType

clipboard

private org.eclipse.swt.dnd.Clipboard clipboard

fShowLevel

private int fShowLevel

fActionHeader

private org.eclipse.jface.action.Action fActionHeader

fActionShowPublic

private org.eclipse.jface.action.Action fActionShowPublic

fActionShowProtected

private org.eclipse.jface.action.Action fActionShowProtected

fActionShowDefault

private org.eclipse.jface.action.Action fActionShowDefault

fActionShowAll

private org.eclipse.jface.action.Action fActionShowAll

fActionAnnotate

private org.eclipse.jface.action.Action fActionAnnotate

fActionCopy

private org.eclipse.jface.action.Action fActionCopy

fActionRefresh

private org.eclipse.jface.action.Action fActionRefresh

fActionAbout

private org.eclipse.jface.action.Action fActionAbout

findTarget

private com.port80.eclipse.util.IncrementalFindTreeTarget findTarget

fSupressSelectionLinking

private boolean fSupressSelectionLinking

typeComparator

private com.port80.eclipse.jdt.util.JavaElementTypeComparator typeComparator

fActionShowInEditor

com.port80.eclipse.jdt.actions.ShowInEditorAction fActionShowInEditor
Constructor Detail

MethodView

public MethodView()
The constructor.

Method Detail

init

public void init(org.eclipse.ui.IViewSite site,
                 org.eclipse.ui.IMemento memento)
          throws org.eclipse.ui.PartInitException
Description copied from interface: org.eclipse.ui.IViewPart
Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the views state from a previous session. Where possible, the view should try to recreate that state within the part controls.

This method is automatically called by the workbench shortly after the part is instantiated. It marks the start of the views's lifecycle. Clients must not call this method.

Specified by:
init in interface org.eclipse.ui.IViewPart

dispose

public void dispose()
Description copied from interface: org.eclipse.ui.IWorkbenchPart
Disposes of this workbench part.

This is the last method called on the IWorkbenchPart. At this point the part controls (if they were ever created) have been disposed as part of an SWT composite. There is no guarantee that createPartControl() has been called, so the part controls may never have been created.

Within this method a part may release any resources, fonts, images, etc.  held by this part. It is also very important to deregister all listeners from the workbench.

Clients should not call this method (the workbench calls this method at appropriate times).

Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite parent)
This is a callback that will allow us to create the viewer and initialize it.

Specified by:
createPartControl in interface org.eclipse.ui.IWorkbenchPart

setFocus

public void setFocus()
Passing the focus request to the viewer's control.

Specified by:
setFocus in interface org.eclipse.ui.IWorkbenchPart

saveState

public void saveState(org.eclipse.ui.IMemento memento)
Description copied from interface: org.eclipse.ui.IViewPart
Saves the object state within a memento.

Specified by:
saveState in interface org.eclipse.ui.IViewPart

setInputElement

public void setInputElement(org.eclipse.jdt.core.IType type)

getViewer

public org.eclipse.jface.viewers.TreeViewer getViewer()

gotoObject

public void gotoObject(java.lang.Object a)

makeActions

private void makeActions()

contributeToActionBars

private void contributeToActionBars()

fillLocalPullDown

private void fillLocalPullDown(org.eclipse.jface.action.IMenuManager manager)

fillLocalToolBar

private void fillLocalToolBar(org.eclipse.jface.action.IToolBarManager manager)

hookContextMenu

private void hookContextMenu()

fillContextMenu

void fillContextMenu(org.eclipse.jface.action.IMenuManager manager)

hookDoubleClickAction

private void hookDoubleClickAction()

hookPartListener

private void hookPartListener()
Listen to any part activation and update the method view if an editor part is activated.


methodViewIsOnTop

boolean methodViewIsOnTop()

hookKeyListener

private void hookKeyListener()
Temporary hack to do the incremental search. Should move to StructuredViewer later.


showMessage

void showMessage(java.lang.String message)

showPublicAction

void showPublicAction()

showProtectedAction

void showProtectedAction()

showDefaultAction

void showDefaultAction()

showAllAction

void showAllAction()

copyAction

void copyAction()

refreshAction

void refreshAction()

annotateAction

void annotateAction()

getSelectedItemText

private java.lang.String getSelectedItemText()

getSelection

private org.eclipse.jface.viewers.IStructuredSelection getSelection()

selectionChanged

public void selectionChanged(org.eclipse.ui.IWorkbenchPart part,
                             org.eclipse.jface.viewers.ISelection selection)
Description copied from interface: org.eclipse.ui.ISelectionListener
Notifies this listener that the selection has changed.

This method is called when the selection changes from one to a non-null value, but not when the selection changes to null. If there is a requirement to be notified in the latter scenario, implement INullSelectionListener. The event will be posted through this method.

Specified by:
selectionChanged in interface org.eclipse.ui.ISelectionListener

propertyChange

public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event)
Description copied from interface: org.eclipse.jface.util.IPropertyChangeListener
Notification that a property has changed.

This method gets called when the observed object fires a property change event.

Specified by:
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListener

enableSyncSelection

private void enableSyncSelection()

disableSyncSelection

private void disableSyncSelection()

keyPressed

public void keyPressed(org.eclipse.swt.events.KeyEvent event)
Description copied from interface: org.eclipse.swt.events.KeyListener
Sent when a key is pressed on the system keyboard.

Specified by:
keyPressed in interface org.eclipse.swt.events.KeyListener

keyReleased

public void keyReleased(org.eclipse.swt.events.KeyEvent event)
Description copied from interface: org.eclipse.swt.events.KeyListener
Sent when a key is released on the system keyboard.

Specified by:
keyReleased in interface org.eclipse.swt.events.KeyListener

beginSession

public void beginSession(boolean forward)

setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection selection,
                         boolean reveal)

setSelectionFromEditor

void setSelectionFromEditor(org.eclipse.ui.IWorkbenchPart part)

adjustInputAndSetSelection

private void adjustInputAndSetSelection(org.eclipse.jdt.core.IJavaElement je)
Update view input and selection to the specified Java element.


findSelectableElement

protected org.eclipse.jdt.core.IJavaElement findSelectableElement(org.eclipse.jdt.core.IJavaElement element)

findInputForElement

protected org.eclipse.jdt.core.IType findInputForElement(org.eclipse.jdt.core.IJavaElement element)
Converts the given Java element to one which is suitable for this view as input. It takes into account wether the view shows working copies or not.


isValidInput

protected boolean isValidInput(java.lang.Object element)
Answers if the given element is a valid element for this part. For MethodView only IType is valid.


errorMessage

private java.lang.String errorMessage(java.lang.String method,
                                      org.eclipse.jdt.core.IJavaElement e)
Return an error message for the given Java element.