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

Quick Search    Search Deep

com.port80.eclipse.jdt.annotation
Class AnnotationManager  view AnnotationManager download AnnotationManager.java

java.lang.Object
  extended byorg.eclipse.jface.viewers.LabelProvider
      extended bycom.port80.eclipse.jdt.annotation.AnnotationManager
All Implemented Interfaces:
org.eclipse.jface.viewers.IBaseLabelProvider, org.eclipse.jface.viewers.IContentProvider, org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.IStructuredContentProvider, org.eclipse.jface.viewers.ITreeContentProvider

public class AnnotationManager
extends org.eclipse.jface.viewers.LabelProvider
implements org.eclipse.jface.viewers.ITreeContentProvider

Data model for AnnotationView. Annotation keep the set of visited IResources together with access information. It kept all visited objects automatically upon visiting instead of manually by user. It can be used to backtrace visit history. It can be further bookmark or annotated by user. This is an enchancement of the BookmarkView which, unfortunately as of Eclipse 2.0, cannot bookmark binary classes and it is not easy for annotation. AnnotationManager also works without the AnnotationView active and manage only the visited object list and its related actions.


Field Summary
private static boolean DEBUG
           
private  java.util.Map fAnnotation
           
private  java.util.Map fFolders
           
private  com.port80.eclipse.jdt.util.PersistentFolder fInbox
           
private  int fInboxLimit
           
private  java.util.List fModelListeners
           
private  org.eclipse.ui.IPartListener fPartListener
           
private  com.port80.eclipse.jdt.util.PersistentFolder fRoot
           
private static java.lang.String ID
           
static java.lang.String INBOX
           
private  org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider labelProvider
           
private static java.lang.String NAME
           
static int RET_CANCEL
           
static int RET_FAIL
           
static int RET_OK
           
static int RET_RESET
           
private static java.lang.String TAG_ROOT
           
private static java.lang.String TAG_VERSION
           
private static boolean VERBOSE
           
private static java.lang.String[] VERSIONS
           
 
Fields inherited from class org.eclipse.jface.viewers.LabelProvider
 
Constructor Summary
AnnotationManager()
           
 
Method Summary
 com.port80.eclipse.jdt.util.PersistentItem add(com.port80.eclipse.jdt.util.PersistentItem item, java.lang.String parent)
          Add an object to the specified folder in Annotation.
 com.port80.eclipse.jdt.util.PersistentItem addAutomatic(org.eclipse.jdt.core.IJavaElement element)
          Added automatically Type or File visited on editor activation.
 com.port80.eclipse.jdt.util.PersistentItem addFromEditor(org.eclipse.ui.IWorkbenchPart part)
          Added currently selected IJavaElement in editor to the Annotation INBOX.
 void addModelListener(IAnnotationModelListener l)
           
 boolean contains(java.lang.Object a, java.lang.String parent)
           
 boolean contains(com.port80.eclipse.jdt.util.PersistentItem a)
           
 boolean copyItem(com.port80.eclipse.jdt.util.PersistentItem item, java.lang.String newfolder)
           
 boolean copyItems(java.lang.Object[] items, java.lang.String newfolder)
           
 void dispose()
          Disposes of this content provider.
protected  org.eclipse.jdt.core.IJavaElement findAutomaticElement(org.eclipse.jdt.core.IJavaElement element)
           
 com.port80.eclipse.jdt.util.PersistentFolder findFolder(java.lang.String name)
          Find folder with given name, create one if not found.
 java.lang.Object findItem(java.lang.Object a)
           
protected  org.eclipse.jdt.core.IJavaElement findSuitableElement(org.eclipse.jdt.core.IJavaElement element)
           
private  void fireModelChange()
           
private  void fireModelChange(org.eclipse.jface.viewers.IStructuredSelection selection)
           
private  void fireModelChange(com.port80.eclipse.jdt.util.PersistentItem item)
           
 com.port80.eclipse.jdt.util.PersistentItem get(java.lang.Object a, java.lang.String parent)
           
 com.port80.eclipse.jdt.util.PersistentItem get(com.port80.eclipse.jdt.util.PersistentItem a)
          Get item in Annotation that represents the given object.
 java.lang.Object[] getChildren(java.lang.Object parent)
          Returns the child elements of the given parent element.
 java.lang.Object[] getElements(java.lang.Object parent)
          Returns the elements to display in the viewer when its input is set to the given element.
 org.eclipse.swt.graphics.Image getImage(java.lang.Object obj)
          The LabelProvider implementation of this ILabelProvider method returns null.
 java.lang.Object getParent(java.lang.Object child)
          Returns the parent for the given element, or null indicating that the parent can't be computed.
 java.lang.Object getRoot()
           
 java.lang.String getText(java.lang.Object obj)
          The LabelProvider implementation of this ILabelProvider method returns the element's toString string.
 boolean hasChildren(java.lang.Object parent)
          Returns whether the given element has children.
 void initPrefs()
           
 void inputChanged(org.eclipse.jface.viewers.Viewer v, java.lang.Object oldInput, java.lang.Object newInput)
          Notifies this content provider that the given viewer's input has been switched to a different element.
private  boolean internalCopyItem(com.port80.eclipse.jdt.util.PersistentItem item, java.lang.String newfolder)
           
private  boolean internalMoveItem(com.port80.eclipse.jdt.util.PersistentItem src, java.lang.String newfolder)
           
 boolean moveItem(com.port80.eclipse.jdt.util.PersistentItem item, java.lang.String newfolder)
          Move item to another folder, create new folder if not yet exists.
 boolean moveItems(java.lang.Object[] items, java.lang.String newfolder)
          Move all items to the new folder.
 boolean remove(java.lang.Object a, java.lang.String parent)
           
 boolean remove(com.port80.eclipse.jdt.util.PersistentItem a)
          Remove object from Annotation.
 boolean removeAll(java.lang.Object[] items)
          Remove an array of items.
 void removeModelListener(IAnnotationModelListener l)
           
 boolean restoreState(org.eclipse.ui.IMemento memento)
           
 boolean restoreXMLState()
          Restore Annotation from state file in metadata area.
 void saveState(org.eclipse.ui.IMemento memento)
           
 boolean saveXMLState()
           
 boolean saveXMLState(java.lang.String filename)
          Save Annotation to state file in metadata area.
(package private)  boolean validVersion(org.eclipse.ui.IMemento memento)
          Validate Memento is in valid version format.
 
Methods inherited from class org.eclipse.jface.viewers.LabelProvider
addListener, fireLabelProviderChanged, isLabelProperty, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

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

ID

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

TAG_ROOT

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

TAG_VERSION

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

VERSIONS

private static final java.lang.String[] VERSIONS

INBOX

public static final java.lang.String INBOX
See Also:
Constant Field Values

RET_FAIL

public static final int RET_FAIL
See Also:
Constant Field Values

RET_OK

public static final int RET_OK
See Also:
Constant Field Values

RET_CANCEL

public static final int RET_CANCEL
See Also:
Constant Field Values

RET_RESET

public static final int RET_RESET
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

VERBOSE

private static final boolean VERBOSE
See Also:
Constant Field Values

fRoot

private com.port80.eclipse.jdt.util.PersistentFolder fRoot

fInbox

private com.port80.eclipse.jdt.util.PersistentFolder fInbox

labelProvider

private org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider labelProvider

fAnnotation

private java.util.Map fAnnotation

fModelListeners

private java.util.List fModelListeners

fFolders

private java.util.Map fFolders

fInboxLimit

private int fInboxLimit

fPartListener

private org.eclipse.ui.IPartListener fPartListener
Constructor Detail

AnnotationManager

public AnnotationManager()
Method Detail

initPrefs

public void initPrefs()

addModelListener

public void addModelListener(IAnnotationModelListener l)

removeModelListener

public void removeModelListener(IAnnotationModelListener l)

fireModelChange

private void fireModelChange()

fireModelChange

private void fireModelChange(com.port80.eclipse.jdt.util.PersistentItem item)

fireModelChange

private void fireModelChange(org.eclipse.jface.viewers.IStructuredSelection selection)

getRoot

public java.lang.Object getRoot()

findItem

public java.lang.Object findItem(java.lang.Object a)

findFolder

public com.port80.eclipse.jdt.util.PersistentFolder findFolder(java.lang.String name)
Find folder with given name, create one if not found.


saveState

public void saveState(org.eclipse.ui.IMemento memento)

restoreState

public boolean restoreState(org.eclipse.ui.IMemento memento)

saveXMLState

public boolean saveXMLState()

saveXMLState

public boolean saveXMLState(java.lang.String filename)
Save Annotation to state file in metadata area.


restoreXMLState

public boolean restoreXMLState()
Restore Annotation from state file in metadata area.


contains

public boolean contains(com.port80.eclipse.jdt.util.PersistentItem a)

contains

public boolean contains(java.lang.Object a,
                        java.lang.String parent)

get

public com.port80.eclipse.jdt.util.PersistentItem get(com.port80.eclipse.jdt.util.PersistentItem a)
Get item in Annotation that represents the given object.


get

public com.port80.eclipse.jdt.util.PersistentItem get(java.lang.Object a,
                                                      java.lang.String parent)

addAutomatic

public com.port80.eclipse.jdt.util.PersistentItem addAutomatic(org.eclipse.jdt.core.IJavaElement element)
Added automatically Type or File visited on editor activation.


add

public com.port80.eclipse.jdt.util.PersistentItem add(com.port80.eclipse.jdt.util.PersistentItem item,
                                                      java.lang.String parent)
Add an object to the specified folder in Annotation. If folder is null, add to INBOX. If object is a PersistentItem, it's parent is set to the specified folder regardless of its existing value.


remove

public boolean remove(com.port80.eclipse.jdt.util.PersistentItem a)
Remove object from Annotation.


remove

public boolean remove(java.lang.Object a,
                      java.lang.String parent)

removeAll

public boolean removeAll(java.lang.Object[] items)
Remove an array of items. Ignoring objects that are not an item.


findAutomaticElement

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

addFromEditor

public com.port80.eclipse.jdt.util.PersistentItem addFromEditor(org.eclipse.ui.IWorkbenchPart part)
Added currently selected IJavaElement in editor to the Annotation INBOX.


findSuitableElement

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

copyItem

public boolean copyItem(com.port80.eclipse.jdt.util.PersistentItem item,
                        java.lang.String newfolder)

copyItems

public boolean copyItems(java.lang.Object[] items,
                         java.lang.String newfolder)

internalCopyItem

private boolean internalCopyItem(com.port80.eclipse.jdt.util.PersistentItem item,
                                 java.lang.String newfolder)

moveItem

public boolean moveItem(com.port80.eclipse.jdt.util.PersistentItem item,
                        java.lang.String newfolder)
Move item to another folder, create new folder if not yet exists. The item to be moved must exists, otherwise error and do nothing.


moveItems

public boolean moveItems(java.lang.Object[] items,
                         java.lang.String newfolder)
Move all items to the new folder. Ignoring objects that is not a valid item.


internalMoveItem

private boolean internalMoveItem(com.port80.eclipse.jdt.util.PersistentItem src,
                                 java.lang.String newfolder)

getParent

public java.lang.Object getParent(java.lang.Object child)
Description copied from interface: org.eclipse.jface.viewers.ITreeContentProvider
Returns the parent for the given element, or null indicating that the parent can't be computed. In this case the tree-structured viewer can't expand a given node correctly if requested.

Specified by:
getParent in interface org.eclipse.jface.viewers.ITreeContentProvider

getChildren

public java.lang.Object[] getChildren(java.lang.Object parent)
Description copied from interface: org.eclipse.jface.viewers.ITreeContentProvider
Returns the child elements of the given parent element.

The difference between this method and IStructuredContentProvider.getElements is that getElements is called to obtain the tree viewer's root elements, whereas getChildren is used to obtain the children of a given parent element in the tree (including a root).

The result is not modified by the viewer.

Specified by:
getChildren in interface org.eclipse.jface.viewers.ITreeContentProvider

hasChildren

public boolean hasChildren(java.lang.Object parent)
Description copied from interface: org.eclipse.jface.viewers.ITreeContentProvider
Returns whether the given element has children.

Intended as an optimization for when the viewer does not need the actual children. Clients may be able to implement this more efficiently than getChildren.

Specified by:
hasChildren in interface org.eclipse.jface.viewers.ITreeContentProvider

getElements

public java.lang.Object[] getElements(java.lang.Object parent)
Description copied from interface: org.eclipse.jface.viewers.IStructuredContentProvider
Returns the elements to display in the viewer when its input is set to the given element. These elements can be presented as rows in a table, items in a list, etc. The result is not modified by the viewer.

Specified by:
getElements in interface org.eclipse.jface.viewers.IStructuredContentProvider

inputChanged

public void inputChanged(org.eclipse.jface.viewers.Viewer v,
                         java.lang.Object oldInput,
                         java.lang.Object newInput)
Description copied from interface: org.eclipse.jface.viewers.IContentProvider
Notifies this content provider that the given viewer's input has been switched to a different element.

A typical use for this method is registering the content provider as a listener to changes on the new input (using model-specific means), and deregistering the viewer from the old input. In response to these change notifications, the content provider should update the viewer (see the add, remove, update and refresh methods on the viewers).

The viewer should not be updated during this call, as it might be in the process of being disposed.

Specified by:
inputChanged in interface org.eclipse.jface.viewers.IContentProvider

dispose

public void dispose()
Description copied from interface: org.eclipse.jface.viewers.IContentProvider
Disposes of this content provider. This is called by the viewer when it is disposed.

The viewer should not be updated during this call, as it is in the process of being disposed.

Specified by:
dispose in interface org.eclipse.jface.viewers.IContentProvider

getText

public java.lang.String getText(java.lang.Object obj)
Description copied from class: org.eclipse.jface.viewers.LabelProvider
The LabelProvider implementation of this ILabelProvider method returns the element's toString string. Subclasses may override.

Specified by:
getText in interface org.eclipse.jface.viewers.ILabelProvider

getImage

public org.eclipse.swt.graphics.Image getImage(java.lang.Object obj)
Description copied from class: org.eclipse.jface.viewers.LabelProvider
The LabelProvider implementation of this ILabelProvider method returns null. Subclasses may override.

Specified by:
getImage in interface org.eclipse.jface.viewers.ILabelProvider

validVersion

boolean validVersion(org.eclipse.ui.IMemento memento)
Validate Memento is in valid version format.