uk.ac.kcl.cch.jb.pliny.dnd
Class AbstractResourceExtensionProcessor

java.lang.Object
  extended byuk.ac.kcl.cch.jb.pliny.dnd.AbstractResourceExtensionProcessor
All Implemented Interfaces:
IResourceExtensionProcessor
Direct Known Subclasses:
ImageEditorResourceExtensionProcessor, PdfEditorResourceExtensionProcessor

public abstract class AbstractResourceExtensionProcessor
extends Object
implements IResourceExtensionProcessor

an abstract class which implements IResourceExtensionProcessor to provide a base set of functionality which other can then be extended to support interactions between Pliny plugins and other plugins. The main features here are code to support drag-and-drop of objects outside of Eclipse into Pliny.

Author:
John Bradley

Nested Class Summary
 
Nested classes inherited from class uk.ac.kcl.cch.jb.pliny.dnd.IResourceExtensionProcessor
IResourceExtensionProcessor.CacheElement
 
Field Summary
protected  String editorId
           
protected  org.eclipse.ui.IWorkbenchPage myPage
           
protected  Vector newResources
           
 
Constructor Summary
AbstractResourceExtensionProcessor(org.eclipse.ui.IWorkbenchPage myPage, String editorId)
           
AbstractResourceExtensionProcessor(String editorId)
           
 
Method Summary
abstract  boolean canHandleObject(Object data)
          see IResourceExtensionProcessor.canHandleObject(java.lang.Object) for details.
 IResourceExtensionProcessor.CacheElement[] getCacheElements(Resource r)
          override this method to provide support for adding cache data from your plugin into a pliny archive file.
abstract  org.eclipse.draw2d.IFigure getContentFigure(Resource resource)
          see IResourceExtensionProcessor.getContentFigure(uk.ac.kcl.cch.jb.pliny.model.Resource) for details.
protected  String getFileContentsAsString(InputStream stream)
           
abstract  ObjectType getMyObjectType()
          see IResourceExtensionProcessor.getMyObjectType() for details.
 IResourceExtensionProcessorSource getSource()
          returns an IResourceExtensionProcessorSource.
protected abstract  void handleFile(String string)
          implement this method to handle a file that has been dropped on your processor.
protected abstract  void handleResource(Resource resource)
          implementment this method to process a Resource that has been dragged into this process from another Pliny application.
protected  void handleString(String input)
           
protected  boolean handleUrl(String input, String title)
           
protected abstract  boolean handleUrl(URL theURL, String title)
          implement this abstract method to provide code to process a dropped object that was a URL.
protected  void handleUrlFile(org.eclipse.core.runtime.IPath myPath)
           
abstract  Resource makeMyResource()
          see IResourceExtensionProcessor.makeMyResource() for details.
protected  void makeNote(String input, String title)
           
protected  URL makeURLfromFileName(org.eclipse.core.runtime.IPath myPath)
           
 void openResources()
           
 void processArchiveEntries(IGetsArchiveEntries archive, Resource r)
          override this method to provide support for creating cache data from Pliny archive files.
 boolean processDrop(org.eclipse.swt.dnd.DropTargetEvent event)
          this method checks the kind of object being dropped in the Pliny environment and depending upon the kind, invokes various other methods to handle different kinds of data.
 void setViewPart(org.eclipse.ui.part.ViewPart myViewPart)
          see IResourceExtensionProcessor.setViewPart(org.eclipse.ui.part.ViewPart).
protected  void writeFile(InputStream in, String outputFileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myPage

protected org.eclipse.ui.IWorkbenchPage myPage

newResources

protected Vector newResources

editorId

protected String editorId
Constructor Detail

AbstractResourceExtensionProcessor

public AbstractResourceExtensionProcessor(String editorId)

AbstractResourceExtensionProcessor

public AbstractResourceExtensionProcessor(org.eclipse.ui.IWorkbenchPage myPage,
                                          String editorId)
Method Detail

setViewPart

public void setViewPart(org.eclipse.ui.part.ViewPart myViewPart)
see IResourceExtensionProcessor.setViewPart(org.eclipse.ui.part.ViewPart). The default implementation takes the given ViewPart, fetches its IWorkbenchPage, and stores that for object use (to allow editors to be opened on newly created Resources.

This method may be extended, but this versioni should also be called via super.setViewPart(...) in the code extension.

Specified by:
setViewPart in interface IResourceExtensionProcessor
Parameters:
myViewPart -

getSource

public IResourceExtensionProcessorSource getSource()
returns an IResourceExtensionProcessorSource. In this default implementation, this is the same as the associated ObjectType.

Specified by:
getSource in interface IResourceExtensionProcessor
Returns:
the appropriate IResourceExtensionProcessorSource

makeMyResource

public abstract Resource makeMyResource()
see IResourceExtensionProcessor.makeMyResource() for details.

Specified by:
makeMyResource in interface IResourceExtensionProcessor
Returns:
Resource a new Resource of suitable type not yet set up in the backing store.
See Also:
PlinyXMLImporter

getMyObjectType

public abstract ObjectType getMyObjectType()
see IResourceExtensionProcessor.getMyObjectType() for details.

Specified by:
getMyObjectType in interface IResourceExtensionProcessor
Returns:
ObjectType the type of resource created by this processor.

canHandleObject

public abstract boolean canHandleObject(Object data)
see IResourceExtensionProcessor.canHandleObject(java.lang.Object) for details.

Specified by:
canHandleObject in interface IResourceExtensionProcessor
Parameters:
data -
Returns:
boolean returns true if this processor can handle this object.

getContentFigure

public abstract org.eclipse.draw2d.IFigure getContentFigure(Resource resource)
see IResourceExtensionProcessor.getContentFigure(uk.ac.kcl.cch.jb.pliny.model.Resource) for details.

Specified by:
getContentFigure in interface IResourceExtensionProcessor
Parameters:
resource - the Resource the IFigure should be about.
Returns:
IFigure the figure to display.

processDrop

public boolean processDrop(org.eclipse.swt.dnd.DropTargetEvent event)
this method checks the kind of object being dropped in the Pliny environment and depending upon the kind, invokes various other methods to handle different kinds of data. See IResourceExtensionProcessor.processDrop(org.eclipse.swt.dnd.DropTargetEvent) for details.

drop data handled include:

Specified by:
processDrop in interface IResourceExtensionProcessor
Parameters:
event -
Returns:
IFigure the figure to display.

handleResource

protected abstract void handleResource(Resource resource)
implementment this method to process a Resource that has been dragged into this process from another Pliny application.

Parameters:
resource - Resource to be introduced.

handleFile

protected abstract void handleFile(String string)
implement this method to handle a file that has been dropped on your processor.

Parameters:
string - String name of the File

openResources

public void openResources()

handleUrlFile

protected void handleUrlFile(org.eclipse.core.runtime.IPath myPath)

handleString

protected void handleString(String input)

handleUrl

protected boolean handleUrl(String input,
                            String title)

handleUrl

protected abstract boolean handleUrl(URL theURL,
                                     String title)
implement this abstract method to provide code to process a dropped object that was a URL.

Parameters:
theURL - URL the URL the object represents
title - String a suggested title for the Resource you should create.
Returns:
boolean return true if the URL was successfully handled.

makeNote

protected void makeNote(String input,
                        String title)

getFileContentsAsString

protected String getFileContentsAsString(InputStream stream)

makeURLfromFileName

protected URL makeURLfromFileName(org.eclipse.core.runtime.IPath myPath)

getCacheElements

public IResourceExtensionProcessor.CacheElement[] getCacheElements(Resource r)
override this method to provide support for adding cache data from your plugin into a pliny archive file. See IResourceExtensionProcessor.getCacheElements(uk.ac.kcl.cch.jb.pliny.model.Resource).

Specified by:
getCacheElements in interface IResourceExtensionProcessor
Returns:
an array of CacheElements that the the archiver what data is to be put in the archive file, and give a handle to a Stream that can provide it.

processArchiveEntries

public void processArchiveEntries(IGetsArchiveEntries archive,
                                  Resource r)
                           throws PlinyImportException
override this method to provide support for creating cache data from Pliny archive files. See IResourceExtensionProcessor.processArchiveEntries(uk.ac.kcl.cch.jb.pliny.dnd.IGetsArchiveEntries, uk.ac.kcl.cch.jb.pliny.model.Resource).

Specified by:
processArchiveEntries in interface IResourceExtensionProcessor
Parameters:
archive - IGetsArchiveEntries archive process that can provide you with access to input streams from the archive containing the data you want to put in the cache.
r - Resource the cache data should belong to.
Throws:
PlinyImportException

writeFile

protected void writeFile(InputStream in,
                         String outputFileName)
                  throws PlinyImportException
Throws:
PlinyImportException