public class GridPasteKeyListener extends Object implements org.eclipse.swt.events.KeyListener
KeyListener
for the paste action on a Grid
control.Constructor and Description |
---|
GridPasteKeyListener(org.eclipse.swt.widgets.Display display,
VControl vControl,
EMFFormsDatabindingEMF dataBinding,
EStructuralFeatureValueConverterService converterService,
EMFFormsLocalizationService localizationService,
boolean selectPastedCells)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canBePasted(org.eclipse.emf.ecore.EStructuralFeature feature,
String cellValue,
org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Checks whether a given value may be pasted.
|
protected String |
extractDiagnosticMessage(org.eclipse.emf.common.util.Diagnostic diag,
org.eclipse.emf.ecore.EStructuralFeature feature,
String value)
Creates the message for the given
Diagnostic which will be displayed to the user. |
protected VControl |
getControl() |
protected EStructuralFeatureValueConverterService |
getConverterService() |
protected boolean |
isEObjectReadOnly(org.eclipse.emf.ecore.EObject eObject)
Called by
pasteContents(Point, Grid, String) to determine whether the values of an EObject should be
changed at all. |
protected boolean |
isSettingReadOnly(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EStructuralFeature feature,
Object convertedValue)
Called by
pasteContents(Point, Grid, String) to determine whether a setting should be changed at all. |
void |
keyPressed(org.eclipse.swt.events.KeyEvent e) |
void |
keyReleased(org.eclipse.swt.events.KeyEvent e) |
protected String |
modifyCellValue(String cellValueSplit)
This method is called by
pasteContents(Point, Grid, String) with the determined value for a cell. |
List<org.eclipse.swt.graphics.Point> |
pasteContents(org.eclipse.swt.graphics.Point startItem,
org.eclipse.nebula.widgets.grid.Grid grid,
String contents)
Performs the paste operation.
|
void |
pasteSelection(org.eclipse.nebula.widgets.grid.Grid grid,
String contents)
Pastes the given contents in the grid.
|
protected void |
postPasteContents()
This method get called by
pasteContents(Point, Grid, String) directely after the paste is done but
before showErrors(List) is called. |
protected void |
prePasteContents()
This method gets called by
pasteContents(Point, Grid, String) before it will start to loop over the to
be pasted values and begins the pasting. |
protected void |
setValue(org.eclipse.core.databinding.observable.value.IObservableValue value,
Object convertedValue)
Sets the given converted value on the observable value.
|
protected void |
showErrors(List<String> msgs)
Shows the errors to the user.
|
public GridPasteKeyListener(org.eclipse.swt.widgets.Display display, VControl vControl, EMFFormsDatabindingEMF dataBinding, EStructuralFeatureValueConverterService converterService, EMFFormsLocalizationService localizationService, boolean selectPastedCells)
display
- the Display
on which to allocate this command's Clipboard
.vControl
- the VTableControl
.dataBinding
- EMFFormsDatabindingEMF
converterService
- EStructuralFeatureValueConverterService
localizationService
- EMFFormsLocalizationService
selectPastedCells
- whether to select the pasted cellspublic void keyPressed(org.eclipse.swt.events.KeyEvent e)
keyPressed
in interface org.eclipse.swt.events.KeyListener
public void keyReleased(org.eclipse.swt.events.KeyEvent e)
keyReleased
in interface org.eclipse.swt.events.KeyListener
public void pasteSelection(org.eclipse.nebula.widgets.grid.Grid grid, String contents)
grid
- the target Grid
contents
- the contents to pastepublic List<org.eclipse.swt.graphics.Point> pasteContents(org.eclipse.swt.graphics.Point startItem, org.eclipse.nebula.widgets.grid.Grid grid, String contents)
startItem
- the start itemgrid
- the gridcontents
- the pasted contentsprotected void prePasteContents()
pasteContents(Point, Grid, String)
before it will start to loop over the to
be pasted values and begins the pasting.
Clients may use this to notify the user about the paste, setting global variables, showing progress, etc.protected void postPasteContents()
pasteContents(Point, Grid, String)
directely after the paste is done but
before showErrors(List)
is called. Please note that the call comes from a finally block meaning that the
paste process may have been stoped by an unhandled exception beforehand.
Clients may use this clean up things done in prePasteContents()
for example.protected String modifyCellValue(String cellValueSplit)
pasteContents(Point, Grid, String)
with the determined value for a cell.
Clients may override this method in order to trim the string or change its formatting.cellValueSplit
- the cell value determined from the clipboard for the cell.protected boolean isEObjectReadOnly(org.eclipse.emf.ecore.EObject eObject)
pasteContents(Point, Grid, String)
to determine whether the values of an EObject should be
changed at all.eObject
- the EObject in questiontrue
if paste for this object should be skipped, false
otherwiseprotected boolean isSettingReadOnly(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature feature, Object convertedValue)
pasteContents(Point, Grid, String)
to determine whether a setting should be changed at all.eObject
- the EObject in questionfeature
- the Feature in questionconvertedValue
- the converted cell valuetrue
if paste for this setting should be skipped, false
otherwiseprotected void showErrors(List<String> msgs)
msgs
- the collected messages, may be empty if no errorsprotected boolean canBePasted(org.eclipse.emf.ecore.EStructuralFeature feature, String cellValue, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
feature
- the feature of the eObject
cellValue
- the cell value to be pastedeObject
- the parent EObject
setting
- EStructuralFeature.Setting
true
, if the value may be pasted, false
otherwiseprotected void setValue(org.eclipse.core.databinding.observable.value.IObservableValue value, Object convertedValue)
value
- the observable valueconvertedValue
- the converted valueprotected String extractDiagnosticMessage(org.eclipse.emf.common.util.Diagnostic diag, org.eclipse.emf.ecore.EStructuralFeature feature, String value)
Diagnostic
which will be displayed to the user.diag
- the diagnostic with the original error messagefeature
- the validated featurevalue
- the validated valueprotected EStructuralFeatureValueConverterService getConverterService()
EStructuralFeatureValueConverterService
Copyright © 2019. All rights reserved.