Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug103691_TransparentPixel.java184
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java84
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug107877_TreeEditorInconsitency.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug113798_ComboSelectionEvent.java50
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug114003_MaximizedShellLocation.java77
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug119157_ShellWithoutFocus.java67
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug123091_TableEditorRefresh.java63
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug127132_TableColumnPackVirtual.java88
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133037_TreeWarnings.java46
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133039_MeasureItemRemoval.java53
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133691_PaintItemColumnWidth.java57
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug138265_SystemMemoryUsage.java117
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug144120_GLCanvasMouseEvents.java120
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug147320_ShellSetBounds.java53
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150015_MeasureEventOverflowTable.java36
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150921_TextCaretPosition.java60
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug151308_TableGetClientAreaColumn.java42
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug152916_ShellSetVisibleBounds.java32
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug171168_GridDataJVMCrash.java42
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug173335_DialogSLED10.java16
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug175964_LTRClippingGC.java111
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug182598_TreeAssertionFailed.java60
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185538_ComboNoFocus.java63
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185817_MouseListener.java149
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug186268_TableItemSetTextBottom.java70
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug191137_ActiveSelectionLost.java62
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197690_CVSWizard.java43
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197785_TextSelectionBehavior.java60
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202013_ShellControlDisposed.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202395_TableGetTopIndex.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug205199_LabelSetImageNull.java85
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug209977_GCEraseItemEventBackground.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug210915_InvisibleShellLocation.java82
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug215268_ShellSetVisibleFront.java75
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug216245_ScrollbarInconsistency.java98
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug217324_ActivateEventDialog.java68
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug218935_SashFlicker.java174
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221955_BackgroundModeQT.java83
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221962_CTabFolderCorrupted.java46
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug223864_ToolTipToolbarButton.java52
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug225725_GCDrawing.java163
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug227261_FocusTraverseException.java56
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug228031_BackgroundInheritancePreferences.java52
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230385_ControlSetGetSizeDiscrepancy.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230422_TableCheckBox.java58
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug233897_BrowserNeverExits.java35
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug236863_VirtualPerformance.java46
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug244274_ShellNoFocus.java79
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug245593_DisposeWidgetParent.java86
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug246196_getFontMetrics.java60
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug249689_MeasureEventWrongBounds.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug251354_TabItemToolTip.java69
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug261288_TreeBGColor.java42
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug262971_EraseItemNotSentScrolling.java90
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug266150_setDefaultButtonAPI.java58
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug268105_JavahelpCrash.java73
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271024_DeviceLoadFont.java28
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271032_CustomTablePainting.java79
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271404_DnDCCombo.java90
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug278882_ToolBarBackgroundImageTest.java62
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug286244_ShellActivateLoop.java57
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug288357_ComboBoxCellEditorExceptionError.java167
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug291073_CrashWhenPrintingToConsole.java69
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292413_MissingSWTFocused.java58
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292459_ToolTipFlicker.java68
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug293581_NO_REDRAW_RESIZE_noeffect.java51
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug294300_TreeRenderingPaintListener.java175
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299045_TableLines.java100
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299492_LabelCenterWrap.java83
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302918_ToolItemSetDisabledImage.java79
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302956_ControlFailedMouseEvent.java48
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302961_TableItemTrackerUpdating.java62
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug303710_ForceActive.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304020_TextLayoutPerformance.java54
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304893_CcomboColor.java43
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug312919_BrowserPaint.java65
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug319612_getSizeResizeOnTop.java56
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug321573_ImageScalingLeakTest.java55
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323044_ReadAndDispatchTrue.java71
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323240_VirtualTableSlowScroll.java90
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug336238_ShellBoundsTest.java46
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug340752_ControlGetSize.java134
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354351_MenuSizing.java78
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354842_PecoTestSnippet.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug35644_GCPaintListener.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug372607_TreeArrowExpand.java95
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug373183_gdkwindowprocessupdatesCrash.java84
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug375385_ShellFullScreen.java71
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug386271_setMenuBar.java76
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug393723_checkForegroundBug.java45
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug399522_TreeColumnNumber.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404448_ImageButtons.java71
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404946_GetActiveShellBug.java30
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug42416_GCWrongOrigin.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430538_JS_Set_Background.java108
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpandItemHeaderHeight.java31
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpanditemGetHeaderHeightIncorrect.java63
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarCroppingIssue.java77
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestFillLayout.java74
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestGridLayout.java74
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestPlain.java68
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestRowLayout.java76
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug449000_TableDrawingColumnMoved.java73
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug457196_TableRightPaddingTest.java61
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug460017_ComboOverwrite.java45
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug46059_FocusListenerSelectAll.java54
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_ListTopIndexTest.java61
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_TopIndexTest.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug465054_PaintItemTestSnippet.java59
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextFormsAbbreviated.java56
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextTest.java53
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476419_TreeWideIcons.java81
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476441_TreeIconTest.java84
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug479200_MenuTest.java70
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug480926_CellEditorPosition.java73
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug481010_ShellSize.java45
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug482457_JVMCrashMainContextIteration.java95
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug483112_TreeColumnsTest.java82
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_AllocationWarnings.java38
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_ExpandBarTest.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487467_TextTopIndexTest.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487522_TextPadding.java47
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug489640_ComboPerformanceTest.java64
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_BackgroundInheritanceTest.java48
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_ColorInheritanceTest.java48
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490713_MaximizedShellTest.java118
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug491167_TableCursorScrolling.java135
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug492783_tracker_glitches.java38
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug493552_NativeTestGDK.java54
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494218_CanvasMouseEvent.java79
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494619TreeDefaultSelectionEvent.java77
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495008_GCsetClippingGTK2.java54
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495909_topItemTree.java50
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496302_GroupComputeSizeGTK2.java128
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496639_DialogFullScreenShell.java82
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497071_LinkColorStyledText.java48
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497705_setBoundsAfterSetVisibleBroken.java145
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497707_ShellAlpha.java33
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug498165_TreeMeasureEventLoop.java54
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug499850_VirtualTableHang.java83
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500631_RHELIcons.java75
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500664_ToolTipWrongMonitor.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500814_GLCanvasCrash.java41
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500924_tabfolder_dispose_crash.java86
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug505418_Listeners_evals.java397
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug508245_TableSelectionListener.java99
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509503_VirtualTableCalculate.java85
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_LocationChangeListener.java69
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_executeCloseListener.java59
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510183_javadocHang.java83
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_editable_table_brokenGtk3.java97
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal.java74
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal_auto.java76
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug511797_locChanged.java52
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug514483_SelectionEventLostFocus.java104
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug515773_shell_ONTOP.java101
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516480_KeydownRussianlayout.java50
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516674_control_focus.java86
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517214_ComboReadOnlyWrongText.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerDouble.java89
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerWrongText.java43
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_eval_hang.java94
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_exec_hang.java142
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug55595_CursorMovementMonitor.java70
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug62247_KDEToolTip.java42
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug69650_FocusLostWhenWidgetDisposed.java53
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug71990_SlowTablePack.java146
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug74739_TableTopIndex.java180
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug75748_FlashingPageDown.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug78888_ToolBarEventInconsistency.java76
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug79462_ChildShellsPositions.java41
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug83833_SetTopIndexSelectionEvent.java49
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug84054_TableActivateEventScroll.java78
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85050_ControlResizeTabFolder.java62
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85131_ToolTipSetNull.java88
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug92176_TreeScrolling.java63
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug96500_DoubleBrowserComposite.java44
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97527_LabelSizing.java46
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97723_TreeHoverParent.java43
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97733_TableSetHeaderVisibleRedraw.java71
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97863_TableColumnDragging.java66
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug_514483_getCursorLocation.java96
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/SimpleTextTransfer.java116
183 files changed, 13371 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug103691_TransparentPixel.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug103691_TransparentPixel.java
new file mode 100644
index 0000000000..0e545a3aa8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug103691_TransparentPixel.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Created on Jul 5, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+
+public class Bug103691_TransparentPixel {
+
+// public static byte byteMe(String prompt) {
+// System.out.print(prompt + " ");
+// return Byte.parseByte(Stdin.readLine());
+// }
+
+ private static byte LO = 0;
+ private static byte MID = 1;
+ private static byte HI = 2;
+
+ private static float markOrigColor (byte orig[]) {
+ int foo[] = new int[3];
+ for (int i=0;i < 3;i++)
+ foo[i] = orig[i]<0?orig[i]+256:orig[i];
+
+ int hi, lo, mid;
+ hi = lo = mid = foo[0];
+ for (int i=1;i < 3;i++)
+ if (foo[i] > hi) {
+ mid = hi;
+ hi = foo[i];
+ }
+ else if (foo[i] < lo) {
+ mid = lo;
+ lo = foo[i];
+ }
+ else
+ mid = foo[i];
+
+ for (int i=0;i < 3;i++)
+ if (foo[i] == hi)
+ orig[i] = HI;
+ else if (foo[i] == lo)
+ orig[i] = LO;
+ else
+ orig[i] = MID;
+
+ return (mid-lo)/(float)(hi-lo);
+ }
+
+ private static void colorize(ImageData data, byte orig[], float midratio) {
+ for (int y=0;y < data.height;y++)
+ for (int x=0;x < data.width;x++) {
+ int pixel = data.getPixel(x, y);
+ if (pixel == data.transparentPixel) {
+ data.setPixel(x, y, data.palette.getPixel(new RGB(0, 0, 255)));
+ continue;
+ }
+
+ RGB pixelValue = data.palette.getRGB(data.getPixel(x, y));
+ int foo[] = new int[] {pixelValue.red, pixelValue.green, pixelValue.blue};
+ int hi, lo, mid;
+ hi = lo = mid = foo[0];
+ for (int i=1;i < 3;i++)
+ if (foo[i] > hi) {
+ mid = hi;
+ hi = foo[i];
+ }
+ else if (foo[i] < lo) {
+ mid = lo;
+ lo = foo[i];
+ }
+ else
+ mid = foo[i];
+
+ float mul = ((hi+mid+lo) / 765.0f * 255 - hi) / hi;
+ hi += mul*hi;
+// mid += mul*mid;
+ lo += mul*lo;
+
+// mul = ((hi+mid+lo) / 765.0f * hi - lo) / (hi-lo+1);
+// mid += mul*(hi-mid);
+// lo += mul*(hi-lo);
+
+ int sat = 100*(255 - lo) / (hi+1);
+// lo = mid = hi;
+ float dif = (255 - (hi-lo))/(float)255;
+ hi *= 1+dif;
+ if (hi > 255)
+ hi = 255;
+ lo -= (sat+0*dif);
+ if (lo < 0)
+ lo = 0;
+// mid *= 1+(.5f*dif);
+// if (mid > 255)
+// mid = 255;
+// mid -= sat/2;
+// if (mid < 0)
+// mid = 0;
+ mid = (int) (midratio*(hi-lo) + lo);
+
+// float mul;
+// int sum = lo+mid+hi;
+// if (sum < 510) {
+// mul = Math.abs(255-sum)/255.0f;
+// mul = 1 - (1-mul)/4;
+// hi *= mul;
+// lo *= mul;
+// mid *= mul;
+// }
+// if (sum > 255) {
+// mul = Math.abs(510-sum)/255.0f;
+// mul = 1 - (1-mul)/4;
+// hi += (255-hi)*mul;
+// lo += (255-lo)*mul;
+// mid += (255-mid)*mul;
+// }
+
+ for (int i=0;i < 3;i++)
+ if (orig[i] == HI)
+ foo[i] = hi;
+ else if (orig[i] == LO)
+ foo[i] = lo;
+ else
+ foo[i] = mid;
+ data.setPixel(x, y, data.palette.getPixel(new RGB(foo[0], foo[1], foo[2])));
+ }
+ }
+
+ public static void printArray(byte bites[]) {
+ System.out.print("[");
+ for (int i=0;i < 2;i++)
+ System.out.print((bites[i]<0?bites[i]+256:bites[i]) + ", ");
+ System.out.println((bites[2]<0?bites[2]+256:bites[2]) + "]");
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ byte orig[] = {(byte) 255, (byte) 64, (byte) 0};
+ float midratio = markOrigColor(orig);
+
+ Display display = new Display ();
+ final Shell shell = new Shell(display);
+
+ final Label label = new Label(shell,SWT.BORDER);
+ Image image = new Image(display, "/home/fmain/Downloads/smallfish.gif");
+ ImageData data = image.getImageData();
+
+ colorize(data, orig, midratio);
+
+ image = new Image(display,data);
+
+ label.setBounds(image.getBounds());
+ shell.pack();
+
+ label.setImage(image);
+
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ //widget.shell.dispose();
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java
new file mode 100644
index 0000000000..126769635f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug106798_TreeCheckBoxTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug106798_TreeCheckBoxTest {
+
+ static boolean[] myModel = new boolean[200];
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ GridLayout gridLayout = new GridLayout(1, false);
+ gridLayout.marginLeft = 10;
+ gridLayout.marginTop = 10;
+ gridLayout.marginBottom = 10;
+ gridLayout.marginRight = 10;
+ shell.setLayout(gridLayout);
+
+ final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL | SWT.CHECK
+ | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ table.addListener(SWT.SetData, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ TableItem item = (TableItem) event.item;
+ int index = table.indexOf(item);
+ boolean checked = myModel[index];
+ item.setChecked(checked);
+ item.setText(0, "Row " + index + ": " + checked);
+ }
+ });
+
+ TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+ tableColumn.setWidth(100);
+ tableColumn.setText("BlahBlah");
+
+ table.setItemCount(myModel.length);
+ table.clearAll();
+
+ table.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ if (e.detail == SWT.CHECK) {
+ TableItem item = (TableItem) e.item;
+ int index = table.indexOf(item);
+ boolean isChecked = item.getChecked();
+ myModel[index] = isChecked;
+ myModel[index / 2] = isChecked;
+ table.clear(new int[] { index, index / 2 });
+ }
+ }
+ });
+
+ shell.setSize(400, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug107877_TreeEditorInconsitency.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug107877_TreeEditorInconsitency.java
new file mode 100644
index 0000000000..68621b7987
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug107877_TreeEditorInconsitency.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug107877_TreeEditorInconsitency {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ Tree tree = new Tree(shell, SWT.NONE);
+ tree.setBounds(10,10,150,150);
+ shell.open();
+ for (int i = 0; i < 3; i++) {
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ ProgressBar pb = new ProgressBar(tree, SWT.SMOOTH);
+ pb.setSelection(50);
+ TreeEditor editor = new TreeEditor(tree);
+ editor.grabHorizontal = true;
+ editor.setEditor(pb, item);
+ }
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug113798_ComboSelectionEvent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug113798_ComboSelectionEvent.java
new file mode 100644
index 0000000000..0bdf618d50
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug113798_ComboSelectionEvent.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Based on Snippet #26. Run this as an SWT Application, and then select the
+ * first "A" from the widget.combo. Text will be printed to the console. Select the
+ * second "A" from the widget.combo, widget.text will not be printed. Open the widget.combo again,
+ * and the first "A" is still selected.
+ */
+public class Bug113798_ComboSelectionEvent {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ Combo combo = new Combo(shell, SWT.READ_ONLY);
+ combo.setItems(new String[] { "A", "A", "B", "C" });
+ combo.setSize(200, 200);
+ combo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("Widget selected");
+ }
+ });
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug114003_MaximizedShellLocation.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug114003_MaximizedShellLocation.java
new file mode 100644
index 0000000000..60323ead55
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug114003_MaximizedShellLocation.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug114003_MaximizedShellLocation
+{
+ public static void main(String[] args)
+ {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new RowLayout());
+ shell.setMaximized(true);
+ Button b = new Button(shell, SWT.NONE);
+ b.setLayoutData (new RowData (100, SWT.DEFAULT));
+
+ b.setText("hide");
+ b.addSelectionListener(new SelectionAdapter()
+ {
+
+ @Override
+ public void widgetSelected(SelectionEvent arg0)
+ {
+ shell.setVisible(false);
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ Thread.sleep(4000);
+ }
+ catch (InterruptedException e)
+ {
+ }
+
+ Display.getDefault().asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ shell.setVisible(true);
+ }
+ });
+
+ }
+ }.start();
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ System.err.println("ended");
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug119157_ShellWithoutFocus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug119157_ShellWithoutFocus.java
new file mode 100644
index 0000000000..13d3bafd62
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug119157_ShellWithoutFocus.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+
+public class Bug119157_ShellWithoutFocus {
+ static Shell dialog = null;
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell main = new Shell(display);
+ main.setLayout(new FillLayout());
+ Button button = new Button(main, SWT.PUSH);
+ button.setText("Press me");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (dialog == null) {
+ dialog = new Shell(main);
+ dialog.setLayout(new FillLayout());
+ Text text = new Text(dialog, SWT.MULTI);
+ text.setText("No focus");
+ List list = new List(dialog, SWT.MULTI);
+ list.add("Multi-select will");
+ list.add("not work");
+ list.add("the second time.");
+ Button button = new Button(dialog, SWT.PUSH);
+ button.setText("OK");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ dialog.setVisible(false);
+ }
+ });
+ dialog.setSize(400, 200);
+ }
+ dialog.setVisible(true);
+ }
+ });
+ main.setSize(200, 200);
+ main.open();
+ while (!main.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug123091_TableEditorRefresh.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug123091_TableEditorRefresh.java
new file mode 100644
index 0000000000..70755e654f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug123091_TableEditorRefresh.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+* Displays a widget.table
+*/
+public class Bug123091_TableEditorRefresh {
+ public static void main(String[] args) {
+ new Bug123091_TableEditorRefresh().run();
+ }
+
+ public void run() {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ for (int i = 0; i < 6; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setMoveable(true);
+ column.setResizable(true);
+ column.setWidth(100);
+ }
+
+ for (int i = 0; i < 10; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ for (int j = 0; j < 5; j++) {
+ item.setText(j, "Row " + i + ", Column " + j);
+ }
+ ProgressBar pbar = new ProgressBar(table, SWT.SMOOTH|SWT.RESIZE);
+ pbar.setMinimum(0);
+ pbar.setSelection(60);
+ TableEditor editor = new TableEditor(table);
+ editor.grabHorizontal = editor.grabVertical = true;
+ editor.setEditor(pbar,item,5);
+
+ }
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug127132_TableColumnPackVirtual.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug127132_TableColumnPackVirtual.java
new file mode 100644
index 0000000000..cf60163abe
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug127132_TableColumnPackVirtual.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug127132_TableColumnPackVirtual {
+
+ /*
+ * Testcase to demonstrate problem with Table not
+ * being able to pack columns for virtual tables
+ */
+
+ private static TableColumn column1;
+ private static TableColumn column2;
+ private static TableColumn column3;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+
+
+ final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.VIRTUAL);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ column1 = new TableColumn(table, SWT.NONE);
+ column1.setText("A");
+ column2 = new TableColumn(table, SWT.NONE);
+ column1.setText("B");
+ column3 = new TableColumn(table, SWT.NONE);
+ column1.setText("C");
+
+ for (int i = 0; i < 500; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
+ }
+
+ // These have no effects on Linux GTK?
+ column1.pack();
+ column2.pack();
+ column3.pack();
+
+ Button action = new Button(shell, SWT.PUSH);
+ action.setText("Pack Columns");
+ action.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // These have no effects on Linux GTK?
+ column1.pack();
+ column2.pack();
+ column3.pack();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+
+ }});
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133037_TreeWarnings.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133037_TreeWarnings.java
new file mode 100644
index 0000000000..9fd6ae533b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133037_TreeWarnings.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug133037_TreeWarnings {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 200, 200);
+ final Tree tree = new Tree(shell, SWT.NONE);
+ tree.setBounds(10,10,150,150);
+ tree.addListener(SWT.MeasureItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ new TreeColumn(tree, SWT.NONE).setWidth(100);
+ new TreeItem(tree, SWT.NONE);
+ }
+ });
+ new TreeItem(tree, SWT.NONE);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133039_MeasureItemRemoval.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133039_MeasureItemRemoval.java
new file mode 100644
index 0000000000..9eefeb873e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133039_MeasureItemRemoval.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug133039_MeasureItemRemoval {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 400, 400);
+ final Tree tree = new Tree(shell, SWT.NONE);
+ tree.setBounds(10,10,350,350);
+ final Listener measureListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ tree.removeListener(SWT.MeasureItem, this); // <---
+ event.height *= 4;
+ display.asyncExec(new Runnable() { /* asyncExec works around GP */
+ @Override
+ public void run() {
+ final TreeItem item0 = new TreeItem(tree, SWT.NONE);
+ final TreeItem item1 = new TreeItem(tree, SWT.NONE);
+ item0.setText(new String[] {"item 1"});
+ item1.setText(new String[] {"item 2"});
+ }
+ });
+ }
+ };
+ tree.addListener(SWT.MeasureItem, measureListener);
+ shell.open();
+ new TreeItem(tree, SWT.NONE).setText("item 0");
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133691_PaintItemColumnWidth.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133691_PaintItemColumnWidth.java
new file mode 100644
index 0000000000..5599e2c17b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug133691_PaintItemColumnWidth.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug133691_PaintItemColumnWidth {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,500,300);
+ final Tree tree = new Tree(shell, SWT.NONE);
+ tree.setHeaderVisible(true);
+ tree.setBounds(10,10,450,200);
+ for (int i = 0; i < 4; i++) {
+ new TreeColumn(tree, SWT.NONE).setWidth(100);
+ }
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText(new String[] {"root 0", "root 1", "root 2", "root 3"});
+ Button button = new Button(shell, SWT.PUSH);
+ button.setBounds(10,230,200,30);
+ button.setText("Add PaintItem Listener");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ tree.addListener(SWT.PaintItem, new Listener() { // <---
+ @Override
+ public void handleEvent(Event event) {
+ // do nothing
+ }
+ });
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug138265_SystemMemoryUsage.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug138265_SystemMemoryUsage.java
new file mode 100644
index 0000000000..b86b60df9f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug138265_SystemMemoryUsage.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug138265_SystemMemoryUsage {
+
+private Display display;
+private Shell shell;
+private Composite mainComposite;
+private Color color;
+
+public Bug138265_SystemMemoryUsage() {
+
+display = new Display ();
+shell = new Shell(display);
+shell.setLayout(new GridLayout());
+
+init();
+
+shell.pack();
+shell.open ();
+
+}
+
+private void init() {
+mainComposite = new Composite(shell, SWT.NONE);
+mainComposite.setLayoutData(getGridData());
+mainComposite.setLayout(new GridLayout());
+
+Composite buttonComposite = new Composite(mainComposite, SWT.NONE);
+buttonComposite.setLayoutData(getGridData());
+buttonComposite.setLayout(new GridLayout(2, true));
+
+Button button = new Button(buttonComposite, SWT.PUSH);
+button.setText("With setBackground");
+GridData gridData = getGridData();
+gridData.grabExcessVerticalSpace = false;
+button.setLayoutData(gridData);
+
+button.addSelectionListener(new SelectionAdapter() {
+@Override
+public void widgetSelected(SelectionEvent arg0) {
+createComposites(true);
+}
+});
+
+Button button2 = new Button(buttonComposite, SWT.PUSH);
+button2.setText("Without setBackground");
+gridData = getGridData();
+gridData.grabExcessVerticalSpace = false;
+button2.setLayoutData(gridData);
+
+button2.addSelectionListener(new SelectionAdapter() {
+@Override
+public void widgetSelected(SelectionEvent arg0) {
+createComposites(false);
+}
+});
+
+color = new Color(display, new RGB(31,150,192));
+
+}
+
+private void createComposites(boolean colorise) {
+for (int i = 0; i < 1500; i++) {
+Composite composite = new Composite(mainComposite, SWT.BORDER);
+if (colorise) {
+composite.setBackground(color);
+}
+composite.setLayoutData(getGridData());
+}
+}
+
+public void run() {
+while (!shell.isDisposed()) {
+if (!display.readAndDispatch()) {
+display.sleep(); }
+} display.dispose();
+}
+
+public GridData getGridData() {
+GridData gridData = new GridData();
+gridData.grabExcessHorizontalSpace = true;
+gridData.grabExcessVerticalSpace = true;
+gridData.horizontalAlignment = SWT.FILL;
+gridData.verticalAlignment = SWT.FILL;
+return gridData;
+ }
+
+
+public static void main(String[] args) {
+Bug138265_SystemMemoryUsage swtMemoryTest = new Bug138265_SystemMemoryUsage();
+swtMemoryTest.run();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug144120_GLCanvasMouseEvents.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug144120_GLCanvasMouseEvents.java
new file mode 100644
index 0000000000..c71a73de82
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug144120_GLCanvasMouseEvents.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.opengl.GLCanvas;
+import org.eclipse.swt.opengl.GLData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specificlanguage governing rights and limitations under the License.
+ *
+ * The Initial Developer of the Original Code is Gregor Mueckl.
+ * All Rights Reserved.
+ *
+ * Created on Nov 16, 2005
+ */
+
+public class Bug144120_GLCanvasMouseEvents {
+
+ private class MyMouseMoveListener implements MouseMoveListener {
+
+ @Override
+ public void mouseMove(MouseEvent event) {
+ long time=System.currentTimeMillis();
+ System.out.println(new Long(time).toString() + " mouse move: " + event.x + " " + event.y);
+ try {
+ synchronized(this) {
+ wait(100);
+ }
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private class MyMouseListener implements MouseListener {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent event) {
+ long time=System.currentTimeMillis();
+ System.out.println(new Long(time).toString() + " mouse doubleclick: " + event.x + " " + event.y);
+ }
+
+ @Override
+ public void mouseDown(MouseEvent event) {
+ long time=System.currentTimeMillis();
+ System.out.println(new Long(time).toString() + " mouse move: " + event.x + " " + event.y);
+ try {
+ synchronized(this) {
+ wait(100);
+ }
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println(new Long(time).toString() + " mouse down: " + event.x + " " + event.y);
+ }
+
+ @Override
+ public void mouseUp(MouseEvent event) {
+ long time=System.currentTimeMillis();
+ System.out.println(new Long(time).toString() + " mouse move: " + event.x + " " + event.y);
+ try {
+ synchronized(this) {
+ wait(100);
+ }
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println(new Long(time).toString() + " mouse up: " + event.x + " " + event.y);
+ }
+
+ }
+
+ public Bug144120_GLCanvasMouseEvents() {
+ Display display=new Display();
+ Shell shell=new Shell();
+ GLCanvas glcanvas=new GLCanvas(shell,0, new GLData());
+
+ glcanvas.addMouseMoveListener(new MyMouseMoveListener());
+ glcanvas.addMouseListener(new MyMouseListener());
+
+ glcanvas.setSize(300,300);
+
+ shell.pack();
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ public static void main(String args[]) {
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug147320_ShellSetBounds.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug147320_ShellSetBounds.java
new file mode 100644
index 0000000000..66c384dd89
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug147320_ShellSetBounds.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug147320_ShellSetBounds {
+
+
+ static final Rectangle[] DIMENSIONS = {
+ new Rectangle (520, 367, 240, 290),
+ new Rectangle (520, 320, 240, 320),
+ new Rectangle (320, 272, 640, 480),
+ new Rectangle (240, 212, 800, 600)};
+ static int counter = 0;
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display, SWT.NONE);
+ Button button = new Button(shell, SWT.PUSH);
+ button.setBounds(10,10,50,30);
+ button.setText("Push");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ Rectangle bounds = DIMENSIONS[counter++];
+ if (counter == 4) counter = 0;
+ System.out.println("setting to: " + bounds);
+ shell.setBounds(bounds);
+ }
+ });
+ shell.setBounds(DIMENSIONS[counter++]);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150015_MeasureEventOverflowTable.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150015_MeasureEventOverflowTable.java
new file mode 100644
index 0000000000..0dfe766a61
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150015_MeasureEventOverflowTable.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug150015_MeasureEventOverflowTable {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ final Table table = new Table(shell, SWT.NONE);
+ table.setBounds(10,10,150,150);
+ new TableItem(table, SWT.NONE).setText("item");
+ table.addListener(SWT.MeasureItem, event -> {
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150921_TextCaretPosition.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150921_TextCaretPosition.java
new file mode 100644
index 0000000000..c688da9c95
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug150921_TextCaretPosition.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug150921_TextCaretPosition {
+
+ public static void main(String [] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ Text single = new Text(shell, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 20;
+ gd.widthHint = 300;
+ single.setLayoutData(gd);
+ single.addModifyListener(new TestListener());
+ Text multi = new Text(shell, SWT.MULTI | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 100;
+ gd.widthHint = 300;
+ multi.setLayoutData(gd);
+ multi.addModifyListener(new TestListener());
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+ private static class TestListener implements ModifyListener {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ Text text = (Text) e.widget;
+ System.out.println("Text: \"" + text.getText() +"\"");
+ System.out.println("Caret Position:" + text.getCaretPosition());
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug151308_TableGetClientAreaColumn.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug151308_TableGetClientAreaColumn.java
new file mode 100644
index 0000000000..0cbbf5cbaa
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug151308_TableGetClientAreaColumn.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class Bug151308_TableGetClientAreaColumn {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,400,300);
+ final Table table = new Table(shell, SWT.NONE);
+ table.setBounds(10,10,350,250);
+ table.setHeaderVisible(true);
+ TableColumn col0 = new TableColumn(table, SWT.NONE);
+ col0.setText("column 0");
+ TableColumn col1 = new TableColumn(table, SWT.NONE);
+ col1.setText("column 1");
+ col0.pack();
+ System.out.println("col0 width: " + col0.getWidth());
+ System.out.println("widget.table clientArea: " + table.getClientArea());
+ System.out.println("col0 width: " + col0.getWidth()); // <--- !!!
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug152916_ShellSetVisibleBounds.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug152916_ShellSetVisibleBounds.java
new file mode 100644
index 0000000000..54bd964c01
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug152916_ShellSetVisibleBounds.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug152916_ShellSetVisibleBounds {
+ public static void main(String[] args) {
+ Display display = new Display();
+
+ Shell shell = new Shell(display);
+ shell.open();
+ shell.setBounds(200, 200, 200, 200);
+ System.out.println("1=" + shell.getBounds());
+ shell.setVisible(false);
+ System.out.println("2=" + shell.getBounds());
+ shell.setVisible(true);
+ System.out.println("3=" + shell.getBounds());
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug171168_GridDataJVMCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug171168_GridDataJVMCrash.java
new file mode 100644
index 0000000000..511d59a05c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug171168_GridDataJVMCrash.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug171168_GridDataJVMCrash {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ Button bz = new Button(shell, SWT.PUSH);
+ bz.setLayoutData(new GridData(SWT.END, SWT.CENTER));
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ shell.dispose();
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug173335_DialogSLED10.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug173335_DialogSLED10.java
new file mode 100644
index 0000000000..e3e35f8de5
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug173335_DialogSLED10.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+public class Bug173335_DialogSLED10 {
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug175964_LTRClippingGC.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug175964_LTRClippingGC.java
new file mode 100644
index 0000000000..0c0a0b1e0c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug175964_LTRClippingGC.java
@@ -0,0 +1,111 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+//package org.eclipse.swt.snippets;
+/*
+ * Small modifications to test the clipping for an RTL widget.tree.
+ *
+ * Tree example snippet: Images on the right side of the TreeItem
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ *
+ * @since 3.2
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug175964_LTRClippingGC {
+ static Color lightGray;
+public static void main(String [] args) {
+ Display display = new Display();
+ lightGray = new Color(null, 192, 192, 192);
+ final Image image = display.getSystemImage(SWT.ICON_INFORMATION);
+ Shell shell = new Shell(display);
+ shell.setText("Clipping rectangle for an RTL widget.tree");//"Images on the right side of the TreeItem");
+ shell.setLayout(new FillLayout ());
+ Tree tree = new Tree(shell, SWT.MULTI | SWT.FULL_SELECTION | SWT.RIGHT_TO_LEFT);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+ int columnCount = 1;//4;
+ for(int i = 0; i < columnCount; i++) {
+ TreeColumn column = new TreeColumn(tree, SWT.NONE);
+ column.setText("Column " + i);
+ }
+ int itemCount = 3;
+ for (int i=0; i<itemCount; i++) {
+ TreeItem item1 = new TreeItem(tree, SWT.NONE);
+ item1.setText("item "+i);
+ for (int c=1; c < columnCount; c++) {
+ item1.setText(c, "item ["+i+"-"+c+"]");
+ }
+ for (int j=0; j<itemCount; j++) {
+ TreeItem item2 = new TreeItem(item1, SWT.NONE);
+ item2.setText("item ["+i+" "+j+"]");
+ for (int c=1; c<columnCount; c++) {
+ item2.setText(c, "item ["+i+" "+j+"-"+c+"]");
+ }
+ for (int k=0; k<itemCount; k++) {
+ TreeItem item3 = new TreeItem(item2, SWT.NONE);
+ item3.setText("item ["+i+" "+j+" "+k+"]");
+ for (int c=1; c<columnCount; c++) {
+ item3.setText(c, "item ["+i+" "+j+" "+k+"-"+c+"]");
+ }
+ }
+ }
+ }
+ /*
+ * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.
+ * Therefore, it is critical for performance that these methods be
+ * as efficient as possible.
+ */
+ Listener paintListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+// case SWT.MeasureItem: {
+// Rectangle rect = graphics.image.getBounds();
+// event.width += rect.width;
+// event.height = Math.max(event.height, rect.height + 2);
+// break;
+// }
+ case SWT.PaintItem: {
+// int x = event.x + event.width;
+// Rectangle rect = graphics.image.getBounds();
+// int offset = Math.max(0, (event.height - rect.height) / 2);
+// event.gc.drawImage(graphics.image, x, event.y + offset);
+ event.gc.setBackground(lightGray);
+ event.gc.fillRectangle(event.gc.getClipping());
+ break;
+ }
+ }
+ }
+ };
+ tree.addListener(SWT.MeasureItem, paintListener);
+ tree.addListener(SWT.PaintItem, paintListener);
+
+ for(int i = 0; i < columnCount; i++) {
+ tree.getColumn(i).pack();
+ }
+ shell.setSize(500, 200);
+ shell.open();
+ while(!shell.isDisposed ()) {
+ if(!display.readAndDispatch()) display.sleep();
+ }
+ if(image != null) image.dispose();
+ display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug182598_TreeAssertionFailed.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug182598_TreeAssertionFailed.java
new file mode 100644
index 0000000000..6adfc4b357
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug182598_TreeAssertionFailed.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug182598_TreeAssertionFailed {
+ public static void main(String[] args) {
+
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ final Tree tree = new Tree(shell, SWT.VIRTUAL);
+ tree.setItemCount(2);
+ tree.setSelection(tree.getItem(1));
+ tree.clearAll(true);
+ tree.addListener(SWT.SetData, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ TreeItem item = (TreeItem) event.item;
+ if (item.getParentItem() == null) {
+ item.setText("item - " + event.index);
+ } else {
+ TreeItem parent = item.getParentItem();
+ int parentIndex = tree.indexOf(parent);
+ item.setText("child " + parentIndex + "/" + event.index);
+ }
+ if (event.index == 1) {
+ Thread.dumpStack();
+ tree.setItemCount(1);
+ }
+ }
+ });
+ shell.setSize(250, 150);
+ tree.setBounds(10, 10, 200, 100);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185538_ComboNoFocus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185538_ComboNoFocus.java
new file mode 100644
index 0000000000..27b6ea9c88
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185538_ComboNoFocus.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug185538_ComboNoFocus {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("Shell");
+
+ final Combo combo = new Combo(shell, SWT.NONE);
+ combo.setItems(new String[] { "do nothing", "dispose this widget.combo" });
+ Point size = combo.computeSize(-1, -1);
+ combo.setBounds(5, 5, size.x, size.y);
+ combo.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (combo.getSelectionIndex() == 1)
+ combo.dispose();
+ }
+ });
+ Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ String type = event.type == SWT.FocusIn ? "FocusIn" : "FocusOut";
+ System.out.println(type + " " + event.widget);
+ }
+ };
+ shell.addListener(SWT.FocusIn, listener);
+ shell.addListener(SWT.FocusOut, listener);
+ combo.addListener(SWT.FocusIn, listener);
+ combo.addListener(SWT.FocusOut, listener);
+
+ shell.setSize(300, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ boolean dispatch = display.readAndDispatch();
+ if (!dispatch)
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185817_MouseListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185817_MouseListener.java
new file mode 100644
index 0000000000..5f02564638
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug185817_MouseListener.java
@@ -0,0 +1,149 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * TableEditor example snippet: edit the widget.text of a widget.table item (in place)
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug185817_MouseListener {
+
+public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Table table = new Table(shell, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ for (int i = 0; i < 10; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {"item " + i, "edit this value"});
+ }
+ column1.pack();
+ column2.pack();
+
+ final TableEditor editor = new TableEditor(table);
+ //The editor must have the same size as the cell and must
+ //not be any smaller than 50 pixels.
+ editor.horizontalAlignment = SWT.LEFT;
+ editor.grabHorizontal = true;
+ editor.minimumWidth = 50;
+ // editing the second column
+ final int EDITABLECOLUMN = 1;
+
+ table.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+// // Clean up any previous editor control
+// Control oldEditor = editor.getEditor();
+// if (oldEditor != null) oldEditor.dispose();
+//
+// // Identify the selected row
+// TableItem item = (TableItem)widget.table.getItem(new Point(e.x,e.y));
+// if (item == null) return;
+//
+// // The control that will be the editor must be a child of the Table
+// Text newEditor = new Text(widget.table, SWT.NONE);
+// newEditor.setText(item.getText(EDITABLECOLUMN));
+// newEditor.addModifyListener(new ModifyListener() {
+// public void modifyText(ModifyEvent me) {
+// Text widget.text = (Text)editor.getEditor();
+// editor.getItem().setText(EDITABLECOLUMN,widget.text.getText());
+// }
+// });
+// newEditor.selectAll();
+// newEditor.setFocus();
+// editor.setEditor(newEditor, item, EDITABLECOLUMN);
+// newEditor.addFocusListener(new FocusAdapter() {
+//
+// public void focusLost(FocusEvent e) {
+// Control oldEditor = editor.getEditor();
+// if (oldEditor != null) oldEditor.dispose();
+// }
+//
+// });
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if( e.count == 2 ) {
+ System.err.println("STARTING UP THE EDITOR");
+ // Clean up any previous editor control
+ Control oldEditor = editor.getEditor();
+ if (oldEditor != null) oldEditor.dispose();
+
+ // Identify the selected row
+ TableItem item = table.getItem(new Point(e.x,e.y));
+ if (item == null) return;
+
+ // The control that will be the editor must be a child of the Table
+ Text newEditor = new Text(table, SWT.NONE);
+ newEditor.setText(item.getText(EDITABLECOLUMN));
+ newEditor.addModifyListener(me -> {
+ Text text = (Text)editor.getEditor();
+ editor.getItem().setText(EDITABLECOLUMN,text.getText());
+ });
+ newEditor.selectAll();
+ newEditor.setFocus();
+ editor.setEditor(newEditor, item, EDITABLECOLUMN);
+ newEditor.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ System.err.println("LOOSING FOCUS");
+ Control oldEditor = editor.getEditor();
+ if (oldEditor != null) oldEditor.dispose();
+ }
+
+ });
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+
+ shell.setSize(300, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug186268_TableItemSetTextBottom.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug186268_TableItemSetTextBottom.java
new file mode 100644
index 0000000000..9e77a6c5ff
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug186268_TableItemSetTextBottom.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug186268_TableItemSetTextBottom {
+
+ static final int COUNT = 1000000;
+
+ public static void main(String[] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout (new RowLayout (SWT.VERTICAL));
+ final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
+
+ table.addListener (SWT.SetData, new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ TableItem item = (TableItem) event.item;
+ int index = table.indexOf (item);
+ long startTime = System.currentTimeMillis();
+ item.setText ("Item " + index);
+ long timeTaken = System.currentTimeMillis() - startTime;
+ System.out.println ("row " + index + " took " + timeTaken +
+"ms");
+ }
+ });
+ table.setLayoutData (new RowData (200, 200));
+ Button button = new Button (shell, SWT.PUSH);
+ button.setText ("Add Items");
+ final Label label = new Label(shell, SWT.NONE);
+ button.addListener (SWT.Selection, new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ long t1 = System.currentTimeMillis ();
+ table.setItemCount (COUNT);
+ long t2 = System.currentTimeMillis ();
+ label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) +
+" (ms)");
+ shell.layout ();
+ }
+ });
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug191137_ActiveSelectionLost.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug191137_ActiveSelectionLost.java
new file mode 100644
index 0000000000..ce51bc02b2
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug191137_ActiveSelectionLost.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug191137_ActiveSelectionLost {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ Table table = new Table(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+
+ TableItem item1 = new TableItem(table, SWT.NONE);
+ item1.setText("First select this Item (click me first)");
+ TableItem item2 = new TableItem(table, SWT.NONE);
+ item2.setText("In Windows the above is blue but in Linux it is gray after step 3");
+
+ final Table dTable = new Table(table, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ TableItem dItem = new TableItem(dTable, SWT.NONE);
+ dTable.setBounds(10,60,375,175);
+ dItem.setText("Second select this item (notice first selection is gray)");
+ Button button = new Button(dTable, SWT.NONE);
+ button.setText("Third click me to dispose this widget.table.");
+ button.setBounds(10,40,350,60);
+ button.addMouseListener( new MouseListener(){
+ @Override
+ public void mouseDoubleClick(MouseEvent arg0) {}
+ @Override
+ public void mouseDown(MouseEvent arg0) {
+ dTable.dispose();
+ }
+ @Override
+ public void mouseUp(MouseEvent arg0) {}
+ });
+
+ table.setBounds(0,0,400,200);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197690_CVSWizard.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197690_CVSWizard.java
new file mode 100644
index 0000000000..095745cc17
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197690_CVSWizard.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug197690_CVSWizard {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell1 = new Shell(display);
+ shell1.setLayout(new FillLayout());
+ shell1.setBounds(10, 10, 300, 300);
+ final DateTime dt = new DateTime(shell1, SWT.DATE);
+ dt.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println(dt.getMonth());
+ System.out.println(dt.getDay());
+ System.out.println(dt.getYear());
+ }
+ });
+ shell1.open();
+ while (!shell1.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197785_TextSelectionBehavior.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197785_TextSelectionBehavior.java
new file mode 100644
index 0000000000..bf1f627633
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug197785_TextSelectionBehavior.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+
+public class Bug197785_TextSelectionBehavior
+{
+ public static void main(String[] args)
+ {
+
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ final Text text = new Text(shell, SWT.V_SCROLL | SWT.MULTI);
+ text.setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10");
+ text.setBounds(5, 5, 50, 50);
+ Text text1 = new Text(shell, SWT.None);
+ text1.setBounds(5, 100, 50, 50);
+
+ Button b = new Button(shell, SWT.PUSH);
+ b.setText("Push me");
+ b.setBounds(5, 200, 50, 20);
+ b.addListener(SWT.Selection, new Listener(){
+ @Override
+ public void handleEvent(Event e)
+ {
+
+ text.setSelection(10, 20);
+ String test = "11\n12\n13\n14\n15";
+ System.out.println(test);
+ text.insert(test);
+ // Alternative to try:
+// widget.text.setSelection(0, text1.getCharCount());
+ System.out.println("Caret line number " + text.getCaretLineNumber());
+ System.out.println("Caret position " + text.getCaretPosition());
+
+ }
+ });
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202013_ShellControlDisposed.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202013_ShellControlDisposed.java
new file mode 100644
index 0000000000..fc9ccdfedb
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202013_ShellControlDisposed.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug202013_ShellControlDisposed {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Listener listener = event -> System.out.println(event);
+ display.addFilter(SWT.KeyDown, listener);
+ display.addFilter(SWT.Traverse, listener);
+ Shell shell = new Shell();
+ shell.setLayout(new FillLayout());
+ shell.setSize(300, 75);
+
+ final Composite c = new Composite(shell, SWT.NONE);
+ c.setLayout(new FillLayout());
+
+ Button b = new Button(c, SWT.PUSH);
+ b.addListener(SWT.Selection, event -> c.dispose());
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202395_TableGetTopIndex.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202395_TableGetTopIndex.java
new file mode 100644
index 0000000000..81fa7a4e78
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug202395_TableGetTopIndex.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public class Bug202395_TableGetTopIndex {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Display display = new Display ();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.open ();
+
+ Table table = new Table(shell,SWT.BORDER|SWT.FULL_SELECTION);
+
+ new TableColumn(table, SWT.RIGHT);
+
+ TableItem tmp;
+ TableItem selection = null;
+
+ for( int i = 0; i < 100; i++ ) {
+ tmp = new TableItem(table,SWT.NONE);
+ tmp.setText(i + "");
+ if( i == 90 ) {
+ selection = tmp;
+ }
+ }
+
+ table.setSelection(new TableItem[] { selection });
+ shell.layout(true);
+
+// while( widget.table.getDisplay().readAndDispatch () ) {
+//
+// }
+
+ System.err.println("TOP-INDEX: " + table.getTopIndex());
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug205199_LabelSetImageNull.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug205199_LabelSetImageNull.java
new file mode 100644
index 0000000000..a5542bc1e6
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug205199_LabelSetImageNull.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug205199_LabelSetImageNull
+{
+ public static void main(String[] args)
+ {
+ new Bug205199_LabelSetImageNull();
+ }
+
+ private Image image;
+ private Label label;
+ private int state=0;
+
+ public Bug205199_LabelSetImageNull()
+ {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout( new FillLayout());
+
+ // Create an graphics.image
+ this.image = new Image (display, 16, 16);
+ Color color = display.getSystemColor (SWT.COLOR_RED);
+ GC gc = new GC (image);
+ gc.setBackground (color);
+ gc.fillRectangle (image.getBounds());
+ gc.dispose ();
+
+ this.label = new Label(shell,SWT.NONE);
+ Button button = new Button(shell,SWT.PUSH);
+ button.setText("click Me");
+ button.addSelectionListener(
+ new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ if (state == 0)
+ {
+ label.setImage(image);
+ label.setText("1. widget.text");
+ }
+ else if (state == 1)
+ {
+ label.setText("2. widget.text");
+ label.setImage(image);
+ }
+ else if (state == 2)
+ {
+ label.setText("3. widget.text");
+ label.setImage(null);
+ }
+ state++;
+ }
+ }
+ );
+
+ shell.open();
+ while (!shell.isDisposed())
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug209977_GCEraseItemEventBackground.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug209977_GCEraseItemEventBackground.java
new file mode 100644
index 0000000000..f96683f79b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug209977_GCEraseItemEventBackground.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug209977_GCEraseItemEventBackground {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ final Table table = new Table(shell, SWT.NONE);
+ table.setBounds(10,10,100,100);
+ new TableItem(table, SWT.NONE).setText("selected item");
+ Text text = new Text(shell, SWT.SINGLE);
+ text.setBounds(10,140,100,30);
+ table.addListener(SWT.EraseItem, event -> {
+ if ((event.detail & SWT.SELECTED) == 0) return;
+ if (table.isFocusControl()) {
+ System.out.print("selection background while focused: ");
+ } else {
+ System.out.print("selection background while not focused: ");
+ }
+ System.out.println(event.gc.getBackground());
+ });
+ table.select(0);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug210915_InvisibleShellLocation.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug210915_InvisibleShellLocation.java
new file mode 100644
index 0000000000..4fbfcb7a2f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug210915_InvisibleShellLocation.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug210915_InvisibleShellLocation {
+
+public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("Main");
+ shell.setLayout(new RowLayout());
+
+ final Button button = new Button(shell, SWT.PUSH);
+ button.setText("Show");
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ showHover(shell, button);
+ }
+ });
+ shell.setBounds(100, 100, 300, 200);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+}
+
+static void showHover(final Shell shell, final Button button) {
+ final Display display = shell.getDisplay();
+ Rectangle bb = button.getBounds();
+ final Point pos = button.toDisplay(bb.x, bb.y + bb.height + 5);
+
+ final Shell hover = new Shell(shell, SWT.ON_TOP | SWT.NO_TRIM);
+ hover.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ hover.setBounds(-30000, 0, 100, 50);
+ hover.setVisible(true);
+
+ display.asyncExec(() -> {
+ System.out.println("before setLocation:" + hover.getLocation());
+ hover.setLocation(pos);
+ System.out.println("after setLocation:" + hover.getLocation());
+ });
+
+ display.timerExec(2000, () -> {
+ Point loc = hover.getLocation();
+ System.out.println("before setVisible(false): " + loc);
+ hover.setVisible(false);
+ Point loc2 = hover.getLocation();
+ System.out.println("after setVisible(false): " + loc2);
+ });
+
+ display.timerExec(4000, () -> {
+ Point loc = hover.getLocation();
+ System.out.println("before setVisible(true): " + loc);
+ hover.setVisible(true);
+ Point loc2 = hover.getLocation();
+ System.out.println("after setVisible(true): " + loc2);
+ });
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug215268_ShellSetVisibleFront.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug215268_ShellSetVisibleFront.java
new file mode 100644
index 0000000000..281704b0f9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug215268_ShellSetVisibleFront.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.swt.widgets.Shell;
+
+
+
+public class Bug215268_ShellSetVisibleFront {
+
+
+
+ public static void main(String[] args) {
+
+ Display display = new Display ();
+
+ Shell shell = new Shell (display, SWT.SHELL_TRIM);
+
+ shell.setText("Shell1");
+
+ shell.open();
+
+ try
+
+ {
+
+ Thread.sleep(2000);
+
+ }
+
+ catch(Throwable t)
+
+ {
+
+ t.printStackTrace();
+
+ }
+
+ Shell shell2 = new Shell (display, SWT.SHELL_TRIM);
+
+ shell2.setText("Shell 2, opened with setVisible(true)");
+
+ shell2.moveBelow(shell);
+
+ shell2.setVisible(true);
+
+ while (!shell.isDisposed ()) {
+
+ if (!display.readAndDispatch ()) display.sleep ();
+
+ }
+
+ display.dispose ();
+
+
+
+ }
+
+
+}
+
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug216245_ScrollbarInconsistency.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug216245_ScrollbarInconsistency.java
new file mode 100644
index 0000000000..981df50e20
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug216245_ScrollbarInconsistency.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug216245_ScrollbarInconsistency {
+
+ public static void main(String[] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FormLayout());
+
+ Button button = new Button(shell, SWT.BORDER);
+ button.setText("Press Me");
+ FormData data = new FormData();
+ data.top = new FormAttachment(0);
+ data.left = new FormAttachment(0);
+ data.right = new FormAttachment(100);
+ data.bottom = new FormAttachment(20);
+ button.setLayoutData(data);
+
+ final Canvas canvas = new Canvas(shell, SWT.BORDER);
+ data = new FormData();
+ data.top = new FormAttachment(button);
+ data.left = new FormAttachment(0);
+ data.right = new FormAttachment(100);
+ data.bottom = new FormAttachment(100);
+ canvas.setLayoutData(data);
+
+ canvas.setLayout(new FillLayout());
+ final Table table = new Table(canvas, SWT.NONE);
+ table.setHeaderVisible(true);
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ column1.setText("Column1");
+ column1.setWidth(100);
+
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ column2.setText("Column2");
+ column2.setWidth(200);
+
+ for (int i = 0; i < 1000; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText("item" + i);
+ }
+
+ button.addSelectionListener(new SelectionListener(){
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ ScrollBar verticalScrollBar = table.getVerticalBar();
+ if(verticalScrollBar != null && !verticalScrollBar.isDisposed())
+ {
+ if(verticalScrollBar.isEnabled()) {
+// widget.table.setEnabled(false);
+ verticalScrollBar.setEnabled(false);
+ } else {
+// widget.table.setEnabled(true);
+ verticalScrollBar.setEnabled(true);
+ }
+ }
+ }});
+ shell.setSize(300, 400);
+ shell.open ();
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug217324_ActivateEventDialog.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug217324_ActivateEventDialog.java
new file mode 100644
index 0000000000..d8d813b29c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug217324_ActivateEventDialog.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+
+public class Bug217324_ActivateEventDialog
+{
+
+ public static void main(String[] args)
+ {
+ Display display = new Display();
+ display.addFilter(SWT.Activate, new Listener()
+ {
+ @Override
+ public void handleEvent(Event event)
+ {
+ System.out.println("activate: " + event);
+ }
+ });
+
+ display.addFilter(SWT.Deactivate, new Listener()
+ {
+ @Override
+ public void handleEvent(Event event)
+ {
+ System.out.println("deactivate: " + event);
+ }
+ });
+
+ Shell shell = new Shell(display);
+ shell.setText("Shell");
+ shell.setSize(200, 200);
+ System.out.println("before widget.shell open");
+ shell.open();
+ System.out.println("after widget.shell open");
+
+ System.out.println("set visible false before");
+ shell.setVisible(false);
+ System.out.println("set visible false after");
+
+ Shell dialog = new Shell(shell);
+ dialog.setText("Dialog");
+ dialog.setSize(200, 200);
+ System.out.println("before dialog open");
+ dialog.open();
+ System.out.println("after dialog open");
+
+ // When dialog is closed no activate event
+
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug218935_SashFlicker.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug218935_SashFlicker.java
new file mode 100644
index 0000000000..c8a0ed6d79
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug218935_SashFlicker.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Sash;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug218935_SashFlicker {
+ private class CursorListener implements MouseMoveListener, MouseTrackListener {
+ private Bug218935_SashFlicker main;
+
+ public CursorListener(Bug218935_SashFlicker main) {
+ this.main = main;
+ }
+
+ @Override
+ public void mouseMove(MouseEvent e) {
+ main.setCursor(e.x);
+ }
+
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ main.setVisible(true);
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e) {
+ main.setVisible(false);
+ }
+
+ @Override
+ public void mouseHover(MouseEvent e) {
+ }
+ }
+
+ public Bug218935_SashFlicker() {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 400, 400);
+ shell.setText("GTK Sash flicker");
+ shell.setLayout(new FillLayout());
+
+ Composite composite = new Composite(shell, SWT.NO_BACKGROUND);
+ composite.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
+
+ GridLayout gridLayout = new GridLayout(1, true);
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 0;
+ composite.setLayout(gridLayout);
+
+ composite.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ e.gc.fillRectangle(e.x, e.y, e.width, e.height);
+ }
+ });
+
+
+ Canvas canvas = new Canvas(composite, SWT.None);
+ canvas.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+
+ canvas.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
+
+ canvas.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ e.gc.fillRectangle(e.x, e.y, e.width, e.height);
+ }
+ });
+
+ Sash sash = new Sash(composite, SWT.NO_BACKGROUND);
+ sash.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
+
+ final GridData sashData = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1);
+ sashData.heightHint = 40;
+ sash.setLayoutData(sashData);
+
+ sash.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ System.err.println(e);
+ e.gc.fillRectangle(e.x, e.y, e.width, e.height);
+ }
+ });
+
+ createCursor(composite);
+
+ CursorListener cursorListener = new CursorListener(this);
+ canvas.addMouseMoveListener(cursorListener);
+ canvas.addMouseTrackListener(cursorListener);
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ new Bug218935_SashFlicker();
+ }
+
+ private Canvas cursorLine;
+
+ private void createCursor(Composite parent) {
+ cursorLine = new Canvas(parent, SWT.NO_BACKGROUND);
+ cursorLine.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
+
+ final GridData cursorLineData = new GridData();
+ cursorLineData.exclude = true;
+ cursorLine.setLayoutData(cursorLineData);
+
+ cursorLine.setSize(1, Integer.MAX_VALUE);
+ cursorLine.setVisible(false);
+ cursorLine.setEnabled(false);
+
+ cursorLine.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Canvas w = ((Canvas)e.widget);
+ Point p = w.getSize();
+ e.gc.drawRectangle(0, 0, p.x, p.y);
+ }
+ });
+ }
+
+
+ void setVisible(boolean visible) {
+ cursorLine.setVisible(visible);
+
+ if (visible) {
+ //Place the cursor above all widgets
+ cursorLine.moveAbove(null);
+ }
+ }
+
+
+ void setCursor(int x) {
+ cursorLine.setLocation(x, 0);
+ cursorLine.getParent().update();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221955_BackgroundModeQT.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221955_BackgroundModeQT.java
new file mode 100644
index 0000000000..bb5985f99c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221955_BackgroundModeQT.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class Bug221955_BackgroundModeQT {
+
+ public static void main( final String[] args ) {
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ shell.setText( "BackgroundMode" );
+ createContent( shell );
+ shell.pack();
+ shell.open();
+ while( !shell.isDisposed() ) {
+ if( !display.readAndDispatch() )
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void createContent( final Composite parent ) {
+ parent.setLayout( new GridLayout( 4, false ) );
+ Color bgColor = parent.getDisplay().getSystemColor( SWT.COLOR_RED );
+
+ Group group1 = new Group( parent, SWT.NONE );
+ group1.setBackground( bgColor );
+ group1.setBackgroundMode( SWT.INHERIT_NONE );
+ group1.setText( "INHERIT_NONE" );
+ createControls( group1 );
+
+ Group group2 = new Group( parent, SWT.NONE );
+ group2.setBackground( bgColor );
+ group2.setBackgroundMode( SWT.INHERIT_DEFAULT );
+ group2.setText( "INHERIT_DEFAULT" );
+ createControls( group2 );
+
+ Group group3 = new Group( parent, SWT.NONE );
+ group3.setBackground( bgColor );
+ group3.setBackgroundMode( SWT.INHERIT_FORCE );
+ group3.setText( "INHERIT_FORCE" );
+ createControls( group3 );
+ }
+
+ private static void createControls( final Composite parent ) {
+ parent.setLayout( new GridLayout() );
+ Label label = new Label( parent, SWT.NONE );
+ label.setText( "Test Label" );
+ Label blueLabel = new Label( parent, SWT.NONE );
+ blueLabel.setText( "Blue Label" );
+ blueLabel.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_BLUE ) );
+ CLabel clabel = new CLabel( parent, SWT.NONE );
+ clabel.setText( "Test CLabel" );
+ Button button = new Button( parent, SWT.PUSH );
+ button.setText( "Test Button" );
+ Button checkbox = new Button( parent, SWT.CHECK );
+ checkbox.setText( "Test Checkbox" );
+ List list = new List( parent, SWT.BORDER );
+ list.add( "Test List" );
+ list.add( "" );
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221962_CTabFolderCorrupted.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221962_CTabFolderCorrupted.java
new file mode 100644
index 0000000000..6920d1d9e9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug221962_CTabFolderCorrupted.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug221962_CTabFolderCorrupted {
+
+ public static final void main(final String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText( "CTabFolder Test" );
+ shell.setLayout( new FillLayout() );
+ CTabFolder folder = new CTabFolder( shell, SWT.BORDER|SWT.FLAT );
+
+ folder.setSimple(false);
+ CTabItem item;
+ item = new CTabItem(folder,SWT.NONE);
+ item.setText("First");
+ item = new CTabItem(folder, SWT.CLOSE);
+ item.setText("Second");
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug223864_ToolTipToolbarButton.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug223864_ToolTipToolbarButton.java
new file mode 100644
index 0000000000..748ef70024
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug223864_ToolTipToolbarButton.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug223864_ToolTipToolbarButton {
+
+ public static void main(String[] args) {
+ Display display= new Display();
+ Shell parent= new Shell(display);
+ parent.setText("Parent");
+
+ Shell child= new Shell(parent, SWT.ON_TOP | SWT.SHELL_TRIM);
+ GridLayout gridLayout= new GridLayout(1, false);
+ child.setLayout(gridLayout);
+ ToolBar bar= new ToolBar(child, SWT.NONE);
+ ToolItem button= new ToolItem(bar, SWT.PUSH);
+ button.setImage(display.getSystemImage(SWT.ICON_QUESTION));
+ button.setToolTipText("Do you see me?");
+
+ parent.setBounds(100, 100, 160, 100);
+ child.setBounds(150, 150, 160, 100);
+
+ parent.open();
+
+ child.setVisible(true);
+ child.setActive(); // comment this out and widget.tooltip appears...
+ parent.setActive();
+
+ while (!parent.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug225725_GCDrawing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug225725_GCDrawing.java
new file mode 100644
index 0000000000..313609c06b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug225725_GCDrawing.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Path;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug225725_GCDrawing {
+
+ public static void main(String[] s){
+ Display display = new Display();
+
+ Shell shell = new Shell( display );
+ shell.setLayout( new GridLayout() );
+ shell.setSize(300,400);
+
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ MenuItem menuBarItem = new MenuItem(menuBar, SWT.CASCADE);
+ menuBarItem.setText("File");
+
+ Menu menu1 = new Menu(shell, SWT.DROP_DOWN);
+ MenuItem menuItem = new MenuItem(menu1, SWT.PUSH);
+ menuItem.setText("Exit");
+
+ menuBarItem.setMenu(menu1);
+ shell.setMenuBar( menuBar );
+
+ ToolBar toolBar = new ToolBar(shell, SWT.FLAT | SWT.WRAP | SWT.RIGHT);
+
+ ToolItem item1 = new ToolItem(toolBar, SWT.PUSH);
+ item1.setText("Item1");
+
+ ToolItem item2 = new ToolItem(toolBar, SWT.PUSH);
+ item2.setText("Item1");
+
+ final Composite composite = new Composite(shell , SWT.BORDER | SWT.DOUBLE_BUFFERED | SWT.H_SCROLL | SWT.V_SCROLL);
+ composite.setLayout(new FillLayout());
+ composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
+ composite.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ ScrollBar xScroll = composite.getHorizontalBar();
+ ScrollBar yScroll = composite.getVerticalBar();
+ paintSomething( e.gc, -xScroll.getSelection(), -yScroll.getSelection());
+ }
+ });
+
+ final ScrollBar hBar = composite.getHorizontalBar();
+ hBar.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ composite.redraw();
+ }
+ });
+
+ final ScrollBar vBar = composite.getVerticalBar();
+ vBar.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ composite.redraw();
+ }
+ });
+
+ composite.addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent arg0) {
+ Rectangle bounds = composite.getBounds();
+ Rectangle client = composite.getClientArea();
+ ScrollBar hBar = composite.getHorizontalBar();
+ ScrollBar vBar = composite.getVerticalBar();
+ hBar.setMaximum(500);
+ vBar.setMaximum(500);
+ hBar.setThumb(Math.min(bounds.width, client.width));
+ vBar.setThumb(Math.min(bounds.height, client.height));
+ }
+ });
+
+ Button newGC = new Button( shell , SWT.PUSH );
+ newGC.setText("Direct Paint");
+ newGC.setLayoutData(new GridData(SWT.FILL,SWT.BOTTOM,true,false));
+ newGC.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ GC gc = new GC( composite );
+ ScrollBar xScroll = composite.getHorizontalBar();
+ ScrollBar yScroll = composite.getVerticalBar();
+ paintSomething(gc, -xScroll.getSelection(), -yScroll.getSelection());
+ gc.dispose();
+ }
+ });
+
+ shell.open();
+ while( !shell.isDisposed() ){
+ if(display.readAndDispatch()){
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ System.exit(0);
+ }
+
+ private static void paintSomething(GC gc, int fromX, int fromY){
+ int x = fromX + 20;
+ int y = fromY + 20;
+
+ String str = "Test";
+ Point strSize = gc.stringExtent(str);
+
+
+ gc.drawString( str ,x, y);
+
+ gc.setLineStyle(SWT.LINE_DASH);
+ gc.setLineWidth(1);
+ Path path = new Path( gc.getDevice() );
+ path.addRectangle( x + 110, y + strSize.y, 100, 100 );
+ gc.drawPath( path );
+ path.dispose();
+ gc.setLineStyle(SWT.LINE_SOLID);
+
+ path = new Path( gc.getDevice() );
+ path.moveTo( x , 20 );
+ path.addRectangle( x, y + strSize.y, 100, 100 );
+ gc.drawPath( path );
+ path.dispose();
+
+ gc.drawString( str ,x, y + strSize.y + 101);
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug227261_FocusTraverseException.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug227261_FocusTraverseException.java
new file mode 100644
index 0000000000..0d4dbc3991
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug227261_FocusTraverseException.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug227261_FocusTraverseException {
+
+ public static void main(String[] args) {
+ Display display = Display.getDefault();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.setSize(new Point(300, 200));
+ final Composite composite = new Composite(shell, SWT.NONE);
+ composite.setSize(new Point(300, 200));
+ composite.setLayout(new GridLayout());
+ Text text = new Text(composite, SWT.BORDER);
+ text.addFocusListener(new FocusAdapter(){
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ composite.dispose();
+ }
+
+ });
+ Button button = new Button(composite, SWT.PUSH);
+ button.setText("Focus?");
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug228031_BackgroundInheritancePreferences.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug228031_BackgroundInheritancePreferences.java
new file mode 100644
index 0000000000..e8f56f52ee
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug228031_BackgroundInheritancePreferences.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+public class Bug228031_BackgroundInheritancePreferences {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ TabFolder parent = new TabFolder(shell, SWT.NONE);
+
+ Composite c1 = new Composite(parent, SWT.NONE);
+ c1.setLayout(new FillLayout());
+
+ // inherits gtk bg graphics.color
+// Composite child = new Composite(c1, SWT.NONE);
+
+ new Composite(c1, SWT.H_SCROLL|SWT.V_SCROLL);
+
+
+ TabItem item = new TabItem(parent, SWT.NONE);
+ item.setText("tab item");
+ item.setControl(c1);
+
+ shell.setSize(400, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230385_ControlSetGetSizeDiscrepancy.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230385_ControlSetGetSizeDiscrepancy.java
new file mode 100644
index 0000000000..d115538c48
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230385_ControlSetGetSizeDiscrepancy.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug230385_ControlSetGetSizeDiscrepancy {
+
+ private static final int SIZE_X = 500;
+ private static final int SIZE_Y = 350;
+
+ public static void main(String[] args) {
+
+ final Display display = new Display();
+ final Shell shell = new Shell();
+
+ shell.setSize(SIZE_X, SIZE_Y);
+ shell.open();
+
+ System.out.println("Size should be : " + SIZE_X + "x" + SIZE_Y);
+ System.out.println("Size actually is: " + shell.getSize().x + "x" +
+ shell.getSize().y + " [as returned by Control.getSize()]");
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230422_TableCheckBox.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230422_TableCheckBox.java
new file mode 100644
index 0000000000..11abaddb4b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug230422_TableCheckBox.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug230422_TableCheckBox {
+ public static void main (String [] args) {
+
+
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new GridLayout());
+ Table table = new Table (shell, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
+ table.setLinesVisible (true);
+ table.setHeaderVisible (true);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = 200;
+ table.setLayoutData(data);
+ String[] titles = {" ", "C", "!", "Description", "Resource", "In Folder", "Location"};
+ for (int i=0; i<titles.length; i++) {
+ TableColumn column = new TableColumn (table, SWT.CENTER);
+ column.setText (titles [i]);
+ }
+ int count = 128;
+ for (int i=0; i<count; i++) {
+ TableItem item = new TableItem (table, SWT.NONE);
+ item.setText (0, "x");
+ item.setText (1, "y");
+ item.setText (2, "!");
+ item.setText (3, "this stuff behaves the way I expect");
+ item.setText (4, "almost everywhere");
+ item.setText (5, "some.folder");
+ item.setText (6, "line " + i + " in nowhere");
+ }
+ for (int i=0; i<titles.length; i++) {
+ table.getColumn (i).pack ();
+ }
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug233897_BrowserNeverExits.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug233897_BrowserNeverExits.java
new file mode 100644
index 0000000000..75c7796cb1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug233897_BrowserNeverExits.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug233897_BrowserNeverExits {
+
+ public static void main(String[] args) {
+ Display display = new Display ();
+ Shell shell = new Shell(display);
+ new Browser( shell, SWT.None );
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ())
+ display.sleep ();
+ }
+ display.dispose ();
+ System.out.println("finished");
+ }
+
+}
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug236863_VirtualPerformance.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug236863_VirtualPerformance.java
new file mode 100644
index 0000000000..32fb2dcd4a
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug236863_VirtualPerformance.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+public class Bug236863_VirtualPerformance {
+ static final int ROWS = 3000000;
+ public static void main (String [] args) {
+ final Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout (new FillLayout ());
+ final Table table = new Table (shell, SWT.VIRTUAL);
+ table.setHeaderVisible (true);
+ table.addListener (SWT.SetData, new Listener () {
+ @Override
+ public void handleEvent (Event e) {
+ TableItem item = (TableItem) e.item;
+ item.setText ("test");
+ }
+ });
+ TableColumn column = new TableColumn (table, SWT.NONE);
+ column.setText ("Column 1");
+ column.setWidth (80);
+
+ long start = System.currentTimeMillis();
+ table.setItemCount (ROWS);
+ System.out.println("" + (System.currentTimeMillis() - start) + "ms");
+
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug244274_ShellNoFocus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug244274_ShellNoFocus.java
new file mode 100644
index 0000000000..0551cb5bbe
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug244274_ShellNoFocus.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.layout.FillLayout;
+
+public class Bug244274_ShellNoFocus {
+ private Shell sShell = null;
+ private Tree tree = null;
+
+ private void createTree() {
+ tree = new Tree(sShell, SWT.NONE);
+ }
+
+ public static void main(String[] args) {
+ Display display = Display.getDefault();
+ Bug244274_ShellNoFocus thisClass = new Bug244274_ShellNoFocus();
+ thisClass.createSShell();
+ thisClass.sShell.open();
+
+ while (!thisClass.sShell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private void createSShell() {
+ sShell = new Shell();
+ sShell.setText("Shell");
+ sShell.setLayout(new FillLayout());
+ createTree();
+ populateTree();
+ sShell.setSize(new Point(300, 200));
+ }
+
+ private void populateTree() {
+ if(tree!=null && !tree.isDisposed()){
+ TreeItem rootItem = new TreeItem(tree, SWT.NULL);
+ rootItem.setText("Root");
+
+ TreeItem item11 = new TreeItem(rootItem, SWT.NULL);
+ item11.setText("1");
+
+ TreeItem item111 = new TreeItem(item11, SWT.NULL);
+ item111.setText("1_1");
+ TreeItem item112 = new TreeItem(item11, SWT.NULL);
+ item112.setText("1_2");
+
+ TreeItem item1111 = new TreeItem(item111, SWT.NULL);
+ item1111.setText("1_1_1");
+ TreeItem item1112 = new TreeItem(item111, SWT.NULL);
+ item1112.setText("1_1_2");
+
+ item1111.setExpanded(true);
+ item1112.setExpanded(true);
+ item111.setExpanded(true);
+ item112.setExpanded(true);
+ item11.setExpanded(true);
+ rootItem.setExpanded(true);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug245593_DisposeWidgetParent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug245593_DisposeWidgetParent.java
new file mode 100644
index 0000000000..7be8d04d52
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug245593_DisposeWidgetParent.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This Snippet is supposed to demonstrate a probable Bug in SWT for gtk. It causes a general protection fault when you do the following:
+ * - launch as swt app
+ * - focus the first textfield
+ * - click into the second textfield
+ * - click back into the first one --> should crash with a GPF with: Symbol=IA__gtk_container_set_focus_child . The symbol changes from time to time to g_object_lib but is the focus_child one most of the time
+ * - it usually happens the first time this is done but you sometimes might have to do it 2-3 times
+ *
+ * The Problem seems to arise because the widget that looses focus is disposed during its own focus event processing. Though this works without problems on windows plattforms.
+ * @author psimon
+ *
+ */
+public class Bug245593_DisposeWidgetParent {
+ Shell shell;
+
+ public Bug245593_DisposeWidgetParent() {
+ final Display display = new Display();
+ shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.setSize(200,200);
+ createWidgets();
+ shell.open ();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+ public static void main(String [] args) {
+ new Bug245593_DisposeWidgetParent();
+ }
+
+ public void disposeWidgets(){
+ parent.dispose();
+ }
+
+ private Composite parent;
+
+ public void createWidgets(){
+ parent = new Composite(shell,SWT.NONE);
+ parent.setLayout(new GridLayout(2,true));
+ Text triggerText = new Text(parent,SWT.BORDER);
+ triggerText.setText("widget.text 1");
+ Text looseFocus = new Text(parent,SWT.BORDER);
+ looseFocus.setText("widget.text 2");
+ triggerText.addFocusListener(new FocusAdapter(){
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ triggerRefresh();
+ }
+
+ });
+
+ shell.layout();
+ }
+
+ public void triggerRefresh(){
+ disposeWidgets();
+ createWidgets();
+ shell.layout();
+ }
+
+ } \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug246196_getFontMetrics.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug246196_getFontMetrics.java
new file mode 100644
index 0000000000..2007e16dec
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug246196_getFontMetrics.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug246196_getFontMetrics {
+
+ public static void main(String[] args) {
+ long start, end;
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ System.out.println("========for default graphics.font==========");
+
+ GC gc = new GC(shell);
+ System.out.println("for first time");
+ start = System.currentTimeMillis();
+ gc.getFontMetrics();
+ end = System.currentTimeMillis();
+ System.out.println("in total:" + (end - start));
+ System.out.println("for second time");
+ start = System.currentTimeMillis();
+ gc.getFontMetrics();
+ end = System.currentTimeMillis();
+ System.out.println("in total:" + (end - start));
+ System.out.println("===============================");
+
+ System.out.println("=======for Sans Italic============");
+ Font font = new Font(display, "Sans", 10, SWT.ITALIC);
+ gc.setFont(font);
+ System.out.println("for first time");
+ start = System.currentTimeMillis();
+ gc.getFontMetrics();
+ end = System.currentTimeMillis();
+ System.out.println("in total:" + (end - start));
+ System.out.println("for second time");
+ start = System.currentTimeMillis();
+ gc.getFontMetrics();
+ end = System.currentTimeMillis();
+ System.out.println("in total:" + (end - start));
+ System.out.println("===============================");
+ shell.dispose();
+ display.dispose();
+ }
+}
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug249689_MeasureEventWrongBounds.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug249689_MeasureEventWrongBounds.java
new file mode 100644
index 0000000000..072263b0d1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug249689_MeasureEventWrongBounds.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug249689_MeasureEventWrongBounds {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Image image = new Image(display, "/home/ericwill/downloads/yrv9.png");
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,800,200);
+ shell.setLayout(new FillLayout());
+ final Table table = new Table(shell, SWT.CHECK);
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {"a","a2"});
+ table.addListener(SWT.MeasureItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ event.gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ event.gc.drawRectangle(event.x, event.y, event.width, event.height);
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ image.dispose();
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug251354_TabItemToolTip.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug251354_TabItemToolTip.java
new file mode 100644
index 0000000000..7830c9da14
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug251354_TabItemToolTip.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+public class Bug251354_TabItemToolTip {
+ public void run() {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ shell.setText("Show ToolTips");
+ shell.setToolTipText("Shell");
+ create(shell);
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+ private void create(Shell shell) {
+ final TabFolder tabFolder1 = new TabFolder(shell, SWT.NONE);
+ tabFolder1.setToolTipText("Tabfolder1");
+ Text text = new Text(tabFolder1, SWT.BORDER);
+ text.setToolTipText("Text");
+ for (int i = 0; i < 4; i++)
+ {
+ TabItem item = new TabItem(tabFolder1, SWT.CLOSE);
+ item.setText("Item "+i);
+ item.setControl(text);
+ item.setToolTipText("Item "+i);
+ }
+
+ final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem one = new TabItem(tabFolder, SWT.NONE);
+ one.setText("Tab 1");
+// one.setToolTipText("This is Tab 1.");
+
+ TabItem two = new TabItem(tabFolder, SWT.NONE);
+ two.setText("Tab 2");
+// two.setToolTipText("This is Tab 2.");
+
+ TabItem three = new TabItem(tabFolder, SWT.NONE);
+ three.setText("Tab 3");
+ three.setToolTipText("This is Tab 3.");
+
+ TabItem four = new TabItem(tabFolder, SWT.NONE);
+ four.setText("Tab 4");
+ four.setToolTipText("This is Tab 4.");
+
+ }
+ public static void main(String[] args) {
+ new Bug251354_TabItemToolTip().run();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug261288_TreeBGColor.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug261288_TreeBGColor.java
new file mode 100644
index 0000000000..f8b87f0b67
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug261288_TreeBGColor.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug261288_TreeBGColor {
+
+ public static void main( final String[] args ) {
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ shell.setLayout( new FillLayout() );
+
+ Tree tree = new Tree( shell, SWT.BORDER | SWT.SINGLE );
+ TreeItem rootItem = new TreeItem( tree, SWT.NONE );
+ rootItem.setText( "Root" );
+ for( int i = 0; i < 5; i++ ) {
+ TreeItem item = new TreeItem( rootItem, SWT.NONE );
+ item.setText( "Node " + ( i + 1 ) );
+ }
+ tree.setBackground( display.getSystemColor( SWT.COLOR_RED ) );
+
+ shell.setSize( 400, 300 );
+ shell.open();
+ while( !shell.isDisposed() ) {
+ if( !display.readAndDispatch() )
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug262971_EraseItemNotSentScrolling.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug262971_EraseItemNotSentScrolling.java
new file mode 100644
index 0000000000..460e1e09b5
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug262971_EraseItemNotSentScrolling.java
@@ -0,0 +1,90 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * Table example snippet: create a widget.table (columns, headers, lines)
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug262971_EraseItemNotSentScrolling {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ Table table = new Table(shell, SWT.MULTI | SWT.BORDER
+ | SWT.FULL_SELECTION);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = 200;
+ table.setLayoutData(data);
+ String[] titles = { " ", "C", "!", "Description", "Resource",
+ "In Folder", "Location" };
+ for (int i = 0; i < titles.length; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText(titles[i]);
+ }
+ int count = 128;
+ for (int i = 0; i < count; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(0, "x");
+ item.setText(1, "y");
+ item.setText(2, "!");
+ item.setText(3, "this stuff behaves the way I expect");
+ item.setText(4, "almost everywhere");
+ item.setText(5, "some.folder");
+ item.setText(6, "line " + i + " in nowhere");
+ }
+ for (int i = 0; i < titles.length; i++) {
+ table.getColumn(i).pack();
+ }
+
+ //Listeners
+
+ table.addListener(SWT.EraseItem, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.index ==1)
+ System.out.println("x = " + event.y + "\t" + "y = " + event.y);
+ }});
+
+ table.getHorizontalBar().addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("scroll.selection");
+
+ }});
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug266150_setDefaultButtonAPI.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug266150_setDefaultButtonAPI.java
new file mode 100644
index 0000000000..bbf442af3b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug266150_setDefaultButtonAPI.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug266150_setDefaultButtonAPI {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout(2, false));
+
+ final Button one = new Button(shell, SWT.PUSH);
+ one.setText("one"); //$NON-NLS-1$
+ one.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("one set to default"); //$NON-NLS-1$
+ shell.setDefaultButton(one);
+ }
+ });
+
+ Button two = new Button(shell, SWT.PUSH);
+ two.setText("two"); //$NON-NLS-1$
+ two.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("null set to default"); //$NON-NLS-1$
+ shell.setDefaultButton(null);
+ }
+ });
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug268105_JavahelpCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug268105_JavahelpCrash.java
new file mode 100644
index 0000000000..ec7b3b338c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug268105_JavahelpCrash.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+// This snippet causes errors on a regular setup. Commenting out for now.
+//
+//import java.awt.Frame;
+//
+//import javax.help.HelpSet;
+//import javax.help.HelpSetException;
+//import javax.help.JHelp;
+//import javax.swing.UIManager;
+//import javax.swing.UnsupportedLookAndFeelException;
+//
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.awt.SWT_AWT;
+//import org.eclipse.swt.layout.FillLayout;
+//import org.eclipse.swt.widgets.Composite;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Shell;
+//
+//public class Bug268105_JavahelpCrash {
+//
+// public static void main(String[] args) {
+// HelpSet helpSet;
+// Display display;
+// Shell widget.shell;
+// Composite composite;
+// Frame frame;
+// JHelp help;
+//
+// try {
+// helpSet = new HelpSet(null, HelpSet.findHelpSet(null, "Animals.hs"));
+// } catch (HelpSetException e) {
+// e.printStackTrace();
+// return;
+// }
+//
+// try {
+// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+// } catch (Exception e) {
+// e.printStackTrace();
+// return;
+// }
+//
+// display = new Display();
+// widget.shell = new Shell(display);
+// widget.shell.setLayout(new FillLayout());
+// composite = new Composite(widget.shell, SWT.NO_BACKGROUND | SWT.EMBEDDED);
+// frame = SWT_AWT.new_Frame(composite);
+// help = new JHelp(helpSet);
+// frame.add(help);
+//
+// frame.setVisible(true);
+// widget.shell.open();
+//
+// while (!widget.shell.isDisposed())
+// if (!display.readAndDispatch())
+// display.sleep();
+//
+// display.dispose();
+// }
+//
+//} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271024_DeviceLoadFont.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271024_DeviceLoadFont.java
new file mode 100644
index 0000000000..e26d9d09c9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271024_DeviceLoadFont.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.Display;
+
+public class Bug271024_DeviceLoadFont {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ if(display.loadFont("garbage.ttf")) {
+ System.out.println("Should not have got here!");
+ } else {
+ System.out.println("OK, this graphics.font does not exist.");
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271032_CustomTablePainting.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271032_CustomTablePainting.java
new file mode 100644
index 0000000000..dde8c5b7ef
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271032_CustomTablePainting.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug271032_CustomTablePainting {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new RowLayout(SWT.VERTICAL));
+ shell.setSize(300, 400);
+
+ Button button = new Button(shell, SWT.PUSH);
+ button.setText("Unselect All");
+ button.pack();
+
+ final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ table.deselectAll();
+ }
+ });
+
+ table.addListener(SWT.EraseItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+// event.detail &= ~SWT.SELECTED;
+ event.detail &= ~SWT.FOCUSED;
+ }
+ });
+
+ TableColumn column0 = new TableColumn(table, SWT.CENTER);
+ TableColumn column1 = new TableColumn(table, SWT.CENTER);
+ TableColumn column2 = new TableColumn(table, SWT.CENTER);
+
+ for(int row = 0; row < 10; row++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {"garbage", "garbage", "garbage"});
+ }
+
+ column0.pack();
+ column1.pack();
+ column2.pack();
+
+ shell.open();
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271404_DnDCCombo.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271404_DnDCCombo.java
new file mode 100644
index 0000000000..84c1854c29
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug271404_DnDCCombo.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug271404_DnDCCombo
+{
+
+
+
+ public static void main( String[] args )
+ {
+ Shell shell = new Shell( );
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ shell.setLayout( gl );
+
+ final Label text = new Label( shell, SWT.BORDER );
+ GridData gd = new GridData( );
+ gd.widthHint = 100;
+ text.setLayoutData( gd );
+ text.setText( "Drag Drop" );
+
+
+ DragSource ds = new DragSource( text, DND.DROP_MOVE );
+ ds.setTransfer( new Transfer[]{
+ SimpleTextTransfer.getInstance( )
+ } );
+ ds.addDragListener( new DragSourceAdapter( ) {
+
+ @Override
+ public void dragSetData( DragSourceEvent event )
+ {
+ event.data = text.getText( );
+ }
+ } );
+
+ final CCombo combo = new CCombo( shell, SWT.BORDER );
+ gd = new GridData( GridData.FILL_HORIZONTAL );
+ gd.widthHint = 150;
+ combo.setLayoutData( gd );
+
+
+ DropTarget dt = new DropTarget( combo, DND.DROP_MOVE );
+ dt.setTransfer( new Transfer[]{
+ SimpleTextTransfer.getInstance( )
+ } );
+ dt.addDropListener( new DropTargetAdapter( ) {
+
+ @Override
+ public void drop( DropTargetEvent event )
+ {
+ combo.setText( (String) event.data );
+ }
+ } );
+
+ shell.pack( );
+ shell.open( );
+ Display display = Display.getDefault( );
+ while ( !shell.isDisposed( ) )
+ if ( !display.readAndDispatch( ) )
+ display.sleep( );
+ display.dispose( );
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug278882_ToolBarBackgroundImageTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug278882_ToolBarBackgroundImageTest.java
new file mode 100644
index 0000000000..19a06abaf1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug278882_ToolBarBackgroundImageTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+public class Bug278882_ToolBarBackgroundImageTest {
+
+ public static void main (String [] args) {
+
+ final Display display = new Display();
+ Shell shell = new Shell( display );
+ //widget.shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ shell.setLayout(new FillLayout());
+
+ final ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ toolBar.setLayoutData(data);
+ toolBar.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ Image originalImage = toolBar.getBackgroundImage();
+
+ Point p = toolBar.getSize();
+ Image bg = new Image(display, p.x, p.y);
+
+ GC gc = new GC(bg);
+ gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(0, 0, p.x, p.y);
+ gc.dispose();
+
+ toolBar.setBackgroundImage(bg);
+
+ if (originalImage != null) {
+ originalImage.dispose();
+ }
+ }
+ });
+ shell.setSize( 400, 300 );
+ shell.open();
+
+ while( !shell.isDisposed() ) {
+ if( !display.readAndDispatch() )
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug286244_ShellActivateLoop.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug286244_ShellActivateLoop.java
new file mode 100644
index 0000000000..324eb63571
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug286244_ShellActivateLoop.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug286244_ShellActivateLoop {
+
+ public static void main(String[] args) {
+ final Display display= new Display();
+ final Shell shell= new Shell(display);
+ shell.addShellListener(new ShellAdapter() {
+ @Override
+ public void shellDeactivated(ShellEvent e) {
+ System.out.println("shellDeactivated()");
+ display.timerExec(2000, new Runnable() {
+ @Override
+ public void run() {
+ System.out.println("forcing active");
+ shell.forceActive();
+ System.out.println("widget.shell is active: "
+ + (display.getActiveShell() == shell));
+ System.out.println("forced active");
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void shellActivated(ShellEvent e) {
+ System.out.println("shellActivated()");
+ }
+ });
+
+ shell.setSize(160, 100);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug288357_ComboBoxCellEditorExceptionError.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug288357_ComboBoxCellEditorExceptionError.java
new file mode 100644
index 0000000000..370ca6c149
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug288357_ComboBoxCellEditorExceptionError.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+/** Commented out to prevent jFace dependency */
+
+//package jface;
+//
+//import java.util.Arrays;
+//import java.util.List;
+//
+//import org.eclipse.jface.dialogs.Dialog;
+//import org.eclipse.jface.dialogs.IDialogConstants;
+//import org.eclipse.jface.viewers.ArrayContentProvider;
+//import org.eclipse.jface.viewers.CellEditor;
+//import org.eclipse.jface.viewers.ComboBoxCellEditor;
+//import org.eclipse.jface.viewers.ICellModifier;
+//import org.eclipse.jface.viewers.LabelProvider;
+//import org.eclipse.jface.viewers.TableViewer;
+//import org.eclipse.jface.window.Window;
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.events.SelectionAdapter;
+//import org.eclipse.swt.events.SelectionEvent;
+//import org.eclipse.swt.layout.GridData;
+//import org.eclipse.swt.layout.RowLayout;
+//import org.eclipse.swt.widgets.Button;
+//import org.eclipse.swt.widgets.Composite;
+//import org.eclipse.swt.widgets.Control;
+//import org.eclipse.swt.widgets.Shell;
+////
+//
+///**
+// * A window that launches a dialog containing a table with an editable cell.
+// * It takes 2 seconds for the cell editor to appear. If the dialog is closed
+// * during that time, an SWTException occurs.
+// *
+// * The dialog and window are both needed so that the SWT event loop continues
+// * to run after the dialog is closed. The {@link ComboBoxCellEditor} also
+// * needs to be using the DROP_DOWN_ON_MOUSE_ACTIVATION style so that the
+// * drop-down list is made visible as soon as the cell editor is activated.
+// *
+// * @author Eleanor Joslin (ejj@corefiling.com)
+// */
+//public class Bug288357_ComboBoxCellEditorExceptionError extends Window {
+//
+// /**
+// * Dialog containing a table with an editable cell.
+// * It takes 2 seconds before the combo box in the cell editor pops up.
+// * Closing the dialog during that time triggers an error.
+// */
+// private static class PopupDialog extends Dialog {
+//
+// private static final int SLEEP_INTERVAL_MILLIS = 2000;
+//
+// private static final List<String> CHOICES = Arrays.asList("Apples", "Pears", "Plums", "Cherries");
+//
+// private final StringHolder _element = new StringHolder();
+//
+// private TableViewer _table;
+//
+// private final ComboBoxCellEditor _cellEditor = new ComboBoxCellEditor();
+//
+// private final ICellModifier _cellModifier = new ICellModifier() {
+//
+// public void modify(final Object element, final String property, final Object value) {
+// _element.setString(CHOICES.get((Integer) value));
+// _table.refresh();
+// }
+//
+// public Object getValue(final Object element, final String property) {
+// return CHOICES.indexOf(_element.getString());
+// }
+//
+// public boolean canModify(final Object element, final String property) {
+// try {
+// Thread.sleep(SLEEP_INTERVAL_MILLIS);
+// }
+// catch (InterruptedException e) {
+// }
+// _cellEditor.setItems(CHOICES.toArray(new String[CHOICES.size()]));
+// return true;
+// }
+// };
+//
+// public PopupDialog(final Shell parentShell) {
+// super(parentShell);
+// }
+//
+// @Override
+// protected Control createDialogArea(final Composite parent) {
+// _table = new TableViewer(parent);
+// _table.setColumnProperties(new String[] {"Only one column"});
+// _table.setCellEditors(new CellEditor[] {_cellEditor });
+// _table.setCellModifier(_cellModifier);
+// _table.setContentProvider(new ArrayContentProvider());
+// _table.setLabelProvider(new LabelProvider());
+// _table.setInput(new Object[] {_element});
+//
+// _table.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+// _cellEditor.setStyle(SWT.READ_ONLY);
+// _cellEditor.setActivationStyle(ComboBoxCellEditor.DROP_DOWN_ON_MOUSE_ACTIVATION);
+// _cellEditor.create(_table.getTable());
+//
+// return _table.getControl();
+// }
+//
+// @Override
+// protected void createButtonsForButtonBar(final Composite parent) {
+// createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+// }
+// }
+//
+// /**
+// * Element to show in the table.
+// */
+// private static class StringHolder {
+//
+// private String _string = "Apples";
+//
+// public void setString(final String string) {
+// _string = string;
+// }
+//
+// public String getString() {
+// return _string;
+// }
+//
+// @Override
+// public String toString() {
+// return _string;
+// }
+// }
+//
+// public Bug288357_ComboBoxCellEditorExceptionError() {
+// super(new Shell());
+// setBlockOnOpen(true);
+// }
+//
+// @Override
+// protected Control createContents(final Composite parent) {
+// Composite composite = new Composite(parent, SWT.NONE);
+// composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+// composite.setLayout(new RowLayout());
+//
+// Button button = new Button(composite, SWT.PUSH);
+// button.setText("Open Dialog");
+// button.addSelectionListener(new SelectionAdapter() {
+// @Override
+// public void widgetSelected(final SelectionEvent e) {
+// new PopupDialog(getShell()).open();
+// }
+// });
+//
+// return composite;
+// }
+//
+// public static void main(final String[] args) {
+// new Bug288357_ComboBoxCellEditorExceptionError().open();
+// }
+//}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug291073_CrashWhenPrintingToConsole.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug291073_CrashWhenPrintingToConsole.java
new file mode 100644
index 0000000000..d0987113fa
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug291073_CrashWhenPrintingToConsole.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.BitSet;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug291073_CrashWhenPrintingToConsole {
+ public static void main(String[] args) throws IOException{
+ Display display = new Display();
+ Shell shell = new Shell (display);
+
+ Font font1 = new Font(display, "Tahoma", 14, SWT.BOLD);
+ Color blue = display.getSystemColor(SWT.COLOR_BLUE);
+ Color yellow = display.getSystemColor(SWT.COLOR_YELLOW);
+
+ final TextLayout layout = new TextLayout(display);
+ TextStyle style1 = new TextStyle(font1, yellow, blue);
+
+ BitSet bs = new BitSet();
+ bs.set(2894298, true);
+ bs.set(324832893, true);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(out);
+ oos.writeObject(bs);
+
+ layout.setText(out.toString());
+ System.out.println("length:"+out.toString());
+ layout.setStyle(style1, 2, out.toString().length() - 10000000);
+ shell.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent (Event event) {
+ Display display = event.display;
+ GC gc = event.gc;
+
+ Rectangle rect0 = layout.getBounds();
+ rect0.x += 10;
+ rect0.y += 10;
+ gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(rect0);
+ layout.draw(gc, rect0.x, rect0.y);
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ font1.dispose();
+ layout.dispose();
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292413_MissingSWTFocused.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292413_MissingSWTFocused.java
new file mode 100644
index 0000000000..6651293951
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292413_MissingSWTFocused.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug292413_MissingSWTFocused {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ shell.setLayout(new FillLayout());
+ final Tree tree = new Tree(shell, SWT.MULTI);
+ for (int i = 0; i < 9; i++) {
+ new TreeItem(tree, SWT.NONE).setText("item " + i);
+ }
+ tree.addListener(SWT.EraseItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("EraseItem event");
+ if ((event.detail & SWT.FOCUSED) != 0) {
+ System.out.println("item has focus: " + ((TreeItem)event.item).getText());
+ }
+ }
+ });
+ tree.addListener(SWT.PaintItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("PaintItem event");
+ if ((event.detail & SWT.FOCUSED) != 0) {
+ System.out.println("item has focus: " + ((TreeItem)event.item).getText());
+ }
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292459_ToolTipFlicker.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292459_ToolTipFlicker.java
new file mode 100644
index 0000000000..de175f0518
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug292459_ToolTipFlicker.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug292459_ToolTipFlicker {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display, SWT.SHELL_TRIM);
+ shell.setLayout(new FillLayout());
+
+ Label test1 = new Label(shell, SWT.BORDER);
+ test1.setText("Test 1");
+ test1.setToolTipText("This is test1\nTest is this is\nwhee");
+
+ final Label test2 = new Label(shell, SWT.BORDER);
+ test2.setText("Test 2");
+ test2.setToolTipText("This is test2\nTest is this is\nwhee");
+
+ final CLabel test3 = new CLabel(shell, SWT.BORDER);
+ test3.setText("Test 3");
+ test3.setToolTipText("This is test3\nTest is this is\nwhee");
+
+ shell.open();
+
+ Timer timer = new Timer(true);
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ // make Label's widget.tooltip flicker by setting it to the same widget.text
+ test2.setToolTipText(test2.getToolTipText());
+
+ // make CLabel's widget.tooltip flicker just by invoking doPaint
+ test3.redraw();
+ }
+ });
+ }
+ }, 1000, 1000);
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug293581_NO_REDRAW_RESIZE_noeffect.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug293581_NO_REDRAW_RESIZE_noeffect.java
new file mode 100644
index 0000000000..31e3baf9f8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug293581_NO_REDRAW_RESIZE_noeffect.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug293581_NO_REDRAW_RESIZE_noeffect {
+
+ static int counter = 0;
+ public static void main(String[] args) {
+ final String IMAGE_FILENAME = "/home/ipun/Desktop/0ba.jpg";
+ final Display display = new Display();
+ Image image = new Image(display, IMAGE_FILENAME);
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ shell.setBackgroundImage(image);
+ Canvas canvas = new Canvas(shell, SWT.NO_REDRAW_RESIZE);
+ canvas.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ event.gc.drawString(String.valueOf(counter++), 0, 0);
+ }
+ });
+ shell.setBounds(10,10,200,200);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ image.dispose();
+ display.dispose();
+ }
+}
+
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug294300_TreeRenderingPaintListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug294300_TreeRenderingPaintListener.java
new file mode 100644
index 0000000000..f2e095794b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug294300_TreeRenderingPaintListener.java
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.TextLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug294300_TreeRenderingPaintListener implements Listener {
+
+ private Tree tree;
+ private TextLayout textLayout;
+
+ Bug294300_TreeRenderingPaintListener(Tree tree) {
+ this.tree = tree;
+ }
+
+ public void setListeners(boolean add) {
+ if (add) {
+ tree.addListener(SWT.EraseItem, this);
+ tree.addListener(SWT.PaintItem, this);
+ } else {
+ tree.removeListener(SWT.EraseItem, this);
+ tree.removeListener(SWT.PaintItem, this);
+ }
+ redraw();
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.PaintItem:
+ paint(event);
+ break;
+ case SWT.EraseItem:
+ erase(event);
+ break;
+ }
+ }
+
+ private void erase(Event event) {
+ event.detail &= ~(SWT.BACKGROUND | SWT.FOREGROUND | SWT.SELECTED | SWT.HOT);
+ }
+
+ private void paint(Event event) {
+ TreeItem item = (TreeItem) event.item;
+ GC gc = event.gc;
+ // remember colors to restore the GC later
+ Color oldForeground = gc.getForeground();
+ Color oldBackground = gc.getBackground();
+
+ int index = event.index;
+
+ Color foreground = item.getForeground(index);
+ if (foreground != null) {
+ gc.setForeground(foreground);
+ }
+
+ Color background = item.getBackground(index);
+ if (background != null) {
+ gc.setBackground(background);
+ }
+
+ if ((event.detail & SWT.SELECTED) != 0) {
+ gc.fillRectangle(item.getBounds(index));
+ }
+
+ Image image = item.getImage(index);
+ if (image != null) {
+ Rectangle imageBounds = item.getImageBounds(index);
+ if (imageBounds != null) {
+ Rectangle bounds = image.getBounds();
+
+ // center the graphics.image in the given space
+ int x = imageBounds.x
+ + Math.max(0, (imageBounds.width - bounds.width) / 2);
+ int y = imageBounds.y
+ + Math.max(0, (imageBounds.height - bounds.height) / 2);
+ gc.drawImage(image, x, y);
+ }
+ }
+
+ Rectangle textBounds = item.getTextBounds(index);
+ if (textBounds != null) {
+ TextLayout layout = getTextLayout();
+ layout.setText(item.getText(index));
+ layout.setFont(item.getFont(index));
+
+ Rectangle layoutBounds = layout.getBounds();
+
+ int x = textBounds.x;
+ int avg = (textBounds.height - layoutBounds.height) / 2;
+ int y = textBounds.y + Math.max(0, avg);
+
+ layout.draw(gc, x, y);
+ }
+
+ gc.setForeground(oldForeground);
+ gc.setBackground(oldBackground);
+ }
+
+ public void redraw() {
+ Rectangle rect = tree.getClientArea();
+ tree.redraw(rect.x, rect.y, rect.width, rect.height, true);
+ }
+
+ private TextLayout getTextLayout() {
+ if (textLayout == null) {
+ int orientation = tree.getStyle()
+ & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+ textLayout = new TextLayout(tree.getDisplay());
+ textLayout.setOrientation(orientation);
+ } else {
+ textLayout.setText("");
+ }
+ return textLayout;
+ }
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 800, 600);
+ shell.setLayout(new GridLayout());
+ final Tree tree = new Tree(shell, SWT.BORDER);
+ tree.setLinesVisible(true);
+ for (int i = 0; i < 5; i++) {
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText("item " + i);
+ for (int j = 0; j < 5; j++) {
+ TreeItem child = new TreeItem(item, SWT.NONE);
+ child.setText("item " + i + "-" + j);
+ }
+ }
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ final Bug294300_TreeRenderingPaintListener painer = new Bug294300_TreeRenderingPaintListener(tree);
+ final Button button = new Button(shell, SWT.CHECK);
+ button.setText("Enable custom painter");
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ painer.setListeners(button.getSelection());
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299045_TableLines.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299045_TableLines.java
new file mode 100644
index 0000000000..0add0117f3
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299045_TableLines.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug299045_TableLines {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Image image = display.getSystemImage(SWT.ICON_INFORMATION);
+ Shell shell = new Shell(display);
+ shell.setText("Images on the right side of the TableItem");
+ shell.setLayout(new FillLayout());
+ Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(false); // changing this to true makes the dotted lines thicker
+ int columnCount = 3;
+ for(int i = 0; i < columnCount; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText("Column " + i);
+ }
+ final int itemCount = 10;
+ for(int i = 0; i < itemCount; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {"item " + i + " a", "item " + i + " Bug510183_javadocHang", "item " + i + " c"});
+ }
+ Listener paintListener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ switch(event.type) {
+ case SWT.MeasureItem: {
+ Rectangle rect = image.getBounds();
+ event.width += rect.width;
+ event.height = Math.max(event.height, rect.height + 2);
+ break;
+ }
+ case SWT.EraseItem: {
+ event.detail &= ~SWT.FOREGROUND;
+ event.detail &= ~SWT.BACKGROUND;
+ event.detail &= ~SWT.SELECTED;
+ event.detail &= ~SWT.FOCUSED;
+ event.detail &= ~SWT.HOT;
+ event.doit = false;
+ break;
+ }
+ case SWT.PaintItem: {
+ Rectangle rect = image.getBounds();
+
+ // shouldn't we subtract rect.width?
+ // it looks like the event.width value set in the SWT.MeasureItem wasn't retained...
+ int x = event.x + event.width /*- rect.width*/;
+ int offset = Math.max(0, (event.height - rect.height) / 2);
+ event.gc.drawImage(image, x, event.y + offset);
+
+ // draws only a blue background filling up the entire cell
+// Color blue = display.getSystemColor(SWT.COLOR_BLUE);
+// event.gc.setBackground(blue);
+// int adhocOffset = 2;
+// event.gc.fillRectangle(event.x - adhocOffset, event.y,
+// event.width + rect.width + adhocOffset, event.height);
+
+ break;
+ }
+ }
+ }
+ };
+ table.addListener(SWT.MeasureItem, paintListener);
+ table.addListener(SWT.EraseItem, paintListener);
+ table.addListener(SWT.PaintItem, paintListener);
+
+ for(int i = 0; i < columnCount; i++) {
+ table.getColumn(i).pack();
+ }
+ shell.setSize(500, 500);
+ shell.open();
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch())
+ display.sleep();
+ }
+
+ // this is incorrect, the graphics.image wasn't allocated by the user!
+// if(graphics.image != null)
+// graphics.image.dispose();
+
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299492_LabelCenterWrap.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299492_LabelCenterWrap.java
new file mode 100644
index 0000000000..2f3397b6b6
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug299492_LabelCenterWrap.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug299492_LabelCenterWrap {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ createLabel1(shell);
+// createLabel2(widget.shell);
+
+ shell.pack();
+ shell.open();
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ // this is inspired from my real-world application code
+ private static void createLabel1(Shell shell) {
+ shell.setLayout(new GridLayout(1, true));
+ Label label = new Label(shell, SWT.HORIZONTAL | SWT.CENTER | SWT.WRAP);
+ label.setText("Very Very Very Long String");
+ label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
+// createLabelInsideComposite(widget.shell);
+ }
+
+ // this doesn't work either
+ @SuppressWarnings("unused")
+ private static void createLabel2(Shell shell) {
+ shell.setLayout(new FillLayout());
+
+ Label label = new Label(shell, SWT.HORIZONTAL | SWT.CENTER | SWT.WRAP);
+ label.setText("Very Very Very Long String");
+// createLabelInsideComposite(widget.shell);
+ }
+
+ // this attempt to workaround the problem by creating two composites
+ // to grab the extra horizontal space doesn't work
+ @SuppressWarnings("unused")
+ private static void createLabelInsideComposite(Shell shell) {
+ Composite parent = new Composite(shell, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(3, false);
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 0;
+ parent.setLayout(gridLayout);
+
+ Composite leftPanel = new Composite(parent, SWT.NONE);
+ leftPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ Label label = new Label(parent, SWT.HORIZONTAL | SWT.CENTER | SWT.WRAP);
+ label.setText("Very Very Very Long String");
+ label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
+
+ Composite rightPanel = new Composite(parent, SWT.NONE);
+ rightPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302918_ToolItemSetDisabledImage.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302918_ToolItemSetDisabledImage.java
new file mode 100644
index 0000000000..dd3e35e6b0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302918_ToolItemSetDisabledImage.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+/*
+ * CoolBar example snippet: create a cool bar
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.CoolBar;
+import org.eclipse.swt.widgets.CoolItem;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug302918_ToolItemSetDisabledImage {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ CoolBar bar = new CoolBar(shell, SWT.BORDER);
+ for (int i = 0; i < 2; i++) {
+ CoolItem item = new CoolItem(bar, SWT.NONE);
+ Button button = new Button(bar, SWT.PUSH);
+ button.setText("Button " + i);
+ Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ item.setPreferredSize(item.computeSize(size.x, size.y));
+ item.setControl(button);
+ }
+ Image nav = new Image (display, "/home/ericwill/git/SWT-snippets/src/widget.toolbar/next_nav.gif");
+ Image nav_dis = new Image(display, "/home/ericwill/git/SWT-snippets/src/widget.toolbar/next_nav_dis.gif");
+
+ ToolBar toolbar = new ToolBar(bar, SWT.NONE);
+ ToolItem item1 = new ToolItem(toolbar, SWT.PUSH);
+ item1.setImage(nav);
+ item1.setDisabledImage(nav_dis);
+ ToolItem item2 = new ToolItem(toolbar, SWT.PUSH);
+ item2.setImage(nav_dis);
+ item2.setDisabledImage(nav);
+ ToolItem item3 = new ToolItem(toolbar, SWT.PUSH);
+ item3.setImage(nav);
+ item3.setDisabledImage(nav_dis);
+ item3.setEnabled(false);
+ ToolItem item4 = new ToolItem(toolbar, SWT.PUSH);
+ item4.setImage(nav_dis);
+ item4.setDisabledImage(nav);
+ item4.setEnabled(false);
+ toolbar.pack();
+
+ CoolItem citem = new CoolItem(bar, SWT.NONE);
+ Point tsize = toolbar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ citem.setPreferredSize(tsize.x+15, tsize.y);
+ citem.setControl(toolbar);
+
+ bar.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302956_ControlFailedMouseEvent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302956_ControlFailedMouseEvent.java
new file mode 100644
index 0000000000..68e8fcb94f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302956_ControlFailedMouseEvent.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug302956_ControlFailedMouseEvent {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 800, 500);
+ Shell shell2 = new Shell(shell, SWT.APPLICATION_MODAL | SWT.SHELL_TRIM);
+ shell2.setBounds(200, 200, 125, 125);
+ Button button = new Button(shell2, SWT.PUSH);
+ button.setBounds(50, 50, 50, 50);
+ button.addMouseTrackListener(new MouseTrackAdapter() {
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ System.out.println("ENTER");
+ }
+ @Override
+ public void mouseExit(MouseEvent e) {
+ System.out.println("EXIT");
+ }
+ });
+ shell.open();
+ shell2.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302961_TableItemTrackerUpdating.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302961_TableItemTrackerUpdating.java
new file mode 100644
index 0000000000..187249c33d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug302961_TableItemTrackerUpdating.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tracker;
+
+public class Bug302961_TableItemTrackerUpdating {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ final Label label = new Label(shell, SWT.NONE);
+ label.setBounds(10,10,100,30);
+ label.setText("widget.label");
+ Table table = new Table(shell, SWT.NONE);
+ table.setBounds(10,50,100,50);
+ final TableItem item = new TableItem(table, SWT.NONE);
+ shell.open ();
+ shell.addListener (SWT.MouseDown, new Listener () {
+ @Override
+ public void handleEvent (Event e) {
+ Tracker tracker = new Tracker (shell, SWT.NONE);
+ tracker.setRectangles (new Rectangle [] {
+ new Rectangle (e.x, e.y, 100, 100),
+ });
+ tracker.addListener(SWT.Move, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println(event.x);
+ String string = String.valueOf(event.x);
+ label.setText(string);
+ item.setText(string);
+ }
+ });
+ tracker.open ();
+ }
+ });
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug303710_ForceActive.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug303710_ForceActive.java
new file mode 100644
index 0000000000..c4a1788df6
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug303710_ForceActive.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug303710_ForceActive {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ final int time = 500;
+ Runnable timer = new Runnable() {
+ @Override
+ public void run() {
+ Point point = display.getCursorLocation();
+ Rectangle rect = shell.getBounds();
+ if (rect.contains(point)) {
+ System.out.println("In");
+ } else {
+ System.out.println("Out");
+ }
+ shell.forceActive();
+ display.timerExec(time, this);
+ }
+ };
+ display.timerExec(time, timer);
+ shell.setSize(200, 200);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304020_TextLayoutPerformance.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304020_TextLayoutPerformance.java
new file mode 100644
index 0000000000..65813acec8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304020_TextLayoutPerformance.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.TextLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug304020_TextLayoutPerformance {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+
+ final TextLayout layout = new TextLayout(display);
+
+ layout.setText(BIG_TEXT);
+ layout.setWidth(600);
+
+ shell.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ event.gc.setAntialias(SWT.ON);
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < 10000; i++) {
+ layout.draw(event.gc, 10, 20);
+ }
+ System.out.println((System.currentTimeMillis() - start) / 1000);
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ layout.dispose();
+ display.dispose();
+ }
+
+ private static final String BIG_TEXT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.\n\nEtiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.\n\nNam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.\n\nCurabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis.\n\nAenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n\nIn dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna.\n\nIn hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Curabitur a felis in nunc fringilla tristique. Morbi mattis ullamcorper velit. Phasellus gravida semper nisi. Nullam vel sem. Pellentesque libero tortor, tincidunt et, tincidunt eget, semper nec, quam. Sed hendrerit. Morbi ac felis. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Donec interdum, metus et hendrerit aliquet, dolor diam sagittis ligula, eget egestas libero turpis vel mi. Nunc nulla. Fusce risus nisl, viverra et, tempor et, pretium in, sapien. Donec venenatis vulputate lorem.\n\nMorbi nec metus. Phasellus blandit leo ut odio. Maecenas ullamcorper, dui et placerat feugiat, eros pede varius nisi, condimentum viverra felis nunc et lorem. Sed magna purus, fermentum eu, tincidunt eu, varius ut, felis. In auctor lobortis lacus. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. Vestibulum ullamcorper mauris at ligula. Fusce fermentum. Nullam cursus lacinia erat. Praesent blandit laoreet nibh.\n\nFusce convallis metus id felis luctus adipiscing. Pellentesque egestas, neque sit amet convallis pulvinar, justo nulla eleifend augue, ac auctor orci leo non est. Quisque id mi. Ut tincidunt tincidunt erat. Etiam feugiat lorem non metus. Vestibulum dapibus nunc ac augue. Curabitur vestibulum aliquam leo. Praesent egestas neque eu enim. In hac habitasse platea dictumst. Fusce a quam. Etiam ut purus mattis mauris sodales aliquam. Curabitur nisi. Quisque malesuada placerat nisl. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus.\n\nSed augue ipsum, egestas nec, vestibulum et, malesuada adipiscing, dui. Vestibulum facilisis, purus nec pulvinar iaculis, ligula mi congue nunc, vitae euismod ligula urna in dolor. Mauris sollicitudin fermentum libero. Praesent nonummy mi in odio. Nunc interdum lacus sit amet orci. Vestibulum rutrum, mi nec elementum vehicula, eros quam gravida nisl, id fringilla neque ante vel mi. Morbi mollis tellus ac sapien. Phasellus volutpat, metus eget egestas mollis, lacus lacus blandit dui, id egestas quam mauris ut lacus. Fusce vel dui. Sed in libero ut nibh placerat accumsan. Proin faucibus arcu quis ante. In consectetuer turpis ut velit. Nulla sit amet est. Praesent metus tellus, elementum eu, semper a, adipiscing nec, purus. Cras risus ipsum, faucibus ut, ullamcorper id, varius ac, leo. Suspendisse feugiat. Suspendisse enim turpis, dictum sed, iaculis a, condimentum nec, nisi. Praesent nec nisl a purus blandit viverra. Praesent ac massa at ligula laoreet iaculis. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit.\n\nMauris turpis nunc, blandit et, volutpat molestie, porta ut, ligula. Fusce pharetra convallis urna. Quisque ut nisi. Donec mi odio, faucibus at, scelerisque quis, convallis in, nisi. Suspendisse non nisl sit amet velit hendrerit rutrum. Ut leo. Ut a nisl id ante tempus hendrerit. Proin pretium, leo ac pellentesque mollis, felis nunc ultrices eros, sed gravida augue augue mollis justo. Suspendisse eu ligula. Nulla facilisi. Donec id justo. Praesent porttitor, nulla vitae posuere iaculis, arcu nisl dignissim dolor, a pretium mi sem ut ipsum. Curabitur suscipit suscipit tellus.\n\nPraesent vestibulum dapibus nibh. Etiam iaculis nunc ac metus. Ut id nisl quis enim dignissim sagittis. Etiam sollicitudin, ipsum eu pulvinar rutrum, tellus ipsum laoreet sapien, quis venenatis ante odio sit amet eros. Proin magna. Duis vel nibh at velit scelerisque suscipit. Curabitur turpis. Vestibulum suscipit nulla quis orci. Fusce ac felis sit amet ligula pharetra condimentum. Maecenas egestas arcu quis ligula mattis placerat. Duis lobortis massa imperdiet quam. Suspendisse potenti.\n\nPellentesque commodo eros a enim. Vestibulum turpis sem, aliquet eget, lobortis pellentesque, rutrum eu, nisl. Sed libero. Aliquam erat volutpat. Etiam vitae tortor. Morbi vestibulum volutpat enim. Aliquam eu nunc. Nunc sed turpis. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Nulla porta dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.\n\nPellentesque dapibus hendrerit tortor. Praesent egestas tristique nibh. Sed a libero. Cras varius. Donec vitae orci sed dolor rutrum auctor. Fusce egestas elit eget lorem. Suspendisse nisl elit, rhoncus eget, elementum ac, condimentum eget, diam. Nam at tortor in tellus interdum sagittis. Aliquam lobortis. Donec orci lectus, aliquam ut, faucibus non, euismod id, nulla. Curabitur blandit mollis lacus. Nam adipiscing. Vestibulum eu odio.\n\nVivamus laoreet. Nullam tincidunt adipiscing enim. Phasellus tempus. Proin viverra, ligula sit amet ultrices semper, ligula arcu tristique sapien, a accumsan nisi mauris ac eros. Fusce neque. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis tellus, vitae iaculis lacus elit id tortor. Vivamus aliquet elit ac nisl. Fusce fermentum odio nec arcu. Vivamus euismod mauris. In ut quam vitae odio lacinia tincidunt. Praesent ut ligula non mi varius sagittis. Cras sagittis. Praesent ac sem eget est egestas volutpat. Vivamus consectetuer hendrerit lacus. Cras non dolor. Vivamus in erat ut urna cursus vestibulum. Fusce commodo aliquam arcu. Nam commodo suscipit quam. Quisque id odio. Praesent venenatis metus at tortor pulvinar varius.\n";
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304893_CcomboColor.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304893_CcomboColor.java
new file mode 100644
index 0000000000..86895f2ac7
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug304893_CcomboColor.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Modified Snippet39
+ */
+public class Bug304893_CcomboColor {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ CCombo combo = new CCombo(shell, SWT.READ_ONLY);
+ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ for (int i = 0; i < 5; i++) {
+ combo.add("item" + i);
+ }
+ combo.setText("item0");
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug312919_BrowserPaint.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug312919_BrowserPaint.java
new file mode 100644
index 0000000000..ff872cb551
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug312919_BrowserPaint.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug312919_BrowserPaint {
+static Region region;
+public static void main(String[] args) {
+final Display display = new Display();
+final Shell shell = new Shell(display);
+shell.setBounds(10, 10, 400, 400);
+shell.setLayout(new FillLayout());
+final Browser browser = new Browser(shell, SWT.NONE);
+browser.setUrl("eclipse.org");
+shell.open();
+display.timerExec(3333, new Runnable() {
+@Override
+public void run() {
+Rectangle bounds = display.map(shell, null,
+browser.getBounds());
+Shell shell2 = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
+shell2.setBounds(bounds);
+final int width = bounds.width;
+region = new Region();
+Rectangle pixel = new Rectangle(0, 0, 1, 1);
+for (int i = 0; i < width; i++) {
+pixel.x = pixel.y = i;
+region.add(pixel);
+}
+shell2.setRegion(region);
+shell2.addListener(SWT.Paint, new Listener() {
+@Override
+public void handleEvent(Event event) {
+event.gc.drawLine(0, 0, width, width);
+}
+});
+shell2.open();
+}
+});
+while (!shell.isDisposed()) {
+if (!display.readAndDispatch()) display.sleep();
+}
+region.dispose();
+shell.dispose();
+display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug319612_getSizeResizeOnTop.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug319612_getSizeResizeOnTop.java
new file mode 100644
index 0000000000..c63b254e35
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug319612_getSizeResizeOnTop.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug319612_getSizeResizeOnTop {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display, SWT.RESIZE | SWT.ON_TOP);
+
+ GridLayout layout= new GridLayout(1, false);
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ shell.setLayout(layout);
+
+ shell.setSize (200, 200);
+ shell.open ();
+
+ for (int i = 0; i < 50; i++) {
+ while (display.readAndDispatch ()) {
+
+ }
+ Point p = shell.getSize();
+ shell.setSize(p.x, p.y);
+
+ try {
+ Thread.currentThread();
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug321573_ImageScalingLeakTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug321573_ImageScalingLeakTest.java
new file mode 100644
index 0000000000..d1729adefd
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug321573_ImageScalingLeakTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+public class Bug321573_ImageScalingLeakTest {
+
+ public static void main(String[] args) {
+ Display display = Display.getDefault();
+ Image image = new Image(display, 3200, 2400);
+ ImageData imageData = image.getImageData();
+ image.dispose();
+ long time = System.currentTimeMillis();
+ for (int i = 0; i < 10000; i++) {
+ image = new Image(display, imageData);
+ image = scale(image, 320, 240);
+ image.dispose();
+ image = null;
+ System.gc(); // just make sure we don't see the Java heap growing
+ System.out.println(i);
+ }
+ System.out.println(System.currentTimeMillis() - time);
+ }
+
+ public static Image scale(Image image, int width, int height) {
+ Rectangle bounds = image.getBounds();
+ Image thumbnail = new Image(image.getDevice(), width, height);
+ GC gc = null;
+ try {
+ gc = new GC(thumbnail);
+ gc.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0, width,
+ height);
+ return thumbnail;
+ } finally {
+ image.dispose();
+ if (gc != null)
+ gc.dispose();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323044_ReadAndDispatchTrue.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323044_ReadAndDispatchTrue.java
new file mode 100644
index 0000000000..02953afc47
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323044_ReadAndDispatchTrue.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+
+*******************************************************************************/
+
+
+/*
+ * UI Automation (for testing tools) snippet: post key events
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ *
+ * @since 3.0
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug323044_ReadAndDispatchTrue {
+
+public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ final Text text = new Text(shell, SWT.BORDER);
+ text.setSize(text.computeSize(150, SWT.DEFAULT));
+ shell.pack();
+ shell.open();
+ new Thread(){
+ @Override
+ public void run(){
+ Event keyEvent = new Event();
+ Event charEvent = new Event();
+ System.out.println("STARTING");
+ for (int i = 0; i < 5000; i++) {
+ System.out.println(i);
+ keyEvent.type = SWT.KeyDown;
+ keyEvent.keyCode = SWT.MOD3;
+ display.post(keyEvent);
+
+ charEvent.type = SWT.KeyDown;
+ charEvent.character = 'a';
+ display.post(charEvent);
+
+ charEvent.type = SWT.KeyUp;
+ charEvent.character = 'a';
+ display.post(charEvent);
+
+ keyEvent.type = SWT.KeyUp;
+ keyEvent.keyCode=SWT.MOD3;
+ display.post(keyEvent);
+ }
+ }
+ }.start();
+ while (!shell.isDisposed()) {
+ boolean readAndDispatch = display.readAndDispatch();
+ System.out.println("readAndDispatch: "+ readAndDispatch);
+ if (!readAndDispatch) display.sleep();
+ }
+
+
+
+ display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323240_VirtualTableSlowScroll.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323240_VirtualTableSlowScroll.java
new file mode 100644
index 0000000000..14e26e6388
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug323240_VirtualTableSlowScroll.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public class Bug323240_VirtualTableSlowScroll {
+
+static final int COUNT = 2000;
+
+public static void main(String[] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout (new GridLayout());
+ final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
+ table.addListener (SWT.SetData, new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ TableItem item = (TableItem) event.item;
+ int index = table.indexOf (item);
+ item.setText (0, "Item " + index);
+
+ for (int i = 1; i <= 10; i++) {
+ item.setText(i, index + " test " + i);
+ }
+
+ }
+ });
+
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData.heightHint = 200;
+ table.setLayoutData(gridData);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ Button button = new Button (shell, SWT.PUSH);
+ button.setText ("Add Items");
+
+ for (int i = 1; i <= 10; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText("header " + i);
+ }
+
+
+ final Label label = new Label(shell, SWT.NONE);
+ button.addListener (SWT.Selection, new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ long t1 = System.currentTimeMillis ();
+ table.setItemCount (COUNT);
+ long t2 = System.currentTimeMillis ();
+ label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) + " (ms)");
+ shell.layout ();
+ }
+ });
+
+ for (TableColumn column: table.getColumns()) {
+ column.pack();
+ }
+
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug336238_ShellBoundsTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug336238_ShellBoundsTest.java
new file mode 100644
index 0000000000..22c4afa4cf
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug336238_ShellBoundsTest.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+//import static org.junit.Assert.*;
+
+import org.eclipse.swt.widgets.Shell;
+//import org.junit.Test;
+
+public class Bug336238_ShellBoundsTest {
+
+ static int cycles = 5;
+
+// @Test
+ public void testSetBounds() {
+
+ int x;
+ int y;
+ int width = 100;
+ int height = 100;
+
+ for (int i=0; i < cycles; i++) {
+
+ x = (new Double(Math.random()*1000)).intValue();
+ y = (new Double(Math.random()*1000)).intValue();
+
+ Shell testShell = new Shell();
+ testShell.open();
+
+ testShell.setBounds(x, y, width, height);
+
+// assertEquals(x, testShell.getLocation().x);
+// assertEquals(y, testShell.getLocation().y);
+ testShell.close();
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug340752_ControlGetSize.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug340752_ControlGetSize.java
new file mode 100644
index 0000000000..940f8227c6
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug340752_ControlGetSize.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+
+public class Bug340752_ControlGetSize {
+static ExpandBar bar;
+static Image image;
+static MenuItem item;
+
+public static void main(String[] args) {
+Shell shell = new Shell();
+Display display = shell.getDisplay();
+shell.setLayout(new FillLayout());
+shell.setText("ExpandBar Example");
+
+Menu menubar = new Menu(shell, SWT.BAR);
+shell.setMenuBar(menubar);
+MenuItem fileItem = new MenuItem(menubar, SWT.CASCADE);
+fileItem.setText("&File");
+Menu submenu = new Menu(shell, SWT.DROP_DOWN);
+fileItem.setMenu(submenu);
+item = new MenuItem(submenu, SWT.PUSH);
+item.setText("New ExpandItem");
+
+bar = new ExpandBar(shell, SWT.V_SCROLL);
+image = display.getSystemImage(SWT.ICON_QUESTION);
+
+// First item
+Composite composite = new Composite(bar, SWT.NONE);
+Menu popupmenu = new Menu(shell, SWT.POP_UP);
+MenuItem popupItem = new MenuItem(popupmenu, SWT.PUSH);
+popupItem.setText("Popup");
+composite.setMenu(popupmenu);
+
+GridLayout layout = new GridLayout(2, false);
+layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
+layout.verticalSpacing = 10;
+composite.setLayout(layout);
+Label label = new Label(composite, SWT.NONE);
+label.setImage(display.getSystemImage(SWT.ICON_ERROR));
+label = new Label(composite, SWT.NONE);
+label.setText("SWT.ICON_ERROR");
+label = new Label(composite, SWT.NONE);
+label.setImage(display.getSystemImage(SWT.ICON_INFORMATION)) ;
+label = new Label(composite, SWT.NONE);
+label.setText("SWT.ICON_INFORMATION");
+label = new Label(composite, SWT.NONE);
+label.setImage(display.getSystemImage(SWT.ICON_WARNING));
+label = new Label(composite, SWT.NONE);
+label.setText("SWT.ICON_WARNING");
+label = new Label(composite, SWT.NONE);
+label.setImage(display.getSystemImage(SWT.ICON_QUESTION));
+label = new Label(composite, SWT.NONE);
+label.setText("SWT.ICON_QUESTION");
+ExpandItem item1 = new ExpandItem(bar, SWT.NONE);
+item1.setText("What is your favorite icon");
+item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+item1.setControl(composite);
+item1.setImage(image);
+
+// Second item
+composite = new Composite(bar, SWT.NONE);
+layout = new GridLayout(2, true);
+layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
+layout.verticalSpacing = 10;
+composite.setLayout(layout);
+Button button1 = new Button(composite, SWT.PUSH);
+button1.setText("Button 1");
+Button button2 = new Button(composite, SWT.PUSH);
+button2.setText("Button 2");
+
+ExpandItem item0 = new ExpandItem(bar, SWT.NONE);
+item0.setText("What is your favorite button");
+item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+item0.setControl(composite);
+item0.setImage(image);
+item0.setExpanded(false);
+
+item.addListener(SWT.Selection, new Listener(){
+@Override
+public void handleEvent(Event e) {
+ExpandItem item2 = new ExpandItem(bar, SWT.NONE);
+Composite composite = new Composite(bar, SWT.NONE);
+GridLayout layout = new GridLayout(2, false);
+composite.setLayout(layout);
+Label label = new Label(composite, SWT.NONE);
+label.setText("What is your name?");
+Composite pcomposite = new Composite(composite, SWT.NONE);
+Text text = new Text(pcomposite, SWT.NONE);
+item2.setText("New Question");
+text.pack();
+composite.pack();
+Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+item2.setHeight(size.y);
+item2.setControl(composite);
+item2.setImage(image);
+item2.setExpanded(true);
+}
+});
+
+bar.setSpacing(8);
+shell.setSize(400, 550);
+shell.open();
+System.out.println("------------------------------");
+System.out.println("getSize: " + button1.getSize());
+System.out.println("getBounds: " + button1.getBounds());
+System.out.println("computeSize: "
++ button1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+System.out.println("getLocation: " + button1.getLocation());
+
+while (!shell.isDisposed()) {
+if (!display.readAndDispatch()) {
+display.sleep();
+}
+}
+image.dispose();
+display.dispose();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354351_MenuSizing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354351_MenuSizing.java
new file mode 100644
index 0000000000..5d1705fc5d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354351_MenuSizing.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug354351_MenuSizing {
+
+ private Display display;
+ private Shell shell;
+
+ private void buildUI() {
+
+ shell = new Shell(display,SWT.CLOSE);
+ shell.setText("SWT Test");
+ shell.setLayout(new GridLayout());
+
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(menuBar);
+ MenuItem fileMenu = new MenuItem(menuBar,SWT.CASCADE);
+ Menu fileSubmenu = new Menu(shell, SWT.DROP_DOWN);
+ fileMenu.setMenu(fileSubmenu);
+ fileMenu.setText("File");
+ MenuItem menuItem = new MenuItem(fileSubmenu,SWT.NONE);
+ menuItem.setText("Menu Item");
+
+ Label l = new Label(shell,SWT.NONE);
+ l.setText("This is some random text.");
+
+ Button button = new Button(shell, SWT.NONE);
+ button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ button.setText("Button");
+
+ shell.addListener(SWT.Close, event -> shell.dispose());
+
+ shell.pack();
+
+ }
+
+ public Bug354351_MenuSizing() {
+
+ display = new Display();
+
+ buildUI();
+
+ if (!shell.isDisposed())
+ shell.open ();
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+
+ }
+
+
+ public static void main(String[] args) {
+
+ new Bug354351_MenuSizing();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354842_PecoTestSnippet.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354842_PecoTestSnippet.java
new file mode 100644
index 0000000000..166543e45c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug354842_PecoTestSnippet.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug354842_PecoTestSnippet {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ CTabFolder folder = new CTabFolder(shell, SWT.NONE);
+ CTabItem item = new CTabItem(folder, SWT.NONE);
+ item.setText("Item");
+
+ Text text = new Text(folder, SWT.NONE);
+ text.setText("test item");
+ item.setControl(text);
+
+ Composite c = new Composite(folder, SWT.NONE);
+ final ToolBar bar = new ToolBar(c, SWT.NONE);
+ ToolItem titem = new ToolItem(bar, SWT.PUSH);
+ titem.setText("Item");
+ folder.setTopRight(c);
+ c.setLayout(new FillLayout());
+
+ shell.setLayout(new FillLayout());
+
+ folder.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("Paint");
+ }
+ });
+
+ shell.setSize(300, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug35644_GCPaintListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug35644_GCPaintListener.java
new file mode 100644
index 0000000000..e5a5429475
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug35644_GCPaintListener.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class Bug35644_GCPaintListener {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+
+ shell.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ if (e.x == 0) return;
+ GC gc1 = new GC(shell);
+ gc1.drawLine(0, 0, 2000, 2000);
+ gc1.dispose();
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug372607_TreeArrowExpand.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug372607_TreeArrowExpand.java
new file mode 100644
index 0000000000..36a35413db
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug372607_TreeArrowExpand.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.TreeEvent;
+import org.eclipse.swt.events.TreeListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug372607_TreeArrowExpand {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout(1, false));
+
+ Tree tree = new Tree(shell, SWT.MULTI | SWT.BORDER);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ for (int i = 0; i < 10; i++) {
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ item.setText("Item " + i);
+ for (int j = 0; j < 10; j++) {
+ TreeItem jtem = new TreeItem(item, SWT.NONE);
+ jtem.setText("Item " + i + ", " + j);
+ for (int k = 0; k < 10; k++) {
+ TreeItem ktem = new TreeItem(jtem, SWT.NONE);
+ ktem.setText("Item " + i + ", " + j + ", " + k);
+ }
+ }
+ }
+ tree.addTreeListener(new TreeListener() {
+ @Override
+ public void treeExpanded(TreeEvent e) {
+ System.out.println(" Expanded: " + e.item + ". getExpanded = " + ((TreeItem) e.item).getExpanded());
+ System.out.println(" " + e);
+ }
+
+ @Override
+ public void treeCollapsed(TreeEvent e) {
+ System.out.println(" Collapsed: " + e.item + ". getExpanded = " + ((TreeItem) e.item).getExpanded());
+ System.out.println(" " + e);
+ }
+ });
+ tree.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println(" Selected: " + e);
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ System.out.println(" DefaultSelected: " + e);
+ }
+ });
+ tree.addKeyListener(new KeyListener() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ System.out.println("Up: " + e);
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ System.out.println("Down: " + e);
+ }
+ });
+
+ shell.setSize(200, 320);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug373183_gdkwindowprocessupdatesCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug373183_gdkwindowprocessupdatesCrash.java
new file mode 100644
index 0000000000..dfbfc374b1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug373183_gdkwindowprocessupdatesCrash.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug373183_gdkwindowprocessupdatesCrash {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("SWT cause jvm crash when handle Setdata event");
+ shell.setLayout(new FillLayout());
+ final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER
+ | SWT.FULL_SELECTION);
+
+ for (int i = 0; i < 2; i++) {
+ TreeColumn column = new TreeColumn(tree, SWT.NONE);
+ column.setText("Column " + i);
+ column.setWidth(100);
+ }
+
+ String[] rowTexts = new String[] { "aa", "bb", "cc", "aa", "bb", "cc"};
+
+// String[] rowTexts = new String[] { "aa", "bb", "cc", "aa", "bb", "cc",
+// "aa", "bb", "cc", "aa", "bb", "cc", "aa", "bb", "cc"};
+
+ tree.setData(rowTexts);
+ tree.addListener(SWT.SetData, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ TreeItem item = (TreeItem) event.item;
+ String rowText = null;
+ String[] rowTexts = (String[]) tree.getData();
+
+ rowText = rowTexts[event.index];
+ item.setText(rowText.toString());
+ item.setText(1, rowText.toString());
+
+ final TreeEditor editor = new TreeEditor(tree);
+ editor.horizontalAlignment = SWT.LEFT;
+ editor.grabHorizontal = true;
+ editor.minimumWidth = 50;
+
+
+ CCombo newEditor = new CCombo(tree, SWT.NONE);
+ newEditor.setText(item.getText(EDITABLECOLUMN));
+
+ newEditor.setFocus();
+ editor.setEditor(newEditor, item, EDITABLECOLUMN);
+ }
+ });
+ tree.setItemCount(rowTexts.length);
+
+ shell.setSize(300, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ final static int EDITABLECOLUMN = 1;
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug375385_ShellFullScreen.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug375385_ShellFullScreen.java
new file mode 100644
index 0000000000..0e15116405
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug375385_ShellFullScreen.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug375385_ShellFullScreen
+{
+ public static void main(String[] args)
+ {
+ Display display = new Display();
+
+ Shell parentShell = new Shell(display);
+ parentShell.setText("Parent widget.shell");
+ parentShell.setSize(400, 300);
+
+ final Shell childShell = new Shell(parentShell, SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.CLOSE);
+ childShell.setSize(300, 200);
+ childShell.setText("Child widget.shell");
+
+ childShell.addMouseListener(new MouseListener()
+ {
+ @Override
+ public void mouseUp(MouseEvent event)
+ {
+
+ }
+
+ @Override
+ public void mouseDown(MouseEvent event)
+ {
+
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent event)
+ {
+ // Toggle full screen mode: works on Mac and Windows, won't work on Linux
+ System.out.println("Full screen: " + childShell.getFullScreen());
+
+ childShell.setFullScreen(! childShell.getFullScreen());
+
+ System.out.println("Full screen: " + childShell.getFullScreen());
+ }
+ });
+
+ parentShell.open();
+ childShell.open();
+
+ while (! parentShell.isDisposed())
+ {
+ if (! display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug386271_setMenuBar.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug386271_setMenuBar.java
new file mode 100644
index 0000000000..c7ade57f9d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug386271_setMenuBar.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug386271_setMenuBar {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("Test Bug?");
+ shell.setSize(1000,550);
+ shell.setLayout(new FormLayout());
+
+ Label testLabel = new Label(shell, SWT.BORDER);
+ testLabel.setText("Some text");
+
+ FormData fdata = new FormData();
+ fdata.left = new FormAttachment(0);
+ fdata.right = new FormAttachment(100);
+ fdata.bottom = new FormAttachment(100);
+ fdata.height = 15;
+ testLabel.setLayoutData(fdata);
+
+ /*When you uncomment the following line, the menu gets created
+ * but the label is pushed back to the bottom and disappears from view.
+ * To me, it seems that the 'bottom' is pushed further down outside the
+ * bottom border shell.
+ */
+ shell.setMenuBar(returnMenu(shell));
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ display.dispose();
+
+ }
+
+ private static Menu returnMenu(Shell shell) {
+ Menu menu = new Menu(shell, SWT.BAR);
+
+ MenuItem fileMenuHeader = new MenuItem(menu, SWT.CASCADE);
+ fileMenuHeader.setText("&File");
+
+ Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
+ fileMenuHeader.setMenu(fileMenu);
+
+ MenuItem fileNewItem = new MenuItem(fileMenu, SWT.PUSH);
+ fileNewItem.setText("&New\tCtrl+N");
+ fileNewItem.setAccelerator(SWT.CTRL + 'N');
+
+ return menu;
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug393723_checkForegroundBug.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug393723_checkForegroundBug.java
new file mode 100644
index 0000000000..e8174733b7
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug393723_checkForegroundBug.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug393723_checkForegroundBug {
+
+public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 200, 200);
+
+ Composite comp = new Composite(shell, SWT.NONE);
+ System.out.println("shell back=" + shell.getBackground());
+ System.out.println("shell fore=" + shell.getForeground());
+ System.out.println("back=" + comp.getBackground());
+ System.out.println("fore=" + comp.getForeground());
+ shell.setForeground(new Color(display, 240, 240, 240));
+ comp.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
+ System.out.println("after");
+ System.out.println("shell back=" + shell.getBackground());
+ System.out.println("shell fore=" + shell.getForeground());
+ System.out.println("back=" + comp.getBackground());
+ System.out.println("fore=" + comp.getForeground());
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug399522_TreeColumnNumber.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug399522_TreeColumnNumber.java
new file mode 100644
index 0000000000..06fe1a09c4
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug399522_TreeColumnNumber.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.*;
+
+
+public class Bug399522_TreeColumnNumber {
+public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ final Table table = new Table(shell, SWT.BORDER);
+ new TableItem(table, SWT.NONE).setText("Item1");
+ new TableColumn(table, SWT.NONE);
+
+ table.setSize(200, 200);
+
+ shell.addListener(SWT.MouseDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println(table.computeSize(-1, -1));
+ }
+ });
+
+ shell.setSize(300, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404448_ImageButtons.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404448_ImageButtons.java
new file mode 100644
index 0000000000..1919640ed8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404448_ImageButtons.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug404448_ImageButtons {
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+
+ Image image = new Image (display, 20, 20);
+ Color color = display.getSystemColor (SWT.COLOR_BLUE);
+ GC gc = new GC (image);
+ gc.setBackground (color);
+ gc.fillRectangle (image.getBounds ());
+ gc.dispose ();
+
+ Image disabledImage = new Image (display, 20, 20);
+ color = display.getSystemColor (SWT.COLOR_GREEN);
+ gc = new GC (disabledImage);
+ gc.setBackground (color);
+ gc.fillRectangle (disabledImage.getBounds ());
+ gc.dispose ();
+
+ Image hotImage = new Image (display, 20, 20);
+ color = display.getSystemColor (SWT.COLOR_RED);
+ gc = new GC (hotImage);
+ gc.setBackground (color);
+ gc.fillRectangle (hotImage.getBounds ());
+ gc.dispose ();
+
+ ToolBar bar = new ToolBar (shell, SWT.BORDER | SWT.FLAT);
+ Rectangle clientArea = shell.getClientArea ();
+ bar.setBounds (clientArea.x, clientArea.y, 200, 32);
+ for (int i=0; i<12; i++) {
+ ToolItem item = new ToolItem (bar, 0);
+ item.setImage (image);
+ item.setDisabledImage (disabledImage);
+ item.setHotImage (hotImage);
+ if (i % 3 == 0) item.setEnabled (false);
+ }
+
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ image.dispose ();
+ disabledImage.dispose ();
+ hotImage.dispose ();
+ display.dispose ();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404946_GetActiveShellBug.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404946_GetActiveShellBug.java
new file mode 100644
index 0000000000..8fe67486f9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug404946_GetActiveShellBug.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class Bug404946_GetActiveShellBug {
+
+ public static void main (String [] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.open();
+ System.out.println(display.getActiveShell() == shell);
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug42416_GCWrongOrigin.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug42416_GCWrongOrigin.java
new file mode 100644
index 0000000000..bcee11edc8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug42416_GCWrongOrigin.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug42416_GCWrongOrigin {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Color red = display.getSystemColor(SWT.COLOR_RED);
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ final Table table = new Table(shell, SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ TableColumn column3 = new TableColumn(table, SWT.NONE);
+ for (int i = 0; i < 10; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] {"asdadas", "asdadasd", "rrwrwrw"});
+ }
+ column1.pack();
+ column2.pack();
+ column3.pack();
+ table.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ System.out.println("mouse down at "+e.x+" "+e.y);
+ GC gc = new GC(table);
+ gc.setForeground(red);
+ gc.drawRectangle(e.x, e.y, 2, 2);
+ gc.dispose();
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430538_JS_Set_Background.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430538_JS_Set_Background.java
new file mode 100644
index 0000000000..252ab31fc4
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430538_JS_Set_Background.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.util.Properties;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Copied and adapted from Snippet128
+ *
+ * Web-Browser that loads a static HTML page.
+ * Then it uses some JavaScript to modify background.
+ * @author lufimtse
+ *
+ */
+
+public class Bug430538_JS_Set_Background {
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ shell.setLayout(gridLayout);
+
+ Button executeJS = new Button(shell, SWT.PUSH);
+ executeJS.setText("Execute JS (Red background)");
+
+ Button evauateJS = new Button(shell, SWT.PUSH);
+ evauateJS.setText("Evaluate JS (Green with return val)");
+
+ Button evaluateGetId = new Button(shell, SWT.PUSH);
+ evaluateGetId.setText("Get paragraph content");
+
+ Button execDefineMethod = new Button(shell, SWT.PUSH);
+ execDefineMethod.setText("Define a method");
+
+ Button execUseNewlyDefineMethod = new Button(shell, SWT.PUSH);
+ execUseNewlyDefineMethod.setText("Use newly defined method");
+
+ final Browser browser = new Browser(shell, SWT.WEBKIT);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ browser.setLayoutData(gd);
+ String html = "<body>Hello<br>world</body>";
+ browser.setText(html);
+
+ // Append Webkit version into snippet title.
+ String SWT_WEBKITGTK_VERSION = "org.eclipse.swt.internal.webkitgtk.version"; //$NON-NLS-1$
+ Properties sp = System.getProperties();
+ String webkitGtkVer = sp.getProperty(SWT_WEBKITGTK_VERSION);
+ shell.setText("Webkit version: " + webkitGtkVer);
+
+ // EXECUTE
+ executeJS.addListener(SWT.MouseDown, ev -> {
+ String script = "document.body.style.backgroundColor = 'red'; function hullo() {return 'hi'}; hullo()";
+ browser.execute(script);
+ });
+
+
+ // EVALUATE << NOT EXECUTE.
+ evauateJS.addListener(SWT.MouseDown, ev -> {
+ String script = "return 1 + 2; document.body.style.backgroundColor = 'green'; function hullo() {return 'hi'}; hullo()";
+ String result = (String) browser.evaluate(script);
+ System.out.println("Java: returned: " + result);
+ });
+
+ evaluateGetId.addListener(SWT.MouseDown, ev -> {
+ String script = "function hullo() {return document.getElementById('myid').childNodes[0].nodeValue;}; hullo()";
+ String result = (String) browser.evaluate(script);
+ System.out.println("Java: returned: " + result);
+ });
+
+ execDefineMethod.addListener(SWT.MouseDown, ev -> {
+ String script = "function myNewFunc() {document.body.style.backgroundColor = 'red';return 'hello world'}";
+ browser.execute(script);
+ });
+ execUseNewlyDefineMethod.addListener(SWT.MouseDown, ev -> {
+ String script = "myNewFunc()";
+ browser.execute(script);
+ });
+
+
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpandItemHeaderHeight.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpandItemHeaderHeight.java
new file mode 100644
index 0000000000..0ac41df513
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpandItemHeaderHeight.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+public class Bug430600_ExpandItemHeaderHeight {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ ExpandBar expandBar = new ExpandBar(shell, SWT.NONE);
+
+ final ExpandItem xpndtmTest = new ExpandItem(expandBar, SWT.NONE);
+ xpndtmTest.setExpanded(true);
+
+ System.out.println(xpndtmTest.getHeaderHeight()); //Correct
+ xpndtmTest.setHeight(100);
+ System.out.println(xpndtmTest.getHeaderHeight()); //Some negative number
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpanditemGetHeaderHeightIncorrect.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpanditemGetHeaderHeightIncorrect.java
new file mode 100644
index 0000000000..c5da472399
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug430600_ExpanditemGetHeaderHeightIncorrect.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+public class Bug430600_ExpanditemGetHeaderHeightIncorrect {
+ public static void main(String[] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ shell.setText("ExpandBar Example");
+
+ ExpandBar expandBar = new ExpandBar(shell, SWT.NONE);
+ Image image = display.getSystemImage(SWT.ICON_QUESTION);
+
+ Composite composite = new Composite (expandBar, SWT.NONE);
+ GridLayout layout = new GridLayout ();
+ layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
+ layout.verticalSpacing = 10;
+ composite.setLayout(layout);
+ Button button = new Button (composite, SWT.PUSH);
+ button.setText("SWT.PUSH");
+ button = new Button (composite, SWT.RADIO);
+ button.setText("SWT.RADIO");
+ button = new Button (composite, SWT.CHECK);
+ button.setText("SWT.CHECK");
+ button = new Button (composite, SWT.TOGGLE);
+ button.setText("SWT.TOGGLE");
+ ExpandItem item0 = new ExpandItem (expandBar, SWT.NONE, 0);
+ item0.setText("What is your favorite button");
+ item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+ item0.setControl(composite);
+ item0.setImage(image);
+ item0.setExpanded(true);
+
+ System.out.println(item0.getHeaderHeight());
+ item0.setHeight(40);
+ System.out.println(item0.getHeaderHeight());
+
+ shell.setSize(400, 350);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+
+ }
+}
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarCroppingIssue.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarCroppingIssue.java
new file mode 100644
index 0000000000..2af34857f9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarCroppingIssue.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug443185_ToolbarCroppingIssue {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(200, 400);
+ shell.setLayout(new GridLayout());
+
+ // Create the tabs
+ CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
+ tabFolder.setMaximizeVisible(true);
+ tabFolder.setMinimizeVisible(true);
+
+ CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
+ item.setText("Tab (1)");
+ item.setShowClose(true);
+ Label content=new Label(tabFolder,SWT.NONE);
+ content.setText("bla");
+ item.setControl(content);
+
+ //intermediate composite with possible different layouts
+// Composite composite = new Composite(tabFolder, SWT.NONE);
+// composite.setLayout(new FillLayout(SWT.HORIZONTAL));
+// composite.setLayout(new GridLayout());
+// composite.setLayout(new RowLayout());
+
+
+ ToolBar toolBar=new ToolBar(tabFolder, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
+// toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+// toolBar.setLayoutData(new RowData());
+ for(int i=0;i<15;i++){
+ ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setText("test_"+i);
+ if(i%5==0){
+ new ToolItem(toolBar, SWT.SEPARATOR);
+ }
+ }
+ tabFolder.setTopRight(toolBar,SWT.RIGHT | SWT.WRAP);
+
+
+ //SWT Loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestFillLayout.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestFillLayout.java
new file mode 100644
index 0000000000..4ebf0dfb5d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestFillLayout.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug443185_ToolbarTestFillLayout {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(200, 400);
+ shell.setLayout(new GridLayout());
+
+ // Create the tabs
+ CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
+ tabFolder.setMaximizeVisible(true);
+ tabFolder.setMinimizeVisible(true);
+
+ CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
+ item.setText("Tab (1)");
+ item.setShowClose(true);
+ Label content=new Label(tabFolder,SWT.NONE);
+ content.setText("bla");
+ item.setControl(content);
+
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayout(new FillLayout(SWT.HORIZONTAL));
+
+
+ ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
+ for(int i=0;i<15;i++){
+ ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setText("test_"+i);
+ if(i%5==0){
+ new ToolItem(toolBar, SWT.SEPARATOR);
+ }
+ }
+ tabFolder.setTopRight(composite,SWT.RIGHT | SWT.WRAP);
+
+
+ //SWT Loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestGridLayout.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestGridLayout.java
new file mode 100644
index 0000000000..2d244f9997
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestGridLayout.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug443185_ToolbarTestGridLayout {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(200, 400);
+ shell.setLayout(new GridLayout());
+
+ // Create the tabs
+ CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
+ tabFolder.setMaximizeVisible(true);
+ tabFolder.setMinimizeVisible(true);
+
+ CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
+ item.setText("Tab (1)");
+ item.setShowClose(true);
+ Label content=new Label(tabFolder,SWT.NONE);
+ content.setText("bla");
+ item.setControl(content);
+
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayout(new GridLayout());
+
+
+ ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
+ toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ for(int i=0;i<15;i++){
+ ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setText("test_"+i);
+ if(i%5==0){
+ new ToolItem(toolBar, SWT.SEPARATOR);
+ }
+ }
+ tabFolder.setTopRight(composite,SWT.RIGHT | SWT.WRAP);
+
+
+ //SWT Loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestPlain.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestPlain.java
new file mode 100644
index 0000000000..4ce561ae32
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestPlain.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug443185_ToolbarTestPlain {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(200, 400);
+ shell.setLayout(new GridLayout());
+
+ // Create the tabs
+ CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
+ tabFolder.setMaximizeVisible(true);
+ tabFolder.setMinimizeVisible(true);
+
+ CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
+ item.setText("Tab (1)");
+ item.setShowClose(true);
+ Label content=new Label(tabFolder,SWT.NONE);
+ content.setText("bla");
+ item.setControl(content);
+
+ ToolBar toolBar=new ToolBar(tabFolder, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
+ for(int i=0;i<15;i++){
+ ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setText("test_"+i);
+ if(i%5==0){
+ new ToolItem(toolBar, SWT.SEPARATOR);
+ }
+ }
+ tabFolder.setTopRight(toolBar,SWT.RIGHT | SWT.WRAP);
+
+
+ //SWT Loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestRowLayout.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestRowLayout.java
new file mode 100644
index 0000000000..09a22f83a9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug443185_ToolbarTestRowLayout.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug443185_ToolbarTestRowLayout {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(200, 400);
+ shell.setLayout(new GridLayout());
+
+ // Create the tabs
+ CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
+ tabFolder.setMaximizeVisible(true);
+ tabFolder.setMinimizeVisible(true);
+
+ CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
+ item.setText("Tab (1)");
+ item.setShowClose(true);
+ Label content=new Label(tabFolder,SWT.NONE);
+ content.setText("bla");
+ item.setControl(content);
+
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayout(new RowLayout());
+
+
+ ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
+ toolBar.setLayoutData(new RowData());
+ for(int i=0;i<15;i++){
+ ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
+ toolItem.setText("test_"+i);
+ if(i%5==0){
+ new ToolItem(toolBar, SWT.SEPARATOR);
+ }
+ }
+ tabFolder.setTopRight(composite ,SWT.RIGHT | SWT.WRAP);
+
+
+ //SWT Loop
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug449000_TableDrawingColumnMoved.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug449000_TableDrawingColumnMoved.java
new file mode 100644
index 0000000000..5bfbf88193
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug449000_TableDrawingColumnMoved.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug449000_TableDrawingColumnMoved {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ GridLayout layout = new GridLayout();
+ shell.setLayout(layout);
+
+ final Table table = new Table(shell, SWT.NONE);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ column1.setText("Column 1");
+ column1.setMoveable(true);
+
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ column2.setText("Column 2");
+ column2.setMoveable(true);
+
+ TableColumn column3 = new TableColumn(table, SWT.NONE);
+ column3.setText("Column 3");
+ column3.setMoveable(true);
+
+ column3.addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent e) {
+ table.getClientArea();
+ }
+ });
+
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] { "column 1 widget.text", "column 2 widget.text",
+ "column 3 widget.text" });
+
+ for (TableColumn column : table.getColumns()) {
+ column.pack();
+ }
+
+ shell.setMinimumSize(200, 200);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug457196_TableRightPaddingTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug457196_TableRightPaddingTest.java
new file mode 100644
index 0000000000..1273cec19a
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug457196_TableRightPaddingTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug457196_TableRightPaddingTest {
+
+ public static void main(String[] a) {
+ Shell shell = new Shell(Display.getDefault());
+ shell.setSize(200, 180);
+ shell.setLayout(new FillLayout());
+
+ Table t = new Table(shell, SWT.BORDER);
+ t.setHeaderVisible(true);
+
+ TableColumn tc1 = new TableColumn(t, SWT.NONE);
+ TableColumn tc2 = new TableColumn(t, SWT.NONE);
+ tc1.setText("First Name");
+ tc2.setText("Last Name");
+ tc1.setWidth(70);
+ tc2.setWidth(70);
+
+ /*t.addListener(SWT.MeasureItem, new Listener() {
+ public void handleEvent(Event event) {
+ event.height = 30;
+ }
+ });*/
+
+ new TableItem(t, SWT.NONE).setText(new String[] { "Tim", "Hatton" });
+ new TableItem(t, SWT.NONE).setText(new String[] { "Caitlyn", "Warner" });
+
+ shell.open();
+ shell.layout();
+
+ Display display = Display.getDefault();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug460017_ComboOverwrite.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug460017_ComboOverwrite.java
new file mode 100644
index 0000000000..8218731012
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug460017_ComboOverwrite.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug460017_ComboOverwrite {
+ public static void main(String[] args) {
+ final Display disp = Display.getDefault();
+ Shell shell = new Shell(disp);
+ shell.setLayout(new GridLayout());
+
+ final Combo combo = new Combo(shell, SWT.READ_ONLY | SWT.BORDER);
+ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ combo.add("first", 0);
+ combo.add("second", 1);
+ combo.add("third", 1);
+ combo.add("fourth", 1);
+
+ shell.setText("Combo Test");
+ shell.setSize(200, 200);
+ shell.setLocation(0, 0);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!disp.readAndDispatch()) {
+ disp.sleep();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug46059_FocusListenerSelectAll.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug46059_FocusListenerSelectAll.java
new file mode 100644
index 0000000000..2df2c57a37
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug46059_FocusListenerSelectAll.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug46059_FocusListenerSelectAll {
+
+ public static final void main(final String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new RowLayout());
+ final Text text1 = new Text(shell, SWT.NULL);
+ text1.setText("Set focus, but select all fails."); //$NON-NLS-1$
+ text1.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ text1.setSelection(0, text1.getText().length());
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ // Do nothing.
+ }
+ });
+ final Text text2 = new Text(shell, SWT.NULL);
+ text2.setText("Use me to change focus."); //$NON-NLS-1$
+ text2.setFocus();
+ shell.pack();
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_ListTopIndexTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_ListTopIndexTest.java
new file mode 100644
index 0000000000..e72c8f07cc
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_ListTopIndexTest.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * List example snippet: print selected items in a widget.list
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug461354_ListTopIndexTest {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ final List list = new List (shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+ for (int i=0; i<128; i++) list.add ("Item " + i);
+ list.setTopIndex(40);
+ System.out.println(list.getTopIndex());
+ Rectangle clientArea = shell.getClientArea ();
+ list.setBounds (clientArea.x, clientArea.y, 100, 100);
+ list.addListener (SWT.Selection, e -> {
+ int [] selection = list.getSelectionIndices ();
+ for (int i=0; i<selection.length; i++) {
+ }
+ System.out.println ("topIndex" + list.getTopIndex());
+ });
+ list.addListener (SWT.DefaultSelection, e -> {
+ int [] selection = list.getSelectionIndices ();
+ for (int i=0; i<selection.length; i++)
+ {
+ }
+ });
+ list.addListener (SWT.MouseWheel, e -> {
+ System.out.println(list.getTopIndex());
+ });
+ list.setTopIndex(4);
+// widget.list.setSelection(60);
+// widget.list.setTopIndex(40);
+ System.out.println(list.getTopIndex());
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_TopIndexTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_TopIndexTest.java
new file mode 100644
index 0000000000..af52ee4033
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug461354_TopIndexTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug461354_TopIndexTest {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display, SWT.SHELL_TRIM);
+ shell.setLayout(new FillLayout());
+ List list= new List(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+
+ // necessary to make the first getTopIndex() call return non-zero:
+ list.setItems(new String[] {"Hello", "World"});
+
+ shell.setSize(500, 500);
+ shell.open();
+
+ list.removeAll();
+ String[] items = new String[100];
+ for (int i = 0; i < items.length; i++) {
+ items[i] = "0-" + i + " name-" + i;
+ }
+ list.setItems(items);
+ list.setSelection(new int[] { 50 });
+ list.showSelection();
+ System.out.println(list.getTopIndex()); // should not be 0
+
+ while (display.readAndDispatch()) { }
+
+ System.out.println(list.getTopIndex()); // should not be 0
+
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug465054_PaintItemTestSnippet.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug465054_PaintItemTestSnippet.java
new file mode 100644
index 0000000000..abcb60227c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug465054_PaintItemTestSnippet.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug465054_PaintItemTestSnippet {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shellMain = new Shell(display, SWT.SHELL_TRIM);
+ shellMain.setLayout(new FillLayout(SWT.VERTICAL));
+
+ Tree tree = new Tree(shellMain, SWT.BORDER);
+ new TreeItem(tree, SWT.NONE).setText("setText");
+ for (int i = 0; i < 100; i++) {
+ new TreeItem(tree, SWT.NONE).setText("setText " + i);
+ }
+
+ tree.addListener(SWT.PaintItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("PaintItem");
+ Rectangle bounds = ((TreeItem) event.item).getBounds(event.index);
+ event.gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+ event.gc.drawText(((TreeItem) event.item).getText(), bounds.x, bounds.y, true);
+ }
+ });
+
+
+ shellMain.open();
+
+ while (!shellMain.isDisposed()) {
+ try {
+ if (!display.readAndDispatch())
+ display.sleep();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextFormsAbbreviated.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextFormsAbbreviated.java
new file mode 100644
index 0000000000..1066bee2e0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextFormsAbbreviated.java
@@ -0,0 +1,56 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * GridLayout snippet: grow/shrink a wrappable Text's height to show its
+ * content as it changes
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug466314_TextFormsAbbreviated {
+
+public static void main(String[] args) {
+ final int TEXT_WIDTH = 100;
+
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ final Text text = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER);
+ text.setLayoutData(new GridData(TEXT_WIDTH, 10));
+ text.setText("Eclipse very good IDE to develop multiple RCP apps and other products");
+ text.addListener(SWT.Modify, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int currentHeight = text.getSize().y;
+ int preferredHeight = text.computeSize(TEXT_WIDTH, SWT.DEFAULT).y;
+ if (currentHeight != preferredHeight) {
+ GridData data = (GridData)text.getLayoutData();
+ data.heightHint = preferredHeight;
+ shell.pack();
+ }
+ }
+ });
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+}
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextTest.java
new file mode 100644
index 0000000000..d683bb8fb5
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug466314_TextTest.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug466314_TextTest {
+
+ public static void main(String[] args) {
+ final int TEXT_WIDTH = 100;
+
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ final Text text = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER);
+ text.setLayoutData(new GridData(TEXT_WIDTH, 50));
+ text.setText("Eclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other productsEclipse very good IDE to develop multiple RCP apps and other products");
+ text.addListener(SWT.Modify, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int currentHeight = text.getSize().y;
+ int preferredHeight = text.computeSize(TEXT_WIDTH, SWT.DEFAULT).y;
+ if (currentHeight != preferredHeight) {
+ GridData data = (GridData)text.getLayoutData();
+ data.heightHint = preferredHeight;
+ shell.pack();
+ }
+ }
+ });
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476419_TreeWideIcons.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476419_TreeWideIcons.java
new file mode 100644
index 0000000000..03f5e8ca5a
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476419_TreeWideIcons.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug476419_TreeWideIcons {
+ public static void main(String [] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ int W = 22, H = 16;
+ final Image xImage = new Image (display, W, H);
+ GC gc = new GC(xImage);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ gc.drawLine(0, 0, W - 1, H -1);
+ gc.drawLine(0, H - 1, W - 1, 0);
+ gc.drawOval(1, 1, W - 2, H - 2);
+ gc.dispose();
+
+ final Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ TreeItem lastItem = new TreeItem(tree, SWT.NONE);
+ lastItem.setImage(xImage);
+ lastItem.setText("root item");
+
+ for (int i = 0; i < 3; i++) {
+ TreeItem newItem = new TreeItem(lastItem, SWT.NONE);
+ newItem.setText("descendant A" + i);
+ newItem.setImage(xImage);
+
+ newItem = new TreeItem(lastItem, SWT.NONE);
+ newItem.setText("descendant B" + i);
+ newItem.setImage(xImage);
+
+ lastItem.setExpanded(true);
+ lastItem = newItem;
+ }
+
+// widget.tree.addListener(SWT.PaintItem, new Listener() {
+// @Override
+// public void handleEvent(Event event) {
+// TreeItem item = (TreeItem)event.item;
+// Rectangle ib = item.getImageBounds(0);
+// You can add an offset here to make the issue more visible:
+// event.gc.drawImage(xImage, ib.x, ib.y + 10);
+// event.gc.drawImage(xImage, ib.x, ib.y);
+
+// Rectangle tb = item.getTextBounds(0);
+// You can add an offset here to make the issue more visible:
+// event.gc.drawText(item.getText(), tb.x + 10, tb.y);
+// event.gc.drawText(item.getText(), tb.x, tb.y);
+// }
+// });
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ xImage.dispose();
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476441_TreeIconTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476441_TreeIconTest.java
new file mode 100644
index 0000000000..cc565b07f2
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug476441_TreeIconTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug476441_TreeIconTest {
+ public static void main(String [] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ int W = 16, H = 16;
+ final Image xImage = new Image (display, W, H);
+ GC gc = new GC(xImage);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ gc.drawLine(0, 0, W - 1, H -1);
+ gc.drawLine(0, H - 1, W - 1, 0);
+ gc.drawOval(1, 1, W - 2, H - 2);
+ gc.dispose();
+
+ final Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ TreeItem lastItem = new TreeItem(tree, SWT.NONE);
+ lastItem.setImage(xImage);
+ lastItem.setText("root item");
+
+ for (int i = 0; i < 3; i++) {
+ TreeItem newItem = new TreeItem(lastItem, SWT.NONE);
+ newItem.setText("descendant A" + i);
+ newItem.setImage(xImage);
+
+ newItem = new TreeItem(lastItem, SWT.NONE);
+ newItem.setText("descendant B" + i);
+ newItem.setImage(xImage);
+
+ lastItem.setExpanded(true);
+ lastItem = newItem;
+ }
+
+ tree.addListener(SWT.PaintItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ TreeItem item = (TreeItem)event.item;
+ Rectangle ib = item.getImageBounds(0);
+// You can add an offset here to make the issue more visible:
+// event.gc.drawImage(xImage, ib.x, ib.y + 10);
+ event.gc.drawImage(xImage, ib.x, ib.y);
+
+ Rectangle tb = item.getTextBounds(0);
+// You can add an offset here to make the issue more visible:
+// event.gc.drawText(item.getText(), tb.x + 10, tb.y);
+ event.gc.drawText(item.getText(), tb.x, tb.y);
+ }
+ });
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ xImage.dispose();
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug479200_MenuTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug479200_MenuTest.java
new file mode 100644
index 0000000000..6a48315e71
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug479200_MenuTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug479200_MenuTest {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Text t = new Text(shell, SWT.BORDER | SWT.MULTI);
+ t.setText ("here is some widget.text to be selected");
+ Menu bar = new Menu (shell, SWT.BAR);
+ shell.setMenuBar (bar);
+ MenuItem editItem = new MenuItem (bar, SWT.CASCADE);
+ editItem.setText ("Edit");
+ Menu submenu = new Menu (shell, SWT.DROP_DOWN);
+ editItem.setMenu (submenu);
+
+ MenuItem item = new MenuItem (submenu, SWT.PUSH);
+ item.addListener (SWT.Selection, new Listener () {
+ @Override
+ public void handleEvent (Event e) {
+ t.selectAll();
+ }
+ });
+ item.setText ("Select &All\tCtrl+A");
+ item.setAccelerator (SWT.MOD1 + 'A');
+
+// Test for error in count
+ item.setEnabled(false);
+ System.out.println(bar.getItemCount());
+
+ // Note that as long as your application has not overridden
+ // the global accelerators for copy, paste, and cut
+ //(CTRL+C or CTRL+INSERT, CTRL+V or SHIFT+INSERT, and CTRL+X or SHIFT+DELETE)
+ // these behaviours are already available by default.
+ // If your application overrides these accelerators,
+ // you will need to call Text.copy(), Text.paste() and Text.cut()
+ // from the Selection callback for the accelerator when the
+ // widget.text widget has focus.
+
+ shell.setSize(200, 200);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug480926_CellEditorPosition.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug480926_CellEditorPosition.java
new file mode 100644
index 0000000000..bb97303e6a
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug480926_CellEditorPosition.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.*;
+
+public class Bug480926_CellEditorPosition {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final Tree tree = new Tree(shell, SWT.FULL_SELECTION);
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+
+ TreeColumn column1 = new TreeColumn(tree, 0);
+ column1.setText("Column 1");
+ column1.setWidth(150);
+
+ TreeColumn column2 = new TreeColumn(tree, 0);
+ column2.setText("Column 2");
+ column2.setWidth(150);
+
+ TreeItem item = new TreeItem(tree, SWT.NONE, 0);
+ item.setText("Row 1");
+
+ final TreeEditor treeEditor = new TreeEditor(tree);
+ treeEditor.horizontalAlignment = SWT.LEFT;
+ treeEditor.grabHorizontal = true;
+
+ tree.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ TreeItem item = tree.getSelection()[0];
+ Text text = new Text(tree, SWT.NONE);
+ treeEditor.setEditor(text, item, 1);
+ }
+ });
+
+ tree.addListener(SWT.PaintItem, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+
+ }
+ });
+
+ shell.setSize(600, 400);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug481010_ShellSize.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug481010_ShellSize.java
new file mode 100644
index 0000000000..2208c82d43
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug481010_ShellSize.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+//import org.eclipse.swt.internal.gtk.OS;
+
+
+/*
+ * NOTE: this snippet requires OS.ascii() to be public in order to function.
+ * Please modify its api.visibility and uncomment the rest of the snippet.
+ */
+
+public class Bug481010_ShellSize {
+
+ public static void main(String[] args) {
+// OS.gtk_init_check(new long[0], new long[0]);
+// /* create a new window */
+// long window = OS.gtk_window_new(OS.GTK_WINDOW_TOPLEVEL);
+//
+//
+// long button = OS.gtk_button_new();
+//
+// long labelHandle = OS.gtk_label_new (OS.ascii("Hello world"));
+// OS.gtk_container_add(button, labelHandle);
+// OS.gtk_container_add(window, button);
+// OS.gtk_widget_show(labelHandle);
+// OS.gtk_widget_show(button);
+//
+// OS.gtk_widget_show(window);
+// OS.gtk_window_resize(window, 400, 400);
+//
+//
+// OS.gtk_main();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug482457_JVMCrashMainContextIteration.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug482457_JVMCrashMainContextIteration.java
new file mode 100644
index 0000000000..0ae9bdf17c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug482457_JVMCrashMainContextIteration.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug482457_JVMCrashMainContextIteration {
+
+ public static void main(String[] args) {
+
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Button button = new Button(shell, SWT.PUSH);
+ button.setText("buttontext");
+ button.setToolTipText("tooltiptext");
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ for (int i = 0; i<3; i++) {
+ final Shell s = new Shell(display, SWT.TOOL);
+ s.addShellListener(new ShellListener() {
+
+ @Override
+ public void shellIconified(ShellEvent e) {}
+
+ @Override
+ public void shellDeiconified(ShellEvent e) {}
+
+
+
+ @Override
+ public void shellDeactivated(ShellEvent e) {
+ if (s != null && !s.isDisposed()) {
+ s.close();
+ }
+ }
+
+ @Override
+ public void shellClosed(ShellEvent e) {}
+
+ @Override
+ public void shellActivated(ShellEvent e) {}
+ });
+
+ Composite c = new Composite(s, SWT.NONE);
+ c.setLayout(new GridLayout(1, true));
+
+ Label l = new Label(c, SWT.NONE);
+
+ l.setText("this is a widget.label");
+ c.pack();
+
+
+ s.layout();
+ s.pack();
+ s.setLocation(250+i*20, 100+1*20);
+ s.open();
+ }
+ }
+
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug483112_TreeColumnsTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug483112_TreeColumnsTest.java
new file mode 100644
index 0000000000..4ece7003b7
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug483112_TreeColumnsTest.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug483112_TreeColumnsTest {
+ public static void main (String [] args) {
+ Display display = Display.getDefault();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ Tree tree = new Tree(shell, SWT.NONE);
+ tree.setHeaderVisible(true);
+
+ TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
+ column1.setText("Column 1");
+ column1.setWidth(50);
+ TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
+ column2.setText("Column 2");
+ column2.setWidth(50);
+ TreeColumn column3 = new TreeColumn(tree, SWT.LEFT);
+ column3.setText("Column 3");
+ column3.setWidth(50);
+
+ int W = 100, H = 100;
+ final Image xImage = new Image (display, W, H);
+ GC gc = new GC(xImage);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ gc.drawLine(0, 0, W - 1, H -1);
+ gc.drawLine(0, H - 1, W - 1, 0);
+ gc.drawOval(1, 1, W - 2, H - 2);
+ gc.dispose();
+
+ int Wz = 40, Hz = 40;
+ final Image zImage = new Image (display, Wz, Hz);
+ GC gcz = new GC(zImage);
+ gcz.setForeground(display.getSystemColor(SWT.COLOR_RED));
+ gcz.drawLine(0, 0, Wz - 1, Hz -1);
+ gcz.drawLine(0, Hz - 1, Wz - 1, 0);
+ gcz.drawOval(1, 1, Wz - 2, Hz - 2);
+ gcz.dispose();
+
+
+ TreeItem item = new TreeItem(tree, SWT.NONE);
+ System.out.println("Image dimensions and size of column renderers is " + xImage.getBounds());
+ item.setImage(0, xImage);
+ item.setImage(1, xImage);
+ item.setImage(2, zImage);
+ item.setText(2, "Test");
+ System.out.println("column 0 getImageBounds() is " + item.getImageBounds(0));
+ System.out.println("column 1 getImageBounds() is " + item.getImageBounds(1));
+ System.out.println("column 2 getImageBounds() is " + item.getImageBounds(2));
+
+ shell.pack();
+ shell.open();
+
+ while(!shell.isDisposed())
+ {
+ if(!display.readAndDispatch())
+ display.sleep();
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_AllocationWarnings.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_AllocationWarnings.java
new file mode 100644
index 0000000000..29cb27724b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_AllocationWarnings.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug486068_AllocationWarnings {
+
+ public Bug486068_AllocationWarnings() {
+
+ }
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ Text text = new Text (shell, SWT.V_SCROLL);
+// text.setBounds(0, 0, 200, 30);
+ shell.setBounds(0, 0, 50, 50);
+ System.out.println(text.getBounds());
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_ExpandBarTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_ExpandBarTest.java
new file mode 100644
index 0000000000..b38cfb1656
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug486068_ExpandBarTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ExpandBar;
+import org.eclipse.swt.widgets.ExpandItem;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug486068_ExpandBarTest {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ shell.setText("ExpandBar Example");
+ ExpandBar bar = new ExpandBar (shell, SWT.V_SCROLL);
+
+
+ // First item
+ Composite composite = new Composite (bar, SWT.NONE);
+ GridLayout layout = new GridLayout ();
+ layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
+ layout.verticalSpacing = 10;
+ composite.setLayout(layout);
+
+
+// Button button = new Button (composite, SWT.PUSH);
+// button.setText("SWT.PUSH");
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("meh");
+
+ ExpandItem item0 = new ExpandItem (bar, SWT.NONE, 0);
+
+ item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+ item0.setControl(composite);
+ item0.setExpanded(true);
+ bar.setSpacing(8);
+
+
+ shell.setSize(400, 350);
+ shell.open();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) {
+ display.sleep ();
+ }
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487467_TextTopIndexTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487467_TextTopIndexTest.java
new file mode 100644
index 0000000000..dd11beddc5
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487467_TextTopIndexTest.java
@@ -0,0 +1,64 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * Text example snippet: set the selection (start, end),
+ * and then scroll the selection to the top of the client area
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug487467_TextTopIndexTest {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ Text text = new Text (shell, SWT.BORDER | SWT.V_SCROLL);
+ Rectangle clientArea = shell.getClientArea ();
+ text.setBounds (clientArea.x + 10, clientArea.y + 10, 100, 100);
+ for (int i=0; i<50; i++) {
+ text.append ("Line " + i + "\n");
+ }
+ shell.open ();
+
+// widget.text.setSelection (0, 5);
+// widget.text.setTopIndex(20);
+// System.out.println(widget.text.getTopIndex());
+// System.out.println ("selection=" + widget.text.getSelection ());
+// System.out.println ("selection widget.text=" + widget.text.getSelectionText ());
+// System.out.println ("caret position=" + widget.text.getCaretPosition ());
+// System.out.println ("caret location=" + widget.text.getCaretLocation ());
+// while (!widget.shell.isDisposed ()) {
+// if (!display.readAndDispatch ()) display.sleep ();
+
+// widget.text.setSelection (0, 5);
+ text.setTopIndex(20);
+ int perm = text.getTopIndex();
+// System.out.println ("selection=" + widget.text.getSelection ());
+// System.out.println ("selection widget.text=" + widget.text.getSelectionText ());
+// System.out.println ("caret position=" + widget.text.getCaretPosition ());
+// System.out.println ("caret location=" + widget.text.getCaretLocation ());
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ if (text.getTopIndex() != 20) {
+ System.out.println("initial " + perm + " " + "current " + text.getTopIndex());
+ }
+
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487522_TextPadding.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487522_TextPadding.java
new file mode 100644
index 0000000000..2c916470b1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug487522_TextPadding.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Creates and opens a wizard dialog with two simple wizard pages.
+ */
+public class Bug487522_TextPadding {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell();
+ shell.setLayout(new GridLayout(1, true));
+ Text text;
+
+ text = new Text(shell, SWT.SEARCH);
+ text.setMessage("search");
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug489640_ComboPerformanceTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug489640_ComboPerformanceTest.java
new file mode 100644
index 0000000000..4d5b3a6d76
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug489640_ComboPerformanceTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.nio.charset.*;
+import java.util.*;
+import java.util.List;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug489640_ComboPerformanceTest {
+
+ public static void main(String[] args) {
+ final Map<String, Charset> charSets = Charset.availableCharsets();
+ final List<String> encodings = new ArrayList<>(charSets.keySet());
+ Collections.sort(encodings);
+
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ final Combo combo = new Combo(shell, SWT.BORDER | SWT.READ_ONLY);
+ combo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+ final Button button = new Button(shell, SWT.PUSH);
+ button.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ button.setText("Fill Combo");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ final String[] items = encodings.toArray(new String[encodings.size()]);
+ System.out.println("Setting widget.combo with " + items.length + " items");
+ final long start = System.currentTimeMillis();
+ combo.setItems(items);
+ final long end = System.currentTimeMillis();
+ System.out.println("took " + (end - start) + " ms.");
+ combo.select(0);
+ }
+ });
+
+ shell.setSize(400, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_BackgroundInheritanceTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_BackgroundInheritanceTest.java
new file mode 100644
index 0000000000..887213731d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_BackgroundInheritanceTest.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * @author Thomas Singer
+ */
+public class Bug490280_BackgroundInheritanceTest {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final Composite panel = new Composite(shell, SWT.NO_RADIO_GROUP);
+ panel.setLayout(new FillLayout());
+ panel.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ panel.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
+
+ final Label textLabel = new Label(panel, SWT.LEFT);
+ textLabel.setText("hello");
+
+ shell.setSize(300, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_ColorInheritanceTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_ColorInheritanceTest.java
new file mode 100644
index 0000000000..a032444b02
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490280_ColorInheritanceTest.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * @author Thomas Singer
+ */
+public class Bug490280_ColorInheritanceTest {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final Composite panel = new Composite(shell, SWT.NO_RADIO_GROUP);
+ panel.setLayout(new FillLayout());
+ panel.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ panel.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
+
+ final Label textLabel = new Label(panel, SWT.LEFT);
+ textLabel.setText("hello");
+
+ shell.setSize(300, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490713_MaximizedShellTest.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490713_MaximizedShellTest.java
new file mode 100644
index 0000000000..f81925a663
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug490713_MaximizedShellTest.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug490713_MaximizedShellTest {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("Main");
+ shell.setSize(400, 400);
+ shell.setLayout(new GridLayout(2,false));
+
+ final Shell shell2 = new Shell(shell,SWT.SHELL_TRIM);
+ shell2.setText("Second");
+ shell2.setSize(400, 400);
+ shell2.setLayout(new GridLayout(2,false));
+
+ Button bMaximize=new Button(shell, SWT.PUSH);
+ bMaximize.setText("Maximize");
+ bMaximize.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ shell2.setMaximized(true);
+ }
+
+ });
+ Button bMinimize=new Button(shell, SWT.PUSH);
+ bMinimize.setText("Unmaximize");
+ bMinimize.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ shell2.setMaximized(false);
+ }
+
+ });
+ Button bShow=new Button(shell, SWT.PUSH);
+ bShow.setText("Show");
+ bShow.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ shell2.setVisible(true);
+
+ }
+
+ });
+ Button bHide=new Button(shell, SWT.PUSH);
+ bHide.setText("Hide");
+ bHide.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ shell2.setVisible(false);
+
+ }
+
+ });
+
+ Button bIsMaxmized=new Button(shell, SWT.PUSH);
+ bIsMaxmized.setText("Is 2 Shell Maximized");
+ bIsMaxmized.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ MessageBox box = new MessageBox(shell);
+ box.setText("Shell2 Maximized");
+ box.setMessage("Shell2 Maximized:"+shell2.getMaximized());
+ box.open();
+ }
+
+ });
+
+ new Composite(shell, SWT.NONE);
+
+ new Label(shell,SWT.BORDER).setText("TestCase1:\n maximize ->\n widget.shell 2 is maximized ->\n hide ->\n widget.shell should still be maximized");
+ new Label(shell,SWT.NONE);
+ new Label(shell,SWT.BORDER).setText("TestCase2a:\n move widget.shell to any position ->\n maximize ->\n hide ->\n show ->\n unmaximize ->\n position should be the initial one");
+ new Label(shell,SWT.BORDER).setText("TestCase2b:\n move widget.shell to any position ->\n maximize ->\n hide ->\n unmaximize ->\n show ->\n position should be the initial one");
+
+
+ shell.open();
+ shell2.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug491167_TableCursorScrolling.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug491167_TableCursorScrolling.java
new file mode 100644
index 0000000000..c123dc6b62
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug491167_TableCursorScrolling.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class demonstrates TableCursor
+ */
+public class Bug491167_TableCursorScrolling {
+ // The number of rows and columns
+ private static final int NUM = 100;
+
+ /**
+ * Runs the program
+ */
+ public void run() {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("Table Cursor Test");
+ createContents(shell);
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+ /**
+ * Creates the main window's contents
+ *
+ * @param widget.shell
+ * the main window
+ */
+ private void createContents(Shell shell) {
+ shell.setLayout(new FillLayout());
+
+ // Create the widget.table
+ final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ // Create the columns
+ for (int i = 0; i < NUM; i++) {
+ TableColumn column = new TableColumn(table, SWT.CENTER);
+ column.setText("Column " + (i + 1));
+ column.pack();
+ }
+
+ // Create the rows
+ for (int i = 0; i < NUM; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText("Text:" + i);
+ }
+
+ // Create the TableCursor
+ final TableCursor cursor = new TableCursor(table, SWT.NONE);
+
+ // Create the editor
+ // Use a ControlEditor, not a TableEditor, because the cursor is the
+ // parent
+ final ControlEditor editor = new ControlEditor(cursor);
+ editor.grabHorizontal = true;
+ editor.grabVertical = true;
+
+ // Add the event handling
+ cursor.addSelectionListener(new SelectionAdapter() {
+ // This is called as the user navigates around the widget.table
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ // Select the row in the widget.table where the TableCursor is
+ table.setSelection(new TableItem[] { cursor.getRow() });
+ }
+
+ // This is called when the user hits Enter
+ @Override
+ public void widgetDefaultSelected(SelectionEvent event) {
+ // Begin an editing session
+ // Notice that the parent of the Text is the TableCursor, not
+ // the Table
+ final Text text = new Text(cursor, SWT.NONE);
+ text.setFocus();
+
+ // Copy the widget.text from the cell to the Text
+ text.setText(cursor.getRow().getText(cursor.getColumn()));
+ text.setFocus();
+
+ // Add a handler to detect key presses
+ text.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent event) {
+ // End the editing and save the widget.text if the user presses
+ // Enter
+ // End the editing and throw away the widget.text if the user
+ // presses Esc
+ switch (event.keyCode) {
+ case SWT.CR:
+ cursor.getRow().setText(cursor.getColumn(), text.getText());
+ case SWT.ESC:
+ text.dispose();
+ break;
+ }
+ }
+ });
+ editor.setEditor(text);
+ }
+ });
+ }
+
+ /**
+ * The application entry point
+ *
+ * @param args
+ * the command line arguments
+ */
+ public static void main(String[] args) {
+ new Bug491167_TableCursorScrolling().run();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug492783_tracker_glitches.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug492783_tracker_glitches.java
new file mode 100644
index 0000000000..dc95540d25
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug492783_tracker_glitches.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tracker;
+
+public class Bug492783_tracker_glitches {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.open ();
+ shell.addListener (SWT.MouseDown, e -> {
+ Tracker tracker = new Tracker (display, SWT.NONE);
+ tracker.setRectangles (new Rectangle [] {
+ new Rectangle (e.x, e.y, 100, 100),
+ });
+ tracker.open ();
+ });
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug493552_NativeTestGDK.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug493552_NativeTestGDK.java
new file mode 100644
index 0000000000..b60c7afb91
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug493552_NativeTestGDK.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+//import org.eclipse.swt.internal.gtk.OS;
+
+/*
+ * NOTE: this snippet requires OS.ascii() to be public in order to function.
+ * Please modify its api.visibility and uncomment the rest of the snippet.
+ */
+
+public class Bug493552_NativeTestGDK {
+
+
+ public static void main(String[] args) {
+// OS.gtk_init_check(new long[0], new long[0]);
+// /* create a new window */
+// long window = OS.gtk_window_new(OS.GTK_WINDOW_TOPLEVEL);
+// OS.gtk_window_set_title(window, OS.ascii("GTK Menu Test"));
+// long widget.menu = OS.gtk_menu_new();
+// long root_menu = OS.gtk_image_menu_item_new_with_label(OS.ascii("Root Menu"));
+// OS.gtk_widget_show(root_menu);
+// for(int i = 0; i < 3; i++) {
+// String buf = "Test-undermenu -" + i;
+// long menu_items = OS.gtk_image_menu_item_new_with_label(OS.ascii(buf));
+// OS.gtk_menu_shell_insert(widget.menu, menu_items, i);
+// OS.gtk_widget_show(menu_items);
+// }
+// /* Now we specify that we want our newly created "widget.menu" to be the widget.menu for the "root widget.menu" */
+// OS.gtk_menu_item_set_submenu(root_menu, widget.menu);
+// /* Create a widget.menu-bar to hold the menus and add it to our main window*/
+// long menu_bar = OS.gtk_menu_bar_new();
+// OS.gtk_container_add(window, menu_bar);
+// OS.gtk_widget_show(menu_bar);
+// OS.gtk_menu_shell_insert(menu_bar, root_menu, 0);
+// OS.gtk_widget_show(window);
+// long /*int*/ screen = OS.gdk_screen_get_default ();
+//// int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, OS.gtk_widget_get_window(window));
+// int monitorNumber = OS.gdk_screen_get_primary_monitor (screen);
+// System.out.println("Primary monitorNumber " + monitorNumber);
+// OS.gtk_main ();
+ }
+
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494218_CanvasMouseEvent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494218_CanvasMouseEvent.java
new file mode 100644
index 0000000000..9f5e00cc35
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494218_CanvasMouseEvent.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug494218_CanvasMouseEvent {
+ /**
+ * Runs the application
+ */
+ public void run() {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("bad canvas");
+ createContents(shell);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+
+ private void createContents(Shell shell) {
+ shell.setLayout(new FillLayout());
+
+ ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ Canvas canvas = new Canvas(sc, SWT.NONE);
+ canvas.setSize(70000, 100);
+
+ canvas.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_GREEN));
+ e.gc.fillRectangle(0, 0, 32767, 200);
+ e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_RED));
+ e.gc.fillRectangle(32768, 0, 40000, 200);
+
+ }
+ });
+
+ sc.setContent(canvas);
+
+ canvas.addMouseListener(new org.eclipse.swt.events.MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ super.mouseUp(e);
+ System.out.println(e.x);
+ }
+
+ });
+
+ sc.setMinWidth(200);
+ }
+
+ public static void main(String[] args) {
+ new Bug494218_CanvasMouseEvent().run();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494619TreeDefaultSelectionEvent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494619TreeDefaultSelectionEvent.java
new file mode 100644
index 0000000000..fc97cbf0a5
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug494619TreeDefaultSelectionEvent.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug494619TreeDefaultSelectionEvent {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Tree tree = new Tree(shell, SWT.BORDER);
+ for (int i = 0; i < 4; i++) {
+ TreeItem iItem = new TreeItem(tree, 0);
+ iItem.setText("TreeItem (0) -" + i);
+ for (int j = 0; j < 4; j++) {
+ TreeItem jItem = new TreeItem(iItem, 0);
+ jItem.setText("TreeItem (1) -" + j);
+ for (int k = 0; k < 4; k++) {
+ TreeItem kItem = new TreeItem(jItem, 0);
+ kItem.setText("TreeItem (2) -" + k);
+ for (int l = 0; l < 4; l++) {
+ TreeItem lItem = new TreeItem(kItem, 0);
+ lItem.setText("TreeItem (3) -" + l);
+ }
+ }
+ }
+ }
+
+ tree.addListener(SWT.KeyDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ //32 in hex = 0x20 - space
+ //13 in hex = 0xD - enter.
+ if (event.keyCode == 0x20 && (event.stateMask & SWT.MODIFIER_MASK) == 0) {
+ System.out.println("KeyDown event. Handle space");
+ event.doit = true;
+ } else if (event.keyCode == 0xD && (event.stateMask & SWT.MODIFIER_MASK) == 0) {
+ System.out.println("KeyDown event. Handle enter");
+ }
+ }
+ });
+ tree.addListener(SWT.DefaultSelection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+
+ System.out.println(event.keyCode);
+ System.out.println("Default Selection event. Handle enter or double-click");
+ }
+ });
+
+ shell.setSize(200, 200);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495008_GCsetClippingGTK2.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495008_GCsetClippingGTK2.java
new file mode 100644
index 0000000000..5d73de16b0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495008_GCsetClippingGTK2.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug495008_GCsetClippingGTK2 {
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final PaletteData palette = new PaletteData(0x00FF0000, 0x0000FF00, 0x000000FF);
+ int width = 100, height = 100;
+ ImageData imageData = new ImageData(width, height, 32, palette);
+ Image image = new Image(display, imageData);
+
+ GC gc = new GC(image);
+ Rectangle clip = gc.getClipping();
+ gc.setClipping(clip);
+ gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ gc.fillRectangle(0, 0, width, height);
+ gc.dispose();
+
+ Shell shell = new Shell(display);
+ shell.addPaintListener(e -> {
+ GC gc1 = e.gc;
+ gc1.drawImage(image, 0, 0);
+ });
+
+ shell.setSize(350, 550);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ image.dispose();
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495909_topItemTree.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495909_topItemTree.java
new file mode 100644
index 0000000000..60845bd006
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug495909_topItemTree.java
@@ -0,0 +1,50 @@
+package org.eclipse.swt.tests.gtk.snippets;
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * List example snippet: print selected items in a widget.list
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug495909_topItemTree {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ final Tree tree = new Tree (shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+ for (int i=0; i<128; i++) new TreeItem (tree, 0).setText("Item " + i);
+ tree.setTopItem(tree.getItem(40));
+ System.out.println(tree.getTopItem().getText());
+ Rectangle clientArea = shell.getClientArea ();
+ tree.setBounds (clientArea.x, clientArea.y, 100, 100);
+ tree.addListener (SWT.MouseWheel, e -> {
+ System.out.println(tree.getTopItem().getText());
+ });
+ tree.addListener (SWT.Selection, e -> {
+ System.out.println(tree.getTopItem().getText());
+ });
+ tree.setTopItem(tree.getItem(20));
+ System.out.println(tree.getTopItem().getText());
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496302_GroupComputeSizeGTK2.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496302_GroupComputeSizeGTK2.java
new file mode 100644
index 0000000000..1c8ebfcdec
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496302_GroupComputeSizeGTK2.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug496302_GroupComputeSizeGTK2 {
+
+ private static Group group;
+ private static Group groupSmall;
+ private static Composite composite;
+ private static Text textGroup;
+ private static Text textGroupSmall;
+ private static Text textComposite;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(400, 400);
+ final GridLayout gridLayout = new GridLayout(1, false);
+ gridLayout.marginWidth = 5;
+ gridLayout.marginHeight = 5;
+ gridLayout.verticalSpacing = 0;
+ gridLayout.horizontalSpacing = 0;
+ shell.setLayout(gridLayout);
+
+ createComposite(shell);
+
+ createGroup(shell);
+ createGroupSmall(shell);
+
+ createButton(shell);
+
+ // widget.shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void createGroup(final Composite parent) {
+ group = new Group(parent, SWT.NONE);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ group.setLayout(new GridLayout(3, false));
+ group.setText("A Group"); //$NON-NLS-1$
+
+ final Label label = new Label(group, SWT.RIGHT);
+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+ label.setText("A Label"); //$NON-NLS-1$
+
+ textGroup = new Text(group, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ textGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ final Combo combo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ combo.setItems(new String[] { "A", "B", "C" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ combo.select(0);
+ }
+
+ private static void createGroupSmall(final Composite parent) {
+ groupSmall = new Group(parent, SWT.NONE);
+ groupSmall.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ groupSmall.setLayout(new GridLayout(1, false));
+ groupSmall.setText("A Group with a very very long title"); //$NON-NLS-1$
+
+ textGroupSmall = new Text(groupSmall, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ textGroupSmall.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ }
+
+ private static void createComposite(final Composite parent) {
+ composite = new Composite(parent, SWT.BORDER);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ composite.setLayout(new GridLayout(3, false));
+
+ final Label label = new Label(composite, SWT.RIGHT);
+ label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+ label.setText("A Label"); //$NON-NLS-1$
+
+ textComposite = new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
+ textComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ final Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ combo.setItems(new String[] { "A", "B", "C" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ combo.select(0);
+ }
+
+ private static void createButton(final Composite parent) {
+ final Button button = new Button(parent, SWT.PUSH);
+ button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+ button.setText("Compute Size"); //$NON-NLS-1$
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ textComposite.setText("" + composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); //$NON-NLS-1$
+ textGroup.setText("" + group.computeSize(SWT.DEFAULT, SWT.DEFAULT)); //$NON-NLS-1$
+ textGroupSmall.setText("" + groupSmall.computeSize(SWT.DEFAULT, SWT.DEFAULT)); //$NON-NLS-1$
+ composite.pack();
+ group.pack();
+ groupSmall.pack();
+ }
+ });
+
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496639_DialogFullScreenShell.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496639_DialogFullScreenShell.java
new file mode 100644
index 0000000000..43e91ab89e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug496639_DialogFullScreenShell.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * @author Thomas Singer
+ */
+public class Bug496639_DialogFullScreenShell {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ Menu menuBar = new Menu(shell, SWT.BAR);
+ MenuItem fileMenuItem = new MenuItem(menuBar, SWT.CASCADE);
+ fileMenuItem.setText("File");
+ Menu fileMenu = new Menu(fileMenuItem);
+ fileMenuItem.setMenu(fileMenu);
+
+ MenuItem toggleFullScreenMenuItem = new MenuItem(fileMenu, SWT.CHECK);
+ toggleFullScreenMenuItem.setText("Toggle full screen");
+ toggleFullScreenMenuItem.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ shell.setFullScreen(toggleFullScreenMenuItem.getSelection());
+ }
+ });
+
+ MenuItem showDialogMenuItem = new MenuItem(fileMenu, SWT.PUSH);
+ showDialogMenuItem.setText("Show dialog");
+ showDialogMenuItem.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ Shell dialogShell = new Shell(shell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
+ dialogShell.setLayout(new FillLayout());
+
+ Text text = new Text(dialogShell, SWT.BORDER);
+ text.setText("Hello world!");
+
+ // center on top of parent widget.shell
+ Point size = dialogShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle bounds = shell.getBounds();
+ dialogShell.setBounds(bounds.x + (bounds.width - size.x) / 2,
+ bounds.y + (bounds.height - size.y) / 2,
+ size.x, size.y);
+ dialogShell.open();
+// dialogShell.forceActive();
+// dialogShell.moveAbove(widget.shell);
+ }
+ });
+
+ shell.setMenuBar(menuBar);
+
+ shell.setSize(300, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497071_LinkColorStyledText.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497071_LinkColorStyledText.java
new file mode 100644
index 0000000000..ed3b7f17ec
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497071_LinkColorStyledText.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug497071_LinkColorStyledText {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final Link link = new Link(shell, SWT.NONE);
+ link.setText("This is a <a href=\"dummy\">link</a>.");
+
+ final StyledText styledText = new StyledText(shell, SWT.READ_ONLY);
+ styledText.setBackground(link.getBackground());
+ styledText.setText("This is a styledText-link.");
+ final StyleRange range = new StyleRange(21, 4, null, null);
+ range.underline = true;
+ range.underlineStyle = SWT.UNDERLINE_LINK;
+ styledText.setStyleRange(range);
+
+ shell.setSize(400, 300);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497705_setBoundsAfterSetVisibleBroken.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497705_setBoundsAfterSetVisibleBroken.java
new file mode 100644
index 0000000000..f9a4ca4f54
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497705_setBoundsAfterSetVisibleBroken.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+//package api.visibility;
+//
+//import static org.junit.Assert.*;
+//
+//import java.lang.reflect.Field;
+//import java.util.Collections;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//import org.eclipse.swt.SWT;
+//import org.eclipse.swt.graphics.Rectangle;
+//import org.eclipse.swt.widgets.Button;
+//import org.eclipse.swt.widgets.Display;
+//import org.eclipse.swt.widgets.Shell;
+//import org.junit.Test;
+//
+//public class Bug497705_nullCordsOnInvisible {
+//
+//
+// // The jvm doesn't permit one to set the environmental values of parents.
+// // TODO
+// // Linux only.
+// // https://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java
+// public static void setEnv(Map<String, String> newenv) throws Exception {
+// Class[] classes = Collections.class.getDeclaredClasses();
+// Map<String, String> env = System.getenv();
+// for(Class cl : classes) {
+// if("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
+// Field field = cl.getDeclaredField("m");
+// field.setAccessible(true);
+// Object obj = field.get(env);
+// Map<String, String> map = (Map<String, String>) obj;
+// map.clear();
+// map.putAll(newenv);
+// }
+// }
+// }
+//
+//
+// @Test
+// public void myTestG2() {
+// System.gc();
+// Map<String, String> newEnv = new HashMap<>();
+// newEnv.put("SWT_GTK3", "0");
+// try {
+// setEnv(newEnv);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail("Faild to set proper version of gtk");
+// }
+//
+// String property = System.getenv("SWT_GTK3");
+// System.err.println("GTK" + (property.equals("1") ? "3" : "2"));
+// Display display = Display.getDefault();
+// Shell shell = new Shell(display);
+// shell.setSize(400, 400);
+// StringBuffer log = new StringBuffer("");
+// int x = 5;
+// int y = 10;
+// int height = 100;
+// int width = 200;
+// boolean passed = true;
+//
+//
+// Button myButton = new Button(shell, SWT.PUSH);
+// myButton.setText("Sized button");
+// myButton.setVisible(false);
+// myButton.setVisible(true);
+// myButton.setBounds(x, y, width, height);
+// Rectangle bounds = myButton.getBounds();
+// if (bounds.x != x | bounds.y != y) {
+// passed = false;
+// log.append("\nERROR: x,y do not match. Expected:" + x + "/" + y + " Actual:" + bounds.x + "/" + bounds.y);
+// }
+// if (bounds.height != height | bounds.width != width) {
+// passed = false;
+// log.append("\nERROR: width,height do not match. Expected:" + width + "/" + height + " Actual:" + bounds.width + "/" + bounds.height);
+// }
+// display.dispose();
+// assertTrue(log.toString(), passed);
+//
+// }
+//
+// @Test
+// public void myTestG3() {
+// System.gc();
+// Map<String, String> newEnv = new HashMap<>();
+// newEnv.put("SWT_GTK3", "1");
+// try {
+// setEnv(newEnv);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail("Faild to set proper version of gtk");
+// }
+//
+// String property = System.getenv("SWT_GTK3");
+// System.err.println("GTK" + (property.equals("1") ? "3" : "2"));
+// Display display = Display.getDefault();
+// Shell shell = new Shell(display);
+// shell.setSize(400, 400);
+// StringBuffer log = new StringBuffer("");
+// int x = 5;
+// int y = 10;
+// int height = 100;
+// int width = 200;
+// boolean passed = true;
+//
+//
+// Button myButton = new Button(shell, SWT.PUSH);
+// myButton.setText("Sized button");
+// myButton.setVisible(false);
+// myButton.setVisible(true);
+// myButton.setBounds(x, y, width, height);
+// Rectangle bounds = myButton.getBounds();
+// if (bounds.x != x | bounds.y != y) {
+// passed = false;
+// log.append("\nERROR: x,y do not match. Expected:" + x + "/" + y + " Actual:" + bounds.x + "/" + bounds.y);
+// }
+// if (bounds.height != height | bounds.width != width) {
+// passed = false;
+// log.append("\nERROR: width,height do not match. Expected:" + width + "/" + height + " Actual:" + bounds.width + "/" + bounds.height);
+// }
+// display.dispose();
+// assertTrue(log.toString(), passed);
+//
+//
+//// shell.open();
+//// while (!shell.isDisposed()) {
+//// if (!display.readAndDispatch())
+//// display.sleep();
+//// }
+//// display.dispose();
+// }
+//}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497707_ShellAlpha.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497707_ShellAlpha.java
new file mode 100644
index 0000000000..282546ac2f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug497707_ShellAlpha.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug497707_ShellAlpha {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell(display);
+ // Set alpha to whatever
+ int alpha = 128;
+ shell.setAlpha(alpha);
+ System.out.println("Alpha is set to " + alpha);
+ System.out.println("Shell.getAlpha() returns: " + shell.getAlpha());
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug498165_TreeMeasureEventLoop.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug498165_TreeMeasureEventLoop.java
new file mode 100644
index 0000000000..65d22afa75
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug498165_TreeMeasureEventLoop.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+/*******************************************************************************
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+/*
+ * Tree example snippet: create a widget.tree
+ *
+ * For a widget.list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug498165_TreeMeasureEventLoop {
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ final Tree tree = new Tree (shell, SWT.BORDER);
+ new TreeItem (tree, 0);
+
+ tree.addListener(SWT.MeasureItem, new Listener() {
+
+ int height = -1;
+
+ @Override
+ public void handleEvent(Event event) {
+ if (height == -1) {
+ height = ((TreeItem)event.item).getImageBounds(0).height;
+ }
+ event.height = height + 3;
+ }
+ });
+ shell.setSize (200, 200);
+ shell.open ();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug499850_VirtualTableHang.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug499850_VirtualTableHang.java
new file mode 100644
index 0000000000..c7dd646a08
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug499850_VirtualTableHang.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.util.Random;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug499850_VirtualTableHang {
+
+ static final int COUNT = 100000;
+
+ public static void main(String[] args) {
+ Random random = new Random();
+ final int[][] data = new int[COUNT][];
+ for (int i = 0; i < data.length; i++) {
+ data[i] = new int[] {i, random.nextInt()};
+ }
+
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setLayout (new RowLayout (SWT.VERTICAL));
+ final Table table = new Table (shell, SWT.VIRTUAL | SWT.MULTI);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setItemCount(COUNT);
+ TableColumn eventColumn = new TableColumn(table, SWT.NONE);
+ eventColumn.setText("Event");
+ eventColumn.setWidth(200);
+ TableColumn dataColumn = new TableColumn(table, SWT.NONE);
+ dataColumn.setText("Data");
+ dataColumn.setWidth(200);
+ table.addListener (SWT.SetData, event -> {
+ TableItem item = (TableItem) event.item;
+ int index = table.indexOf (item);
+ int[] datum = data[index + 1];
+ item.setText(new String[] {Integer.toString(datum[0]),
+ Integer.toString(datum[1]) });
+ });
+ table.setLayoutData (new RowData (400, 300));
+ Button button = new Button (shell, SWT.PUSH);
+ button.setText ("Add Items");
+ button.addListener (SWT.Selection, event -> {
+ table.setItemCount (COUNT);
+ shell.layout ();
+ });
+ Button removeButton;
+ removeButton = new Button(shell, SWT.PUSH);
+ removeButton.setText("Remove All");
+ final Label label = new Label(shell, SWT.NONE);
+ label.setLayoutData(new RowData (400, 30));
+ removeButton.addListener(SWT.Selection, e -> {
+ long t1 = System.currentTimeMillis ();
+ table.removeAll();
+ long t2 = System.currentTimeMillis ();
+ label.setText ("Items: " + COUNT + ", Time to remove: " + (t2 - t1) + " (ms)");
+ });
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500631_RHELIcons.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500631_RHELIcons.java
new file mode 100644
index 0000000000..c127f14f27
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500631_RHELIcons.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug500631_RHELIcons {
+
+ public Bug500631_RHELIcons(Display display){
+
+ Shell shell = new Shell(display);
+ shell.setLayout(new RowLayout());
+ shell.setText("Photo Application");
+ shell.setSize(500, 500);
+
+ //creating a widget.menu
+ Composite composite = new Composite(shell, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ composite.setLayout(gridLayout);
+
+ Menu menu = new Menu(shell,SWT.BAR); //root widget.menu bar
+
+ MenuItem menuItem = new MenuItem(menu,SWT.CASCADE); //adding a widget.menu item to hold each drop-down widget.menu
+ menuItem.setText("Menu");
+
+ Menu fileMenu = new Menu(menuItem);
+
+ MenuItem menuItem1 = new MenuItem(fileMenu, SWT.PUSH);
+
+ menuItem1.setText("ADD");
+ menuItem1.setImage(Display.getDefault().getSystemImage(SWT.ICON_WORKING));
+
+ MenuItem menuItem2 = new MenuItem(fileMenu,SWT.PUSH);
+ menuItem2.setText("RMB");
+ menuItem2.setImage(Display.getDefault().getSystemImage(SWT.ICON_WORKING));
+
+ menuItem.setMenu(fileMenu);
+
+ shell.setMenuBar(menu);
+ shell.pack();
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ }
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ Display display = new Display();
+ new Bug500631_RHELIcons(display);
+ display.dispose();
+
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500664_ToolTipWrongMonitor.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500664_ToolTipWrongMonitor.java
new file mode 100644
index 0000000000..ef37fca0d3
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500664_ToolTipWrongMonitor.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolTip;
+
+public class Bug500664_ToolTipWrongMonitor {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ final Text text = new Text(shell, SWT.MULTI | SWT.WRAP |
+ SWT.V_SCROLL);
+ text.setBounds(10,10,150,150);
+ text.setText("TextField");
+ text.addModifyListener(new ModifyListener(){
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ ToolTip t = new ToolTip(shell, SWT.BALLOON);
+ t.setText("Balloon widget.tooltip");
+ t.setLocation(shell.getLocation());
+ t.setVisible(true);
+ }
+
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500814_GLCanvasCrash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500814_GLCanvasCrash.java
new file mode 100644
index 0000000000..931c8fdd5c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500814_GLCanvasCrash.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.opengl.GLCanvas;
+import org.eclipse.swt.opengl.GLData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug500814_GLCanvasCrash {
+
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+
+ GLCanvas canvas;
+ GLData data = new GLData();
+ data.doubleBuffer = true;
+ data.depthSize = 24;
+ data.alphaSize = 8;
+ data.blueSize = 8;
+ data.redSize = 8;
+ data.greenSize = 8;
+ data.stencilSize = 8;
+ data.sampleBuffers = 1;
+ data.samples = 4;
+ canvas = new GLCanvas(shell, SWT.NONE, data);
+ canvas.setCurrent(); // <-- it crashes here...
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500924_tabfolder_dispose_crash.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500924_tabfolder_dispose_crash.java
new file mode 100644
index 0000000000..77bc5cca89
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug500924_tabfolder_dispose_crash.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+public class Bug500924_tabfolder_dispose_crash {
+ private static TabItem tab1;
+ private static TabItem tab2;
+ private static Composite cmp1;
+ private static Composite cmp2;
+ private static TabFolder folder;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setText("SWT Tabitem dispose bug");
+ shell.setLayout(new GridLayout(1,false));
+
+ Button btn1 = new Button(shell, SWT.PUSH);
+ btn1.setText("Show/Hide tab1");
+ btn1.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,false));
+ btn1.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ TabItem[] arr = folder.getItems();
+ for (int a = 0; a < arr.length; a++) {
+ Control ctrl = arr[a].getControl();
+ arr[a].setControl(null);
+ ctrl.dispose();
+ arr[a].dispose();
+ }
+ }
+ });
+
+ folder = new TabFolder(shell, SWT.NONE);
+ folder.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
+
+ tab1 = new TabItem(folder, SWT.NONE);
+ tab1.setText("Tab 1");
+
+ cmp1 = new Composite(folder, SWT.NONE);
+ cmp1.setLayout(new FillLayout());
+ new Button(cmp1, SWT.NONE).setText("Button 1");
+ new Button(cmp1, SWT.NONE).setText("Button 2");
+ tab1.setControl(cmp1);
+
+
+ tab2 = new TabItem(folder, SWT.NONE);
+ tab2.setText("Tab 2");
+ cmp2 = new Composite(folder, SWT.NONE);
+ cmp2.setLayout(new FillLayout());
+ new Button(cmp2, SWT.NONE).setText("Button 3");
+ new Button(cmp2, SWT.NONE).setText("Button 4");
+ tab2.setControl(cmp2);
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug505418_Listeners_evals.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug505418_Listeners_evals.java
new file mode 100644
index 0000000000..ab293810a0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug505418_Listeners_evals.java
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.browser.VisibilityWindowListener;
+import org.eclipse.swt.browser.WindowEvent;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug505418_Listeners_evals {
+
+ public static int count = 0;
+
+ public static void main(String[] args) {
+// locationChange(); // new url
+ progressListener(); // make progress.
+// statusTextListener();
+// closeWindowListener();
+// openWindowListener();
+// titleListener();
+// visibilityWindowListener(); // Quircky on webkit2.
+// miscSWTListeners();
+ }
+
+ @SuppressWarnings("unused")
+ private static void locationChange() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addProgressListener(new ProgressListener() {
+ @Override
+ public void completed(ProgressEvent event) {
+ browser.addLocationListener(new LocationListener() {
+ @Override
+ public void changing(LocationEvent event) {
+ System.out.println ("changing...");
+
+ String value = (String)browser.evaluate("return 'Changing eval...'");
+ System.out.println("changing returned: " + value);
+
+// widget.browser.evaluate("return 'Changing eval...'");
+
+// event.doit = false; // Stop page load.
+ }
+
+ @Override
+ public void changed(LocationEvent event) {
+ System.out.print("Changed!");
+ String value = (String)browser.evaluate("return 'finished callback'");
+ System.out.println("Changed returned: " + value);
+ }
+ });
+ }
+ @Override
+ public void changed(ProgressEvent event) {}
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void progressListener () {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addProgressListener(new ProgressListener() {
+
+ @Override
+ public void completed(ProgressEvent event) {
+ System.out.println("compleated!! " + event.current);
+ evalTest(browser, "");
+ }
+
+ @Override
+ public void changed(ProgressEvent event) {
+ System.out.println("changing..." + event.current);
+ evalTest(browser, "");
+
+
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static void statusTextListener() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addStatusTextListener(event -> {
+ System.out.println("Status has changed");
+ evalTest(browser, "Status changed");
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static void closeWindowListener() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ Button closeBrowserButton = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ closeBrowserButton.setText("Close widget.browser button");
+ closeBrowserButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ browser.execute("window.close()");
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+ });
+
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addCloseWindowListener(event -> {
+ System.out.println("closing...");
+ evalTest(browser, "closing...");
+ System.out.println("Browser getText(): "+ browser.getText());
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static void openWindowListener() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ Button closeBrowserButton = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ closeBrowserButton.setText("Close widget.browser button");
+ closeBrowserButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ browser.execute("window.open()");
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+ });
+
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addOpenWindowListener(event -> {
+ System.out.println("opening...");
+ evalTest(browser, "opening...");
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static void titleListener() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ browser.addTitleListener(event -> {
+ System.out.println("Title has changed :" + event.title);
+ evalTest(browser, "title change... ");
+ });
+
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static void visibilityWindowListener() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ Button closeBrowserButton = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+
+ final Shell shell2 = new Shell(display);
+ shell2.setLayout(new FillLayout());
+ final Browser browser2 = new Browser(shell2, SWT.NONE);
+ browser2.addVisibilityWindowListener(new VisibilityWindowListener() {
+
+ @Override
+ public void show(WindowEvent event) {
+ System.out.println("showing...");
+ shell2.open();
+ evalTest(browser2, "browse2 show");
+ evalTest(browser, "browse1 show");
+ }
+
+ @Override
+ public void hide(WindowEvent event) {
+ }
+ });
+
+ closeBrowserButton.setText("Close widget.browser button");
+ closeBrowserButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ browser.execute("document.body.style.backgroundColor = 'red'");
+ browser.execute("window.open('https://www.google.com', 'Dialog')");
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+ });
+
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addOpenWindowListener(event -> {
+ System.out.println("opening...");
+ event.browser = browser2;
+
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ @SuppressWarnings("unused")
+ private static void miscSWTListeners() {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+ browser.setText("Hello world!");
+ browser.addMouseMoveListener(e -> {
+ System.out.println("mouse moved!");
+ String str = (String) browser.evaluate("return 'hello world'");
+ System.out.println("Evaluated: " + str);
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void evalTest(final Browser browser, Object msg) {
+ String value = (String)browser.evaluate("return 'hello'");
+ System.out.println("Returned: " + value);
+ String script = "document.body.style.backgroundColor = 'red'";
+ browser.execute(script);
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug508245_TableSelectionListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug508245_TableSelectionListener.java
new file mode 100644
index 0000000000..4be543c4ec
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug508245_TableSelectionListener.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug508245_TableSelectionListener {
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+// List listTableTree = new List (widget.shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+// Table listTableTree = new Table (widget.shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ Tree listTableTree = new Tree (shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ for (int i=0; i<12; i++) {
+// widget.list.add("Item " + i);
+//
+// TableItem item = new TableItem (listTableTree, 0);
+// item.setText ("Item " + i);
+
+ TreeItem item = new TreeItem (listTableTree, 0);
+ item.setText ("Item " + i);
+ }
+ Rectangle clientArea = shell.getClientArea ();
+
+
+ listTableTree.setBounds (clientArea.x, clientArea.y, 400, 400);
+ shell.setSize (400, 400);
+ shell.open ();
+
+ listTableTree.addSelectionListener(new SelectionListener() {
+
+ /**
+ * Selection event occurs when clicking or using arrow keys.
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if ((e.stateMask & SWT.MOD1) != 0 | ((e.stateMask & SWT.MOD4) != 0)) {
+ System.out.println("Selection event" + "\n"
+ + " Cocoa: Ctrl+Click (Mod4) or Cmd+Click (Mod1) \n"
+ + " Gtk: Ctrl+Click (mod1) \n"
+ + " Win32: Ctrl+Click (mod1)");
+ } else if ((e.stateMask & SWT.MOD2) != 0) {
+ System.out.println("Selection event" + "\n"
+ + " Cocoa/Gtk/Win32: Shift+Click (Mod2) \n");
+ } else if ((e.stateMask & SWT.MOD3) != 0) {
+ System.out.println("Selection event" + "\n"
+ + " Cocoa/Gtk/Win32: Alt+Click (Mod3)");
+ } else { // Do not use (e.stateMask == 0), as on Win32/Cocoa StateMask is not 0 (=524288?) when no modifiers are pressed.
+ System.out.println("Selection event" + "\n"
+ + " Cocoa/Gtk/Win32: Arrow keys and click (can be first click in a double click");
+ }
+ }
+
+ /**
+ * Default selection triggered upon "double click" or "enter" button.
+ */
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ if ((e.stateMask & SWT.MOD1) != 0 | ((e.stateMask & SWT.MOD4) != 0)) {
+ System.out.println("Default selection event" + "\n"
+ + " Cocoa: Ctrl+Enter (Mod4) or Cmd+Enter/Cmd+DoubleClick (Mod1) \n"
+ + " Gtk: Ctrl+Enter or Ctrl+Doubleclick (mod1) \n"
+ + " Win32: Ctrl+Enter does NOT trigger default selection. Ctrl+DoubleClick does\n");
+ } else if ((e.stateMask & SWT.MOD2) != 0) {
+ System.out.println("Default selection event" + "\n"
+ + " Cocoa/Gtk/Win32: Shift+Enter or Shift+DoubleClick(Mod2) \n");
+ } else if ((e.stateMask & SWT.MOD3) != 0) {
+ System.out.println("Default selection event" + "\n"
+ + " Cocoa/Gtk/Win32: Alt+Enter or Alt+DoubleClick (Mod3)");
+ } else {
+ System.out.println("Default selection event \n"
+ + " Cocoa/Gtk/Win32: Enter or double click (no mod)");
+ }
+ }
+ });
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509503_VirtualTableCalculate.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509503_VirtualTableCalculate.java
new file mode 100644
index 0000000000..2d7804cf7f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509503_VirtualTableCalculate.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * @author Thomas Singer
+ */
+public class Bug509503_VirtualTableCalculate {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display, SWT.NO_FOCUS | SWT.ON_TOP);
+ shell.setLayout(new FillLayout());
+
+ final Table table = new Table(shell, SWT.VIRTUAL | SWT.V_SCROLL);
+
+ final TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+ tableColumn.setText("Column");
+
+ final Listener listener = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.MeasureItem) {
+ final Point size = event.gc.stringExtent(getText(event));
+ event.width = size.x;
+ event.height = size.y;
+ } else if (event.type == SWT.PaintItem) {
+ event.gc.drawString(getText(event), event.x, event.y);
+ } else if (event.type == SWT.SetData) {
+ event.item.setData("Row " + event.index);
+ } else if (event.type == SWT.MouseDown) {
+ if (event.button == 3) {
+ shell.dispose();
+ }
+ }
+ }
+
+ private String getText(Event event) {
+ return String.valueOf(event.item.getData());
+ }
+ };
+ table.addListener(SWT.SetData, listener);
+ table.addListener(SWT.MeasureItem, listener);
+ table.addListener(SWT.PaintItem, listener);
+ table.addListener(SWT.MouseDown, listener);
+ table.setItemCount(20);
+ table.clearAll();
+
+ shell.layout(true, false);
+
+ tableColumn.pack();
+ final int width = tableColumn.getWidth();
+ System.out.println("column width = " + width);
+
+ final int max = Math.min(10, table.getItemCount());
+ final Rectangle lastRowBounds = table.getItem(max - 1).getBounds();
+ final Rectangle rectangle = table.computeTrim(0, 0, width, lastRowBounds.y + lastRowBounds.height);
+
+ final Rectangle shellBounds = shell.computeTrim(0, 0, rectangle.width, rectangle.height);
+ shell.setSize(shellBounds.width, shellBounds.height);
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_LocationChangeListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_LocationChangeListener.java
new file mode 100644
index 0000000000..211353b5ee
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_LocationChangeListener.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug509615_auto_LocationChangeListener {
+
+ static int count = 0;
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+
+ browser.addLocationListener(new LocationListener() {
+ @Override
+ public void changing(LocationEvent event) {
+ System.out.println("Changing ....");
+ browser.evaluate("return 123");
+ }
+
+ @Override
+ public void changed(LocationEvent event) {
+ System.out.println("Changed !!!!");
+ browser.evaluate("return 123");
+ }
+ });
+ browser.addProgressListener(new ProgressListener() {
+
+ @Override
+ public void completed(ProgressEvent event) {
+ System.out.println("Progress Completed !!!! ");
+ }
+
+ @Override
+ public void changed(ProgressEvent event) {
+ System.out.println("Progress Changing ....");
+ }
+ });
+
+ browser.setText("Hello world");
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_executeCloseListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_executeCloseListener.java
new file mode 100644
index 0000000000..eb62eefad2
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug509615_auto_executeCloseListener.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug509615_auto_executeCloseListener {
+
+ static int count = 0;
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+ browser.setText("Hello world");
+
+// widget.browser.addLocationListener(new LocationListener() {
+// @Override
+// public void changing(LocationEvent event) {}
+//
+// @Override
+// public void changed(LocationEvent event) {
+// if (count == 0) {
+// widget.browser.execute("window.close()");
+// count++;
+// }
+//
+// System.out.println("Location has changed.");
+// }
+// });
+
+ browser.addCloseWindowListener(e -> {
+ System.out.println("window is closing");
+ });
+ browser.execute("window.close()");
+
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510183_javadocHang.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510183_javadocHang.java
new file mode 100644
index 0000000000..86384097a8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510183_javadocHang.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug510183_javadocHang {
+
+ public static int count = 0;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ Button button = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+ button.setText("Click to increase count.");
+ button.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseUp(MouseEvent e) {}
+ @Override
+ public void mouseDown(MouseEvent e) {
+ shell.setText("Count: " + count++);
+ }
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ browser.setText("<html><title>Snippet</title><body><a href=\"https://eclipse.org/\">Eclipse.org Disposing on link change causes hang</a></body></html>");
+ browser.addProgressListener(new ProgressListener() {
+ @Override
+ public void completed(ProgressEvent event) {
+ browser.addLocationListener(new LocationListener() {
+ @Override
+ public void changing(LocationEvent event) {
+ browser.dispose();
+// System.out.println("KILLING OF THE BROWSER");
+//
+// String value = (String)widget.browser.evaluate("return 'hello'");
+// System.out.println("Returned: " + value);
+//
+// String script = "document.body.style.backgroundColor = 'red'";
+// widget.browser.execute(script);
+ }
+ @Override
+ public void changed(LocationEvent event) {
+ }
+ });
+ }
+ @Override
+ public void changed(ProgressEvent event) {}
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_editable_table_brokenGtk3.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_editable_table_brokenGtk3.java
new file mode 100644
index 0000000000..6cebf13fe4
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510803_TabFolder_editable_table_brokenGtk3.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+// clicking on a row item and typing appends characters.
+// Gtk2: Works as expected.
+// Gtk3: Spam of errors, black second window.
+//(SWT:7324): Gdk-WARNING **: gdk_window_new(): parent is destroyed
+//(SWT:7324): Gdk-CRITICAL **: gdk_window_set_user_data: assertion 'GDK_IS_WINDOW (window)' failed
+//(SWT:7324): Gdk-CRITICAL **: gdk_window_get_scale_factor: assertion 'GDK_IS_WINDOW (window)' failed
+//(SWT:7324): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
+
+public class Bug510803_TabFolder_editable_table_brokenGtk3 {
+ public static void main(String[] args) {
+ Shell shell = shellSetup();
+
+ final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText("Hello tab");
+
+ Table table = new Table(tabFolder, SWT.NONE);
+ TableItem tableItem = new TableItem(table, SWT.None);
+ tableItem.setText("Item 1");
+ TableItem tableItem2 = new TableItem(table, SWT.None);
+ tableItem2.setText("Item 2");
+
+ // Notes:
+ // - Seems to occur with any control, not just Text. (Tested with Button also)
+ final Text cellEditorText = new Text(table, SWT.SINGLE); // Note,
+ cellEditorText.setText("Hello world");
+
+// Listeners that make typing into Table edit controls. Useful to test
+// functionality, but errors occur without the listeners also.
+ table.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ cellEditorText.setFocus();
+ }
+ });
+
+ cellEditorText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ TableItem selectedItem = table.getSelection()[0];
+ selectedItem.setText(selectedItem.getText() + e.character);
+ }
+ });
+
+ // Location of setControl() method call has an impact.
+ // If it's before 'Text' creation, no errors are thrown into the
+ // console.
+ tabItem.setControl(table);
+
+ mainEventLoop(shell);
+ }
+
+ private static Shell shellSetup() {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ return shell;
+ }
+
+ private static void mainEventLoop(Shell shell) {
+ Display display = shell.getDisplay();
+ shell.open();
+ shell.setSize(200, 300);
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal.java
new file mode 100644
index 0000000000..d7dc293bc0
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug510972_WinClearedSignal {
+ static int count = 0;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Button loadNewPage = new Button(shell, SWT.PUSH);
+ final Button execFunc = new Button(shell, SWT.PUSH);
+ final Browser browser = new Browser(shell, SWT.NONE);
+
+
+ class CustomFunction extends BrowserFunction { // Note: Local class defined inside method.
+ CustomFunction(Browser browser, String name) {
+ super(browser, name);
+ }
+
+ @Override
+ public Object function(Object[] arguments) {
+ System.out.println( this.getName() + " called from javascript");
+ return null;
+ }
+ }
+ new CustomFunction(browser, "callCustomFunction");
+
+ // Button
+ loadNewPage.setText("load new page");
+ loadNewPage.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ browser.setText("Count is: " + count++);
+ }
+ });
+
+ // Button
+ execFunc.setText("Call java function");
+ execFunc.addListener(SWT.MouseDown, ev -> {
+ System.out.println("mouse down.");
+ browser.execute("callCustomFunction()");
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal_auto.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal_auto.java
new file mode 100644
index 0000000000..42f822efc1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug510972_WinClearedSignal_auto.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.browser.ProgressEvent;
+import org.eclipse.swt.browser.ProgressListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug510972_WinClearedSignal_auto {
+ static int count = 0;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+
+ class CustomFunction extends BrowserFunction { // Note: Local class defined inside method.
+ CustomFunction(Browser browser, String name) {
+ super(browser, name);
+ }
+
+ @Override
+ public Object function(Object[] arguments) {
+ System.out.println( this.getName() + " called from javascript");
+ if (count == 0) {
+ browser.setText("2nd page load");
+ count++;
+ } else {
+ System.out.println("Test passed.");
+ }
+ return null;
+ }
+ }
+ browser.setText("1st (initial) page load");
+ new CustomFunction(browser, "callCustomFunction");
+ browser.execute("callCustomFunction()");
+
+
+ browser.addProgressListener(new ProgressListener() {
+ @Override
+ public void completed(ProgressEvent event) {
+ System.out.println("load finished.");
+ browser.execute("document.body.style.backgroundColor = 'red'");
+ browser.execute("callCustomFunction()");
+ }
+
+ @Override
+ public void changed(ProgressEvent event) {
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug511797_locChanged.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug511797_locChanged.java
new file mode 100644
index 0000000000..e345917302
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug511797_locChanged.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.LocationEvent;
+import org.eclipse.swt.browser.LocationListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug511797_locChanged {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.NONE);
+
+
+ browser.addLocationListener(new LocationListener() {
+ @Override
+ public void changing(LocationEvent event) {
+ System.out.println("Changing ....");
+ }
+
+ @Override
+ public void changed(LocationEvent event) {
+ System.out.println("Changed !!!!");
+ }
+ });
+ browser.setText("Hello world");
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug514483_SelectionEventLostFocus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug514483_SelectionEventLostFocus.java
new file mode 100644
index 0000000000..747285c8ed
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug514483_SelectionEventLostFocus.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import static org.eclipse.swt.events.SelectionListener.*;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug514483_SelectionEventLostFocus {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setText("Shell");
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginWidth = 10;
+ fillLayout.marginHeight = 10;
+ shell.setLayout(fillLayout);
+
+ Button open = new Button (shell, SWT.PUSH);
+ open.setText ("Prompt for a String");
+ open.addSelectionListener(widgetSelectedAdapter(e -> {
+ final Shell dialog = new Shell (shell, SWT.TOOL | SWT.ON_TOP | SWT.RESIZE);
+ dialog.setText("Dialog Shell");
+ FormLayout formLayout = new FormLayout ();
+ formLayout.marginWidth = 10;
+ formLayout.marginHeight = 10;
+ formLayout.spacing = 10;
+ dialog.setLayout (formLayout);
+ dialog.setLocation(26, 52);
+
+ Label label = new Label (dialog, SWT.NONE);
+ label.setText ("Type a String:");
+ FormData data = new FormData ();
+ label.setLayoutData (data);
+
+ Button cancel = new Button (dialog, SWT.PUSH);
+ cancel.setText ("Cancel");
+ data = new FormData ();
+ data.width = 60;
+ data.right = new FormAttachment (100, 0);
+ data.bottom = new FormAttachment (100, 0);
+ cancel.setLayoutData (data);
+ cancel.addSelectionListener (widgetSelectedAdapter(event -> {
+ System.out.println("User cancelled dialog");
+ dialog.close ();
+ }));
+
+ final Text text = new Text(dialog, SWT.SINGLE | SWT.BORDER | SWT.SEARCH
+ | SWT.ICON_CANCEL);
+
+
+ data = new FormData ();
+ data.width = 200;
+ data.left = new FormAttachment (label, 0, SWT.DEFAULT);
+ data.right = new FormAttachment (100, 0);
+ data.top = new FormAttachment (label, 0, SWT.CENTER);
+ data.bottom = new FormAttachment (cancel, 0, SWT.DEFAULT);
+ text.setLayoutData (data);
+
+ Button ok = new Button (dialog, SWT.PUSH);
+ ok.setText ("OK");
+ data = new FormData ();
+ data.width = 60;
+ data.right = new FormAttachment (cancel, 0, SWT.DEFAULT);
+ data.bottom = new FormAttachment (100, 0);
+ ok.setLayoutData (data);
+ ok.addSelectionListener (widgetSelectedAdapter(event -> {
+ dialog.close ();
+ }));
+
+ dialog.setDefaultButton (ok);
+ dialog.pack ();
+ text.setFocus();
+ dialog.open ();
+ System.out.println("dialog at "+dialog.getBounds());
+ }));
+ shell.pack ();
+ shell.open ();
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+ } \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug515773_shell_ONTOP.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug515773_shell_ONTOP.java
new file mode 100644
index 0000000000..90c32bdad8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug515773_shell_ONTOP.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
+
+public class Bug515773_shell_ONTOP {
+ public static void main (String [] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell (display);
+ shell.setText("Shell");
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginWidth = 10;
+ fillLayout.marginHeight = 10;
+ shell.setLayout(fillLayout);
+
+ Button open = new Button (shell, SWT.PUSH);
+ open.setText ("Prompt for a String");
+ open.addSelectionListener(widgetSelectedAdapter(e -> {
+ final Shell dialog = new Shell (shell, SWT.TOOL | SWT.ON_TOP | SWT.RESIZE);
+ dialog.setText("Dialog Shell");
+ FormLayout formLayout = new FormLayout ();
+ formLayout.marginWidth = 10;
+ formLayout.marginHeight = 10;
+ formLayout.spacing = 10;
+ dialog.setLayout (formLayout);
+ dialog.setLocation(26, 52);
+
+ Label label = new Label (dialog, SWT.NONE);
+ label.setText ("Type a String:");
+ FormData data = new FormData ();
+ label.setLayoutData (data);
+
+ Button cancel = new Button (dialog, SWT.PUSH);
+ cancel.setText ("Cancel");
+ data = new FormData ();
+ data.width = 60;
+ data.right = new FormAttachment (100, 0);
+ data.bottom = new FormAttachment (100, 0);
+ cancel.setLayoutData (data);
+ cancel.addSelectionListener (widgetSelectedAdapter(event -> {
+ System.out.println("User cancelled dialog");
+ dialog.close ();
+ }));
+
+ final Text text = new Text(dialog, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
+
+ data = new FormData ();
+ data.width = 200;
+ data.left = new FormAttachment (label, 0, SWT.DEFAULT);
+ data.right = new FormAttachment (100, 0);
+ data.top = new FormAttachment (label, 0, SWT.CENTER);
+ data.bottom = new FormAttachment (cancel, 0, SWT.DEFAULT);
+ text.setLayoutData (data);
+
+ Button ok = new Button (dialog, SWT.PUSH);
+ ok.setText ("OK");
+ data = new FormData ();
+ data.width = 60;
+ data.right = new FormAttachment (cancel, 0, SWT.DEFAULT);
+ data.bottom = new FormAttachment (100, 0);
+ ok.setLayoutData (data);
+ ok.addSelectionListener (widgetSelectedAdapter(event -> {
+ dialog.close ();
+ }));
+
+ dialog.setDefaultButton (ok);
+ dialog.pack ();
+ text.setFocus();
+ dialog.open ();
+ System.out.println("dialog at "+dialog.getBounds());
+ }));
+ shell.pack ();
+ shell.open ();
+
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516480_KeydownRussianlayout.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516480_KeydownRussianlayout.java
new file mode 100644
index 0000000000..fedd05e4ba
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516480_KeydownRussianlayout.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Bug516480_KeydownRussianlayout {
+ /**
+ * @author Thomas Singer
+ */
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final StyledText text = new StyledText(shell, SWT.BORDER);
+ text.setText("hello world");
+
+ text.addListener(SWT.KeyDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("event.character = " + (int)event.character);
+ System.out.println("event.keyCode = " + event.keyCode);
+ }
+ });
+
+ shell.setSize(300, 200);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516674_control_focus.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516674_control_focus.java
new file mode 100644
index 0000000000..18a2d4fdb4
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug516674_control_focus.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import java.awt.AWTException;
+import java.awt.Robot;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug516674_control_focus
+{
+ public static void main(String[] args)
+ {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText("TabItem");
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ tabItem.setControl(composite);
+ composite.setLayout(new GridLayout());
+ Text text = new Text(composite, SWT.NONE);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ shell.pack();
+ shell.setSize(500, 500);
+ shell.open();
+
+ tabFolder.setFocus();
+
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ text.getShell().forceActive();
+ text.getShell().forceFocus();
+ text.forceFocus();
+ }
+ });
+
+ try {
+ Thread.sleep(1000);
+ Robot robot = new Robot();
+ String string = "this is a test".toUpperCase();
+ for (int i = 0; i < string.length(); i++) {
+ char c = string.charAt(i);
+ robot.keyPress(c);
+ robot.keyRelease(c);
+ Thread.sleep(50);
+ }
+ } catch (AWTException | InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ thread.start();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517214_ComboReadOnlyWrongText.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517214_ComboReadOnlyWrongText.java
new file mode 100644
index 0000000000..76a461d18f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517214_ComboReadOnlyWrongText.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug517214_ComboReadOnlyWrongText {
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ Combo combo = new Combo (shell, SWT.READ_ONLY);
+ combo.setItems ("Alpha");
+ Rectangle clientArea = shell.getClientArea ();
+ combo.setBounds (clientArea.x, clientArea.y, 200, 200);
+ MouseAdapter clickListener = new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ System.out.println("hello");
+ }
+ };
+ shell.addMouseListener(clickListener);
+ shell.pack ();
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerDouble.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerDouble.java
new file mode 100644
index 0000000000..6ad8e3a54f
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerDouble.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+
+public class Bug517633_SpinnerDouble {
+
+ int originalValue;
+
+ Button apply;
+
+ Spinner spinner;
+
+ public Control createContent(Composite aParent) {
+ Composite container = new Composite(aParent, SWT.NONE);
+ container.setLayout(new GridLayout());
+ spinner = new Spinner(container, SWT.BORDER);
+ spinner.setValues(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, 1, 2);
+ GridData spinnerLD = new GridData(SWT.LEFT, SWT.TOP, false, false);
+ spinnerLD.widthHint = 50;
+ spinner.setLayoutData(spinnerLD);
+ Composite buttonsContainer = new Composite(aParent, SWT.NONE);
+ buttonsContainer.setLayout(new GridLayout());
+ buttonsContainer.setLayoutData(new GridData(SWT.RIGHT,SWT.BOTTOM, true, true));
+ apply = new Button(buttonsContainer, SWT.NONE);
+ apply.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
+ apply.setText("Apply Changes");
+ setInput(originalValue);
+ spinner.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent aEvent) {
+ updateButtons();
+ }
+
+ });
+ return container;
+ }
+
+ public void setInput(int aValue) {
+ originalValue = aValue;
+ if ((spinner != null) && !spinner.isDisposed()) {
+ spinner.setSelection(aValue);
+ updateButtons();
+ }
+ }
+
+ protected void updateButtons() {
+ apply.setEnabled(spinner.getSelection() != originalValue);
+ }
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ Bug517633_SpinnerDouble page = new Bug517633_SpinnerDouble();
+ Control pageControl =page.createContent(shell);
+ page.setInput(10003);
+ GridData pageLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ pageLayoutData.widthHint = 200;
+ pageControl.setLayoutData(pageLayoutData);
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ display.readAndDispatch();
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerWrongText.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerWrongText.java
new file mode 100644
index 0000000000..5240acb565
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug517633_SpinnerWrongText.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+
+public class Bug517633_SpinnerWrongText {
+ public static void main(String[] args) {
+ Display display = Display.getDefault();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+ Label info = new Label(shell, SWT.NONE);
+ info.setText("Select '1' in spinner text and type '2'");
+ info.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ Spinner spin = new Spinner(shell, SWT.BORDER);
+ spin.setValues(1000, 0, 10000, 0, 1, 10);
+ spin.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ spin.addListener(SWT.Selection, e -> info.setText("Value changed: " + spin.getSelection()));
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_eval_hang.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_eval_hang.java
new file mode 100644
index 0000000000..d4eb6c46fc
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_eval_hang.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: [GTK3][Webkit2] Implement webkit2 support for browser function (Part 2: Java return a value from callback.)
+ * How to run: Snippet to execute javascript via input prompt, to test Browser Func return value ability.
+ * Bug description:
+ * Expected results:
+ * GTK Version(s):
+ */
+public class Bug527564_eval_hang {
+
+ static int count = 0;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(500, 600);
+
+ shell.setLayout(new FillLayout());
+ final Browser browser = new Browser(shell, SWT.None);
+ browser.setText("Hello 1");
+// Boolean retVal1 = (Boolean) browser.evaluate("return true"); // Eval doesn't cause it to hang, only function.
+ new CustomFunction (browser, "theJavaFunction");
+
+ final Browser browser2 = new Browser(shell, SWT.None);
+ browser2.setText("Hello 2");
+// Boolean retVal2 = (Boolean) browser2.evaluate("return true"); // Eval doesn't cause it to hang, only function.
+ new CustomFunction2 (browser2, "theJavaFunction2");
+// browser2.execute("document.body.style.backgroundColor = 'red'");
+// browser2.execute("");
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ static class CustomFunction extends BrowserFunction { // copied from snippet 307
+ CustomFunction (Browser browser, String name) {
+ super (browser, name);
+ }
+ @Override
+ public Object function (Object[] arguments) {
+ System.out.println ("theJavaFunction() called from javascript with args:");
+ for (int i = 0; i < arguments.length; i++) {
+ Object arg = arguments[i];
+ if (arg == null) {
+ System.out.println ("\t-->null");
+ } else {
+ System.out.println ("\t-->" + arg.getClass ().getName () + ": " + arg.toString ());
+ }
+ }
+ return arguments;
+ }
+ }
+
+ static class CustomFunction2 extends BrowserFunction { // copied from snippet 307
+ CustomFunction2 (Browser browser, String name) {
+ super (browser, name);
+ }
+ @Override
+ public Object function (Object[] arguments) {
+ System.out.println ("theJavaFunction() called from javascript with args:");
+ for (int i = 0; i < arguments.length; i++) {
+ Object arg = arguments[i];
+ if (arg == null) {
+ System.out.println ("\t-->null");
+ } else {
+ System.out.println ("\t-->" + arg.getClass ().getName () + ": " + arg.toString ());
+ }
+ }
+ return arguments;
+ }
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_exec_hang.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_exec_hang.java
new file mode 100644
index 0000000000..3dc1389d1c
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug527564_exec_hang.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.BrowserFunction;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * Title: [GTK3][Webkit2] Implement webkit2 support for browser function (Part 2: Java return a value from callback.)
+ * How to run: Snippet to execute javascript via input prompt, to test Browser Func return value ability.
+ * Bug description:
+ * Expected results:
+ * GTK Version(s):
+ */
+public class Bug527564_exec_hang {
+
+ static int count = 0;
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setSize(500, 600);
+
+ shell.setLayout(new RowLayout());
+
+ Composite leftBrowser = new Composite(shell, SWT.NONE);
+ Composite rightBrowser = new Composite(shell, SWT.None);
+ Button button = new Button (rightBrowser, SWT.PUSH);
+ button.setText("my button");
+
+ final Browser browser = makeBrowserWithConsole(leftBrowser, "theJavaFunction");
+ final Browser browser2 = makeBrowserWithConsole(rightBrowser, "theJavaFunction2");
+ new CustomFunction (browser, "theJavaFunction");
+ new CustomFunction2 (browser2, "theJavaFunction2");
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ /**
+ * @param leftBrowser
+ * @return
+ */
+ private static Browser makeBrowserWithConsole(Composite leftBrowser, String funcName) {
+ GridLayout gridLayout = new GridLayout();
+ leftBrowser.setLayout(gridLayout);
+
+ final Text jsConsole = new Text(leftBrowser, SWT.BORDER);
+ jsConsole.setText("document.body.innerHTML = " + funcName + "(123)"); // Case where there are no paramaters.
+ jsConsole.setSelection(jsConsole.getText().length());
+ GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+ jsConsole.setLayoutData(data);
+
+ final Browser browser = new Browser(leftBrowser, SWT.NONE);
+ browser.setText("hello <b>world!</b>");
+ data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ browser.setLayoutData(data);
+
+ jsConsole.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == 13) { // 13 = Enter
+ browser.execute(jsConsole.getText());
+ }
+ }
+ });
+
+ Button loadNewPage = new Button(leftBrowser, SWT.PUSH);
+ loadNewPage.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+ loadNewPage.setText("Load new Page");
+ loadNewPage.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ browser.setText("New page!" + count++);
+ }
+ });
+ return browser;
+ }
+
+ static class CustomFunction extends BrowserFunction { // copied from snippet 307
+ CustomFunction (Browser browser, String name) {
+ super (browser, name);
+ }
+ @Override
+ public Object function (Object[] arguments) {
+ System.out.println ("theJavaFunction() called from javascript with args:");
+ for (int i = 0; i < arguments.length; i++) {
+ Object arg = arguments[i];
+ if (arg == null) {
+ System.out.println ("\t-->null");
+ } else {
+ System.out.println ("\t-->" + arg.getClass ().getName () + ": " + arg.toString ());
+ }
+ }
+ return arguments;
+ }
+ }
+ static class CustomFunction2 extends BrowserFunction { // copied from snippet 307
+ CustomFunction2 (Browser browser, String name) {
+ super (browser, name);
+ }
+ @Override
+ public Object function (Object[] arguments) {
+ System.out.println ("theJavaFunction() called from javascript with args:");
+ for (int i = 0; i < arguments.length; i++) {
+ Object arg = arguments[i];
+ if (arg == null) {
+ System.out.println ("\t-->null");
+ } else {
+ System.out.println ("\t-->" + arg.getClass ().getName () + ": " + arg.toString ());
+ }
+ }
+ return arguments;
+ }
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug55595_CursorMovementMonitor.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug55595_CursorMovementMonitor.java
new file mode 100644
index 0000000000..2ce5b0d837
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug55595_CursorMovementMonitor.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug55595_CursorMovementMonitor {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.addListener(SWT.MouseMove, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("MouseMove x "+event.x+" y "+event.y);
+ }});
+ shell.addListener(SWT.MouseUp, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("MouseUp x "+event.x+" y "+event.y);
+ }});
+ shell.addListener(SWT.MouseDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("MouseDown x "+event.x+" y "+event.y);
+ }});
+ new Thread() {
+ @Override
+ public void run() {
+ while (!shell.isDisposed()) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {}
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Point pt = shell.getLocation();
+ Event event = new Event();
+ event.type = SWT.MouseMove;
+ event.x = pt.x + 100;
+ event.y = pt.y + 100;
+ display.post(event);
+ }
+ });
+ }
+ }
+ }.start();
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ }
+}
+
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug62247_KDEToolTip.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug62247_KDEToolTip.java
new file mode 100644
index 0000000000..116b520ecd
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug62247_KDEToolTip.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug62247_KDEToolTip {
+
+
+public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ Composite c = new Composite(shell, SWT.NONE);
+ c.addListener(SWT.Paint, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ System.out.println("Paint");
+ }
+ });
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug69650_FocusLostWhenWidgetDisposed.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug69650_FocusLostWhenWidgetDisposed.java
new file mode 100644
index 0000000000..a8e4722091
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug69650_FocusLostWhenWidgetDisposed.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug69650_FocusLostWhenWidgetDisposed {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ display.addFilter(SWT.KeyDown, new Listener() {
+ int count = 0;
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("Got a key down: " + count);
+ count++;
+ }
+ });
+ Text text = new Text(shell, SWT.BORDER);
+ text.setBounds(20, 20, 200, 40);
+
+ final Text text2 = new Text(shell, SWT.BORDER);
+ text2.setBounds(80, 80, 200, 40);
+ text2.addListener(SWT.KeyDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("ok, here goes");
+ text2.dispose();
+ }
+ });
+
+ shell.open();
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug71990_SlowTablePack.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug71990_SlowTablePack.java
new file mode 100644
index 0000000000..9361319be6
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug71990_SlowTablePack.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug71990_SlowTablePack {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ long start = System.currentTimeMillis();
+
+ final Composite parent = new Composite(shell, SWT.NONE);
+ parent.setLayout(new FillLayout());
+ parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final StackLayout layout = new StackLayout();
+ parent.setLayout(layout);
+
+ final Composite c1 = new Composite(parent, SWT.NONE);
+ c1.setLayout(new FillLayout());
+ final Composite c2 = new Composite(parent, SWT.NONE);
+ c2.setLayout(new FillLayout());
+
+ final Button button = new Button(shell, SWT.NONE);
+ button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ button.setText("Switch");
+
+ final Table t1 = makeTable(c1);
+ final Table t2 = makeTable(c2);
+
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ long st = System.currentTimeMillis();
+
+ if (layout.topControl == c1) {
+ layout.topControl = c2;
+ makeColumns(t2, false);
+ } else {
+ layout.topControl = c1;
+ makeColumns(t1, false);
+ }
+
+ parent.layout();
+
+ System.out.println("Layout: "
+ + (System.currentTimeMillis() - st));
+
+ }
+ });
+
+ layout.topControl = c1;
+
+ long packTime = System.currentTimeMillis();
+
+ shell.pack();
+ shell.setSize(400, 400);
+ shell.open();
+
+ System.out.println("Pack: " + (System.currentTimeMillis() - packTime));
+
+ System.out.println("Finish: " + (System.currentTimeMillis() - start));
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ public static Table makeTable(Composite parent) {
+ Table table = new Table(parent, SWT.MULTI | SWT.BORDER
+ | SWT.FULL_SELECTION);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ String[] titles = { " ", "C", "!", "Description", "Resource",
+ "In Folder", "Location" };
+ for (int i = 0; i < titles.length; i++) {
+ TableColumn column = new TableColumn(table, SWT.NULL);
+ column.setText(titles[i]);
+ }
+ makeColumns(table, true);
+ table.pack();
+ return table;
+ }
+
+ public static void makeColumns(Table table, boolean pack) {
+ int count = 1024;
+
+ long time = System.currentTimeMillis();
+
+ table.removeAll();
+
+ System.out.println("Time RemoveAll: "
+ + (System.currentTimeMillis() - time));
+
+ long time0 = System.currentTimeMillis();
+
+ for (int i = 0; i < count; i++) {
+ TableItem item = new TableItem(table, SWT.NULL);
+ item.setText(0, "x");
+ item.setText(1, "y");
+ item.setText(2, "!");
+ item.setText(3, "this stuff behaves the way I expect");
+ item.setText(4, "almost everywhere");
+ item.setText(5, "some.folder");
+ item.setText(6, "line " + i + " in nowhere");
+ }
+
+ long time1 = System.currentTimeMillis();
+
+ System.out.println("Time add Items: " + (time1 - time0));
+
+ if (pack) {
+ for (int i = 0; i < table.getColumnCount(); i++)
+ table.getColumn(i).pack();
+ long time2 = System.currentTimeMillis();
+ System.out.println("Time column pack: " + (time2 - time1));
+ }
+
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug74739_TableTopIndex.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug74739_TableTopIndex.java
new file mode 100644
index 0000000000..848a9a2bdc
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug74739_TableTopIndex.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ControlEditor;
+import org.eclipse.swt.custom.TableCursor;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * Created on Sep 22, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * @author jcalder
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class Bug74739_TableTopIndex {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new GridLayout());
+
+ Font font = new Font(display, "Courier", 10, SWT.NORMAL);
+
+ // create a a widget.table with 3 columns and fill with data
+ final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+
+ table.setFont(font);
+
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ TableColumn column1 = new TableColumn(table, SWT.NONE);
+ TableColumn column2 = new TableColumn(table, SWT.NONE);
+ TableColumn column3 = new TableColumn(table, SWT.NONE);
+ for (int i = 0; i < 500; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
+ }
+ column1.pack();
+ column2.pack();
+ column3.pack();
+
+ // create a TableCursor to navigate around the widget.table
+ final TableCursor cursor = new TableCursor(table, SWT.NONE);
+ // create an editor to edit the cell when the user hits "ENTER"
+ // while over a cell in the widget.table
+ final ControlEditor editor = new ControlEditor(cursor);
+ editor.grabHorizontal = true;
+ editor.grabVertical = true;
+
+ cursor.addSelectionListener(new SelectionAdapter() {
+ // when the TableEditor is over a cell, select the corresponding row in
+ // the widget.table
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ table.setSelection(new TableItem[] {cursor.getRow()});
+ }
+ // when the user hits "ENTER" in the TableCursor, pop up a widget.text editor so that
+ // they can change the widget.text of the cell
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e){
+ final Text text = new Text(cursor, SWT.NONE);
+ TableItem row = cursor.getRow();
+ int column = cursor.getColumn();
+ text.setText(row.getText(column));
+ text.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ // close the widget.text editor and copy the data over
+ // when the user hits "ENTER"
+ if (e.character == SWT.CR) {
+ TableItem row = cursor.getRow();
+ int column = cursor.getColumn();
+ row.setText(column, text.getText());
+ text.dispose();
+ }
+ // close the widget.text editor when the user hits "ESC"
+ if (e.character == SWT.ESC) {
+ text.dispose();
+ }
+ }
+ });
+ editor.setEditor(text);
+ text.setFocus();
+ }
+ });
+ // Hide the TableCursor when the user hits the "MOD1" or "MOD2" key.
+ // This alows the user to select multiple items in the widget.table.
+ cursor.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.MOD1 ||
+ e.keyCode == SWT.MOD2 ||
+ (e.stateMask & SWT.MOD1) != 0 ||
+ (e.stateMask & SWT.MOD2) != 0) {
+ cursor.setVisible(false);
+ }
+ }
+ });
+ // Show the TableCursor when the user releases the "MOD2" or "MOD1" key.
+ // This signals the end of the multiple selection task.
+ table.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.keyCode == SWT.MOD1 && (e.stateMask & SWT.MOD2) != 0) return;
+ if (e.keyCode == SWT.MOD2 && (e.stateMask & SWT.MOD1) != 0) return;
+ if (e.keyCode != SWT.MOD1 && (e.stateMask & SWT.MOD1) != 0) return;
+ if (e.keyCode != SWT.MOD2 && (e.stateMask & SWT.MOD2) != 0) return;
+
+ TableItem[] selection = table.getSelection();
+ TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
+ table.showItem(row);
+ cursor.setSelection(row, 0);
+ cursor.setVisible(true);
+ cursor.setFocus();
+ }
+ });
+
+
+ ScrollBar scrollBar = table.getVerticalBar();
+ scrollBar.addSelectionListener(new SelectionListener(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int tableIndex = table.getTopIndex();
+ System.out.println("widget.table index is: " + tableIndex);
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }});
+
+ table.setTopIndex(20);
+ System.out.println("getTopIndex: " + table.getTopIndex());
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ font.dispose();
+ display.dispose();
+ }
+
+
+
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug75748_FlashingPageDown.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug75748_FlashingPageDown.java
new file mode 100644
index 0000000000..f037dff567
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug75748_FlashingPageDown.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug75748_FlashingPageDown {
+
+ public static void main (String [] args) {
+ Display display = new Display ();
+ Shell shell = new Shell (display);
+ shell.setLayout(new FillLayout());
+ StyledText s = new StyledText(shell, SWT.H_SCROLL |SWT.V_SCROLL);
+ s.setFont(new Font(display, "Monospace", 10, SWT.NONE));
+ String mytext = new String();
+ int i, n = 256;
+ for(i = 0; i < n; i++) {
+ for(int j = 0; j < 72; j++) mytext += (j % 10);
+ mytext += " [" + i + "]\n";
+ }
+ s.setText(mytext);
+ shell.setSize(400,400);
+ shell.open ();
+ while (!shell.isDisposed ()) {
+ if (!display.readAndDispatch ()) display.sleep ();
+ }
+ display.dispose ();
+ }
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug78888_ToolBarEventInconsistency.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug78888_ToolBarEventInconsistency.java
new file mode 100644
index 0000000000..60493505b7
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug78888_ToolBarEventInconsistency.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+public class Bug78888_ToolBarEventInconsistency {
+ public static void main(String[] args) {
+ Display display = new Display ();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ ToolBar bar = new ToolBar(shell, SWT.FLAT);
+ bar.setBounds(10,10,150,30);
+ ToolItem item = new ToolItem(bar, SWT.PUSH);
+ item.setText("&item 1");
+ bar.addTraverseListener(new TraverseListener() {
+ @Override
+ public void keyTraversed(TraverseEvent e) {
+ System.out.println("traverse");
+ }
+ });
+ bar.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ System.out.println("mouse down");
+ }
+ @Override
+ public void mouseUp(MouseEvent e) {
+ System.out.println("mouse up");
+ }
+ });
+ item.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("selection");
+ }
+ });
+ bar.addKeyListener(new KeyListener() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ System.out.println("key down");
+ }
+ @Override
+ public void keyReleased(KeyEvent e) {
+ System.out.println("key up");
+ }
+ });
+ shell.open();
+ bar.setFocus();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug79462_ChildShellsPositions.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug79462_ChildShellsPositions.java
new file mode 100644
index 0000000000..bb6a8c9df8
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug79462_ChildShellsPositions.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug79462_ChildShellsPositions {
+public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.addListener (SWT.MouseDown, new Listener () {
+ @Override
+ public void handleEvent(Event event) {
+ Shell dialog = new Shell (shell, SWT.DIALOG_TRIM);
+ dialog.setBounds (10, 10, 100, 100);
+ dialog.open();
+ while (!dialog.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug83833_SetTopIndexSelectionEvent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug83833_SetTopIndexSelectionEvent.java
new file mode 100644
index 0000000000..9ca2dd67fc
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug83833_SetTopIndexSelectionEvent.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug83833_SetTopIndexSelectionEvent {
+ public static void main(String [] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ Table table = new Table(shell, SWT.NONE);
+ ScrollBar scrollBar = table.getVerticalBar();
+ scrollBar.setEnabled(false);
+ scrollBar.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("Selection event");
+ }
+ });
+ for(int i = 0; i < 500; i++) {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(0, "This is item " + i);
+ }
+ table.setTopIndex(20);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug84054_TableActivateEventScroll.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug84054_TableActivateEventScroll.java
new file mode 100644
index 0000000000..9ef58f57d9
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug84054_TableActivateEventScroll.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug84054_TableActivateEventScroll {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(10,10,400,400);
+ final Table table = new Table(shell, SWT.NONE);
+ table.setBounds(10,10,100,100);
+ for (int i = 0; i < 99; i++) {
+ new TableItem(table, SWT.NONE).setText("item " + i);
+ }
+
+ final Table table2 = new Table(shell, SWT.NONE);
+ table2.setBounds(10,130,100,100);
+ for (int i = 0; i < 99; i++) {
+ new TableItem(table2, SWT.NONE).setText("item " + i);
+ }
+
+ table.addListener(SWT.Activate, new Listener() {
+
+ @Override
+ public void handleEvent(Event arg0) {
+ System.out.println(" 1 activated");
+
+ }});
+
+ table.addListener(SWT.Deactivate, new Listener() {
+
+ @Override
+ public void handleEvent(Event arg0) {
+ System.out.println(" 1 deactivated");
+
+ }});
+
+ table2.addListener(SWT.Activate, new Listener() {
+
+ @Override
+ public void handleEvent(Event arg0) {
+ System.out.println(" 2 activated");
+
+ }});
+
+ table2.addListener(SWT.Deactivate, new Listener() {
+
+ @Override
+ public void handleEvent(Event arg0) {
+ System.out.println(" 2 deactivated");
+
+ }});
+
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85050_ControlResizeTabFolder.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85050_ControlResizeTabFolder.java
new file mode 100644
index 0000000000..8ebb7cd7b1
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85050_ControlResizeTabFolder.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+public class Bug85050_ControlResizeTabFolder {
+ public static void main(String [] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+
+ final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
+ TabItem item = new TabItem(tabFolder, SWT.NONE);
+ System.out.println(tabFolder.computeTrim(0,0,0,0));
+ tabFolder.setFont(new Font(display, "Arial", 20, SWT.ITALIC));
+ System.out.println(tabFolder.computeTrim(0,0,0,0));
+ final TabItem item2 = new TabItem(tabFolder, SWT.NONE);
+ Button button = new Button(tabFolder, SWT.PUSH);
+ button.setText("george");
+ item2.setControl(button);
+ Button button2 = new Button(tabFolder, SWT.PUSH);
+ button2.setText("ralph");
+ item.setControl(button2);
+ button.addSelectionListener(new SelectionListener () {
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ System.out.println("before: " + tabFolder.computeTrim(0,0,0,0));
+ //tabFolder.setFont(new Font(display, "Arial", 2, SWT.ITALIC));
+ item2.setImage(new Image(display, 60, 60));
+ System.out.println("after: " + tabFolder.computeTrim(0,0,0,0));
+ //item2.dispose();
+ }
+ });
+ tabFolder.setBounds(0,0,200,200);
+
+ shell.open();
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85131_ToolTipSetNull.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85131_ToolTipSetNull.java
new file mode 100644
index 0000000000..d0f47cb73d
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug85131_ToolTipSetNull.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This code reproduce GTK's setToolTipText(null) problem.
+ */
+public class Bug85131_ToolTipSetNull
+{
+ public static void main(String[]v)
+ {
+ Display disp = Display.getDefault();
+ final Shell shell = new Shell(disp, SWT.DIALOG_TRIM|SWT.RESIZE );
+ shell.setText( "Test Tooltip" );
+
+ shell.setLayout( new FillLayout() );
+
+ final Canvas canvas = new Canvas( shell, SWT.NONE );
+ canvas.addPaintListener( new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e)
+ {
+ Rectangle r = canvas.getClientArea();
+ int wm = r.width/8, w2 = r.width/2;
+ int hm = r.height/8;
+ int rw = w2-wm, rh = r.height-2*hm;
+
+ e.gc.setBackground( new Color(null,200,0,0) );
+ e.gc.fillRectangle( 0,hm,w2,rh);
+ e.gc.setBackground( new Color(null,0,0,200) );
+ e.gc.fillRectangle( w2,hm+hm,rw+wm,rh-hm);
+ }
+ });
+ canvas.addMouseMoveListener( new MouseMoveListener() {
+ @Override
+ public void mouseMove(org.eclipse.swt.events.MouseEvent
+e) {
+ int mx = e.x;
+ int my = e.y;
+
+ Rectangle r = canvas.getClientArea();
+ int wm = r.width/8, w2 = r.width/2;
+ int hm = r.height/8;
+ int rw = w2-wm, rh = r.height-2*hm;
+
+ String tip = null;
+ if( mx>=0 && mx <= 0+w2 && my >= hm && my <= hm+rh )
+ {
+ tip = "Red Rectangle";
+ }
+ else if( mx>=w2 && mx <= w2+rw+wm && my >= hm+hm && my <=
+hm+rh )
+ {
+ tip = "Blue Rectangle";
+ }
+System.out.println("setToolTipText("+tip+")");
+ canvas.setToolTipText( tip );
+ }
+ });
+
+ shell.setSize( 300, 200 );
+ shell.open();
+
+ while (!shell.isDisposed())
+ if (!disp.readAndDispatch())
+ disp.sleep();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug92176_TreeScrolling.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug92176_TreeScrolling.java
new file mode 100644
index 0000000000..a6fc0c6f19
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug92176_TreeScrolling.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug92176_TreeScrolling {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setText("PR");
+
+ final Tree tree = new Tree (shell, SWT.BORDER);
+ tree.setSize (100, 100);
+ shell.setSize (200, 200);
+
+ final TreeItem[] items = new TreeItem[100];
+ items[0] = new TreeItem(tree, 0);
+ items[0].setText("elt"+0);
+ int n = 50;
+ for (int i = 1; i < n; i++) {
+ items[i] = new TreeItem(items[i-1], 0);
+ items[i].setText("child"+i);
+ }
+ for (int i = n; i < items.length; i++) {
+ items[i] = new TreeItem(tree, 0);
+ items[i].setText("elt "+i);
+ }
+
+ Button button = new Button(shell, SWT.PUSH);
+ button.setBounds(120,0,50,20);
+ button.setText("show");
+ button.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event e) {
+ tree.showItem(items[45]);
+ }
+ });
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug96500_DoubleBrowserComposite.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug96500_DoubleBrowserComposite.java
new file mode 100644
index 0000000000..5e9cf8bed3
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug96500_DoubleBrowserComposite.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug96500_DoubleBrowserComposite {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ Browser browser;
+
+ browser = new Browser (shell, SWT.NONE);
+ browser.setBounds (10, 10, 500, 200);
+ browser.setText("<html><body><A HREF=\"www\">lala</a> <AHREF=\"www\">lala</a><br><input type=\"widget.text\" value='' maxlength=256></body></html>");
+ browser.getAccessible();
+ browser = new Browser (shell, SWT.NONE);
+ browser.setBounds (10, 220, 500, 200);
+ browser.setText("<html><body><A HREF=\"www\">lala</a> <A HREF=\"www\">lala</a><br><input type=\"widget.text\" value='' maxlength=256></body></html>");
+
+ Button button= new Button (shell, SWT.PUSH);
+ button.setBounds(10, 500, 70, 28);
+ button.setText("Button");
+
+ shell.open();
+ while (!shell.isDisposed())
+ if (!display.readAndDispatch())
+ display.sleep();
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97527_LabelSizing.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97527_LabelSizing.java
new file mode 100644
index 0000000000..761877e530
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97527_LabelSizing.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug97527_LabelSizing {
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ GridLayout layout = new GridLayout(2,false);
+ layout.numColumns = 2;
+ shell.setLayout(layout);
+ Label label = new Label(shell, SWT.WRAP);
+ label.setText("here is a long piece of widget.text which might wrap or might not depending on the platform at runtime" +
+ " here is a long piece of widget.text which might wrap or might not depending on the" +
+ "platform at runtime");
+ final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+ label.setLayoutData(gridData);
+
+ shell.pack();
+ System.out.println(shell.getSize());
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97723_TreeHoverParent.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97723_TreeHoverParent.java
new file mode 100644
index 0000000000..bce71efe62
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97723_TreeHoverParent.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+public class Bug97723_TreeHoverParent {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10,10,200,200);
+ final Tree tree = new Tree(shell, SWT.NONE);
+ tree.setBounds(10,10,150,150);
+ new TreeColumn(tree, SWT.NONE).setWidth(100);
+ new TreeColumn(tree, SWT.NONE).setWidth(100);
+ shell.open();
+ shell.addListener(SWT.MouseHover, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ System.out.println("hover");
+ }
+ });
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97733_TableSetHeaderVisibleRedraw.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97733_TableSetHeaderVisibleRedraw.java
new file mode 100644
index 0000000000..3ed7f144cc
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97733_TableSetHeaderVisibleRedraw.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+public class Bug97733_TableSetHeaderVisibleRedraw {
+ static int counter = 0;
+public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10, 10, 300, 300);
+ final Table table = new Table(shell, SWT.NONE);
+ table.setHeaderVisible(true);
+ table.setBounds(10, 10, 200, 200);
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText("0");
+ column.setWidth(75);
+ column = new TableColumn(table,SWT.CENTER);
+ column.setText("1");
+ column.setWidth(120);
+ new TableItem(table, SWT.NONE).setText(new String[] {"abc","def"});
+ shell.addListener(SWT.MouseDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (counter == 0) {
+ System.out.println("setRedraw(false)");
+ table.setRedraw(false);
+ counter++;
+ return;
+ }
+ if (counter == 1) {
+ System.out.println("setHeaderVisible(true): overwrites item");
+ table.setHeaderVisible(false);
+ //widget.table.setColumnOrder(new int[] {1,0});
+ counter++;
+ return;
+ }
+ if (counter == 2) {
+ System.out.println("setRedraw(true), item reappears");
+ table.setRedraw(true);
+ counter++;
+ return;
+ }
+ System.out.println("nothing left to do");
+ }
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+}
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97863_TableColumnDragging.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97863_TableColumnDragging.java
new file mode 100644
index 0000000000..027699df20
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug97863_TableColumnDragging.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class Bug97863_TableColumnDragging {
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setBounds(10,10,400,400);
+ final Table tree = new Table(shell, SWT.NONE);
+ tree.setBounds(10,10,300,300);
+ tree.setHeaderVisible(true);
+ ControlListener controlListener = new ControlListener() {
+ @Override
+ public void controlResized(ControlEvent e) {
+ System.out.println("column resized: " + e.widget);
+ }
+ @Override
+ public void controlMoved(ControlEvent e) {
+ System.out.println("column moved: " + e.widget);
+ }
+ };
+ TableColumn column = new TableColumn(tree, SWT.NONE);
+ column.setWidth(50);
+ column.setText("col 0");
+ column.setMoveable(true);
+ column.addControlListener(controlListener);
+ column = new TableColumn(tree, SWT.NONE);
+ column.setWidth(50);
+ column.setText("col 1");
+ column.setMoveable(true);
+ column.addControlListener(controlListener);
+ column = new TableColumn(tree, SWT.NONE);
+ column.setWidth(50);
+ column.setText("col 2");
+ column.setMoveable(true);
+ column.addControlListener(controlListener);
+ column = new TableColumn(tree, SWT.NONE);
+ column.setWidth(50);
+ column.setText("col 3");
+ column.setMoveable(true);
+ column.addControlListener(controlListener);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+}
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug_514483_getCursorLocation.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug_514483_getCursorLocation.java
new file mode 100644
index 0000000000..f1a6063dc2
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug_514483_getCursorLocation.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug_514483_getCursorLocation
+{
+ public static void main(String[] args)
+ {
+ final Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setBounds(0, 0, 600, 600);
+
+ Label parentShellLabel = new Label(shell, SWT.None);
+ parentShellLabel.setText("Parent widget.shell.\n"
+ + "INSTRUCTIONS:\n"
+ + "- Parent widget.shell should be maximized.\n"
+ + "- Child widget.shell should be at x400 y400 (in yellow square).\n"
+ + "- Click inside the child widget.shell, observe result coordinates below.\n"
+ + "\n"
+ + "The bug is that x,y is not relative to parent, but relative to child-widget.shell itself (0-200 range).\n"
+ + "Expected coordinates: between ~400 to ~600. (i.e, relative to parent's x,y.)\n"
+ + "Result Coordinates:");
+ parentShellLabel.setBounds(0, 0, 600, 200);
+
+ final Label resultLbl = new Label(shell, SWT.None);
+ resultLbl.setBounds(0,180, 600, 100);
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+
+ Label childShellLocation = new Label(shell, SWT.None);
+ childShellLocation.setText("Child Shell should be here.\nIf it is not, move it here \nmanually");
+ childShellLocation.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
+ childShellLocation.setBounds(400, 400, 200, 160);
+
+ Shell childShell = new Shell(shell, SWT.ON_TOP);
+ childShell.setBackground(display.getSystemColor(SWT.COLOR_DARK_YELLOW));
+
+ MouseAdapter clickListener = new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ Point loc = display.getCursorLocation();
+ resultLbl.setText(loc.toString());
+ if (loc.x > 300 && loc.x < 700 && loc.y > 300 && loc.y < 700) // give user some slack.
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
+ else
+ resultLbl.setBackground(display.getSystemColor(SWT.COLOR_RED));
+ }
+ };
+ childShell.addMouseListener(clickListener);
+
+// display.addFilter(SWT.KeyDown, new Listener() {
+// public void handleEvent(Event e) {
+// if (e.type == SWT.KeyDown) {
+// switch (e.keyCode) {
+// case SWT.F1:
+// System.out.println("Passed");
+// break;
+// case SWT.F2:
+// System.out.println("Failed");
+// break;
+// case SWT.F3:
+// System.out.println("Skipped");
+// break;
+// case SWT.F4:
+// System.out.println("Exit Test suite");
+// break;
+// }
+// }
+// }
+// });
+
+ shell.open();
+ childShell.open();
+ childShell.setBounds(400, 400, 200, 200);
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/SimpleTextTransfer.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/SimpleTextTransfer.java
new file mode 100644
index 0000000000..ee2e41f859
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/SimpleTextTransfer.java
@@ -0,0 +1,116 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+
+/*******************************************************************************
+ * Copyright (c) 2004, 2018 Actuate Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+
+
+import org.eclipse.swt.dnd.ByteArrayTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+
+/**
+ *
+ */
+
+public class SimpleTextTransfer extends ByteArrayTransfer
+{
+
+ private static final SimpleTextTransfer instance = new SimpleTextTransfer( );
+
+ private static final String TYPE_NAME = "simple-widget.text-transfer";//$NON-NLS-1$
+
+ private static final int TYPEID = registerType( TYPE_NAME );
+
+ private SimpleTextTransfer( )
+ {
+
+ }
+
+ public static SimpleTextTransfer getInstance( )
+ {
+ return instance;
+ }
+
+ @Override
+ protected int[] getTypeIds( )
+ {
+ return new int[]{
+ TYPEID
+ };
+ }
+
+ @Override
+ protected String[] getTypeNames( )
+ {
+ return new String[]{
+ TYPE_NAME
+ };
+ }
+
+ private boolean checkText( Object object )
+ {
+ return ( object != null && object instanceof String && ( (String) object ).length( ) > 0 );
+ }
+
+ @Override
+ protected boolean validate( Object object )
+ {
+ return checkText( object );
+ }
+
+ /**
+ * This implementation of <code>javaToNative</code> converts plain widget.text
+ * represented by a java <code>String</code> to a platform specific
+ * representation.
+ *
+ * @param object
+ * a java <code>String</code> containing widget.text
+ * @param transferData
+ * an empty <code>TransferData</code> object; this object will
+ * be filled in on return with the platform specific format of
+ * the data
+ *
+ * @see Transfer#javaToNative
+ */
+ @Override
+ public void javaToNative( Object object, TransferData transferData )
+ {
+ if ( checkText( object ) && isSupportedType( transferData ) )
+ {
+ super.javaToNative( ( (String) object ).getBytes( ), transferData );
+ }
+ }
+
+ /**
+ * This implementation of <code>nativeToJava</code> converts a platform
+ * specific representation of plain widget.text to a java <code>String</code>.
+ *
+ * @param transferData
+ * the platform specific representation of the data to be
+ * converted
+ * @return a java <code>String</code> containing widget.text if the conversion
+ * was successful; otherwise null
+ *
+ * @see Transfer#nativeToJava
+ */
+ @Override
+ public Object nativeToJava( TransferData transferData )
+ {
+ if ( !isSupportedType( transferData ) )
+ {
+ return null;
+ }
+ byte[] bytes = (byte[]) super.nativeToJava( transferData );
+ return new String( bytes );
+ }
+
+}

Back to the top