Issue #145 - Modifications to support NatTable in RAP#146
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduced a new helper class
org.eclipse.nebula.widgets.nattable.util.PlatformHelperthat contains methods to handle situations that differ between platforms.This class contains the following:
IDialogConstantsvalues, because in SWT you access those constants directly from theIDialogConstantsinterface, in RAP/RWT you first need to get an instance before you can access the contants.IDialogConstantsare used in the NatTableExceptionDialogwhich is mainly used in theNatExporter.isRAP()andisMAC()to be able to handle situations where processing needs to be skipped completely (e.g. when trying to trigger printing) or to handle situations differently when in RAP or running on a MAC.Following methods are missing in RWT:
FontMetrics#getDescent()FontMetrics#getAscent()FontMetrics#getLeading()These methods are used in
AbstractTextPainter,GraphicsUtilsandVerticalTextPainter. Without these there are no textdecorations (underline, strikethrough) available in NatTable with RAP. And the location of the text in vertical text representation might be not 100% accurate.FileDialog#getFilterIndex()FileDialog#setFilterPath(String)FileDialog#setOverwrite(boolean)FileDialog#setFileName(String)FileDialog#setFilterNames(String[])Used in
FileOutputStreamProviderthat opens aFileDialogto select the target on exporting a NatTable and in theFileDialogCellEditor.Note that the
FileDialogin RAP can only be used to select a file for upload (SWT.OPEN) and not for saving (SWT.SAVE).Therefore the
FileOutputStreamProviderwas modified to create the export with the default filename in a temp directory, which can then be downloaded via RAP API as described in Service Handler and DownloadsScrollBar#getIncrement()ScrollBar#getPageIncrement()ScrollBar#setIncrement(int)ScrollBar#setPageIncrement(int)Used in
ScrollBarScrollerand is called byScrollBarHandlerTemplate(onlysetIncrement(int)andsetPageIncrement(int)). As RAP/RWT does not supportScrollBaron aCanvas, this should not have direct effect in RAP, despite that it does not break on opening a NatTable with scrolling in RAP.Note that to support scrolling in NatTable, there need to be a workaround implementation in a RAP specific NatTable fragment.
Control#addPaintListener(PaintListener)Control#removePaintListener(PaintListener)ControlDecoration#showHoverText(String)These methods are used in the
ControlDecorationProvider. ThePaintListenermethods are used to position the error decoration correctly with the default positioning, because the cell bounds are only available afteractivateCell().This means, the
SWT.DEFAULTdecoration position does not work in RAP.The
PaintListenermethods are also used to correct the position of the filter combobox in case filtering removes the scrollbar and the table would therefore be moved. This does also not work on RAP, but is more like a small visual glitch in a special case.NatTable/Canvas#addMouseMoveListener(MouseMoveListener)NatTable/Canvas#addMouseTrackListener(MouseTrackListener)NatTable/Canvas#addMouseWheelListener(MouseWheelListener)Mouse move and mouse track events are not supported in RAP because of performance reasons. The support for mouse move in NatTable, for example to support column and row resizing or reordering, needs to be implemented in a RAP specific NatTable fragment using Javascript.
The hover styling on the other hand will not be supported in NatTable with RAP. To support this the mouse move events needs to be transported from the browser client to the server side, which will be a performance and networking issue.
The mouse wheel events are not supported for Canvas, although there should be no performance issue. But probably it is not supported because in RAP
Canvasdoes not support scrollbars, so the mouse wheel support doesn't seem to be necessary.Therefore the
ScalingMouseWheelListenercan not be used in NatTable with RAP and the instantiation and registration is suppressed in case of RAP.Note that the
ScalingUiBindingConfigurationdoesn't seem to affect NatTable in RAP anyway, because the key bindings and the mouse wheel binding is used to zoom in and out via the browser and the interactions doesn't seem to be tracked in theUiBindingRegistryafterwards.org.eclipse.swt.printingandorg.eclipse.swt.programare not available in RAP and therefore now defined as optional package dependencies in the MANIFEST.RAP does not support printing, so all print related classes are not available. All print related actions in NatTable are encapsulated in
org.eclipse.nebula.widgets.nattable.print.LayerPrinter.To avoid the instantiation of a
LayerPrinterwith RAP, thePrintCommandHandlernow only triggers the instantiation and printing if the platform is not RAP.In places where the printing is customized in downstream projects, such a guard needs to be added there in case the rendering with RAP is planned.
As
org.eclipse.swt.program.Programis not available in RAP, it is not supported that a generated Excel export is directly opened after the export finishes.org.eclipse.jface.window.ToolTiporg.eclipse.jface.window.DefaultToolTipTherefore the NatTable tooltip support via
NatTableContentTooltipand subclasses likeFormulaTooltipErrorReporterare not supported in NatTable in RAP.As these classes can not even be instantiated in RAP, downstream projects need to add a guard to avoid that in their own code.
org.eclipse.jface.viewers.StyledCellLabelProviderorg.eclipse.jface.viewers.StyledStringorg.eclipse.jface.viewers.StyledString.StylerThese classes are used in the
PersistenceDialogto render the default view configuration italic.To support the
PersistenceDialogalso in RAP, a newSimpleViewConfigurationNameLabelProviderwas added that does not support the italic rendering.This
SimpleViewConfigurationNameLabelProviderwill be used in case the platform is RAP.org.eclipse.swt.graphics.Patternorg.eclipse.swt.graphics.RegionWithout the support of these two classes, the NatTable painter
BackgroundImagePainterandPercentageBarDecoratorare not supported in NatTable in RAP.They need to be removed or programmatically conditionally replaced by something else if the NatTable configuration should be used in SWT and RAP.
SWT.MeasureItemAs this event is not available in RAP, it is not possible to configure a fixed sub cell height in a
TableCellEditor.CursorconstructorsRAP does not support custom
Cursor. The necessary constructors in theCursorclass are missing.As the custom
Cursorimplementations in NatTable are registered in handlers of the mouse move events, which by default are not supported in RAP (see above), this should not be an issue for NatTable in RAP.GCinstantiation on anImageRAP only allows painting on the Canvas widget.
In NatTable there are several places where such
GCinstances are created to render the NatTable in memory for example and directly disposed to avoid resource leaks.In places that are not usable in RAP anyway (e.g. drag modes and
AutoResizeHelperin memory rendering on print) the codes stays untouched. TheNatExporternow has a guard to avoid the in memory rendering for auto resize on export too, as this leads to an exception.Also the code in
GraphicsUtilsstays untouched. The methods in charge are only used by theVerticalTextImagePainter. If vertical text rendering is required, switch to theVerticalTextPainterwhich directly renders the transformed text on NatTable and does not create a temporary image that gets rotated.In places that are reachable in RAP (e.g.
ImageExporter, ) the usage in RAP is not supported and guarded to avoid runtime issues.As of now the Nebula Extension and the E4 Extension are not usable with RAP. This is mostly due to dependency issues, e.g. there are versioned package imports that can not be satisfied by RAP/RWT or there are
Require-Bundledependencies onorg.eclipse.swtwhich can not be resolved.There is an issue related to redrawing NatTable in case of visual changes. NatTable is collecting
IVisualChangeEventsand triggers a redraw by default only every 20ms.This is to avoid that too many redraw operations are handled, which for example could happen on sorting or filtering when using GlazedLists.
The reason why this is not working in RAP is, that UI updates from a background thread are not automatically processed. This is described in more detail in RAP Developer's Guide - Server Push.
To fix this a
ServerPushSessionneeds to be created and started for a NatTable instance. As this is RAP specific API, this issue needs to be addressed in a RAP specific NatTable fragment.NatTable adds a
ResizeListenerto close an open editor if the parentCompositeis resized. This is to keep the editor position and size in synch with the NatTable presentation. Unfortunately RAP is triggering strange resize events for unknown reasons in several places.This leads to suddenly closed editors. To avoid this, the
ResizeListenerare not registered if the platform is RAP.In RAP there is a difference in the event processing compared to SWT. The order in which for example key events are processed differs, for example if a
TextCellEditoris opened in a dialog, pressing ENTER in SWT will first trigger a push on the OK button in the dialog, then key event in theTextcontrol.But in RWT the key event is first processed in the
Textcontrol and then in the dialog. Therefore the commit on enter is disabled when the platform is RAP and the editor is opened in a dialog.The
NatComboneeded a modification to be usable as cell editor in NatTable. The#notifyListener()method needs to call the super implementation, which is necessary in RAP in order to manage the lifecycle correctly. This was not necessary in SWT.With some additional checks this change does not seem to affect the
NatComboin SWT and now works correctly in RAP.A collection of limitations in RAP/RWT can be found in the RAP Developers Guide