uk.ac.kcl.cch.jb.pliny.pdfAnnot
Class PDFEditor

java.lang.Object
  extended byorg.eclipse.core.commands.common.EventManager
      extended byorg.eclipse.ui.part.WorkbenchPart
          extended byorg.eclipse.ui.part.EditorPart
              extended byorg.eclipse.ui.part.MultiPageEditorPart
                  extended byuk.ac.kcl.cch.jb.pliny.pdfAnnot.PDFEditor
All Implemented Interfaces:
org.eclipse.gef.commands.CommandStackListener, EventListener, org.eclipse.core.runtime.IAdaptable, org.eclipse.ui.IEditorPart, org.eclipse.core.runtime.IExecutableExtension, IHandlesAnnotations, IPageSettableEditorPart, IResourceDrivenPart, org.eclipse.ui.ISaveablePart, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.part.IWorkbenchPartOrientation, PropertyChangeListener

public class PDFEditor
extends org.eclipse.ui.part.MultiPageEditorPart
implements PropertyChangeListener, IResourceDrivenPart, IPageSettableEditorPart, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.gef.commands.CommandStackListener, IHandlesAnnotations

the EditPart for the PDF annotator. Much of this code is taken directly from JPedal's example of how to use their PDF browser in an Eclipse environment. The annotation area is a GEF-managed object, as elsewhere.

A problem to making this code work is that JPedal's code really works within the AWT/Swing model, and here we must be in the SWT model. After trying various ways to make the two live together I ended up using JPedal's component for making an image of a page, which I then converted to an SWT image! See the utility class that does this conversion in SwtImageFromPdf. Since each PDF page is presented to this editor as an image, there are many echos here between this code and the code for the Pliny ImageEditor.

Author:
John Bradley

Field Summary
static boolean debug
           
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Constructor Summary
PDFEditor()
           
 
Method Summary
 void commandStackChanged(EventObject event)
           
protected  void createActions()
           
protected  void createPages()
          This is a callback that will allow us to create the viewer and initialize it.
protected  void displayPage(int newPage)
           
 void dispose()
           
 void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void doSaveAs()
           
protected  org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()
           
 Object getAdapter(Class key)
           
 org.eclipse.gef.commands.CommandStack getCommandStack()
           
 org.eclipse.gef.EditDomain getEditDomain()
           
 Resource getMyResource()
          returns the Resource that this part is currently using as its input.
 org.jpedal.PdfDecoder getPdfDecoder()
           
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput input)
           
 boolean isDirty()
           
 boolean isSaveAsAllowed()
           
 void propertyChange(PropertyChangeEvent arg0)
           
 void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
           
 void setFocus()
          Passing the focus request to the viewer's control.
 void turnToPage(int pageNo)
          causes the implementor to turn to the given page in its display.
 void updateCommandStackActions()
           
 void zoom(float scale)
           
 
Methods inherited from class org.eclipse.ui.part.MultiPageEditorPart
addPage, addPage, addPage, addPage, createPageContainer, createPartControl, createSite, getActiveEditor, getActivePage, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageText, handlePropertyChange, pageChange, removePage, setActivePage, setControl, setPageImage, setPageText
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, setInputWithNotify, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
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, createPartControl, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 

Field Detail

debug

public static final boolean debug
See Also:
Constant Field Values
Constructor Detail

PDFEditor

public PDFEditor()
Method Detail

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
doSave in interface org.eclipse.ui.ISaveablePart

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart

init

public void init(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput input)
          throws org.eclipse.ui.PartInitException
Specified by:
init in interface org.eclipse.ui.IEditorPart
Throws:
org.eclipse.ui.PartInitException

dispose

public void dispose()
Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart

isDirty

public boolean isDirty()
Specified by:
isDirty in interface org.eclipse.ui.ISaveablePart

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.ISaveablePart

createPages

protected void createPages()
This is a callback that will allow us to create the viewer and initialize it.


getEditDomain

public org.eclipse.gef.EditDomain getEditDomain()

getCommandStack

public org.eclipse.gef.commands.CommandStack getCommandStack()

getActionRegistry

protected org.eclipse.gef.ui.actions.ActionRegistry getActionRegistry()

createActions

protected void createActions()

zoom

public void zoom(float scale)

displayPage

protected void displayPage(int newPage)

setFocus

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

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

getAdapter

public Object getAdapter(Class key)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable

propertyChange

public void propertyChange(PropertyChangeEvent arg0)
Specified by:
propertyChange in interface PropertyChangeListener

getMyResource

public Resource getMyResource()
Description copied from interface: IResourceDrivenPart
returns the Resource that this part is currently using as its input.

Specified by:
getMyResource in interface IResourceDrivenPart
Returns:
Resource

commandStackChanged

public void commandStackChanged(EventObject event)
Specified by:
commandStackChanged in interface org.eclipse.gef.commands.CommandStackListener

updateCommandStackActions

public void updateCommandStackActions()

selectionChanged

public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
Specified by:
selectionChanged in interface org.eclipse.jface.viewers.ISelectionChangedListener

turnToPage

public void turnToPage(int pageNo)
Description copied from interface: IPageSettableEditorPart
causes the implementor to turn to the given page in its display.

Specified by:
turnToPage in interface IPageSettableEditorPart
Parameters:
pageNo - int the requested page number.

getPdfDecoder

public org.jpedal.PdfDecoder getPdfDecoder()