Package org.eclipse.graphiti.ui.features
Class DefaultPrintFeature
java.lang.Object
org.eclipse.graphiti.features.impl.AbstractFeature
org.eclipse.graphiti.features.impl.AbstractPrintFeature
org.eclipse.graphiti.ui.features.DefaultPrintFeature
- All Implemented Interfaces:
IFeature
,IFeatureProviderHolder
,IPrintFeature
,IDescription
,IName
The default feature implementation for printing a diagram. This feature is
used to trigger printing from inside an open and initialized
DiagramEditor
. It relies on an existing GraphicalViewer
showing the diagram to print.- Since:
- 0.10 Has been moved from plug-in org.eclipse.graphiti package org.eclipse.graphiti.features
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.gef.GraphicalViewer
getGraphicalViewer
(IPrintContext context) Must return aGraphicalViewer
that contains the diagram to be printed.protected IPrintConfiguration
getPrintConfiguration
(org.eclipse.gef.GraphicalViewer viewer, org.eclipse.swt.printing.Printer printer) Called to create a configuration object for the printing that defines what to print on which printer and how.protected org.eclipse.swt.printing.PrinterData
getPrinterData
(IPrintContext context) Creates thePrinterData
information used for this print feature.protected org.eclipse.draw2d.PrintFigureOperation
getPrintOperation
(IPrintConfiguration printConfiguration) Called to create the operation that is actually used for printing a diagram.void
print
(IPrintContext context) Performs the print operation.Methods inherited from class org.eclipse.graphiti.features.impl.AbstractPrintFeature
canExecute, canPrint, execute, getName, hasDoneChanges, postPrint, prePrint
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, canUndo, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDescription, getDiagram, getDiagramBehavior, getFeatureProvider, getProgressCallback, getUserDecision, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElement
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.graphiti.IDescription
getDescription
Methods inherited from interface org.eclipse.graphiti.features.IFeature
canExecute, canUndo, execute, hasDoneChanges, isAvailable
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
Methods inherited from interface org.eclipse.graphiti.features.IPrintFeature
canPrint, postPrint, prePrint
-
Constructor Details
-
DefaultPrintFeature
Creates a newDefaultPrintFeature
.- Parameters:
fp
- The feature provider providing this feature
-
-
Method Details
-
print
Performs the print operation. The default implementation delegates togetGraphicalViewer(IPrintContext)
to retrieve theGraphicalViewer
that already displays the diagram, queries forPrinterData
to use by callinggetPrinterData(IPrintContext)
and finally uses#getPrintOperation(Printer, IPrintConfiguration)
to create an operation to perform the printing. All those methods may be overridden to change the default behavior, so normally one would not need to override this method unless the complete sequence needs to changed or the printing is performed in a completely different scenario.- Specified by:
print
in interfaceIPrintFeature
- Parameters:
context
- Context information for printing.
-
getGraphicalViewer
Must return aGraphicalViewer
that contains the diagram to be printed. The default implementation returns the viewer of theDiagramEditor
that started this print feature; this is the one associated to the feature provider of the currently opened diagram, see#getDiagramEditor()
.- Parameters:
context
- Context information for printing.- Returns:
- the viewer holding the diagram to print.
-
getPrinterData
Creates thePrinterData
information used for this print feature. The default implementation simply gets the info for the default printer of the system or the first printer in the list of available printers in case no default is defined.- Parameters:
context
- Context information for printing.- Returns:
- The printer data to use for this print feature.
-
getPrintConfiguration
protected IPrintConfiguration getPrintConfiguration(org.eclipse.gef.GraphicalViewer viewer, org.eclipse.swt.printing.Printer printer) Called to create a configuration object for the printing that defines what to print on which printer and how. The default implementation returns the standard Graphiti dialog used for printing that allows the user to define which printer to use, which figure to print and various other print settings.- Parameters:
viewer
- The viewer displaying the diagram to printprinter
- The printer to use as default- Returns:
- A newly created dialog that implements the
IPrintConfiguration
interface used in the print job.
-
getPrintOperation
protected org.eclipse.draw2d.PrintFigureOperation getPrintOperation(IPrintConfiguration printConfiguration) Called to create the operation that is actually used for printing a diagram. The default implementation returns the Graphiti default print operation that should be sufficient for almost all use cases.- Parameters:
printConfiguration
- TheIPrintConfiguration
instance that was used to configure this print operation. In the default implementation this is the dialog to use for selecting the printer and other settings.- Returns:
- The operation that will be used to actually perform the printing.
-