RSE
Release 1.0

org.eclipse.rse.ui.view.scratchpad
Class SystemScratchpadView

java.lang.Object
  extended byorg.eclipse.jface.viewers.Viewer
      extended byorg.eclipse.jface.viewers.ContentViewer
          extended byorg.eclipse.jface.viewers.StructuredViewer
              extended byorg.eclipse.jface.viewers.AbstractTreeViewer
                  extended byorg.eclipse.jface.viewers.TreeViewer
                      extended byorg.eclipse.rse.ui.view.scratchpad.SystemScratchpadView
All Implemented Interfaces:
EventListener, IInputProvider, IInputSelectionProvider, IMenuListener, IPostSelectionProvider, ISelectionChangedListener, ISelectionProvider, ISystemDeleteTarget, ISystemRemoteChangeListener, ISystemRenameTarget, ISystemResourceChangeListener, ISystemSelectAllTarget

public class SystemScratchpadView
extends TreeViewer
implements IMenuListener, ISystemDeleteTarget, ISystemRenameTarget, ISystemSelectAllTarget, ISystemResourceChangeListener, ISystemRemoteChangeListener, ISelectionChangedListener, ISelectionProvider

This subclass of the standard JFace tabletree viewer is used to show a generic tabletree view of the selected object


Nested Class Summary
 
Nested classes inherited from class org.eclipse.jface.viewers.StructuredViewer
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders
 
Field Summary
protected  ClearAction _clearAllAction
           
protected  ClearSelectedAction _clearSelectedAction
           
protected  SystemCommonDeleteAction _deleteAction
           
protected  SystemOpenExplorerPerspectiveAction _openToPerspectiveAction
           
protected  PropertyDialogAction _propertyDialogAction
           
protected  SystemRefreshAction _refreshAction
           
protected  SystemRemotePropertiesAction _remotePropertyDialogAction
           
protected  SystemCommonRenameAction _renameAction
           
protected  SystemCommonSelectAllAction _selectAllAction
           
protected  boolean _selectionEnableDeleteAction
           
protected  boolean _selectionEnableRenameAction
           
protected  boolean _selectionFlagsUpdated
           
protected  boolean _selectionIsRemoteObject
           
protected  boolean _selectionShowDeleteAction
           
protected  boolean _selectionShowOpenViewActions
           
protected  boolean _selectionShowRefreshAction
           
protected  boolean _selectionShowRenameAction
           
protected  SystemShowInTableAction _showInTableAction
           
protected  boolean menuListenerAdded
           
 
Fields inherited from class org.eclipse.jface.viewers.AbstractTreeViewer
ALL_LEVELS
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
SystemScratchpadView(Tree tableTree, ISystemMessageLine msgLine)
          Constructor for the table view
 
Method Summary
 boolean canDelete()
          Required method from ISystemDeleteTarget Decides whether to enable the delete menu item.
 boolean canRename()
          Required method from ISystemRenameTarget Decides whether to enable the rename menu item.
 void clearMessage()
          Clear message/status shown on the message/status line
 void displayMessage(String msg)
          Display a message/status on the message/status line
 void dispose()
           
 boolean doDelete(IProgressMonitor monitor)
          Actually do the delete of currently selected items.
 boolean doRename(String[] newNames)
          Required method from ISystemRenameTarget
 void doSelectAll(IStructuredSelection selection)
          When this action is run via Edit->Select All or via Ctrl+A, perform the select all action.
 boolean enableSelectAll(IStructuredSelection selection)
          Return true if select all should be enabled for the given object.
 void fillContextMenu(IMenuManager menu)
           
protected  ISystemViewElementAdapter getAdapter(Object obj)
          Convenience method for retrieving the view adapter for an object
protected  IAction getClearAllAction()
           
protected  IAction getClearSelectedAction()
           
 Menu getContextMenu()
          Return the popup menu for the table
 MenuManager getContextMenuManager()
          Return the popup menu for the table
protected  IAction getDeleteAction()
          Rather than pre-defined this common action we wait until it is first needed, for performance reasons.
 Object getInput()
           
 Layout getLayout()
           
protected  SystemOpenExplorerPerspectiveAction getOpenToPerspectiveAction()
          Get the common "Open to->" action for opening a new Remote System Explorer view, scoped to the currently selected object.
protected  Object getParentForContent(Object element)
           
protected  PropertyDialogAction getPropertyDialogAction()
          Rather than pre-defining this common action we wait until it is first needed, for performance reasons.
protected  IAction getRefreshAction()
          Return the refresh action
protected  ISystemRemoteElementAdapter getRemoteAdapter(Object o)
          Returns the implementation of ISystemRemoteElement for the given object.
protected  SystemRemotePropertiesAction getRemotePropertyDialogAction()
          Rather than pre-defining this common action we wait until it is first needed, for performance reasons.
protected  IAction getRenameAction()
          Rather than pre-defined this common action we wait until it is first needed, for performance reasons.
protected  IAction getSelectAllAction()
          Return the select All action
 ISelection getSelection()
           
 Shell getShell()
          This is the method in your class that will be called to return the shell for your viewer
protected  SystemShowInTableAction getShowInTableAction()
           
protected  void initDragAndDrop()
           
 void inputChanged(Object newObject, Object oldObject)
          Called whenever the input for the view changes
 void menuAboutToShow(IMenuManager manager)
           
 void removeAsListener()
          Remove as listener.
 boolean sameParent()
          This is called to ensure all elements in a multiple-selection have the same parent in the tree viewer.
protected  void scanSelections()
          -------------------------------------------------------------------------------- For many actions we have to walk the selection list and examine each selected object to decide if a given common action is supported or not.
 void selectionChanged(SelectionChangedEvent event)
           
 void setWorkbenchPart(IWorkbenchPart part)
           
 boolean showDelete()
          Required method from ISystemDeleteTarget.
protected  boolean showRefresh()
          Decides whether to even show the refresh menu item.
 boolean showRename()
          Required method from ISystemRenameTarget.
 void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
          This is the method in your class that will be called when a remote resource changes.
 void systemResourceChanged(ISystemResourceChangeEvent event)
          Used to asynchronously update the view whenever properties change.
 
Methods inherited from class org.eclipse.jface.viewers.TreeViewer
addTreeListener, assertContentProviderType, buildLabel, cancelEditing, createChildren, doUpdateItem, editElement, getCellEditors, getCellModifier, getChild, getChildren, getColumnProperties, getControl, getExpanded, getItem, getItemCount, getItemCount, getItems, getLabelProvider, getParentElement, getParentItem, getRawChildren, getSelection, getTree, hookControl, internalAdd, internalRefreshStruct, isCellEditorActive, isExpandable, isSameSelection, mapElement, newItem, removeAll, replace, setCellEditors, setCellModifier, setChildCount, setColumnProperties, setExpanded, setLabelProvider, setSelection, showItem
 
Methods inherited from class org.eclipse.jface.viewers.AbstractTreeViewer
add, add, addSelectionListener, addTreeListener, associate, collapseAll, collapseToLevel, createTreeItem, disassociate, doFindInputItem, doFindItem, doUpdateItem, expandAll, expandToLevel, expandToLevel, fireTreeCollapsed, fireTreeExpanded, getAutoExpandLevel, getExpandedElements, getExpandedState, getExpandedTreePaths, getFilteredChildren, getNextItem, getPreviousItem, getSelectionFromWidget, getSortedChildren, getTreePathFromItem, getVisibleExpandedElements, handleDoubleSelect, handleTreeCollapse, handleTreeExpand, indexForElement, insert, internalCollapseToLevel, internalExpand, internalExpandToLevel, internalGetWidgetToSelect, internalRefresh, internalRefresh, internalRefresh, internalRemove, internalRemove, labelProviderChanged, remove, remove, remove, removeTreeListener, reveal, scrollDown, scrollUp, setAutoExpandLevel, setContentProvider, setExpandedElements, setExpandedState, setExpandedTreePaths, setSelectionToWidget, setSelectionToWidget, updateChildren, updatePlus
 
Methods inherited from class org.eclipse.jface.viewers.StructuredViewer
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilters, getRoot, getSorter, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, internalUpdate, needsRefilter, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setInput, setSelection, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMap
 
Methods inherited from class org.eclipse.jface.viewers.ContentViewer
getContentProvider, handleDispose
 
Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider
addSelectionChangedListener, removeSelectionChangedListener, setSelection
 

Field Detail

_refreshAction

protected SystemRefreshAction _refreshAction

_propertyDialogAction

protected PropertyDialogAction _propertyDialogAction

_remotePropertyDialogAction

protected SystemRemotePropertiesAction _remotePropertyDialogAction

_openToPerspectiveAction

protected SystemOpenExplorerPerspectiveAction _openToPerspectiveAction

_showInTableAction

protected SystemShowInTableAction _showInTableAction

_deleteAction

protected SystemCommonDeleteAction _deleteAction

_renameAction

protected SystemCommonRenameAction _renameAction

_selectAllAction

protected SystemCommonSelectAllAction _selectAllAction

_clearSelectedAction

protected ClearSelectedAction _clearSelectedAction

_clearAllAction

protected ClearAction _clearAllAction

_selectionShowRefreshAction

protected boolean _selectionShowRefreshAction

_selectionShowOpenViewActions

protected boolean _selectionShowOpenViewActions

_selectionShowDeleteAction

protected boolean _selectionShowDeleteAction

_selectionShowRenameAction

protected boolean _selectionShowRenameAction

_selectionEnableDeleteAction

protected boolean _selectionEnableDeleteAction

_selectionEnableRenameAction

protected boolean _selectionEnableRenameAction

_selectionIsRemoteObject

protected boolean _selectionIsRemoteObject

_selectionFlagsUpdated

protected boolean _selectionFlagsUpdated

menuListenerAdded

protected boolean menuListenerAdded
Constructor Detail

SystemScratchpadView

public SystemScratchpadView(Tree tableTree,
                            ISystemMessageLine msgLine)
Constructor for the table view

Method Detail

getLayout

public Layout getLayout()

setWorkbenchPart

public void setWorkbenchPart(IWorkbenchPart part)

getContextMenu

public Menu getContextMenu()
Return the popup menu for the table


getContextMenuManager

public MenuManager getContextMenuManager()
Return the popup menu for the table


inputChanged

public void inputChanged(Object newObject,
                         Object oldObject)
Called whenever the input for the view changes


getInput

public Object getInput()
Specified by:
getInput in interface IInputProvider

getAdapter

protected ISystemViewElementAdapter getAdapter(Object obj)
Convenience method for retrieving the view adapter for an object


initDragAndDrop

protected void initDragAndDrop()

systemResourceChanged

public void systemResourceChanged(ISystemResourceChangeEvent event)
Used to asynchronously update the view whenever properties change.

Specified by:
systemResourceChanged in interface ISystemResourceChangeListener
See Also:
ISystemResourceChangeEvent

systemRemoteResourceChanged

public void systemRemoteResourceChanged(ISystemRemoteChangeEvent event)
This is the method in your class that will be called when a remote resource changes. You will be called after the resource is changed.

Specified by:
systemRemoteResourceChanged in interface ISystemRemoteChangeListener
See Also:
ISystemRemoteChangeEvent

displayMessage

public void displayMessage(String msg)
Display a message/status on the message/status line


clearMessage

public void clearMessage()
Clear message/status shown on the message/status line


selectionChanged

public void selectionChanged(SelectionChangedEvent event)
Specified by:
selectionChanged in interface ISelectionChangedListener

dispose

public void dispose()

removeAsListener

public void removeAsListener()
Remove as listener.


getPropertyDialogAction

protected PropertyDialogAction getPropertyDialogAction()
Rather than pre-defining this common action we wait until it is first needed, for performance reasons.


getRemotePropertyDialogAction

protected SystemRemotePropertiesAction getRemotePropertyDialogAction()
Rather than pre-defining this common action we wait until it is first needed, for performance reasons.


getSelectAllAction

protected IAction getSelectAllAction()
Return the select All action


getRenameAction

protected IAction getRenameAction()
Rather than pre-defined this common action we wait until it is first needed, for performance reasons.


getDeleteAction

protected IAction getDeleteAction()
Rather than pre-defined this common action we wait until it is first needed, for performance reasons.


getClearSelectedAction

protected IAction getClearSelectedAction()

getClearAllAction

protected IAction getClearAllAction()

getRefreshAction

protected IAction getRefreshAction()
Return the refresh action


getOpenToPerspectiveAction

protected SystemOpenExplorerPerspectiveAction getOpenToPerspectiveAction()
Get the common "Open to->" action for opening a new Remote System Explorer view, scoped to the currently selected object.


getShowInTableAction

protected SystemShowInTableAction getShowInTableAction()

getShell

public Shell getShell()
Description copied from interface: ISystemResourceChangeListener
This is the method in your class that will be called to return the shell for your viewer

Specified by:
getShell in interface ISystemResourceChangeListener

showDelete

public boolean showDelete()
Required method from ISystemDeleteTarget. Decides whether to even show the delete menu item. Assumes scanSelections() has already been called

Specified by:
showDelete in interface ISystemDeleteTarget

canDelete

public boolean canDelete()
Required method from ISystemDeleteTarget Decides whether to enable the delete menu item. Assumes scanSelections() has already been called

Specified by:
canDelete in interface ISystemDeleteTarget

doDelete

public boolean doDelete(IProgressMonitor monitor)
Description copied from interface: ISystemDeleteTarget
Actually do the delete of currently selected items. Return true if it worked. Return false if it didn't (you display msg), or throw an exception (framework displays msg)

Specified by:
doDelete in interface ISystemDeleteTarget

showRename

public boolean showRename()
Required method from ISystemRenameTarget. Decides whether to even show the rename menu item. Assumes scanSelections() has already been called

Specified by:
showRename in interface ISystemRenameTarget

canRename

public boolean canRename()
Required method from ISystemRenameTarget Decides whether to enable the rename menu item. Assumes scanSelections() has already been called

Specified by:
canRename in interface ISystemRenameTarget

getParentForContent

protected Object getParentForContent(Object element)

doRename

public boolean doRename(String[] newNames)
Required method from ISystemRenameTarget

Specified by:
doRename in interface ISystemRenameTarget

getRemoteAdapter

protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
Returns the implementation of ISystemRemoteElement for the given object. Returns null if this object does not adaptable to this.


enableSelectAll

public boolean enableSelectAll(IStructuredSelection selection)
Return true if select all should be enabled for the given object. For a tree view, you should return true if and only if the selected object has children. You can use the passed in selection or ignore it and query your own selection.

Specified by:
enableSelectAll in interface ISystemSelectAllTarget

doSelectAll

public void doSelectAll(IStructuredSelection selection)
When this action is run via Edit->Select All or via Ctrl+A, perform the select all action. For a tree view, this should select all the children of the given selected object. You can use the passed in selected object or ignore it and query the selected object yourself.

Specified by:
doSelectAll in interface ISystemSelectAllTarget

menuAboutToShow

public void menuAboutToShow(IMenuManager manager)
Specified by:
menuAboutToShow in interface IMenuListener

getSelection

public ISelection getSelection()
Specified by:
getSelection in interface ISelectionProvider

fillContextMenu

public void fillContextMenu(IMenuManager menu)

showRefresh

protected boolean showRefresh()
Decides whether to even show the refresh menu item. Assumes scanSelections() has already been called


sameParent

public boolean sameParent()
This is called to ensure all elements in a multiple-selection have the same parent in the tree viewer. If they don't we automatically disable all actions.

Designed to be as fast as possible by going directly to the SWT widgets


scanSelections

protected void scanSelections()
-------------------------------------------------------------------------------- For many actions we have to walk the selection list and examine each selected object to decide if a given common action is supported or not.

Walking this list multiple times while building the popup menu is a performance hit, so we have this common method that does it only once, setting instance variables for all of the decisions we are in interested in. --------------------------------------------------------------------------------


RSE
Release 1.0

Copyright (c) IBM Corporation and others 2000, 2006. All Rights Reserved.