Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Caks2014-08-04 09:06:39 +0000
committerChristoph Caks2014-08-04 09:06:39 +0000
commitdc0a90169a955e2828d7b129357abd9b8b19b66c (patch)
tree4cbeb7f1ace3e3d32d61a6cf29543c4905300f56 /bundles
parentc2d7b31a58b3d3639bc9de8c2e30218640af8919 (diff)
parentc8a588ce13f18b015212c5547b9dca0f915ca24f (diff)
downloadorg.eclipse.efxclipse-dc0a90169a955e2828d7b129357abd9b8b19b66c.tar.gz
org.eclipse.efxclipse-dc0a90169a955e2828d7b129357abd9b8b19b66c.tar.xz
org.eclipse.efxclipse-dc0a90169a955e2828d7b129357abd9b8b19b66c.zip
Merge branch 'master' of git://git.eclipse.org/gitroot/efxclipse/org.eclipse.efxclipse.git
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanProperty.java1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanValueProperty.java7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/JFXBeanProperties.java14
-rw-r--r--bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/AdaptValueSupplier.java8
-rw-r--r--bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java18
-rw-r--r--bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java25
-rw-r--r--bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java2
-rw-r--r--bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java4
-rw-r--r--bundles/runtime/org.eclipse.fx.core.log4j/.DS_Storebin6148 -> 0 bytes
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.log4j/META-INF/MANIFEST.MF6
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/.classpath (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath)0
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/.gitignore3
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/.project (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/.project)2
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/.settings/org.eclipse.jdt.core.prefs (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs)2
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/META-INF/MANIFEST.MF13
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/l10n/bundle.properties3
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/slf4jlogger.xml8
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/about.html (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/about.html)0
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/build.properties6
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.slf4j/pom.xml34
-rw-r--r--bundles/runtime/org.eclipse.fx.core.slf4j/src/org/eclipse/fx/core/slf4j/Slf4JLoggerFactory.java275
-rw-r--r--bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableList.java5
-rw-r--r--bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactory.java3
-rw-r--r--bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactory.java3
-rw-r--r--bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeTableCellFactory.java3
-rwxr-xr-xbundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/AbstractJFXApplication.java7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/OSGiFXMLLoader.java66
-rw-r--r--bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java61
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FadeAnimation.java5
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FlipAnimation.java43
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/PageChangeAnimation.java166
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/RotateOutAnimation.java7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/SlideAnimation.java29
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/ZoomSlideAnimation.java78
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/.classpath15
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.resources.prefs2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.jdt.core.prefs107
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF14
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/InsertMarkerSample.java22
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/SimpleStyledText.java5
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/TabOutLineMarkerSample.java39
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/controls.cssext4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIcon.java36
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconStyleConverter.java45
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconView.java339
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/behavior/FontIconViewBehavior.java16
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.css3
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.cssext23
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/skin/FontIconViewSkin.java125
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontLookup.java97
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontProvider.java6
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/AreaOverlay.java68
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/PositionMarker.java192
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java165
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/ActionEvent.java71
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyleRange.java387
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java1889
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextContent.java120
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangedEvent.java69
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangingEvent.java70
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextSelection.java37
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextStyle.java740
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/VerifyEvent.java100
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java272
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/skin/StyledTextSkin.java848
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/styledtextarea.css33
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java495
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/skin/DnDTabPaneSkin.java426
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/PropertyTableCellFactory.java10
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java11
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlReadOnlyPropertyValueProperty.java30
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlValueProperty.java9
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/DatePickerValueProperty.java1
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/SingleSelectionProperty.java6
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/TemplateComputedValue.java20
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/BasicResourceProvider.java1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/DIApplication.java1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/FXMLLoaderFactory.java1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/InjectingFXMLLoader.java81
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/FXMLLoaderSupplier.java26
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/LoggerSupplier.java6
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/ResourceServiceImpl.java1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingProcessingAddon.java364
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingServiceAddon.java14
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/EBindingService.java190
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceCreationFunction.java8
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceImpl.java173
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTable.java268
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTableManager.java146
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/ContextSet.java71
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingFactoryImpl.java12
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingImpl.java35
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyBindingImpl.java19
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeySequenceImpl.java71
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyStrokeImpl.java119
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerImpl.java9
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerSequenceImpl.java54
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/Util.java429
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Binding.java39
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyBinding.java5
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeySequence.java12
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyStroke.java23
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/ParseException.java14
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Trigger.java5
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/TriggerSequence.java18
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore2
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF19
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java81
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java26
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Card.java35
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Deck.java86
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/MobileApp.java18
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/TransitionType.java29
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/animations/TransitionDelegate.java116
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/.classpath1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/.settings/org.eclipse.jdt.core.prefs2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/AbstractLayoutPane.java107
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/FillLayoutPane.java16
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridData.java389
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridLayoutPane.java233
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowData.java118
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowLayoutPane.java1155
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/SashLayoutPane.java408
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.panes/src/panes.cssext39
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/TestFillLayout.java42
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/sample.css7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/sync/UISynchronize.java55
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.theme/META-INF/MANIFEST.MF5
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.theme/src/org/eclipse/fx/ui/theme/internal/DefaultThemeManager.java62
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.base/META-INF/MANIFEST.MF7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java89
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/restart/RestartPreferenceUtil.java3
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.fx/META-INF/MANIFEST.MF5
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java24
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java27
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/internal/UISynchronizeImpl.java49
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/key/KeyBindingDispatcher.java6
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/META-INF/MANIFEST.MF12
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseCompositePartRenderer.java187
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemContainerRenderer.java167
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemRenderer.java2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuItemRenderer.java20
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuRenderer.java111
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePartRenderer.java90
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePopupMenuRenderer.java190
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseRenderer.java35
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseStackRenderer.java4
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseToolBarRenderer.java83
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWindowRenderer.java83
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWorkbenchRendererFactory.java19
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/CleanUpAddon.java77
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/DnDAddon.java219
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WCompositePart.java89
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WDragTargetWidget.java14
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WLayoutedWidget.java2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPart.java6
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPopupMenu.java8
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/META-INF/MANIFEST.MF8
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefAreaRenderer.java8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefCompositePartRenderer.java352
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java23
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPopupMenuRenderer.java41
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefSashRenderer.java18
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefStackRenderer.java121
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWorkbenchRendererFactory.java8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/CustomContainerSupport.java4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DefaultDnDFeedback.java1
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDSupport.java85
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDTabPane.java429
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/widget/WLayoutedWidgetImpl.java137
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/.classpath7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/.gitignore1
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/.project33
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/.settings/org.eclipse.jdt.core.prefs398
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/META-INF/MANIFEST.MF21
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/OSGI-INF/lifecyclecomponent.xml (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml)8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/about.html28
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/build.properties (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties)2
-rwxr-xr-x[-rw-r--r--]bundles/runtime/org.eclipse.fx.ui.workbench.services/pom.xml (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml)4
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/ELifecycleService.java55
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/EModelStylingService.java51
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/LifecycleAddon.java (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java)41
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreClose.java (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java)8
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreShow.java (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java)7
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleContextFunction.java (renamed from bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java)6
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleServiceImpl.java94
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.converter/META-INF/MANIFEST.MF5
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/AbstractConverterHandler.java10
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/ConvertSVGHandler.java23
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext.ui/META-INF/MANIFEST.MF8
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssFile.java39
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.cssext/META-INF/MANIFEST.MF30
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.css.jfx8/.project6
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.jfx8/src/jfx8.cssext55
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css.ui/META-INF/MANIFEST.MF12
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css/META-INF/MANIFEST.MF26
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.css/plugin.xml4
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.fxgraph.ui/META-INF/MANIFEST.MF10
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.fxgraph/META-INF/MANIFEST.MF30
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.fxml/src/org/eclipse/fx/ide/fxml/editors/FXMLCompletionProposalComputer.java15
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.java6/.settings/org.eclipse.jdt.core.prefs6
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.java6/src/org/eclipse/fx/ide/java6/JavaVersionCheck.java5
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.jdt.core/META-INF/MANIFEST.MF2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.jdt.ui/META-INF/MANIFEST.MF12
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.jdt.ui/src/org/eclipse/fx/ide/jdt/ui/internal/handler/AddFXBeanGetterSetterHandler.java201
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.model/META-INF/MANIFEST.MF2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/e4App.rtask2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/mediaSample.rtask2
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.pde.ui/META-INF/MANIFEST.MF4
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/.settings/org.eclipse.jdt.core.prefs7
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/build.properties1
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.rrobot.dsl.ui/META-INF/MANIFEST.MF6
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.rrobot.dsl/META-INF/MANIFEST.MF16
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.rrobot.model/META-INF/MANIFEST.MF10
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.rrobot/META-INF/MANIFEST.MF2
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF10
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.ui.preview/src/org/eclipse/fx/ide/ui/preview/LivePreviewSynchronizer.java5
-rwxr-xr-xbundles/tooling/org.eclipse.fx.ide.ui/META-INF/MANIFEST.MF8
223 files changed, 11610 insertions, 5748 deletions
diff --git a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanProperty.java b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanProperty.java
index 3b615ad85..fc983f740 100755
--- a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanProperty.java
+++ b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanProperty.java
@@ -13,7 +13,6 @@ package org.eclipse.fx.core.databinding;
import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.property.IProperty;
-import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
/**
diff --git a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanValueProperty.java b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanValueProperty.java
index db31702ae..9f7448d08 100755
--- a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanValueProperty.java
+++ b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/IJFXBeanValueProperty.java
@@ -11,6 +11,7 @@
package org.eclipse.fx.core.databinding;
import org.eclipse.core.databinding.property.value.IValueProperty;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Single valued property
@@ -23,7 +24,7 @@ public interface IJFXBeanValueProperty extends IJFXBeanProperty, IValueProperty
* the name
* @return child property
*/
- public IJFXBeanValueProperty value(String propertyName);
+ public @NonNull IJFXBeanValueProperty value(@NonNull String propertyName);
/**
* Create a child property with a type
@@ -34,7 +35,7 @@ public interface IJFXBeanValueProperty extends IJFXBeanProperty, IValueProperty
* the type
* @return child property
*/
- public IJFXBeanValueProperty value(String propertyName, Class<?> valueType);
+ public @NonNull IJFXBeanValueProperty value(@NonNull String propertyName, Class<?> valueType);
/**
* Create a child property from a property
@@ -43,5 +44,5 @@ public interface IJFXBeanValueProperty extends IJFXBeanProperty, IValueProperty
* the property
* @return the child property
*/
- public IJFXBeanValueProperty value(IJFXBeanValueProperty property);
+ public @NonNull IJFXBeanValueProperty value(@NonNull IJFXBeanValueProperty property);
}
diff --git a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/JFXBeanProperties.java b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/JFXBeanProperties.java
index 8c75dd44b..bbe773c84 100755
--- a/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/JFXBeanProperties.java
+++ b/bundles/runtime/org.eclipse.fx.core.databinding/src/org/eclipse/fx/core/databinding/JFXBeanProperties.java
@@ -19,6 +19,8 @@ import org.eclipse.fx.core.databinding.internal.AnonymousFXBeanValueProperty;
import org.eclipse.fx.core.databinding.internal.FXBeanPropertyHelper;
import org.eclipse.fx.core.databinding.internal.FXBeanValueProperty;
import org.eclipse.fx.core.databinding.internal.FXBeanValuePropertyDecorator;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* Factory to create property descriptions
@@ -31,7 +33,7 @@ public class JFXBeanProperties {
* the name of the property (nested properties are separated with a .)
* @return the property
*/
- public static IJFXBeanValueProperty value(String propertyName) {
+ public static @NonNull IJFXBeanValueProperty value(@NonNull String propertyName) {
return value(null, propertyName, null);
}
@@ -44,7 +46,7 @@ public class JFXBeanProperties {
* the type
* @return the property
*/
- public static IJFXBeanValueProperty value(String propertyName, Class<?> valueType) {
+ public static @NonNull IJFXBeanValueProperty value(@NonNull String propertyName, Class<?> valueType) {
return value(null, propertyName, valueType);
}
@@ -59,9 +61,9 @@ public class JFXBeanProperties {
* the type
* @return the property
*/
- public static IJFXBeanValueProperty value(Class<?> beanClass, String propertyName, Class<?> _valueType) {
+ public static @NonNull IJFXBeanValueProperty value(@Nullable Class<?> beanClass, @NonNull String propertyName, @Nullable Class<?> _valueType) {
Class<?> valueType = _valueType;
- String[] propertyNames = split(propertyName);
+ @NonNull String[] propertyNames = split(propertyName);
if (propertyNames.length > 1) {
valueType = null;
}
@@ -76,6 +78,7 @@ public class JFXBeanProperties {
property = new FXBeanValueProperty(propertyDescriptor, valueType);
}
+ @NonNull
IJFXBeanValueProperty beanProperty = new FXBeanValuePropertyDecorator(property, propertyDescriptor);
for (int i = 1; i < propertyNames.length; i++) {
beanProperty = beanProperty.value(propertyNames[i]);
@@ -83,7 +86,8 @@ public class JFXBeanProperties {
return beanProperty;
}
- private static String[] split(String _propertyName) {
+ @SuppressWarnings("null")
+ private static @NonNull String[] split(@NonNull String _propertyName) {
String propertyName = _propertyName;
if (propertyName.indexOf('.') == -1)
return new String[] { propertyName };
diff --git a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/AdaptValueSupplier.java b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/AdaptValueSupplier.java
index 451db298c..cdad319d0 100644
--- a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/AdaptValueSupplier.java
+++ b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/AdaptValueSupplier.java
@@ -28,6 +28,7 @@ import org.eclipse.e4.core.internal.di.Requestor;
import org.eclipse.fx.core.adapter.Adapt;
import org.eclipse.fx.core.adapter.AdapterService;
import org.eclipse.fx.core.adapter.AdapterService.ValueAccess;
+import org.eclipse.jdt.annotation.Nullable;
/**
* Supplier working for {@link Adapt}
@@ -35,10 +36,14 @@ import org.eclipse.fx.core.adapter.AdapterService.ValueAccess;
@SuppressWarnings("restriction")
public class AdaptValueSupplier extends ExtendedObjectSupplier {
+ @SuppressWarnings("null")
@Override
public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
Requestor<?> r = (Requestor<?>) requestor;
Class<?> desiredClass = getDesiredClass(descriptor.getDesiredType());
+ if( desiredClass == null ) {
+ return IInjector.NOT_A_VALUE;
+ }
final String key;
if( descriptor.hasQualifier(Named.class) ) {
@@ -72,7 +77,7 @@ public class AdaptValueSupplier extends ExtendedObjectSupplier {
return IInjector.NOT_A_VALUE;
}
- private static Class<?> getDesiredClass(Type desiredType) {
+ private static @Nullable Class<?> getDesiredClass(Type desiredType) {
if (desiredType instanceof Class<?>)
return (Class<?>) desiredType;
if (desiredType instanceof ParameterizedType) {
@@ -108,6 +113,7 @@ public class AdaptValueSupplier extends ExtendedObjectSupplier {
return (O) this.context.get(key);
}
+ @SuppressWarnings("null")
@Override
public <O> O getValue(Class<O> key) {
return this.context.get(key);
diff --git a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java
index 9654e9350..c23ee19a5 100644
--- a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java
+++ b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ContextBoundValueSupplier.java
@@ -27,22 +27,26 @@ import org.eclipse.fx.core.di.ContextValue;
@SuppressWarnings("restriction")
public class ContextBoundValueSupplier extends ExtendedObjectSupplier {
+ @SuppressWarnings("null")
@Override
public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
ContextValue qualifier = descriptor.getQualifier(ContextValue.class);
- Requestor r = (Requestor) requestor;
+ if( qualifier == null ) {
+ return IInjector.NOT_A_VALUE;
+ }
+ Class<?> desiredClass = getDesiredClass(descriptor.getDesiredType());
+ if( desiredClass == null ) {
+ return IInjector.NOT_A_VALUE;
+ }
+
+ Requestor<?> r = (Requestor<?>) requestor;
EclipseContextBoundValue<?> c = r.getInjector().make(EclipseContextBoundValue.class, r.getPrimarySupplier());
c.setContextKey(qualifier.value());
- Class<?> desiredClass = getDesiredClass(descriptor.getDesiredType());
-
if( desiredClass == ContextBoundValue.class) {
return c;
} else {
- if( desiredClass != null ) {
- return c.adaptTo(desiredClass);
- }
- return IInjector.NOT_A_VALUE;
+ return c.adaptTo(desiredClass);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java
index 68370fe1b..228800c57 100644
--- a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java
+++ b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/EclipseContextBoundValue.java
@@ -27,6 +27,8 @@ import org.eclipse.fx.core.adapter.AdapterService;
import org.eclipse.fx.core.adapter.AdapterService.ValueAccess;
import org.eclipse.fx.core.di.ContextBoundValue;
import org.eclipse.fx.core.di.ScopedObjectFactory;
+import org.eclipse.fx.core.log.Log;
+import org.eclipse.fx.core.log.Logger;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -54,6 +56,10 @@ public class EclipseContextBoundValue<T> implements ContextBoundValue<T> {
@Optional
@Nullable
IEventBroker eventBroker;
+
+ @Inject
+ @Log
+ private Logger logger;
/**
* Create a new bound value
@@ -93,7 +99,11 @@ public class EclipseContextBoundValue<T> implements ContextBoundValue<T> {
this.value = o;
if (this.callbacks != null) {
for (Callback<?> c : this.callbacks.toArray(new Callback<?>[0])) {
- ((Callback<T>) c).call(o);
+ try {
+ ((Callback<T>) c).call(o);
+ } catch(Throwable t) {
+ this.logger.error("Failed while executing callback", t); //$NON-NLS-1$
+ }
}
}
}
@@ -155,8 +165,9 @@ public class EclipseContextBoundValue<T> implements ContextBoundValue<T> {
};
}
+ @SuppressWarnings("null")
@Override
- public <A> A adaptTo(Class<A> adapt) {
+ public <A> A adaptTo(@NonNull Class<A> adapt) {
return this.adapterService.adapt(this, adapt, new ValueAccessImpl(this.context));
}
@@ -170,7 +181,12 @@ public class EclipseContextBoundValue<T> implements ContextBoundValue<T> {
List<Callback<Void>> disposalCallbacks = this.disposalCallbacks;
if (disposalCallbacks != null) {
for (Callback<?> callback : disposalCallbacks.toArray(new Callback<?>[0])) {
- callback.call(null);
+ try {
+ callback.call(null);
+ } catch(Throwable t) {
+ this.logger.error("Failure while executing clean up callback", t); //$NON-NLS-1$
+ }
+
}
disposalCallbacks.clear();
}
@@ -193,8 +209,9 @@ public class EclipseContextBoundValue<T> implements ContextBoundValue<T> {
return (O) this.context.get(key);
}
+ @SuppressWarnings("null")
@Override
- public <O> O getValue(Class<O> key) {
+ public <O> O getValue(@NonNull Class<O> key) {
return this.context.get(key);
}
diff --git a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java
index 43bf873fa..d047d0745 100644
--- a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java
+++ b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/ObservableAdapterProvider.java
@@ -41,7 +41,7 @@ public class ObservableAdapterProvider implements AdapterProvider<ContextBoundVa
return true;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "null" })
@Override
public IObservableValue adapt(final ContextBoundValue sourceObject, Class<IObservableValue> targetType, ValueAccess... valueAccess) {
Realm r = null;
diff --git a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java
index eff4f2201..3b77a4636 100644
--- a/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java
+++ b/bundles/runtime/org.eclipse.fx.core.di.context/src/org/eclipse/fx/core/di/context/internal/PropertyAdapterProvider.java
@@ -57,6 +57,10 @@ public class PropertyAdapterProvider implements AdapterProvider<ContextBoundValu
@Override
public void call(Object value) {
+ if (rv.get() == null && value == null)
+ return;
+ if (rv.get() != null && rv.get().equals(value))
+ return;
rv.set(value);
}
});
diff --git a/bundles/runtime/org.eclipse.fx.core.log4j/.DS_Store b/bundles/runtime/org.eclipse.fx.core.log4j/.DS_Store
deleted file mode 100644
index 36f5dc2e2..000000000
--- a/bundles/runtime/org.eclipse.fx.core.log4j/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/bundles/runtime/org.eclipse.fx.core.log4j/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.core.log4j/META-INF/MANIFEST.MF
index 30e2b76fc..fdb4dadbe 100755
--- a/bundles/runtime/org.eclipse.fx.core.log4j/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.core.log4j/META-INF/MANIFEST.MF
@@ -5,9 +5,9 @@ Bundle-SymbolicName: org.eclipse.fx.core.log4j
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
-Require-Bundle: org.apache.log4j;bundle-version="1.2.15",
- org.eclipse.fx.core;bundle-version="0.9.0",
+Require-Bundle: org.eclipse.fx.core;bundle-version="0.9.0",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
Service-Component: OSGI-INF/log4jlogger.xml
-Import-Package: javax.inject;version="1.0.0"
+Import-Package: javax.inject;version="1.0.0",
+ org.apache.log4j
Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath b/bundles/runtime/org.eclipse.fx.core.slf4j/.classpath
index eca7bdba8..eca7bdba8 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.classpath
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/.classpath
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/.gitignore b/bundles/runtime/org.eclipse.fx.core.slf4j/.gitignore
new file mode 100644
index 000000000..ccbe796cc
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/.gitignore
@@ -0,0 +1,3 @@
+/bin
+/target
+/log4j.properties
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.project b/bundles/runtime/org.eclipse.fx.core.slf4j/.project
index 7b38d57b1..8b77a4018 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.project
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.eclipse.fx.ui.lifecycle</name>
+ <name>org.eclipse.fx.core.slf4j</name>
<comment></comment>
<projects>
</projects>
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.core.slf4j/.settings/org.eclipse.jdt.core.prefs
index 5671530f4..8d88004d6 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/.settings/org.eclipse.jdt.core.prefs
@@ -50,7 +50,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.core.slf4j/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..f504ad42e
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.fx.core.slf4j
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.fx.core;bundle-version="0.9.0",
+ org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
+Service-Component: OSGI-INF/slf4jlogger.xml
+Import-Package: javax.inject;version="1.0.0",
+ org.slf4j
+Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/l10n/bundle.properties b/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 000000000..d1c77dad2
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.fx.core.log4j
+Bundle-Vendor = Eclipse.org
+Bundle-Name = Log4j Implementation of Logger \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/slf4jlogger.xml b/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/slf4jlogger.xml
new file mode 100644
index 000000000..43699f208
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/OSGI-INF/slf4jlogger.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.core.log4j.slf4jlogger">
+ <implementation class="org.eclipse.fx.core.slf4j.Slf4JLoggerFactory"/>
+ <property name="service.ranking" type="Integer" value="1"/>
+ <service>
+ <provide interface="org.eclipse.fx.core.log.LoggerFactory"/>
+ </service>
+</scr:component>
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/about.html b/bundles/runtime/org.eclipse.fx.core.slf4j/about.html
index c258ef55d..c258ef55d 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/about.html
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/about.html
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/build.properties b/bundles/runtime/org.eclipse.fx.core.slf4j/build.properties
new file mode 100644
index 000000000..5138cc8a8
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ about.html
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/pom.xml b/bundles/runtime/org.eclipse.fx.core.slf4j/pom.xml
new file mode 100755
index 000000000..54d7e84ac
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <name>e(fx)clipse - Runtime - slf4j</name>
+ <groupId>org.eclipse.fx.runtime</groupId>
+ <artifactId>org.eclipse.fx.core.slf4j</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <parent>
+ <groupId>org.eclipse.fx</groupId>
+ <artifactId>releng</artifactId>
+ <relativePath>../../../releng/org.eclipse.fx.releng/pom.xml</relativePath>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <resources>
+ <!-- to ensure that the feature lookup of the ui test works -->
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>META-INF/</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.core.slf4j/src/org/eclipse/fx/core/slf4j/Slf4JLoggerFactory.java b/bundles/runtime/org.eclipse.fx.core.slf4j/src/org/eclipse/fx/core/slf4j/Slf4JLoggerFactory.java
new file mode 100644
index 000000000..83fa3d5d9
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.core.slf4j/src/org/eclipse/fx/core/slf4j/Slf4JLoggerFactory.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2014 EM-SOFTWARE GmbH 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:
+ * Christoph Keimel<c.keimel@emsw.de> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.core.slf4j;
+
+import java.text.MessageFormat;
+
+import javax.inject.Provider;
+
+import org.eclipse.fx.core.log.Logger;
+import org.eclipse.fx.core.log.LoggerFactory;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Factory to create a logger backed by slf4j
+ */
+public class Slf4JLoggerFactory implements LoggerFactory, Provider<LoggerFactory> {
+
+ @Override
+ public LoggerFactory get() {
+ return this;
+ }
+
+ @Override @NonNull
+ public Logger createLogger(@NonNull String name) {
+ return new LoggerImpl(name);
+ }
+
+ static class LoggerImpl implements Logger {
+ private org.slf4j.Logger logger;
+
+ private String name;
+
+ public LoggerImpl(@NonNull String name) {
+ this.name = name;
+ }
+
+ private org.slf4j.Logger getLogger() {
+ if( this.logger == null ) {
+ this.logger = org.slf4j.LoggerFactory.getLogger(this.name);
+ }
+ return this.logger;
+ }
+
+ @Override
+ public void log(@NonNull Level level, @NonNull String message) {
+ switch (level) {
+ case TRACE:
+ getLogger().trace(message);
+ break;
+ case DEBUG:
+ getLogger().debug(message);
+ break;
+ case INFO:
+ getLogger().info(message);
+ break;
+ case WARNING:
+ getLogger().warn(message);
+ break;
+ case ERROR:
+ case FATAL:
+ getLogger().error(message);
+ break;
+ }
+ }
+
+ @Override
+ public void log(@NonNull Level level, @NonNull String message, @NonNull Throwable t) {
+ switch (level) {
+ case TRACE:
+ getLogger().trace(message, t);
+ break;
+ case DEBUG:
+ getLogger().debug(message, t);
+ break;
+ case INFO:
+ getLogger().info(message, t);
+ break;
+ case WARNING:
+ getLogger().warn(message, t);
+ break;
+ case ERROR:
+ case FATAL:
+ getLogger().error(message, t);
+ break;
+ }
+ }
+
+ @SuppressWarnings("null")
+ @Override
+ public void logf(@NonNull Level level, @NonNull String pattern, Object... args) {
+ if(isEnabled(level)) {
+ log(level, MessageFormat.format(pattern, args));
+ }
+ }
+
+ @SuppressWarnings("null")
+ @Override
+ public void logf(@NonNull Level level, @NonNull String pattern, @NonNull Throwable t, Object... args) {
+ if(isEnabled(level)) {
+ log(level, MessageFormat.format(pattern, args), t);
+ }
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void trace(@NonNull String message) {
+ log(Level.TRACE, message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void debug(@NonNull String message) {
+ log(Level.DEBUG, message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void info(@NonNull String message) {
+ log(Level.INFO,message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void warning(@NonNull String message) {
+ log(Level.WARNING,message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void error(@NonNull String message) {
+ log(Level.ERROR,message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void fatal(@NonNull String message) {
+ log(Level.FATAL,message);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void trace(@NonNull String message, @NonNull Throwable t) {
+ log(Level.TRACE,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void debug(@NonNull String message, @NonNull Throwable t) {
+ log(Level.DEBUG,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void info(@NonNull String message, @NonNull Throwable t) {
+ log(Level.INFO,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void warning(@NonNull String message, @NonNull Throwable t) {
+ log(Level.WARNING,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void error(@NonNull String message, @NonNull Throwable t) {
+ log(Level.ERROR,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void fatal(@NonNull String message, @NonNull Throwable t) {
+ log(Level.FATAL,message,t);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void tracef(String pattern, Object... args) {
+ logf(Level.TRACE, pattern, args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void debugf(@NonNull String pattern, Object... args) {
+ logf(Level.DEBUG,pattern,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void infof(@NonNull String pattern, Object... args) {
+ logf(Level.INFO,pattern,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void warningf(@NonNull String pattern, Object... args) {
+ logf(Level.WARNING,pattern,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void errorf(@NonNull String pattern, Object... args) {
+ logf(Level.ERROR,pattern,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void fatalf(@NonNull String pattern, Object... args) {
+ logf(Level.FATAL,pattern,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void tracef(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.TRACE,pattern,t,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void debugf(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.DEBUG,pattern,t,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void infof(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.INFO,pattern,t,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void warningf(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.WARNING,pattern,t,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void errorf(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.ERROR,pattern,t,args);
+ }
+
+ @SuppressWarnings("all")
+ @Override
+ public void fatalf(@NonNull String pattern, @NonNull Throwable t, Object... args) {
+ logf(Level.FATAL,pattern,t,args);
+ }
+
+ @Override
+ public boolean isEnabled(Level level) {
+ switch (level) {
+ case TRACE:
+ return getLogger().isTraceEnabled();
+ case DEBUG:
+ return getLogger().isDebugEnabled();
+ case INFO:
+ return getLogger().isInfoEnabled();
+ case WARNING:
+ return getLogger().isWarnEnabled();
+ case ERROR:
+ case FATAL:
+ return getLogger().isErrorEnabled();
+ }
+ return true;
+ }
+
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableList.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableList.java
index def302c37..4b9991ed4 100644
--- a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableList.java
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableList.java
@@ -65,13 +65,10 @@ public class AdapterFactoryObservableList<T> implements ObservableList<T> {
* @param root
* the root
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked" })
public AdapterFactoryObservableList(@NonNull AdapterFactory adapterFactory, @NonNull final Object root) {
super();
- if (adapterFactory == null)
- throw new IllegalArgumentException("AdapterFactory must not be null."); //$NON-NLS-1$
-
this.adapterFactory = adapterFactory;
this.root = root;
Object contentProvider = adapterFactory.adapt(root, IStructuredItemContentProvider.class);
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactory.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactory.java
index 721867909..693398ead 100644
--- a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactory.java
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactory.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.jdt.annotation.NonNull;
/**
* This list cell factory wraps an {@link AdapterFactory} and delegates calls to its {@link TableCell}s to the
@@ -56,7 +57,7 @@ public class AdapterFactoryTableCellFactory<S, T> extends AdapterFactoryCellFact
* @param columnIndex
* the column index
*/
- public AdapterFactoryTableCellFactory(AdapterFactory adapterFactory, int columnIndex) {
+ public AdapterFactoryTableCellFactory(@NonNull AdapterFactory adapterFactory, int columnIndex) {
super(adapterFactory);
this.columnIndex = columnIndex;
}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactory.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactory.java
index d209eac23..8f47ad83b 100644
--- a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactory.java
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactory.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemFontProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.jdt.annotation.NonNull;
/**
* This {@link TreeCell} factory wraps an {@link AdapterFactory} and delegates calls to its {@link TreeCell}s
@@ -44,7 +45,7 @@ public class AdapterFactoryTreeCellFactory extends AdapterFactoryCellFactory imp
* @param adapterFactory
* the adapter factory
*/
- public AdapterFactoryTreeCellFactory(AdapterFactory adapterFactory) {
+ public AdapterFactoryTreeCellFactory(@NonNull AdapterFactory adapterFactory) {
super(adapterFactory);
}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeTableCellFactory.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeTableCellFactory.java
index aff6be2da..522ebab6b 100644
--- a/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeTableCellFactory.java
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeTableCellFactory.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.jdt.annotation.NonNull;
/**
* This list cell factory wraps an {@link AdapterFactory} and delegates calls to its {@link TableCell}s to the
@@ -56,7 +57,7 @@ public class AdapterFactoryTreeTableCellFactory<S, T> extends AdapterFactoryCell
* @param columnIndex
* the column index
*/
- public AdapterFactoryTreeTableCellFactory(AdapterFactory adapterFactory, int columnIndex) {
+ public AdapterFactoryTreeTableCellFactory(@NonNull AdapterFactory adapterFactory, int columnIndex) {
super(adapterFactory);
this.columnIndex = columnIndex;
}
diff --git a/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/AbstractJFXApplication.java b/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/AbstractJFXApplication.java
index a33720236..306c33f3c 100755
--- a/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/AbstractJFXApplication.java
+++ b/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/AbstractJFXApplication.java
@@ -20,6 +20,7 @@ import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.fx.core.databinding.JFXRealm;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -32,7 +33,8 @@ import org.osgi.service.event.EventAdmin;
*/
public abstract class AbstractJFXApplication implements IApplication {
static AbstractJFXApplication SELF;
-
+
+ @Nullable
IApplicationContext applicationContext;
Object returnValue;
EventAdmin eventAdmin;
@@ -44,6 +46,7 @@ public abstract class AbstractJFXApplication implements IApplication {
private AbstractJFXApplication osgiApp = SELF;
private IApplicationContext applicationContext;
+ @SuppressWarnings("null")
@Override
public void start(final Stage primaryStage) throws Exception {
this.applicationContext = this.osgiApp.applicationContext;
@@ -71,7 +74,7 @@ public abstract class AbstractJFXApplication implements IApplication {
public final Object start(IApplicationContext context) throws Exception {
SELF = this;
this.applicationContext = context;
- this.applicationContext.applicationRunning();
+ context.applicationRunning();
Bundle b = FrameworkUtil.getBundle(AbstractJFXApplication.class);
BundleContext bundleContext = b.getBundleContext();
diff --git a/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/OSGiFXMLLoader.java b/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/OSGiFXMLLoader.java
index fdd3441b8..a4d63c68b 100755
--- a/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/OSGiFXMLLoader.java
+++ b/bundles/runtime/org.eclipse.fx.osgi.util/src/org/eclipse/fx/osgi/util/OSGiFXMLLoader.java
@@ -30,6 +30,16 @@ import org.osgi.framework.wiring.BundleWiring;
* Helper class which is able to load FXML-Files in OSGi is an easy way
*/
public class OSGiFXMLLoader {
+ @SuppressWarnings("null")
+ private static @NonNull ClassLoader getClassLoader(Class<?> clazz) {
+ return clazz.getClassLoader();
+ }
+
+ @SuppressWarnings("null")
+ private static @NonNull ClassLoader getClassLoader(Bundle bundle) {
+ return bundle.adapt(BundleWiring.class).getClassLoader();
+ }
+
/**
* Load a FXML file relative to the requested
*
@@ -46,8 +56,10 @@ public class OSGiFXMLLoader {
*/
public static <O> O load(@NonNull Class<?> requester, @NonNull String relativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory) throws IOException {
URL url = requester.getResource(relativeFxmlPath);
- ClassLoader loader = requester.getClassLoader();
- return load(loader, url, resourceBundle, builderFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+relativeFxmlPath+"' relative to '"+requester+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return load(getClassLoader(requester), url, resourceBundle, builderFactory);
}
/**
@@ -66,8 +78,10 @@ public class OSGiFXMLLoader {
*/
public static <O,C> FXMLData<O,C> loadWithController(@NonNull Class<?> requester, @NonNull String relativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory) throws IOException {
URL url = requester.getResource(relativeFxmlPath);
- ClassLoader loader = requester.getClassLoader();
- return loadWithController(loader, url, resourceBundle, builderFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+relativeFxmlPath+"' relative to '"+requester+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return loadWithController(getClassLoader(requester), url, resourceBundle, builderFactory);
}
/**
@@ -86,8 +100,10 @@ public class OSGiFXMLLoader {
*/
public static <O> O load(@NonNull Bundle bundle, @NonNull String bundleRelativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory) throws IOException {
URL url = bundle.getResource(bundleRelativeFxmlPath);
- ClassLoader loader = bundle.adapt(BundleWiring.class).getClassLoader();
- return load(loader, url, resourceBundle, builderFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+bundleRelativeFxmlPath+"' relative to '"+bundle+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return load(getClassLoader(bundle), url, resourceBundle, builderFactory);
}
/**
@@ -106,8 +122,10 @@ public class OSGiFXMLLoader {
*/
public static <O,C> FXMLData<O,C> loadWithController(@NonNull Bundle bundle, @NonNull String bundleRelativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory) throws IOException {
URL url = bundle.getResource(bundleRelativeFxmlPath);
- ClassLoader loader = bundle.adapt(BundleWiring.class).getClassLoader();
- return loadWithController(loader, url, resourceBundle, builderFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+bundleRelativeFxmlPath+"' relative to '"+bundle+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return loadWithController(getClassLoader(bundle), url, resourceBundle, builderFactory);
}
/**
@@ -165,8 +183,10 @@ public class OSGiFXMLLoader {
public static <O> O load(@NonNull Class<?> requester, @NonNull String relativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory,
@Nullable Callback<Class<?>, Object> controllerFactory) throws IOException {
URL url = requester.getResource(relativeFxmlPath);
- ClassLoader loader = requester.getClassLoader();
- return load(loader, url, resourceBundle, builderFactory, controllerFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+relativeFxmlPath+"' relative to '"+requester+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return load(getClassLoader(requester), url, resourceBundle, builderFactory, controllerFactory);
}
/**
@@ -188,8 +208,10 @@ public class OSGiFXMLLoader {
public static <O,C> FXMLData<O,C> loadWithController(@NonNull Class<?> requester, @NonNull String relativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory,
@Nullable Callback<Class<?>, Object> controllerFactory) throws IOException {
URL url = requester.getResource(relativeFxmlPath);
- ClassLoader loader = requester.getClassLoader();
- return loadWithController(loader, url, resourceBundle, builderFactory, controllerFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+relativeFxmlPath+"' relative to '"+requester+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return loadWithController(getClassLoader(requester), url, resourceBundle, builderFactory, controllerFactory);
}
/**
@@ -211,8 +233,10 @@ public class OSGiFXMLLoader {
public static <O> O load(@NonNull Bundle bundle, @NonNull String bundleRelativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory,
@Nullable Callback<Class<?>, Object> controllerFactory) throws IOException {
URL url = bundle.getResource(bundleRelativeFxmlPath);
- ClassLoader loader = bundle.adapt(BundleWiring.class).getClassLoader();
- return load(loader, url, resourceBundle, builderFactory, controllerFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+bundleRelativeFxmlPath+"' relative to '"+bundle+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return load(getClassLoader(bundle), url, resourceBundle, builderFactory, controllerFactory);
}
/**
@@ -234,8 +258,10 @@ public class OSGiFXMLLoader {
public static <O,C> FXMLData<O,C> loadWithController(@NonNull Bundle bundle, @NonNull String bundleRelativeFxmlPath, @Nullable ResourceBundle resourceBundle, @Nullable BuilderFactory builderFactory,
@Nullable Callback<Class<?>, Object> controllerFactory) throws IOException {
URL url = bundle.getResource(bundleRelativeFxmlPath);
- ClassLoader loader = bundle.adapt(BundleWiring.class).getClassLoader();
- return loadWithController(loader, url, resourceBundle, builderFactory, controllerFactory);
+ if( url == null ) {
+ throw new IOException("Unable to load '"+bundleRelativeFxmlPath+"' relative to '"+bundle+"'"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return loadWithController(getClassLoader(bundle), url, resourceBundle, builderFactory, controllerFactory);
}
/**
@@ -305,8 +331,10 @@ public class OSGiFXMLLoader {
try (InputStream in = url.openStream()) {
O value = loader.load(in);
- in.close();
- return new FXMLData<O, C>(value, (C) loader.getController());
+ if( value != null ) {
+ return new FXMLData<O, C>(value, (C) loader.getController());
+ }
+ throw new IOException("Unable to construct UI from FXML '"+url+"'"); //$NON-NLS-1$//$NON-NLS-2$
}
}
@@ -329,7 +357,7 @@ public class OSGiFXMLLoader {
@Nullable
public final C controller;
- FXMLData(N node, C controller) {
+ FXMLData(@NonNull N node, @Nullable C controller) {
this.node = node;
this.controller = controller;
}
diff --git a/bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java b/bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java
index 0659880d5..1394ac9a5 100644
--- a/bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java
+++ b/bundles/runtime/org.eclipse.fx.osgi/src/org/eclipse/fx/osgi/fxloader/FXClassLoader.java
@@ -50,24 +50,31 @@ public class FXClassLoader extends ClassLoaderHook {
}
private static ClassLoader getSWTClassloader(Generation generation) {
- for( Bundle b : generation.getRevision().getBundle().getBundleContext().getBundles() ) {
- if( SWT_SYMBOLIC_NAME.equals(b.getSymbolicName()) ) {
- if ((b.getState() & Bundle.INSTALLED) == 0) {
- // Ensure the bundle is started else we are unable to
- // extract the
- // classloader
- if ((b.getState() & Bundle.ACTIVE) != 0) {
- try {
- b.start();
- } catch (BundleException e) {
- e.printStackTrace();
+ try {
+ // Should we better use findProviders() see PackageAdminImpl?
+ for( Bundle b : generation.getBundleInfo().getStorage().getModuleContainer().getFrameworkWiring().getBundle().getBundleContext().getBundles() ) {
+ if( SWT_SYMBOLIC_NAME.equals(b.getSymbolicName()) ) {
+ if ((b.getState() & Bundle.INSTALLED) == 0) {
+ // Ensure the bundle is started else we are unable to
+ // extract the
+ // classloader
+ if ((b.getState() & Bundle.ACTIVE) != 0) {
+ try {
+ b.start();
+ } catch (BundleException e) {
+ e.printStackTrace();
+ }
}
+ return b.adapt(BundleWiring.class).getClassLoader();
}
- return b.adapt(BundleWiring.class).getClassLoader();
+
}
-
}
+ } catch(Throwable t) {
+ System.err.println("Failed to access swt classloader"); //$NON-NLS-1$
+ t.printStackTrace();
}
+
return null;
}
@@ -356,22 +363,42 @@ public class FXClassLoader extends ClassLoaderHook {
static class SWTFXClassloader extends ClassLoader {
private final ClassLoader lastResortLoader;
private final ClassLoader primaryLoader;
- private boolean implicitExitSet;
public SWTFXClassloader(ClassLoader lastResortLoader,
ClassLoader primaryLoader) {
this.lastResortLoader = lastResortLoader;
this.primaryLoader = primaryLoader;
+ if (FXClassloaderConfigurator.DEBUG) {
+ System.err.println("FXClassLoader.SWTFXClassloader#init - Primary Loader " + primaryLoader); //$NON-NLS-1$
+ System.err.println("FXClassLoader.SWTFXClassloader#init - Lastresort Loader " + lastResortLoader); //$NON-NLS-1$
+ }
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
try {
- return this.primaryLoader.loadClass(name);
+ if (FXClassloaderConfigurator.DEBUG) {
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - Loading " + name + " with primary"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ Class<?> loadClass = this.primaryLoader.loadClass(name);
+ if (FXClassloaderConfigurator.DEBUG) {
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - Result " + name + " " + loadClass); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return loadClass;
} catch (ClassNotFoundException c) {
- try {
- return this.lastResortLoader.loadClass(name);
+ if (FXClassloaderConfigurator.DEBUG) {
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown"); //$NON-NLS-1$
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - Loading " + name + " with last resort"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ try {
+ Class<?> loadClass = this.lastResortLoader.loadClass(name);
+ if (FXClassloaderConfigurator.DEBUG) {
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - Result " + name + " " + loadClass); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return loadClass;
} catch (ClassNotFoundException tmp) {
+ System.err.println("FXClassLoader.SWTFXClassloader#findClass - Even last resort was unable to load " + name); //$NON-NLS-1$
throw c;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FadeAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FadeAnimation.java
index 3dcf1b59f..56e0e3e88 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FadeAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FadeAnimation.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
import javafx.animation.Animation;
@@ -26,13 +25,13 @@ public class FadeAnimation extends CenterSwitchAnimation {
@Override
protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
- FadeTransition t = new FadeTransition(Duration.millis(1000),curNode);
+ FadeTransition t = new FadeTransition(Duration.millis(1000), curNode);
t.setInterpolator(Interpolator.EASE_BOTH);
t.setFromValue(1.0);
t.setToValue(0.0);
return t;
}
-
+
@Override
protected void resetProperties(Node curNode, Node newNode) {
curNode.setOpacity(1);
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FlipAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FlipAnimation.java
index 22f7d00b3..8c187bf56 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FlipAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/FlipAnimation.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.RotateTransition;
@@ -38,78 +37,78 @@ public class FlipAnimation extends CenterSwitchAnimation {
public void animate(final BorderPane pane, final Node newNode, Runnable postAnimation) {
pane.setDepthTest(DepthTest.DISABLE);
final Node curNode = pane.getCenter();
-
+
pane.setCenter(null);
-
+
final Group area = new Group();
area.setDepthTest(DepthTest.ENABLE);
-
+
Bounds b = curNode.getBoundsInParent();
newNode.resizeRelocate(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight());
area.getChildren().add(newNode);
area.getChildren().add(curNode);
-
+
newNode.setTranslateZ(0.1);
curNode.setTranslateZ(-0.1);
newNode.setRotationAxis(Rotate.Y_AXIS);
newNode.setRotate(180);
-
+
pane.setCenter(area);
-
+
if (this.imageView != null) {
- pane.getChildren().add(0,this.imageView);
+ pane.getChildren().add(0, this.imageView);
}
-
+
Animation animation = createAndPrepareAnimation(area, null);
-
+
animation.onFinishedProperty().set(new EventHandler<ActionEvent>() {
-
+
@Override
public void handle(ActionEvent event) {
pane.getChildren().remove(curNode);
pane.getChildren().remove(newNode);
pane.setCenter(newNode);
resetProperties(curNode, newNode);
-
+
if (FlipAnimation.this.imageView != null) {
pane.getChildren().remove(FlipAnimation.this.imageView);
}
- if( postAnimation != null ) {
- postAnimation.run();
+ if (postAnimation != null) {
+ postAnimation.run();
}
}
});
-
+
animation.play();
}
-
+
@Override
protected Animation createAndPrepareAnimation(Node area, @Nullable Node newNode) {
ScaleTransition zoomOut = new ScaleTransition(Duration.millis(300));
zoomOut.setToX(0.7);
zoomOut.setToY(0.7);
zoomOut.setInterpolator(Interpolator.EASE_BOTH);
-
+
ScaleTransition zoomIn = new ScaleTransition(Duration.millis(300));
zoomIn.setToX(1);
zoomIn.setToY(1);
zoomIn.setInterpolator(Interpolator.EASE_BOTH);
-
+
RotateTransition rt = new RotateTransition(Duration.millis(8000));
rt.setAxis(Rotate.Y_AXIS);
rt.setByAngle(180);
rt.setInterpolator(Interpolator.EASE_BOTH);
-
+
return new SequentialTransition(area, zoomOut, rt, zoomIn);
-
+
}
@Override
protected void resetProperties(Node curNode, Node newNode) {
newNode.setTranslateZ(0);
curNode.setTranslateZ(0);
- newNode.setRotate(0);
- curNode.setRotate(0);
+ newNode.setRotate(0);
+ curNode.setRotate(0);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/PageChangeAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/PageChangeAnimation.java
index 937e6d0d8..5a1451b6c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/PageChangeAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/PageChangeAnimation.java
@@ -10,17 +10,17 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
import javafx.animation.Animation;
-import javafx.animation.FadeTransitionBuilder;
+import javafx.animation.FadeTransition;
import javafx.animation.Interpolator;
-import javafx.animation.ParallelTransitionBuilder;
-import javafx.animation.PathTransitionBuilder;
-import javafx.animation.ScaleTransitionBuilder;
-import javafx.animation.SequentialTransitionBuilder;
+import javafx.animation.ParallelTransition;
+import javafx.animation.PathTransition;
+import javafx.animation.ScaleTransition;
+import javafx.animation.SequentialTransition;
import javafx.geometry.Bounds;
import javafx.scene.Node;
import javafx.scene.shape.CubicCurve;
+import javafx.scene.shape.Shape;
import javafx.util.Duration;
import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
@@ -28,102 +28,94 @@ import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
/**
* A page change animation
*/
-@SuppressWarnings("deprecation")
public class PageChangeAnimation extends CenterSwitchAnimation {
@Override
protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
Bounds b = curNode.getBoundsInLocal();
- double cX = b.getMinX() + b.getWidth()/2;
- double cY = b.getMinY() + b.getHeight()/2;
-
+ double cX = b.getMinX() + b.getWidth() / 2;
+ double cY = b.getMinY() + b.getHeight() / 2;
+
double val = 200;
-
+
CubicCurve cIn = new CubicCurve(cX - val, cY, cX - val, cY - val, cX, cY - val, cX, cY);
CubicCurve cOut = new CubicCurve(cX, cY, cX, cY + val, cX + val, cY + val, cX + val, cY + 0);
- PathTransitionBuilder moveOut = PathTransitionBuilder.create()
- .duration(new Duration(1000))
- .node(curNode)
- .path(cOut)
- ;
-
- PathTransitionBuilder moveIn = PathTransitionBuilder.create()
- .duration(new Duration(1000))
- .node(newNode)
- .path(cIn)
- ;
-
-
- ScaleTransitionBuilder zoomOut = ScaleTransitionBuilder.create()
- .duration(new Duration(1000))
- .toX(0.2)
- .toY(0.2)
- .interpolator(Interpolator.EASE_BOTH);
- ScaleTransitionBuilder zoomIn = ScaleTransitionBuilder.create()
- .duration(new Duration(1000))
- .fromX(0.2)
- .fromY(0.2)
- .toX(0.7)
- .toY(0.7)
- .interpolator(Interpolator.EASE_BOTH);
-
- Animation main = ParallelTransitionBuilder.create()
- .children(
- zoomOut.node(curNode).build(),
- zoomIn.node(newNode).build(),
- moveIn.build(),
- moveOut.build()
- ,
- FadeTransitionBuilder.create()
- .node(curNode)
- .duration(new Duration(1000))
- .fromValue(1)
- .toValue(0)
- .build(),
- moveOut.build(),
- FadeTransitionBuilder.create()
- .node(newNode)
- .duration(new Duration(1000))
- .fromValue(0)
- .toValue(1)
- .build()
- )
- .build();
-
- ScaleTransitionBuilder zoomOut1 = ScaleTransitionBuilder.create()
- .duration(new Duration(300))
- .toX(0.7)
- .toY(0.7)
- .interpolator(Interpolator.EASE_BOTH);
- ScaleTransitionBuilder zoomIn1 = ScaleTransitionBuilder.create()
- .duration(new Duration(300))
- .toX(1)
- .toY(1)
- .interpolator(Interpolator.EASE_BOTH);
-
- return SequentialTransitionBuilder.create()
- .children(
- ParallelTransitionBuilder.create().children(
- zoomOut1.node(curNode).build(),
- zoomOut1.node(newNode).build()
- ).build(),
- main,
- ParallelTransitionBuilder.create().children(
- zoomIn1.node(curNode).build(),
- zoomIn1.node(newNode).build()
- ).build()
- )
- .build();
+ Animation main = new ParallelTransition(
+ // zoom
+ zoomOut(curNode), zoomIn(newNode),
+ // move
+ move(newNode, cIn), move(curNode, cOut),
+ // fade
+ fadeOut(curNode), fadeIn(newNode));
+ return new SequentialTransition(
+ // zoom out
+ new ParallelTransition(zoomOut1(curNode), zoomOut1(newNode)),
+ // main
+ main,
+ // zoom in
+ new ParallelTransition(zoomIn1(curNode), zoomIn1(newNode)));
+ }
+
+ private static final PathTransition move(Node n, Shape path) {
+ return new PathTransition(Duration.millis(1000), path, n);
+ }
+
+ private static final ScaleTransition zoomIn(Node n) {
+ ScaleTransition t = new ScaleTransition(Duration.millis(1000), n);
+ t.setInterpolator(Interpolator.EASE_BOTH);
+ t.setFromX(0.2);
+ t.setFromY(0.2);
+ t.setToX(0.7);
+ t.setToY(0.7);
+ return t;
+ }
+
+ private static final ScaleTransition zoomOut(Node n) {
+ ScaleTransition t = new ScaleTransition(Duration.millis(1000), n);
+ t.setInterpolator(Interpolator.EASE_BOTH);
+ t.setToX(0.2);
+ t.setToY(0.2);
+ return t;
+ }
+
+ private static final FadeTransition fadeOut(Node n) {
+ FadeTransition t = new FadeTransition(Duration.millis(1000), n);
+ t.setFromValue(1);
+ t.setToValue(0);
+ return t;
+ }
+
+ private static final FadeTransition fadeIn(Node n) {
+ FadeTransition t = new FadeTransition(Duration.millis(1000), n);
+ t.setFromValue(0);
+ t.setToValue(1);
+ return t;
+ }
+
+ private static final ScaleTransition zoomOut1(Node n) {
+ ScaleTransition s = new ScaleTransition(Duration.millis(300), n);
+ s.setToX(0.7);
+ s.setToY(0.7);
+ s.setInterpolator(Interpolator.EASE_BOTH);
+ return s;
+ }
+
+ private static final ScaleTransition zoomIn1(Node n) {
+ ScaleTransition s = new ScaleTransition(Duration.millis(300), n);
+ s.setToX(1);
+ s.setToY(1);
+ s.setInterpolator(Interpolator.EASE_BOTH);
+ return s;
}
@Override
protected void resetProperties(Node curNode, Node newNode) {
newNode.setTranslateZ(0);
curNode.setTranslateZ(0);
- newNode.setRotate(0);
- curNode.setRotate(0);
-
+ newNode.setRotate(0);
+ curNode.setRotate(0);
+
curNode.setScaleX(1);
curNode.setScaleY(1);
curNode.setOpacity(1);
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/RotateOutAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/RotateOutAnimation.java
index bea9ec97c..ab9b7fb8a 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/RotateOutAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/RotateOutAnimation.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
import javafx.animation.Animation;
import javafx.animation.ParallelTransition;
import javafx.animation.RotateTransition;
@@ -29,14 +28,14 @@ public class RotateOutAnimation extends CenterSwitchAnimation {
protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
RotateTransition rt = new RotateTransition(Duration.millis(600), curNode);
rt.setByAngle(360);
-
+
ScaleTransition sc = new ScaleTransition(Duration.millis(600), curNode);
sc.setToX(0);
sc.setToY(0);
-
+
return new ParallelTransition(rt, sc);
}
-
+
@Override
protected void resetProperties(Node curNode, Node newNode) {
curNode.setRotate(0);
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/SlideAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/SlideAnimation.java
index 0b65c7cb8..0774fd10a 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/SlideAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/SlideAnimation.java
@@ -10,36 +10,35 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
-import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
-
import javafx.animation.Animation;
import javafx.animation.Interpolator;
-import javafx.animation.ParallelTransitionBuilder;
-import javafx.animation.TranslateTransitionBuilder;
+import javafx.animation.ParallelTransition;
+import javafx.animation.TranslateTransition;
import javafx.scene.Node;
import javafx.util.Duration;
+import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
+
/**
* Slide transition
*/
-@SuppressWarnings("deprecation")
public class SlideAnimation extends CenterSwitchAnimation {
@Override
protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
newNode.setOpacity(1);
-
+
double deltaX = -curNode.getBoundsInLocal().getWidth();
newNode.setTranslateX(-deltaX);
-
-
- TranslateTransitionBuilder builder = TranslateTransitionBuilder.create()
- .interpolator(Interpolator.EASE_BOTH)
- .byX(deltaX)
- .duration(new Duration(1000));
-
- return ParallelTransitionBuilder.create().children(builder.node(curNode).build(), builder.node(newNode).build()).build();
+
+ return new ParallelTransition(createTransition(curNode, deltaX), createTransition(newNode, deltaX));
+ }
+
+ private static TranslateTransition createTransition(Node n, double deltaX) {
+ TranslateTransition t = new TranslateTransition(Duration.millis(1000), n);
+ t.setInterpolator(Interpolator.EASE_BOTH);
+ t.setByX(deltaX);
+ return t;
}
@Override
diff --git a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/ZoomSlideAnimation.java b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/ZoomSlideAnimation.java
index a15e10f6a..ee254906a 100755
--- a/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/ZoomSlideAnimation.java
+++ b/bundles/runtime/org.eclipse.fx.ui.animation/src/org/eclipse/fx/ui/animation/pagetransition/animation/ZoomSlideAnimation.java
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.fx.ui.animation.pagetransition.animation;
-
import javafx.animation.Animation;
import javafx.animation.Interpolator;
-import javafx.animation.ParallelTransitionBuilder;
-import javafx.animation.ScaleTransitionBuilder;
-import javafx.animation.SequentialTransitionBuilder;
-import javafx.animation.TranslateTransitionBuilder;
+import javafx.animation.ParallelTransition;
+import javafx.animation.ScaleTransition;
+import javafx.animation.SequentialTransition;
+import javafx.animation.TranslateTransition;
import javafx.scene.Node;
import javafx.util.Duration;
@@ -25,48 +24,43 @@ import org.eclipse.fx.ui.animation.pagetransition.CenterSwitchAnimation;
/**
* Zoom and slide animations
*/
-@SuppressWarnings("deprecation")
public class ZoomSlideAnimation extends CenterSwitchAnimation {
@Override
protected Animation createAndPrepareAnimation(Node curNode, Node newNode) {
double deltaX = -curNode.getBoundsInLocal().getWidth();
newNode.setTranslateX(-deltaX);
-
-
- TranslateTransitionBuilder slide = TranslateTransitionBuilder.create()
- .interpolator(Interpolator.EASE_BOTH)
- .byX(deltaX)
- .duration(new Duration(300));
-
- ScaleTransitionBuilder zoomOut = ScaleTransitionBuilder.create()
- .duration(new Duration(300))
- .toX(0.7)
- .toY(0.7)
- .interpolator(Interpolator.EASE_BOTH);
- ScaleTransitionBuilder zoomIn = ScaleTransitionBuilder.create()
- .duration(new Duration(300))
- .toX(1)
- .toY(1)
- .interpolator(Interpolator.EASE_BOTH);
-
- return SequentialTransitionBuilder.create()
- .children(
- ParallelTransitionBuilder.create().children(
- zoomOut.node(curNode).build(),
- zoomOut.node(newNode).build()
- ).build(),
- ParallelTransitionBuilder.create().children(
- slide.node(curNode).build(),
- slide.node(newNode).build()
- ).build(),
- ParallelTransitionBuilder.create().children(
- zoomIn.node(curNode).build(),
- zoomIn.node(newNode).build()
- ).build()
- )
- .build();
-
+
+ return new SequentialTransition(
+ // zoom out
+ new ParallelTransition(zoomOut(curNode), zoomOut(newNode)),
+ // slide
+ new ParallelTransition(slide(curNode, deltaX), slide(newNode, deltaX)),
+ // zoom in
+ new ParallelTransition(zoomIn(curNode), zoomIn(newNode)));
+ }
+
+ private static TranslateTransition slide(Node n, double deltaX) {
+ TranslateTransition t = new TranslateTransition(Duration.millis(300), n);
+ t.setInterpolator(Interpolator.EASE_BOTH);
+ t.setByX(deltaX);
+ return t;
+ }
+
+ private static ScaleTransition zoomIn(Node n) {
+ ScaleTransition zoomIn = new ScaleTransition(Duration.millis(300), n);
+ zoomIn.setToX(1);
+ zoomIn.setToY(1);
+ zoomIn.setInterpolator(Interpolator.EASE_BOTH);
+ return zoomIn;
+ }
+
+ private static ScaleTransition zoomOut(Node n) {
+ ScaleTransition zoomIn = new ScaleTransition(Duration.millis(300), n);
+ zoomIn.setToX(0.7);
+ zoomIn.setToY(0.7);
+ zoomIn.setInterpolator(Interpolator.EASE_BOTH);
+ return zoomIn;
}
@Override
@@ -77,7 +71,7 @@ public class ZoomSlideAnimation extends CenterSwitchAnimation {
curNode.setTranslateX(0);
curNode.setScaleX(1);
curNode.setScaleY(1);
-
+
curNode.setEffect(null);
newNode.setEffect(null);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/.classpath b/bundles/runtime/org.eclipse.fx.ui.controls/.classpath
index db83a474a..b862a296d 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/.classpath
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/.classpath
@@ -1,8 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="src-sample"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.resources.prefs b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.resources.prefs
new file mode 100755
index 000000000..4824b8026
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.runtime.prefs b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.runtime.prefs
new file mode 100755
index 000000000..deae05a97
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.jdt.core.prefs
index 0c68a61dc..8d88004d6 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,114 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
index 1b047f198..a81efbd41 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/META-INF/MANIFEST.MF
@@ -4,9 +4,13 @@ Bundle-Name: Controls
Bundle-SymbolicName: org.eclipse.fx.ui.controls
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
-Export-Package: org.eclipse.fx.ui.controls.markers,
- org.eclipse.fx.ui.controls.styledtext
+Require-Bundle: org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
+ org.eclipse.fx.ide.css.jfx8;bundle-version="1.0.0";resolution:=optional
+Export-Package: org.eclipse.fx.ui.controls.image,
+ org.eclipse.fx.ui.controls.image.spi,
+ org.eclipse.fx.ui.controls.markers,
+ org.eclipse.fx.ui.controls.styledtext,
+ org.eclipse.fx.ui.controls.tabpane
Import-Package: com.sun.javafx;version="2.2.0",
com.sun.javafx.accessible;version="2.2.0",
com.sun.javafx.accessible.providers;version="2.2.0",
@@ -118,4 +122,6 @@ Import-Package: com.sun.javafx;version="2.2.0",
javafx.scene.web;version="2.2.0",
javafx.stage;version="2.2.0",
javafx.util;version="2.2.0",
- javafx.util.converter;version="2.2.0"
+ javafx.util.converter;version="2.2.0",
+ org.osgi.framework;version="1.8.0";resolution:=optional
+Bundle-ActivationPolicy: lazy
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/InsertMarkerSample.java b/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/InsertMarkerSample.java
deleted file mode 100644
index 195a6604f..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/InsertMarkerSample.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.fx.ui.controls;
-
-import javafx.application.Application;
-import javafx.scene.Scene;
-import javafx.scene.layout.BorderPane;
-import javafx.stage.Stage;
-
-import org.eclipse.fx.ui.controls.markers.PositionMarker;
-
-public class InsertMarkerSample extends Application {
-
- @Override
- public void start(Stage primaryStage) throws Exception {
- BorderPane p = new BorderPane(new PositionMarker());
- primaryStage.setScene(new Scene(p,300,300));
- primaryStage.show();
- }
-
- public static void main(String[] args) {
- launch(args);
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/SimpleStyledText.java b/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/SimpleStyledText.java
deleted file mode 100644
index c21b73d4c..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/SimpleStyledText.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.eclipse.fx.ui.controls;
-
-public class SimpleStyledText {
-
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/TabOutLineMarkerSample.java b/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/TabOutLineMarkerSample.java
deleted file mode 100644
index 55e86747f..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src-sample/org/eclipse/fx/ui/controls/TabOutLineMarkerSample.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.eclipse.fx.ui.controls;
-
-import org.eclipse.fx.ui.controls.markers.TabOutlineMarker;
-
-import javafx.application.Application;
-import javafx.geometry.BoundingBox;
-import javafx.scene.Scene;
-import javafx.scene.control.Tab;
-import javafx.scene.control.TabPane;
-import javafx.scene.layout.AnchorPane;
-import javafx.stage.Stage;
-
-public class TabOutLineMarkerSample extends Application {
- @Override
- public void start(Stage primaryStage) throws Exception {
- AnchorPane p = new AnchorPane();
-
- TabPane t = new TabPane();
- t.getTabs().addAll(new Tab("Tab 1"),new Tab("Tab 2"));
- p.getChildren().add(t);
- t.getSelectionModel().select(1);
- AnchorPane.setLeftAnchor(t, 0.0);
- AnchorPane.setTopAnchor(t, 0.0);
- AnchorPane.setRightAnchor(t, 0.0);
- AnchorPane.setBottomAnchor(t, 0.0);
-
- primaryStage.setScene(new Scene(p, 400, 400));
- primaryStage.show();
-
- TabOutlineMarker marker = new TabOutlineMarker(t.getBoundsInLocal(), new BoundingBox(54, 5, 68, 28), true);
- marker.setManaged(false);
- p.getChildren().add(marker);
-
- }
-
- public static void main(String[] args) {
- launch(args);
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/controls.cssext b/bundles/runtime/org.eclipse.fx.ui.controls/src/controls.cssext
index ada031a09..f40c79f42 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/controls.cssext
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/controls.cssext
@@ -1,10 +1,10 @@
import javafx.scene.Group
package org.eclipse.fx.ui.controls {
- PositionMarker extends Group {
+ PositionMarker extends Group styleclass position-marker {
-fx-fill <javafx.paint> default: "rgb(0, 139, 255)";
}
- TabOutlineMarker extends Group {
+ TabOutlineMarker extends Group styleclass tab-outline-marker {
-fx-fill <javafx.paint> default: "orange";
}
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIcon.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIcon.java
new file mode 100644
index 000000000..12d47772b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIcon.java
@@ -0,0 +1,36 @@
+package org.eclipse.fx.ui.controls.image;
+
+public interface FontIcon {
+
+ char getIconCode();
+ String getIconName();
+
+
+ public static FontIcon create(final char iconCode) {
+ return new FontIcon() {
+ @Override
+ public char getIconCode() {
+ return iconCode;
+ }
+
+ @Override
+ public String getIconName() {
+ return null;
+ }
+ };
+ }
+
+ public static FontIcon create(final String iconName) {
+ return new FontIcon() {
+ @Override
+ public char getIconCode() {
+ return '0';
+ }
+
+ @Override
+ public String getIconName() {
+ return iconName;
+ }
+ };
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconStyleConverter.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconStyleConverter.java
new file mode 100644
index 000000000..4316dfe0b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconStyleConverter.java
@@ -0,0 +1,45 @@
+package org.eclipse.fx.ui.controls.image;
+
+import java.security.Provider;
+import java.security.Provider.Service;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.eclipse.fx.ui.controls.image.spi.IconFontProvider;
+
+import com.sun.javafx.Utils;
+import com.sun.javafx.css.StyleConverterImpl;
+
+import javafx.css.ParsedValue;
+import javafx.css.StyleConverter;
+import javafx.scene.text.Font;
+
+public class FontIconStyleConverter extends StyleConverter<String, FontIcon> {
+
+ @Override
+ public FontIcon convert(ParsedValue<String, FontIcon> value, Font font) {
+ System.err.println("convert " + value + ", " + font);
+ String v = value.getValue();
+ System.err.println(v);
+ // this converts a java unicode (\\u....)
+ // however css standard uses the syntax (\....) without u
+ v = Utils.convertUnicode(v);
+ System.err.println(v);
+
+
+ if (v.length() == 1) {
+ char c = v.charAt(0);
+ System.err.println("creating char");
+ return FontIcon.create(c);
+ }
+ else {
+ System.err.println("creating name");
+ return FontIcon.create(v);
+// IconFontProvider sup = getSupportForFont(font);
+// return FontIcon.create(sup.map(v));
+ }
+// return super.convert(value, font);
+ }
+
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconView.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconView.java
new file mode 100644
index 000000000..e4707dad9
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/FontIconView.java
@@ -0,0 +1,339 @@
+package org.eclipse.fx.ui.controls.image;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+
+
+
+
+
+
+import com.sun.javafx.css.converters.InsetsConverter;
+import com.sun.javafx.css.converters.PaintConverter;
+
+import javafx.beans.property.ObjectProperty;
+import javafx.beans.property.ReadOnlyObjectProperty;
+import javafx.css.CssMetaData;
+import javafx.css.FontCssMetaData;
+import javafx.css.SimpleStyleableObjectProperty;
+import javafx.css.StyleOrigin;
+import javafx.css.Styleable;
+import javafx.css.StyleableObjectProperty;
+import javafx.css.StyleableProperty;
+import javafx.geometry.Insets;
+import javafx.scene.control.Control;
+import javafx.scene.control.Labeled;
+import javafx.scene.control.Skin;
+import javafx.scene.paint.Color;
+import javafx.scene.paint.Paint;
+import javafx.scene.text.Font;
+
+public class FontIconView extends Control {
+
+ public FontIconView() {
+ getStyleClass().setAll("fonticonview");
+
+ setMouseTransparent(true);
+ }
+
+ @Override
+ protected String getUserAgentStylesheet() {
+ String uri = FontIconView.class.getResource("fonticonview.css").toExternalForm();
+ return uri;
+ }
+
+ /**
+ * Most Controls return true for focusTraversable, so Control overrides
+ * this method to return true, but Label returns false for
+ * focusTraversable's initial value; hence the override of the override.
+ * This method is called from CSS code to get the correct initial value.
+ * @treatAsPrivate implementation detail
+ */
+ @Deprecated @Override
+ protected /*do not make final*/ Boolean impl_cssGetFocusTraversableInitialValue() {
+ return Boolean.FALSE;
+ }
+
+ private ObjectProperty<FontIcon> icon;
+ public ObjectProperty<FontIcon> iconProperty() {
+ if (icon == null) {
+ icon = new SimpleStyleableObjectProperty<FontIcon>(StyleableProperties.ICON, FontIcon.create('?'));
+ }
+ return icon;
+ }
+
+ public void setIcon(FontIcon icon) {
+ this.iconProperty().set(icon);
+ }
+
+ public FontIcon getIcon() {
+ return icon == null ? null : icon.get();
+ }
+
+ /**
+ * The default font to use for text in the Labeled. If the Label's text is
+ * rich text then this font may or may not be used depending on the font
+ * information embedded in the rich text, but in any case where a default
+ * font is required, this font will be used.
+ */
+ public final ObjectProperty<Font> fontProperty() {
+
+ if (font == null) {
+ font = new StyleableObjectProperty<Font>(Font.getDefault()) {
+
+ private boolean fontSetByCss = false;
+
+ @Override
+ public void applyStyle(StyleOrigin newOrigin, Font value) {
+ System.err.println("applyStyle " + font + " " + value);
+ System.err.println(" origin " + newOrigin);
+ //
+ // RT-20727 - if CSS is setting the font, then make sure invalidate doesn't call impl_reapplyCSS
+ //
+ try {
+ // super.applyStyle calls set which might throw if value is bound.
+ // Have to make sure fontSetByCss is reset.
+ fontSetByCss = true;
+ super.applyStyle(newOrigin, value);
+ } catch(Exception e) {
+ throw e;
+ } finally {
+ fontSetByCss = false;
+ }
+ }
+
+ @Override
+ public void set(Font value) {
+ final Font oldValue = get();
+ if (value != null ? !value.equals(oldValue) : oldValue != null) {
+ super.set(value);
+ }
+
+ }
+
+ @Override
+ protected void invalidated() {
+ // RT-20727 - if font is changed by calling setFont, then
+ // css might need to be reapplied since font size affects
+ // calculated values for styles with relative values
+ if(fontSetByCss == false) {
+ FontIconView.this.impl_reapplyCSS();
+ }
+ }
+
+ @Override
+ public CssMetaData<FontIconView,Font> getCssMetaData() {
+ return StyleableProperties.FONT;
+ }
+
+ @Override
+ public Object getBean() {
+ return FontIconView.this;
+ }
+
+ @Override
+ public String getName() {
+ return "font";
+ }
+ };
+ }
+ return font;
+ }
+ private ObjectProperty<Font> font;
+ public final void setFont(Font value) { fontProperty().setValue(value); }
+ public final Font getFont() { return font == null ? Font.getDefault() : font.getValue(); }
+
+ /**
+ * The padding around the Labeled's text and graphic content.
+ * By default labelPadding is Insets.EMPTY and cannot be set to null.
+ * Subclasses may add nodes outside this padding and inside the Labeled's padding.
+ *
+ * This property can only be set from CSS.
+ */
+ public final ReadOnlyObjectProperty<Insets> iconPaddingProperty() {
+ return iconPaddingPropertyImpl();
+ }
+ private ObjectProperty<Insets> iconPaddingPropertyImpl() {
+ if (iconPadding == null) {
+ System.err.println("INIT iconPadding");
+ iconPadding = new StyleableObjectProperty<Insets>(Insets.EMPTY) {
+ private Insets lastValidValue = Insets.EMPTY;
+
+// @Override
+// public void set(Insets v) {
+// // TODO Auto-generated method stub
+// super.set(v);
+// }
+//
+// @Override
+// public void setValue(Insets v) {o
+// // TODO Auto-generated method stub
+// super.setValue(v);
+// }
+
+
+ @Override
+ public void invalidated() {
+
+ final Insets newValue = get();
+ if (newValue == null) {
+ set(lastValidValue);
+ throw new NullPointerException("cannot set iconPadding to null");
+ }
+ lastValidValue = newValue;
+ requestLayout();
+ }
+
+ @Override
+ public CssMetaData<FontIconView,Insets> getCssMetaData() {
+ return StyleableProperties.ICON_PADDING;
+ }
+
+ @Override
+ public Object getBean() {
+ return FontIconView.this;
+ }
+
+ @Override
+ public String getName() {
+ return "iconPadding";
+ }
+ };
+ }
+ return iconPadding;
+ }
+ private ObjectProperty<Insets> iconPadding;
+ private void setIconPadding(Insets value) { iconPaddingPropertyImpl().set(value); }
+ public final Insets getIconPadding() { return iconPadding == null ? Insets.EMPTY : iconPadding.get(); }
+
+ /**
+ * The {@link Paint} used to fill the text.
+ */
+ private ObjectProperty<Paint> iconFill; // TODO for now change this
+
+ public final void setIconFill(Paint value) {
+ iconFillProperty().set(value);
+ }
+
+ public final Paint getIconFill() {
+ return iconFill == null ? Color.BLACK : iconFill.get();
+ }
+
+ public final ObjectProperty<Paint> iconFillProperty() {
+ if (iconFill == null) {
+ iconFill = new StyleableObjectProperty<Paint>(Color.BLACK) {
+
+ @Override
+ public CssMetaData<FontIconView,Paint> getCssMetaData() {
+ return StyleableProperties.ICON_FILL;
+ }
+
+ @Override
+ public Object getBean() {
+ return FontIconView.this;
+ }
+
+ @Override
+ public String getName() {
+ return "iconFill";
+ }
+ };
+ }
+ return iconFill;
+ }
+
+ private static class StyleableProperties {
+ private static final FontCssMetaData<FontIconView> FONT =
+ new FontCssMetaData<FontIconView>("-fx-font", Font.getDefault()) {
+
+ @Override
+ public boolean isSettable(FontIconView n) {
+ return n.font == null || !n.font.isBound();
+ }
+
+ @Override
+ public StyleableProperty<Font> getStyleableProperty(FontIconView n) {
+ return (StyleableProperty)n.fontProperty();
+ }
+
+ };
+
+ private static final CssMetaData<FontIconView, FontIcon> ICON =
+ new CssMetaData<FontIconView, FontIcon>("-fx-icon", new FontIconStyleConverter()) {
+ @Override
+ public boolean isSettable(FontIconView styleable) {
+ return true;
+ }
+
+ @Override
+ public StyleableProperty<FontIcon> getStyleableProperty(FontIconView styleable) {
+ return (StyleableProperty)styleable.iconProperty();
+ }
+ };
+ private static final CssMetaData<FontIconView,Insets> ICON_PADDING =
+ new CssMetaData<FontIconView, Insets>("-fx-icon-padding", InsetsConverter.getInstance(), Insets.EMPTY) {
+
+ @Override
+ public boolean isSettable(FontIconView n) {
+ return n.iconPadding == null || !n.iconPadding.isBound();
+ }
+
+ @Override
+ public StyleableProperty<Insets> getStyleableProperty(FontIconView n) {
+ return (StyleableProperty)n.iconPaddingPropertyImpl();
+ }
+ };
+
+ private static final CssMetaData<FontIconView,Paint> ICON_FILL =
+ new CssMetaData<FontIconView,Paint>("-fx-icon-fill",
+ PaintConverter.getInstance(), Color.BLACK) {
+
+ @Override
+ public boolean isSettable(FontIconView n) {
+ return n.iconFill == null || !n.iconFill.isBound();
+ }
+
+ @Override
+ public StyleableProperty<Paint> getStyleableProperty(FontIconView n) {
+ return (StyleableProperty)n.iconFillProperty();
+ }
+ };
+
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+ static {
+ final List<CssMetaData<? extends Styleable, ?>> styleables =
+ new ArrayList<CssMetaData<? extends Styleable, ?>>(Control.getClassCssMetaData());
+ Collections.addAll(styleables,
+ FONT,
+ ICON,
+ ICON_FILL,
+ ICON_PADDING
+ );
+ STYLEABLES = Collections.unmodifiableList(styleables);
+ }
+
+ }
+
+ /**
+ * @return The CssMetaData associated with this class, which may include the
+ * CssMetaData of its super classes.
+ * @since JavaFX 8.0
+ */
+ public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
+ return StyleableProperties.STYLEABLES;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since JavaFX 8.0
+ */
+ @Override
+ public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() {
+ return getClassCssMetaData();
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/behavior/FontIconViewBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/behavior/FontIconViewBehavior.java
new file mode 100644
index 000000000..640cf7dc1
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/behavior/FontIconViewBehavior.java
@@ -0,0 +1,16 @@
+package org.eclipse.fx.ui.controls.image.behavior;
+
+import java.util.List;
+
+import org.eclipse.fx.ui.controls.image.FontIconView;
+
+import com.sun.javafx.scene.control.behavior.BehaviorBase;
+import com.sun.javafx.scene.control.behavior.KeyBinding;
+
+public class FontIconViewBehavior extends BehaviorBase<FontIconView> {
+
+ public FontIconViewBehavior(FontIconView control, List<KeyBinding> keyBindings) {
+ super(control, keyBindings);
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.css b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.css
new file mode 100644
index 000000000..6970bfb40
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.css
@@ -0,0 +1,3 @@
+.fonticonview {
+ -fx-skin: "org.eclipse.fx.ui.controls.image.skin.FontIconViewSkin";
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.cssext b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.cssext
new file mode 100644
index 000000000..625534390
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/fonticonview.cssext
@@ -0,0 +1,23 @@
+import javafx.font
+import javafx.paint
+import javafx.scene.control.Control
+
+package org.eclipse.fx.ui.controls.image {
+
+
+ /**
+ * The FontIconView allows the use of Icon Fonts
+ */
+ FontIconView extends Control {
+
+ -fx-font <font>;
+ /**
+ *
+ */
+ -fx-icon @STRING default: null;
+
+ -fx-icon-fill <paint> default: black;
+ }
+
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/skin/FontIconViewSkin.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/skin/FontIconViewSkin.java
new file mode 100644
index 000000000..f21b6737c
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/skin/FontIconViewSkin.java
@@ -0,0 +1,125 @@
+package org.eclipse.fx.ui.controls.image.skin;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.geometry.Insets;
+import javafx.geometry.Point2D;
+import javafx.scene.control.SkinBase;
+import javafx.scene.text.Font;
+import javafx.scene.text.Text;
+
+import org.eclipse.fx.ui.controls.image.FontIcon;
+import org.eclipse.fx.ui.controls.image.FontIconView;
+import org.eclipse.fx.ui.controls.image.spi.IconFontLookup;
+import org.eclipse.fx.ui.controls.image.spi.IconFontProvider;
+
+import com.sun.javafx.tk.FontMetrics;
+import com.sun.javafx.tk.Toolkit;
+
+public class FontIconViewSkin extends SkinBase<FontIconView> {
+
+ private Text text;
+
+ public FontIconViewSkin(FontIconView control) {
+ super(control);
+
+// System.err.println(System.identityHashCode(getSkinnable()) + " Skinnable BEGIN: " + getSkinnable().getIcon().getIconName() + " / " + getSkinnable().getFont());
+
+ text = new Text();
+ text.setMouseTransparent(true);
+
+ getChildren().add(text);
+
+ text.fontProperty().bind(getSkinnable().fontProperty());
+
+ text.fillProperty().bind(getSkinnable().iconFillProperty());
+
+ getSkinnable().fontProperty().addListener(new ChangeListener<Font>() {
+ @Override
+ public void changed(ObservableValue<? extends Font> observable,
+ Font oldValue, Font newValue) {
+ updateIcon(getSkinnable().getIcon(), newValue);
+ }
+ });
+ getSkinnable().iconProperty().addListener(
+ new ChangeListener<FontIcon>() {
+
+ @Override
+ public void changed(
+ ObservableValue<? extends FontIcon> observable,
+ FontIcon oldValue, FontIcon newValue) {
+ updateIcon(newValue, getSkinnable().getFont());
+ }
+ });
+
+// System.err.println(System.identityHashCode(getSkinnable()) + " Skinnable END: " + getSkinnable().getIcon().getIconName() + " / " + getSkinnable().getFont());
+
+ // TODO do we need this = ?
+ text.setText(convert(getSkinnable().getIcon(), getSkinnable().getFont()));
+ }
+
+ private void updateIcon(FontIcon icon, Font font) {
+// System.err.println("UPDATE ICON " + icon.getIconName() + " / " + font);
+ computeIconSize(icon, font);
+ text.setText(convert(icon, font));
+ }
+
+ private String convert(FontIcon icon, Font font) {
+ if (icon != null) {
+ if (icon.getIconCode() != '0') {
+ return Character.toString(icon.getIconCode());
+ } else {
+ IconFontProvider sup = getSupportForFont(font);
+// System.err.println("support = " + sup);
+ if (sup != null) {
+ char v = sup.map(icon.getIconName());
+ return Character.toString(v);
+ }
+ }
+ }
+ return "?";
+ }
+
+ private IconFontProvider getSupportForFont(Font font) {
+
+ return IconFontLookup.getProviderForFont(font);
+// System.err.println("using service loader");
+// ServiceLoader<IconFontProvider> load = ServiceLoader
+// .<IconFontProvider> load(IconFontProvider.class);
+// System.err.println(" => " + load);
+// load.forEach((r)->System.err.println(" * > " + r));
+//
+//
+// Iterator<IconFontProvider> it = load.iterator();
+// while (it.hasNext()) {
+// IconFontProvider sup = it.next();
+// if (sup.getName().equals(font.getName())) {
+// return sup;
+// }
+// }
+// return null;
+ }
+
+ private Point2D computeIconSize(FontIcon icon, Font font) {
+ String iconString = convert(icon, font);
+
+ FontMetrics metrics = Toolkit.getToolkit().getFontLoader().getFontMetrics(font);
+
+ float width = metrics.computeStringWidth(iconString);
+ float height = metrics.getLineHeight();
+// System.err.println("icon size is : " + width + " x " + height);
+ return new Point2D(width, height);
+ }
+
+// @Override
+// protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
+// final Insets iconPadding = getSkinnable().getIconPadding();
+// super.layoutChildren(contentX + iconPadding.getLeft(),
+// contentY + iconPadding.getTop(),
+// contentWidth - (iconPadding.getLeft() + iconPadding.getRight()),
+// contentHeight - (iconPadding.getTop() + iconPadding.getBottom()));
+// }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontLookup.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontLookup.java
new file mode 100644
index 000000000..132f06625
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontLookup.java
@@ -0,0 +1,97 @@
+package org.eclipse.fx.ui.controls.image.spi;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import javafx.scene.text.Font;
+
+public class IconFontLookup {
+
+ public static IconFontProvider getProviderForFont(Font font) {
+ IconFontProvider result = null;
+ try {
+ Class<?> util = Class.forName("org.osgi.framework.FrameworkUtil");
+ if (util != null) {
+ final Method method = util.getMethod("getBundle", Class.class);
+ Bundle bundle = (Bundle) method.invoke(null, IconFontLookup.class);
+ if (bundle != null) {
+ result = getProviderForFontOSGi(bundle, font);
+ return result;
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ }
+
+ if (result == null) {
+ result = getProviderForFontSPI(font);
+ }
+
+ return result;
+ }
+
+
+ private static IconFontProvider getProviderForFontOSGi(Bundle bundle, Font font) {
+// System.err.println("getProviderForFontOSGi " + font);
+ IconFontProvider result = null;
+ try {
+ final BundleContext bundleContext = bundle.getBundleContext();
+ final Collection<ServiceReference<IconFontProvider>> serviceReferences = bundleContext.getServiceReferences(IconFontProvider.class, null);
+ for (ServiceReference<IconFontProvider> ref : serviceReferences) {
+ final IconFontProvider service = bundleContext.getService(ref);
+ if (service.getName().equals(font.getName())) {
+ result = service;
+ break;
+ }
+ }
+// System.err.println("getProviderForFontOSGi => " + result);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+
+ }
+
+ private static IconFontProvider getProviderForFontSPI(Font font) {
+// System.err.println("getProviderForFontSPI " + font);
+ IconFontProvider result = null;
+
+ ServiceLoader<IconFontProvider> load = ServiceLoader
+ .<IconFontProvider> load(IconFontProvider.class);
+// System.err.println(" => " + load);
+// load.forEach((r)->System.err.println(" * > " + r));
+
+
+ Iterator<IconFontProvider> it = load.iterator();
+ while (it.hasNext()) {
+ IconFontProvider sup = it.next();
+ if (sup.getName().equals(font.getName())) {
+ result = sup;
+ break;
+ }
+ }
+
+// System.err.println("getProviderForFontSPI => " + result);
+ return result;
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontProvider.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontProvider.java
new file mode 100644
index 000000000..700ddb701
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/image/spi/IconFontProvider.java
@@ -0,0 +1,6 @@
+package org.eclipse.fx.ui.controls.image.spi;
+
+public abstract class IconFontProvider {
+ public abstract String getName();
+ public abstract char map(String id);
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/AreaOverlay.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/AreaOverlay.java
new file mode 100644
index 000000000..cd082d179
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/AreaOverlay.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.controls.markers;
+
+import javafx.geometry.Insets;
+import javafx.scene.control.Label;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.Region;
+
+/**
+ * Overlay to represent different area
+ */
+public final class AreaOverlay extends Region {
+ private final BorderPane left;
+ private final BorderPane right;
+ private final BorderPane top;
+ private final BorderPane bottom;
+
+ private final double leftRightRatio;
+
+ /**
+ * Create an area overlay
+ *
+ * @param leftRightRatio
+ * the ration used by the left and right areas
+ */
+ public AreaOverlay(double leftRightRatio) {
+ getStyleClass().add("area-overlay"); //$NON-NLS-1$
+
+ this.leftRightRatio = leftRightRatio;
+ this.left = new BorderPane(new Label("Left")); //$NON-NLS-1$
+ this.left.getStyleClass().addAll("left", "area"); //$NON-NLS-1$//$NON-NLS-2$
+
+ this.right = new BorderPane(new Label("Right")); //$NON-NLS-1$
+ this.right.getStyleClass().addAll("right", "area"); //$NON-NLS-1$//$NON-NLS-2$
+
+ this.top = new BorderPane(new Label("Top")); //$NON-NLS-1$
+ this.top.getStyleClass().addAll("top", "area"); //$NON-NLS-1$//$NON-NLS-2$
+
+ this.bottom = new BorderPane(new Label("Bottom")); //$NON-NLS-1$
+ this.bottom.getStyleClass().addAll("bottom", "area"); //$NON-NLS-1$//$NON-NLS-2$
+
+ getChildren().addAll(this.left, this.right, this.top, this.bottom);
+ }
+
+ @Override
+ protected void layoutChildren() {
+ super.layoutChildren();
+
+ Insets pad = getPadding();
+ double width = getWidth() * this.leftRightRatio;
+ double height = getHeight() - (pad.getTop() + pad.getBottom());
+
+ this.left.resizeRelocate(pad.getLeft(), pad.getTop(), width, height);
+ this.right.resizeRelocate(getWidth() - pad.getRight() - width, pad.getTop(), width, height);
+
+ this.top.resizeRelocate(this.left.getLayoutX() + this.left.getWidth(), this.left.getLayoutY(), getWidth() - width * 2, height / 2);
+ this.bottom.resizeRelocate(this.left.getLayoutX() + this.left.getWidth(), this.top.getLayoutY() + this.top.getHeight(), getWidth() - width * 2, height / 2);
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/PositionMarker.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/PositionMarker.java
index 4838dc4b7..ef426757f 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/PositionMarker.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/PositionMarker.java
@@ -10,17 +10,19 @@
*******************************************************************************/
package org.eclipse.fx.ui.controls.markers;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+
import javafx.beans.property.ObjectProperty;
import javafx.css.CssMetaData;
+import javafx.css.SimpleStyleableObjectProperty;
import javafx.css.Styleable;
-import javafx.css.StyleableObjectProperty;
import javafx.css.StyleableProperty;
import javafx.scene.Group;
+import javafx.scene.control.TabPane;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
@@ -30,15 +32,22 @@ import javafx.scene.shape.StrokeLineCap;
import com.sun.javafx.css.converters.PaintConverter;
-public class PositionMarker extends Group {
+/**
+ * Marker which can be used to show an insert position {@link TabPane}
+ */
+@SuppressWarnings("restriction")
+public final class PositionMarker extends Group {
+ /**
+ * Create a new marker
+ */
public PositionMarker() {
setMouseTransparent(true);
- getStyleClass().add("position-marker");
+ getStyleClass().add("position-marker"); //$NON-NLS-1$
Circle outer = new Circle(8);
outer.setFill(Color.WHITE);
-
+
getChildren().add(outer);
-
+
{
Line l = new Line();
l.setStartX(0);
@@ -50,15 +59,15 @@ public class PositionMarker extends Group {
l.setStroke(Color.WHITE);
getChildren().add(l);
}
-
+
Circle c = new Circle(6);
c.fillProperty().bind(fillProperty());
getChildren().add(c);
-
+
Circle inner = new Circle(3);
inner.setFill(Color.WHITE);
getChildren().add(inner);
-
+
{
Line l = new Line();
l.setStartX(0);
@@ -67,81 +76,108 @@ public class PositionMarker extends Group {
l.setEndY(40);
l.setStrokeWidth(3);
l.setStrokeLineCap(StrokeLineCap.ROUND);
- l.strokeProperty().bind(fill);
- getChildren().add(l);
+ l.strokeProperty().bind(this.fill);
+ getChildren().add(l);
}
-
+
setEffect(new DropShadow(3, Color.BLACK));
}
-
- private ObjectProperty<Paint> fill;
-
- public ObjectProperty<Paint> fillProperty() {
- if( fill == null ) {
- fill = new StyleableObjectProperty<Paint>(Color.rgb(0, 139, 255)) {
-
- @Override
- public CssMetaData<? extends Styleable, Paint> getCssMetaData() {
- return FILL;
- }
-
- @Override
- public Object getBean() {
- return PositionMarker.this;
- }
-
- @Override
- public String getName() {
- return "fill";
- }
-
- };
- }
- return fill;
+
+ @SuppressWarnings("null")
+ @NonNull
+ private final ObjectProperty<@NonNull Paint> fill = new SimpleStyleableObjectProperty<>(FILL, this, "fill", Color.rgb(0, 139, 255)); //$NON-NLS-1$
+
+ /**
+ * The property
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is Color.rgb(0, 139, 255)</td>
+ * <td><div style=
+ * "background-color: rgb(0, 139, 255); border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @return the fill property of the marker
+ */
+ public @NonNull ObjectProperty<@NonNull Paint> fillProperty() {
+ return this.fill;
}
-
- public void setFill(Paint fill) {
+
+ /**
+ * Set the fill of the marker
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is Color.rgb(0, 139, 255)</td>
+ * <td><div style=
+ * "background-color: rgb(0, 139, 255); border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @param fill
+ * the new fill
+ */
+ public void setFill(@NonNull Paint fill) {
fillProperty().set(fill);
}
-
- public Paint getFill() {
+
+ /**
+ * Access the current fill
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is Color.rgb(0, 139, 255)</td>
+ * <td><div style=
+ * "background-color: rgb(0, 139, 255); border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @return the current fill
+ */
+ public @NonNull Paint getFill() {
return fillProperty().get();
}
-
- private static final CssMetaData<PositionMarker,Paint> FILL =
- new CssMetaData<PositionMarker,Paint>("-fx-fill",
- PaintConverter.getInstance(), Color.rgb(0, 139, 255)) {
-
- @Override
- public boolean isSettable(PositionMarker node) {
- return node.fill == null || !node.fill.isBound();
- }
-
- @Override
- public StyleableProperty<Paint> getStyleableProperty(PositionMarker node) {
- return (StyleableProperty<Paint>)node.fillProperty();
- }
-
-
- };
-
- private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
-
- static {
-
- final List<CssMetaData<? extends Styleable, ?>> styleables =
- new ArrayList<CssMetaData<? extends Styleable, ?>>(Group.getClassCssMetaData());
- styleables.add(FILL);
- STYLEABLES = Collections.unmodifiableList(styleables);
- }
-
- public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
- return STYLEABLES;
- }
-
- @Override
- public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
- return getClassCssMetaData();
- }
-
+
+ @SuppressWarnings("null")
+ private static final CssMetaData<PositionMarker, @NonNull Paint> FILL = new CssMetaData<PositionMarker, @NonNull Paint>("-fx-fill", PaintConverter.getInstance(), Color.rgb(0, 139, 255)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(PositionMarker node) {
+ return !node.fillProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<@NonNull Paint> getStyleableProperty(PositionMarker node) {
+ return (StyleableProperty<@NonNull Paint>) node.fillProperty();
+ }
+
+ };
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+
+ static {
+
+ @SuppressWarnings("static-access")
+ final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(Group.getClassCssMetaData());
+ styleables.add(FILL);
+ STYLEABLES = Collections.unmodifiableList(styleables);
+ }
+
+ public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
+ return STYLEABLES;
+ }
+
+ @Override
+ public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
+ return getClassCssMetaData();
+ }
+
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
index 225bc1391..50a2dd5ad 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/markers/TabOutlineMarker.java
@@ -16,8 +16,8 @@ import java.util.List;
import javafx.beans.property.ObjectProperty;
import javafx.css.CssMetaData;
+import javafx.css.SimpleStyleableObjectProperty;
import javafx.css.Styleable;
-import javafx.css.StyleableObjectProperty;
import javafx.css.StyleableProperty;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
@@ -27,19 +27,51 @@ import javafx.scene.paint.Paint;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeType;
+import org.eclipse.jdt.annotation.NonNull;
+
import com.sun.javafx.css.converters.PaintConverter;
-public class TabOutlineMarker extends Group {
+/**
+ * Marks a Tab-Position
+ */
+@SuppressWarnings("restriction")
+public final class TabOutlineMarker extends Group {
+ @NonNull
private Bounds containerBounds;
+ @NonNull
private Bounds referenceBounds;
private boolean before;
- public TabOutlineMarker(Bounds containerBounds, Bounds referenceBounds, boolean before) {
+ /**
+ * Create a new tab outline
+ *
+ * @param containerBounds
+ * the bounds of the container
+ * @param referenceBounds
+ * the bounds of the reference tab
+ * @param before
+ * <code>true</code> to mark the insert point before reference
+ * bounds
+ */
+ public TabOutlineMarker(@NonNull Bounds containerBounds, @NonNull Bounds referenceBounds, boolean before) {
+ this.containerBounds = containerBounds;
+ this.referenceBounds = referenceBounds;
updateBounds(containerBounds, referenceBounds, before);
- getStyleClass().add("tab-outline-marker");
+ getStyleClass().add("tab-outline-marker"); //$NON-NLS-1$
}
- public void updateBounds(Bounds containerBounds, Bounds referenceBounds, boolean before) {
+ /**
+ * Update the tab outline
+ *
+ * @param containerBounds
+ * the bounds of the container
+ * @param referenceBounds
+ * the bounds of the reference tab
+ * @param before
+ * <code>true</code> to mark the insert point before reference
+ * bounds
+ */
+ public void updateBounds(@NonNull Bounds containerBounds, @NonNull Bounds referenceBounds, boolean before) {
if (containerBounds.equals(this.containerBounds) && referenceBounds.equals(this.referenceBounds) && before == this.before) {
return;
}
@@ -50,98 +82,130 @@ public class TabOutlineMarker extends Group {
Polyline pl = new Polyline();
+ Bounds _referenceBounds = referenceBounds;
+
if (before) {
- referenceBounds = new BoundingBox(Math.max(0, referenceBounds.getMinX() - referenceBounds.getWidth() / 2), referenceBounds.getMinY(), referenceBounds.getWidth(), referenceBounds.getHeight());
+ _referenceBounds = new BoundingBox(Math.max(0, _referenceBounds.getMinX() - _referenceBounds.getWidth() / 2), _referenceBounds.getMinY(), _referenceBounds.getWidth(), _referenceBounds.getHeight());
} else {
- referenceBounds = new BoundingBox(Math.max(0, referenceBounds.getMaxX() - referenceBounds.getWidth() / 2), referenceBounds.getMinY(), referenceBounds.getWidth(), referenceBounds.getHeight());
+ _referenceBounds = new BoundingBox(Math.max(0, _referenceBounds.getMaxX() - _referenceBounds.getWidth() / 2), _referenceBounds.getMinY(), _referenceBounds.getWidth(), _referenceBounds.getHeight());
}
pl.getPoints().addAll(
- // -----------------
- // top
- // -----------------
- // start
- 0.0, referenceBounds.getMaxY(),
+ // -----------------
+ // top
+ // -----------------
+ // start
+ Double.valueOf(0.0), Double.valueOf(_referenceBounds.getMaxY()),
// tab start
- referenceBounds.getMinX(), referenceBounds.getMaxY(),
+ Double.valueOf(_referenceBounds.getMinX()), Double.valueOf(_referenceBounds.getMaxY()),
// // tab start top
- referenceBounds.getMinX(), referenceBounds.getMinY(),
+ Double.valueOf(_referenceBounds.getMinX()), Double.valueOf(_referenceBounds.getMinY()),
// tab end right
- referenceBounds.getMaxX(), referenceBounds.getMinY(),
+ Double.valueOf(_referenceBounds.getMaxX()), Double.valueOf(_referenceBounds.getMinY()),
// tab end bottom
- referenceBounds.getMaxX(), referenceBounds.getMaxY(),
+ Double.valueOf(_referenceBounds.getMaxX()), Double.valueOf(_referenceBounds.getMaxY()),
// end
- containerBounds.getMaxX(), referenceBounds.getMaxY(),
+ Double.valueOf(containerBounds.getMaxX()), Double.valueOf(_referenceBounds.getMaxY()),
// -----------------
// right
// -----------------
- containerBounds.getMaxX(), containerBounds.getMaxY(),
+ Double.valueOf(containerBounds.getMaxX()), Double.valueOf(containerBounds.getMaxY()),
// -----------------
// bottom
// -----------------
- containerBounds.getMinX(), containerBounds.getMaxY(),
+ Double.valueOf(containerBounds.getMinX()), Double.valueOf(containerBounds.getMaxY()),
// -----------------
// left
// -----------------
- containerBounds.getMinX(), referenceBounds.getMaxY());
+ Double.valueOf(containerBounds.getMinX()), Double.valueOf(_referenceBounds.getMaxY()));
pl.strokeProperty().bind(fillProperty());
pl.setStrokeWidth(3);
pl.setStrokeType(StrokeType.INSIDE);
getChildren().setAll(pl);
}
- private ObjectProperty<Paint> fill;
-
- public ObjectProperty<Paint> fillProperty() {
- if (fill == null) {
- fill = new StyleableObjectProperty<Paint>(Color.ORANGE) {
-
- @Override
- public CssMetaData<? extends Styleable, Paint> getCssMetaData() {
- return FILL;
- }
-
- @Override
- public Object getBean() {
- return TabOutlineMarker.this;
- }
-
- @Override
- public String getName() {
- return "fill";
- }
-
- };
- }
- return fill;
+ @SuppressWarnings("null")
+ @NonNull
+ private final ObjectProperty<@NonNull Paint> fill = new SimpleStyleableObjectProperty<>(FILL, this, "fill", Color.ORANGE); //$NON-NLS-1$
+
+ /**
+ * The fill property
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is {@link Color#ORANGE}</td>
+ * <td><div style=
+ * "background-color: orange; border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull ObjectProperty<@NonNull Paint> fillProperty() {
+ return this.fill;
}
- public void setFill(Paint fill) {
+ /**
+ * Set a new fill
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is {@link Color#ORANGE}</td>
+ * <td><div style=
+ * "background-color: orange; border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @param fill
+ * the fill
+ */
+ public void setFill(@NonNull Paint fill) {
fillProperty().set(fill);
}
- public Paint getFill() {
+ /**
+ * Get the current fill
+ * <p>
+ * <table>
+ * <tr>
+ * <td>The default value is {@link Color#ORANGE}</td>
+ * <td><div style=
+ * "background-color: orange; border-width: 1px; border-color: black; border-style: solid; width: 15; height: 15;"
+ * ></div></td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @return the current fill
+ */
+ public @NonNull Paint getFill() {
return fillProperty().get();
}
- private static final CssMetaData<TabOutlineMarker, Paint> FILL = new CssMetaData<TabOutlineMarker, Paint>("-fx-fill", PaintConverter.getInstance(), Color.rgb(0, 139, 255)) {
+ @SuppressWarnings("null")
+ private static final CssMetaData<TabOutlineMarker, @NonNull Paint> FILL = new CssMetaData<TabOutlineMarker, @NonNull Paint>("-fx-fill", PaintConverter.getInstance(), Color.ORANGE) { //$NON-NLS-1$
@Override
public boolean isSettable(TabOutlineMarker node) {
- return node.fill == null || !node.fill.isBound();
+ return !node.fillProperty().isBound();
}
+ @SuppressWarnings("unchecked")
@Override
- public StyleableProperty<Paint> getStyleableProperty(TabOutlineMarker node) {
- return (StyleableProperty<Paint>) node.fillProperty();
+ public StyleableProperty<@NonNull Paint> getStyleableProperty(TabOutlineMarker node) {
+ return (StyleableProperty<@NonNull Paint>) node.fillProperty();
}
};
@@ -149,6 +213,7 @@ public class TabOutlineMarker extends Group {
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
static {
+ @SuppressWarnings("static-access")
final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(Group.getClassCssMetaData());
styleables.add(FILL);
STYLEABLES = Collections.unmodifiableList(styleables);
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/ActionEvent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/ActionEvent.java
index d0c22a110..334e73353 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/ActionEvent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/ActionEvent.java
@@ -1,41 +1,78 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
import javafx.event.Event;
import javafx.event.EventTarget;
import javafx.event.EventType;
+/**
+ * An action event
+ */
public class ActionEvent extends Event {
/**
*
*/
private static final long serialVersionUID = 1L;
-
- public static final EventType<ActionEvent> ACTION =
- new EventType<ActionEvent>(Event.ANY, "STYLED_TEXT_ACTION");
-
+
+ /**
+ * Event type
+ */
+ public static final EventType<ActionEvent> ACTION = new EventType<ActionEvent>(Event.ANY, "STYLED_TEXT_ACTION"); //$NON-NLS-1$
+
+ /**
+ * The type
+ */
public enum ActionType {
+ /**
+ * Action to delete previous word
+ */
DELETE_WORD_PREVIOUS,
+ /**
+ * Action to delete next word
+ */
DELETE_WORD_NEXT,
-
+ /**
+ * Action to go to the next word
+ */
WORD_NEXT,
+ /**
+ * Action to go to the previous word
+ */
WORD_PREVIOUS,
-
+ /**
+ * Action to go to the line start
+ */
LINE_START,
+ /**
+ * Action to go to the line end
+ */
LINE_END
}
-
+
+ /**
+ * The type
+ */
public final ActionType type;
-
+
+ /**
+ * Create a new action event
+ *
+ * @param source
+ * the source
+ * @param target
+ * the target
+ * @param type
+ * the type
+ */
public ActionEvent(Object source, EventTarget target, ActionType type) {
super(source, target, ACTION);
this.type = type;
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyleRange.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyleRange.java
index 24954bbce..739a611ab 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyleRange.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyleRange.java
@@ -12,222 +12,269 @@ package org.eclipse.fx.ui.controls.styledtext;
import javafx.scene.paint.Color;
-
/**
- * <code>StyleRange</code> defines a set of styles for a specified
- * range of text.
+ * <code>StyleRange</code> defines a set of styles for a specified range of
+ * text.
* <p>
- * The hashCode() method in this class uses the values of the public
- * fields to compute the hash value. When storing instances of the
- * class in hashed collections, do not modify these fields after the
- * object has been inserted.
+ * The hashCode() method in this class uses the values of the public fields to
+ * compute the hash value. When storing instances of the class in hashed
+ * collections, do not modify these fields after the object has been inserted.
* </p>
*
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further
+ * information</a>
*/
public class StyleRange extends TextStyle implements Cloneable {
/**
* The font style constant indicating a normal weight, non-italic font
- * (value is 0). This constant is also used with <code>ProgressBar</code>
- * to indicate a normal state.
- * <p><b>Used By:</b><ul>
+ * (value is 0). This constant is also used with <code>ProgressBar</code> to
+ * indicate a normal state.
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>ProgressBar</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*/
public static final int NORMAL = 0;
-
+
/**
- * The font style constant indicating a bold weight font
- * (value is 1&lt;&lt;0).
+ * The font style constant indicating a bold weight font (value is
+ * 1&lt;&lt;0).
*/
public static final int BOLD = 1 << 0;
-
+
/**
- * The font style constant indicating an italic font
- * (value is 1&lt;&lt;1).
+ * The font style constant indicating an italic font (value is 1&lt;&lt;1).
*/
public static final int ITALIC = 1 << 1;
-
+
/**
* the start offset of the range, zero-based from the document start
*/
public int start;
-
+
/**
* the length of the range
*/
public int length;
/**
- * the font style of the range. It may be a combination of
- * SWT.NORMAL, SWT.ITALIC or SWT.BOLD
+ * the font style of the range. It may be a combination of SWT.NORMAL,
+ * SWT.ITALIC or SWT.BOLD
*
- * Note: the font style is not used if the <code>font</code> attribute
- * is set
+ * Note: the font style is not used if the <code>font</code> attribute is
+ * set
*/
public int fontStyle = NORMAL;
-
-/**
- * Create a new style range with no styles
- *
- * @since 3.2
- */
-public StyleRange() {
-}
-/**
- * Create a new style range from an existing text style.
- *
- * @param style the text style to copy
- *
- * @since 3.4
- */
-public StyleRange(TextStyle style) {
- super(style);
-}
+ /**
+ * Create a new style range with no styles
+ *
+ * @param stylename
+ * the css stylename
+ *
+ * @since 3.2
+ */
+ public StyleRange(String stylename) {
+ super(stylename);
+ }
-/**
- * Create a new style range.
- *
- * @param start start offset of the style
- * @param length length of the style
- * @param foreground foreground color of the style, null if none
- * @param background background color of the style, null if none
- */
-public StyleRange(int start, int length, Color foreground, Color background) {
- super(null, foreground, background);
- this.start = start;
- this.length = length;
-}
+ /**
+ * Create a new style range from an existing text style.
+ *
+ * @param style
+ * the text style to copy
+ *
+ * @since 3.4
+ */
+ public StyleRange(TextStyle style) {
+ super(style);
+ }
-/**
- * Create a new style range.
- *
- * @param start start offset of the style
- * @param length length of the style
- * @param foreground foreground color of the style, null if none
- * @param background background color of the style, null if none
- * @param fontStyle font style of the style, may be SWT.NORMAL, SWT.ITALIC or SWT.BOLD
- */
-public StyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
- this(start, length, foreground, background);
- this.fontStyle = fontStyle;
-}
+ /**
+ * Create a new style range.
+ *
+ * @param stylename
+ * the css stylename
+ *
+ * @param start
+ * start offset of the style
+ * @param length
+ * length of the style
+ * @param foreground
+ * foreground color of the style, null if none
+ * @param background
+ * background color of the style, null if none
+ */
+ public StyleRange(String stylename, int start, int length,
+ Color foreground, Color background) {
+ super(stylename, null, foreground, background);
+ this.start = start;
+ this.length = length;
+ }
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode()
- */
-public boolean equals(Object object) {
- if (object == this) return true;
- if (object instanceof StyleRange) {
- StyleRange style = (StyleRange)object;
- if (start != style.start) return false;
- if (length != style.length) return false;
- return similarTo(style);
+ /**
+ * Create a new style range.
+ *
+ * @param stylename
+ * the css stylename
+ *
+ * @param start
+ * start offset of the style
+ * @param length
+ * length of the style
+ * @param foreground
+ * foreground color of the style, null if none
+ * @param background
+ * background color of the style, null if none
+ * @param fontStyle
+ * font style of the style, may be SWT.NORMAL, SWT.ITALIC or
+ * SWT.BOLD
+ */
+ public StyleRange(String stylename, int start, int length,
+ Color foreground, Color background, int fontStyle) {
+ this(stylename, start, length, foreground, background);
+ this.fontStyle = fontStyle;
}
- return false;
-}
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals(Object)
- */
-public int hashCode() {
- return super.hashCode() ^ fontStyle;
-}
-boolean isVariableHeight() {
- return font != null /*|| metrics != null*/ || rise != 0;
-}
-/**
- * Returns whether or not the receiver is unstyled (i.e., does not have any
- * style attributes specified).
- *
- * @return true if the receiver is unstyled, false otherwise.
- */
-public boolean isUnstyled() {
- if (font != null) return false;
- if (rise != 0) return false;
-// if (metrics != null) return false;
- if (foreground != null) return false;
- if (background != null) return false;
- if (fontStyle != NORMAL) return false;
- if (underline) return false;
- if (strikeout) return false;
- if (borderStyle != NONE) return false;
- return true;
-}
+ /**
+ * Compares the argument to the receiver, and returns true if they represent
+ * the <em>same</em> object using a class specific comparison.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and
+ * <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (object == this)
+ return true;
+ if (object instanceof StyleRange) {
+ StyleRange style = (StyleRange) object;
+ if (this.start != style.start)
+ return false;
+ if (this.length != style.length)
+ return false;
+ return similarTo(style);
+ }
+ return false;
+ }
-/**
- * Compares the specified object to this StyleRange and answer if the two
- * are similar. The object must be an instance of StyleRange and have the
- * same field values for except for start and length.
- *
- * @param style the object to compare with this object
- * @return true if the objects are similar, false otherwise
- */
-public boolean similarTo(StyleRange style) {
- if (!super.equals(style)) return false;
- if (fontStyle != style.fontStyle) return false;
- return true;
-}
+ /**
+ * Returns an integer hash code for the receiver. Any two objects that
+ * return <code>true</code> when passed to <code>equals</code> must return
+ * the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode() ^ this.fontStyle;
+ }
-/**
- * Returns a new StyleRange with the same values as this StyleRange.
- *
- * @return a shallow copy of this StyleRange
- */
-public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
+ boolean isVariableHeight() {
+ return this.font != null /* || metrics != null */|| this.rise != 0;
}
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the StyleRange
- */
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("StyleRange {");
- buffer.append(start);
- buffer.append(", ");
- buffer.append(length);
- buffer.append(", fontStyle=");
- switch (fontStyle) {
+ /**
+ * Returns whether or not the receiver is unstyled (i.e., does not have any
+ * style attributes specified).
+ *
+ * @return true if the receiver is unstyled, false otherwise.
+ */
+ public boolean isUnstyled() {
+ if (this.font != null)
+ return false;
+ if (this.rise != 0)
+ return false;
+ // if (metrics != null) return false;
+ if (this.stylename != null)
+ return false;
+ if (this.foreground != null)
+ return false;
+ if (this.background != null)
+ return false;
+ if (this.fontStyle != NORMAL)
+ return false;
+ if (this.underline)
+ return false;
+ if (this.strikeout)
+ return false;
+ if (this.borderStyle != NONE)
+ return false;
+ return true;
+ }
+
+ /**
+ * Compares the specified object to this StyleRange and answer if the two
+ * are similar. The object must be an instance of StyleRange and have the
+ * same field values for except for start and length.
+ *
+ * @param style
+ * the object to compare with this object
+ * @return true if the objects are similar, false otherwise
+ */
+ public boolean similarTo(StyleRange style) {
+ if (!super.equals(style))
+ return false;
+ if (this.fontStyle != style.fontStyle)
+ return false;
+ return true;
+ }
+
+ /**
+ * Returns a new StyleRange with the same values as this StyleRange.
+ *
+ * @return a shallow copy of this StyleRange
+ */
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a string representation of the StyleRange
+ */
+ @Override
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("StyleRange {"); //$NON-NLS-1$
+ buffer.append(this.start);
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(this.length);
+ buffer.append(", fontStyle="); //$NON-NLS-1$
+ switch (this.fontStyle) {
case BOLD:
- buffer.append("bold");
+ buffer.append("bold"); //$NON-NLS-1$
break;
case ITALIC:
- buffer.append("italic");
+ buffer.append("italic"); //$NON-NLS-1$
break;
case BOLD | ITALIC:
- buffer.append("bold-italic");
+ buffer.append("bold-italic"); //$NON-NLS-1$
break;
default:
- buffer.append("normal");
+ buffer.append("normal"); //$NON-NLS-1$
+ }
+ String str = super.toString();
+ int index = str.indexOf('{');
+ str = str.substring(index + 1);
+ if (str.length() > 1)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(str);
+ return buffer.toString();
}
- String str = super.toString();
- int index = str.indexOf('{');
- str = str.substring(index + 1);
- if (str.length() > 1) buffer.append(", ");
- buffer.append(str);
- return buffer.toString();
-}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
index 1830f8d88..487f4e833 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextArea.java
@@ -1,20 +1,18 @@
/*******************************************************************************
-* Copyright (c) 2013 IBM & BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-* IBM Corporation - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2013 IBM & BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
import java.lang.ref.WeakReference;
-
-import org.eclipse.fx.ui.controls.styledtext.StyledTextContent.TextChangeListener;
-import org.eclipse.fx.ui.controls.styledtext.skin.StyledTextSkin;
+import java.util.Collections;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
@@ -25,188 +23,364 @@ import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Point2D;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
+import javafx.scene.input.Clipboard;
+import javafx.scene.input.DataFormat;
import javafx.scene.paint.Color;
-import javafx.scene.text.Font;
-import javafx.scene.text.FontWeight;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextContent.TextChangeListener;
+import org.eclipse.fx.ui.controls.styledtext.skin.StyledTextSkin;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * Control which allows to implemented a code-editor
+ */
public class StyledTextArea extends Control {
-
- private ObjectProperty<StyledTextContent> contentProperty = new SimpleObjectProperty<StyledTextContent>(this, "content") {
+
+ @NonNull
+ final ObjectProperty<@NonNull StyledTextContent> contentProperty = new SimpleObjectProperty<@NonNull StyledTextContent>(
+ this, "content", new DefaultContent()) { //$NON-NLS-1$
WeakReference<StyledTextContent> oldContent;
-
+
+ @Override
protected void invalidated() {
- if( oldContent != null && oldContent.get() != null ) {
- oldContent.get().removeTextChangeListener(textChangeListener);
- }
- StyledTextContent newContent = contentProperty.get();
-
- if( newContent != null ) {
- oldContent = new WeakReference<StyledTextContent>(newContent);
- newContent.addTextChangeListener(textChangeListener);
- } else {
- oldContent = null;
+ if (this.oldContent != null && this.oldContent.get() != null) {
+ this.oldContent.get().removeTextChangeListener(
+ StyledTextArea.this.textChangeListener);
}
+ StyledTextContent newContent = StyledTextArea.this.contentProperty
+ .get();
+
+ this.oldContent = new WeakReference<StyledTextContent>(newContent);
+ newContent
+ .addTextChangeListener(StyledTextArea.this.textChangeListener);
}
};
-
+
TextChangeListener textChangeListener = new TextChangeListener() {
+ @Override
public void textChanging(TextChangingEvent event) {
handleTextChanging(event);
}
+
+ @Override
public void textChanged(TextChangedEvent event) {
handleTextChanged(event);
}
+
+ @Override
public void textSet(TextChangedEvent event) {
handleTextSet(event);
}
};
-
- private StyledTextRenderer renderer = new StyledTextRenderer();
- private IntegerProperty caretOffsetProperty = new SimpleIntegerProperty(this, "caretOffset", -1);
- private BooleanProperty lineRulerVisible = new SimpleBooleanProperty(this, "lineRulerVisible");
-
-// private int lastTextChangeStart;
-//
-// private int lastTextChangeNewLineCount;
-//
-// private int lastTextChangeNewCharCount;
-//
-// private int lastTextChangeReplaceLineCount;
-//
-// private int lastTextChangeReplaceCharCount;
-
+
+ @NonNull
+ private final StyledTextRenderer renderer = new StyledTextRenderer();
+
+ @NonNull
+ private final IntegerProperty caretOffsetProperty = new SimpleIntegerProperty(
+ this, "caretOffset", -1); //$NON-NLS-1$
+
+ @NonNull
+ private final BooleanProperty lineRulerVisible = new SimpleBooleanProperty(
+ this, "lineRulerVisible"); //$NON-NLS-1$
+
+ @NonNull
+ private final ObjectProperty<TextSelection> currentSelection = new SimpleObjectProperty<>(
+ this, "currentSelection"); //$NON-NLS-1$
+
+ // private int lastTextChangeStart;
+ //
+ // private int lastTextChangeNewLineCount;
+ //
+ // private int lastTextChangeNewCharCount;
+ //
+ // private int lastTextChangeReplaceLineCount;
+ //
+ // private int lastTextChangeReplaceCharCount;
+
+ /**
+ * Create a new control
+ */
public StyledTextArea() {
- getStylesheets().add(getClass().getResource("styledtextarea.css").toExternalForm());
- contentProperty.set(new DefaultContent());
+ getStylesheets().add(
+ getClass().getResource("styledtextarea.css").toExternalForm()); //$NON-NLS-1$
setFocusTraversable(true);
}
-
+
void handleTextChanging(TextChangingEvent event) {
if (event.replaceCharCount < 0) {
event.offset += event.replaceCharCount;
event.replaceCharCount *= -1;
}
-// lastTextChangeStart = event.offset;
-// lastTextChangeNewLineCount = event.newLineCount;
-// lastTextChangeNewCharCount = event.newCharCount;
-// lastTextChangeReplaceLineCount = event.replaceLineCount;
-// lastTextChangeReplaceCharCount = event.replaceCharCount;
-
- renderer.textChanging(event);
+ // lastTextChangeStart = event.offset;
+ // lastTextChangeNewLineCount = event.newLineCount;
+ // lastTextChangeNewCharCount = event.newCharCount;
+ // lastTextChangeReplaceLineCount = event.replaceLineCount;
+ // lastTextChangeReplaceCharCount = event.replaceCharCount;
+
+ this.renderer.textChanging(event);
}
-
+
void handleTextSet(TextChangedEvent event) {
-
+ // TODO Implement
}
-
+
void handleTextChanged(TextChangedEvent event) {
-// int firstLine = getContent().getLineAtOffset(lastTextChangeStart);
- if( getSkin() instanceof StyledTextSkin ) {
- ((StyledTextSkin)getSkin()).recalculateItems();
+ // int firstLine = getContent().getLineAtOffset(lastTextChangeStart);
+ if (getSkin() instanceof StyledTextSkin) {
+ ((StyledTextSkin) getSkin()).recalculateItems();
}
-
-// lastCharCount += lastTextChangeNewCharCount;
-// lastCharCount -= lastTextChangeReplaceCharCount;
+
+ // lastCharCount += lastTextChangeNewCharCount;
+ // lastCharCount -= lastTextChangeReplaceCharCount;
}
-
+
@Override
protected Skin<?> createDefaultSkin() {
return new StyledTextSkin(this);
}
-
- public BooleanProperty lineRulerVisibleProperty() {
- return lineRulerVisible;
+
+ /**
+ * Show a line ruler on the left
+ * <p>
+ * Default is <code>false</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty lineRulerVisibleProperty() {
+ return this.lineRulerVisible;
}
-
+
+ /**
+ * Show/hide the line ruler
+ * <p>
+ * Default is <code>false</code>
+ * </p>
+ *
+ * @param lineRulerVisible
+ * the new state
+ */
public void setLineRulerVisible(boolean lineRulerVisible) {
- this.lineRulerVisible.set(lineRulerVisible);
+ lineRulerVisibleProperty().set(lineRulerVisible);
}
-
+
+ /**
+ * Is line ruler shown
+ * <p>
+ * Default is <code>false</code>
+ * </p>
+ *
+ * @return the current state
+ */
public boolean isLineRulerVisible() {
- return this.lineRulerVisible.get();
+ return lineRulerVisibleProperty().get();
}
-
- public IntegerProperty caretOffsetProperty() {
- return caretOffsetProperty;
+
+ /**
+ * The current caret offset
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty caretOffsetProperty() {
+ return this.caretOffsetProperty;
}
-
+
+ /**
+ * Set the current caret offset
+ *
+ * @param offset
+ * the new offset
+ */
public void setCaretOffset(int offset) {
- caretOffsetProperty.set(offset);
+ // System.err.println("OFFSET: " + offset);
+ caretOffsetProperty().set(offset);
+ clearSelection();
}
-
+
+ /**
+ * Setting the caret offset and updateing the selection if requested
+ *
+ * @param offset
+ * the offset
+ * @param selection
+ * <code>true</code> to update the current selection
+ */
+ public void setCaretOffset(int offset, boolean selection) {
+ if (selection) {
+ TextSelection s = getSelection();
+ int lastOffset = getCaretOffset();
+
+ caretOffsetProperty().set(offset);
+
+ int selectStart = s.offset;
+ int selectionEnd = s.offset + s.length;
+
+ if (offset > selectionEnd) {
+ selectStart = s.offset;
+ selectionEnd = offset;
+ } else if (offset < selectionEnd && offset > selectStart) {
+ if (lastOffset > offset) {
+ selectStart = s.offset;
+ selectionEnd = offset;
+ } else {
+ selectStart = offset;
+ }
+
+ } else if (offset < selectStart) {
+ selectStart = offset;
+ } else {
+ selectStart = offset;
+ selectionEnd = offset;
+ }
+
+ setSelectionRange(selectStart, selectionEnd - selectStart);
+ } else {
+ setCaretOffset(offset);
+ }
+ }
+
+ /**
+ * @return the current caret offset
+ */
public int getCaretOffset() {
- return caretOffsetProperty.get();
+ return caretOffsetProperty().get();
}
- public void setContent(StyledTextContent content) {
- contentProperty.set(content);
+ /**
+ * Set the content
+ *
+ * @param content
+ * the content
+ */
+ public void setContent(@NonNull StyledTextContent content) {
+ contentProperty().set(content);
}
-
- public StyledTextContent getContent() {
- return contentProperty.get();
+
+ /**
+ * Access the content
+ *
+ * @return the content
+ */
+ public @NonNull StyledTextContent getContent() {
+ return contentProperty().get();
}
-
- public ObjectProperty<StyledTextContent> contentProperty() {
- return contentProperty;
+
+ /**
+ * The content property
+ *
+ * @return the property
+ */
+ public @NonNull ObjectProperty<@NonNull StyledTextContent> contentProperty() {
+ return this.contentProperty;
}
-
- public void setStyleRange(StyleRange range) {
+
+ /**
+ * Set the style range
+ *
+ * @param range
+ * the range
+ */
+ public void setStyleRange(@Nullable StyleRange range) {
if (range != null) {
if (range.isUnstyled()) {
setStyleRanges(range.start, range.length, null, null, false);
} else {
- setStyleRanges(range.start, 0, null, new StyleRange[]{range}, false);
+ setStyleRanges(range.start, 0, null,
+ new StyleRange[] { range }, false);
}
} else {
setStyleRanges(0, 0, null, null, true);
}
}
-
- public void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles) {
+
+ /**
+ * Set the style range
+ *
+ * @param start
+ * the start
+ * @param length
+ * the length
+ * @param ranges
+ * the ranges
+ * @param styles
+ * the style ranges
+ */
+ public void setStyleRanges(int start, int length, @Nullable int[] ranges,
+ @Nullable StyleRange[] styles) {
if (ranges == null || styles == null) {
setStyleRanges(start, length, null, null, false);
} else {
setStyleRanges(start, length, ranges, styles, false);
}
}
-
- public void setStyleRanges(int[] ranges, StyleRange[] styles) {
+
+ /**
+ * Set the style ranges
+ *
+ * @param ranges
+ * the ranges
+ * @param styles
+ * the style ranges
+ */
+ public void setStyleRanges(@Nullable int[] ranges,
+ @Nullable StyleRange[] styles) {
if (ranges == null || styles == null) {
setStyleRanges(0, 0, null, null, true);
} else {
setStyleRanges(0, 0, ranges, styles, true);
}
}
-
- public void setStyleRanges(StyleRange[] ranges) {
+
+ /**
+ * Set the style ranges
+ *
+ * @param ranges
+ * the ranges
+ */
+ public void setStyleRanges(@Nullable StyleRange[] ranges) {
setStyleRanges(0, 0, null, ranges, true);
}
-
- public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
- if (ranges == null) throw new IllegalArgumentException();
- setStyleRanges(start, length, null, ranges, false);
+
+ /**
+ * Replace style ranges
+ *
+ * @param start
+ * the start
+ * @param length
+ * the length
+ * @param ranges
+ * the new ranges
+ */
+ public void replaceStyleRanges(int start, int length,
+ @Nullable StyleRange[] ranges) {
+ if (ranges == null)
+ throw new IllegalArgumentException();
+ setStyleRanges(start, length, null, ranges, false);
}
-
- void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles, boolean reset) {
-// System.err.println("New styles: " + Arrays.toString(styles));
-
-
+
+ void setStyleRanges(int start, int length, int[] ranges,
+ StyleRange[] styles, boolean reset) {
+ // System.err.println("New styles: " + Arrays.toString(styles));
+
int charCount = getContent().getCharCount();
int end = start + length;
if (start > end || start < 0) {
throw new IllegalArgumentException();
}
-
+
if (styles != null) {
if (end > charCount) {
throw new IllegalArgumentException();
}
if (ranges != null) {
- if (ranges.length != styles.length << 1) throw new IllegalArgumentException();
+ if (ranges.length != styles.length << 1)
+ throw new IllegalArgumentException();
}
int lastOffset = 0;
-// boolean variableHeight = false;
- for (int i = 0; i < styles.length; i ++) {
+ // boolean variableHeight = false;
+ for (int i = 0; i < styles.length; i++) {
if (styles[i] == null) {
throw new IllegalArgumentException();
}
@@ -219,7 +393,7 @@ public class StyledTextArea extends Control {
rangeLength = styles[i].length;
}
if (rangeLength < 0) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
}
if (!(0 <= rangeStart && rangeStart + rangeLength <= charCount)) {
throw new IllegalArgumentException();
@@ -227,59 +401,87 @@ public class StyledTextArea extends Control {
if (lastOffset > rangeStart) {
throw new IllegalArgumentException();
}
-// variableHeight |= styles[i].isVariableHeight();
+ // variableHeight |= styles[i].isVariableHeight();
lastOffset = rangeStart + rangeLength;
}
-// if (variableHeight) setVariableLineHeight();
+ // if (variableHeight) setVariableLineHeight();
}
-
+
+ @SuppressWarnings("unused")
int rangeStart = start, rangeEnd = end;
if (styles != null && styles.length > 0) {
if (ranges != null) {
rangeStart = ranges[0];
- rangeEnd = ranges[ranges.length - 2] + ranges[ranges.length - 1];
+ rangeEnd = ranges[ranges.length - 2]
+ + ranges[ranges.length - 1];
} else {
rangeStart = styles[0].start;
- rangeEnd = styles[styles.length - 1].start + styles[styles.length - 1].length;
+ rangeEnd = styles[styles.length - 1].start
+ + styles[styles.length - 1].length;
}
}
-
- if( reset ) {
- renderer.setStyleRanges(null, null);
+
+ if (reset) {
+ this.renderer.setStyleRanges(null, null);
} else {
- renderer.updateRanges(start, length, length);
+ this.renderer.updateRanges(start, length, length);
}
-
+
if (styles != null && styles.length > 0) {
- renderer.setStyleRanges(ranges, styles);
+ this.renderer.setStyleRanges(ranges, styles);
}
-
- if( getSkin() instanceof StyledTextSkin ) {
- ((StyledTextSkin)getSkin()).recalculateItems();
+
+ if (getSkin() instanceof StyledTextSkin) {
+ ((StyledTextSkin) getSkin()).recalculateItems();
}
}
-
- public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) {
- StyleRange[] ranges = renderer.getStyleRanges(start, length, includeRanges);
- if (ranges != null) return ranges;
+
+ /**
+ * Access style ranges in the specified segment
+ *
+ * @param start
+ * the start
+ * @param length
+ * the length
+ * @param includeRanges
+ * include ranges
+ * @return the ranges
+ */
+ public StyleRange[] getStyleRanges(int start, int length,
+ boolean includeRanges) {
+ StyleRange[] ranges = this.renderer.getStyleRanges(start, length,
+ includeRanges);
+ if (ranges != null)
+ return ranges;
return new StyleRange[0];
}
-
+
+ /**
+ * The style range at the given offset
+ *
+ * @param offset
+ * the offset
+ * @return the style range
+ */
public StyleRange getStyleRangeAtOffset(int offset) {
if (offset < 0 || offset >= getCharCount()) {
throw new IllegalArgumentException();
}
-// if (!isListening(ST.LineGetStyle)) {
- StyleRange[] ranges = renderer.getStyleRanges(offset, 1, true);
- if (ranges != null) return ranges[0];
-// }
+ // if (!isListening(ST.LineGetStyle)) {
+ StyleRange[] ranges = this.renderer.getStyleRanges(offset, 1, true);
+ if (ranges != null)
+ return ranges[0];
+ // }
return null;
}
-
+
+ /**
+ * @return the current char count
+ */
public int getCharCount() {
- return contentProperty.get().getCharCount();
+ return getContent().getCharCount();
}
-
+
static class LineInfo {
int flags;
Color background;
@@ -293,35 +495,33 @@ public class StyledTextArea extends Control {
public LineInfo() {
}
+
public LineInfo(LineInfo info) {
if (info != null) {
- flags = info.flags;
- background = info.background;
- alignment = info.alignment;
- indent = info.indent;
- wrapIndent = info.wrapIndent;
- justify = info.justify;
- segments = info.segments;
- segmentsChars = info.segmentsChars;
- tabStops = info.tabStops;
+ this.flags = info.flags;
+ this.background = info.background;
+ this.alignment = info.alignment;
+ this.indent = info.indent;
+ this.wrapIndent = info.wrapIndent;
+ this.justify = info.justify;
+ this.segments = info.segments;
+ this.segmentsChars = info.segmentsChars;
+ this.tabStops = info.tabStops;
}
}
}
-
+
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
+ * Copyright (c) 2000, 2011 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
+ * Contributors: IBM Corporation - initial API and implementation
*******************************************************************************/
class StyledTextRenderer {
-
-
-
+
StyleRange[] stylesSet;
int stylesSetCount = 0;
int[] ranges;
@@ -332,188 +532,236 @@ public class StyledTextArea extends Control {
int lineCount;
int[] lineWidth;
int[] lineHeight;
-
+
final static boolean COMPACT_STYLES = true;
final static boolean MERGE_STYLES = true;
final static int GROW = 32;
-
- void setStyleRanges (int[] newRanges, StyleRange[] newStyles) {
- if (newStyles == null) {
- stylesSetCount = styleCount = 0;
- ranges = null;
- styles = null;
- stylesSet = null;
- hasLinks = false;
+
+ void setStyleRanges(int[] newRanges, StyleRange[] newStyles) {
+ int[] _newRanges = newRanges;
+ StyleRange[] _newStyles = newStyles;
+ if (_newStyles == null) {
+ this.stylesSetCount = this.styleCount = 0;
+ this.ranges = null;
+ this.styles = null;
+ this.stylesSet = null;
+ this.hasLinks = false;
return;
}
- if (newRanges == null && COMPACT_STYLES) {
- newRanges = new int[newStyles.length << 1];
- StyleRange[] tmpStyles = new StyleRange[newStyles.length];
- if (stylesSet == null) stylesSet = new StyleRange[4];
- for (int i = 0, j = 0; i < newStyles.length; i++) {
- StyleRange newStyle = newStyles[i];
- newRanges[j++] = newStyle.start;
- newRanges[j++] = newStyle.length;
+ if (_newRanges == null && COMPACT_STYLES) {
+ _newRanges = new int[_newStyles.length << 1];
+ StyleRange[] tmpStyles = new StyleRange[_newStyles.length];
+ if (this.stylesSet == null)
+ this.stylesSet = new StyleRange[4];
+ for (int i = 0, j = 0; i < _newStyles.length; i++) {
+ StyleRange newStyle = _newStyles[i];
+ _newRanges[j++] = newStyle.start;
+ _newRanges[j++] = newStyle.length;
int index = 0;
- while (index < stylesSetCount) {
- if (stylesSet[index].similarTo(newStyle)) break;
+ while (index < this.stylesSetCount) {
+ if (this.stylesSet[index].similarTo(newStyle))
+ break;
index++;
}
- if (index == stylesSetCount) {
- if (stylesSetCount == stylesSet.length) {
- StyleRange[] tmpStylesSet = new StyleRange[stylesSetCount + 4];
- System.arraycopy(stylesSet, 0, tmpStylesSet, 0, stylesSetCount);
- stylesSet = tmpStylesSet;
+ if (index == this.stylesSetCount) {
+ if (this.stylesSetCount == this.stylesSet.length) {
+ StyleRange[] tmpStylesSet = new StyleRange[this.stylesSetCount + 4];
+ System.arraycopy(this.stylesSet, 0, tmpStylesSet,
+ 0, this.stylesSetCount);
+ this.stylesSet = tmpStylesSet;
}
- stylesSet[stylesSetCount++] = newStyle;
+ this.stylesSet[this.stylesSetCount++] = newStyle;
}
- tmpStyles[i] = stylesSet[index];
+ tmpStyles[i] = this.stylesSet[index];
}
- newStyles = tmpStyles;
+ _newStyles = tmpStyles;
}
-
- if (styleCount == 0) {
- if (newRanges != null) {
- ranges = new int[newRanges.length];
- System.arraycopy(newRanges, 0, ranges, 0, ranges.length);
+
+ if (this.styleCount == 0) {
+ if (_newRanges != null) {
+ this.ranges = new int[_newRanges.length];
+ System.arraycopy(_newRanges, 0, this.ranges, 0,
+ this.ranges.length);
}
- styles = new StyleRange[newStyles.length];
- System.arraycopy(newStyles, 0, styles, 0, styles.length);
- styleCount = newStyles.length;
+ this.styles = new StyleRange[_newStyles.length];
+ System.arraycopy(_newStyles, 0, this.styles, 0,
+ this.styles.length);
+ this.styleCount = _newStyles.length;
return;
}
- if (newRanges != null && ranges == null) {
- ranges = new int[styles.length << 1];
- for (int i = 0, j = 0; i < styleCount; i++) {
- ranges[j++] = styles[i].start;
- ranges[j++] = styles[i].length;
+ if (_newRanges != null && this.ranges == null) {
+ this.ranges = new int[this.styles.length << 1];
+ for (int i = 0, j = 0; i < this.styleCount; i++) {
+ this.ranges[j++] = this.styles[i].start;
+ this.ranges[j++] = this.styles[i].length;
}
}
- if (newRanges == null && ranges != null) {
- newRanges = new int[newStyles.length << 1];
- for (int i = 0, j = 0; i < newStyles.length; i++) {
- newRanges[j++] = newStyles[i].start;
- newRanges[j++] = newStyles[i].length;
+ if (_newRanges == null && this.ranges != null) {
+ _newRanges = new int[_newStyles.length << 1];
+ for (int i = 0, j = 0; i < _newStyles.length; i++) {
+ _newRanges[j++] = _newStyles[i].start;
+ _newRanges[j++] = _newStyles[i].length;
}
}
- if (ranges != null) {
- int rangeCount = styleCount << 1;
- int start = newRanges[0];
+ if (this.ranges != null && _newRanges != null) {
+ int rangeCount = this.styleCount << 1;
+ int start = _newRanges[0];
int modifyStart = getRangeIndex(start, -1, rangeCount), modifyEnd;
boolean insert = modifyStart == rangeCount;
if (!insert) {
- int end = newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1];
+ int end = _newRanges[_newRanges.length - 2]
+ + _newRanges[_newRanges.length - 1];
modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
- insert = modifyStart == modifyEnd && ranges[modifyStart] >= end;
+ insert = modifyStart == modifyEnd
+ && this.ranges[modifyStart] >= end;
}
if (insert) {
- addMerge(newRanges, newStyles, newRanges.length, modifyStart, modifyStart);
+ addMerge(_newRanges, _newStyles, _newRanges.length,
+ modifyStart, modifyStart);
return;
}
modifyEnd = modifyStart;
int[] mergeRanges = new int[6];
StyleRange[] mergeStyles = new StyleRange[3];
- for (int i = 0; i < newRanges.length; i += 2) {
- int newStart = newRanges[i];
- int newEnd = newStart + newRanges[i + 1];
- if (newStart == newEnd) continue;
+ for (int i = 0; i < _newRanges.length; i += 2) {
+ int newStart = _newRanges[i];
+ int newEnd = newStart + _newRanges[i + 1];
+ if (newStart == newEnd)
+ continue;
int modifyLast = 0, mergeCount = 0;
while (modifyEnd < rangeCount) {
- if (newStart >= ranges[modifyStart] + ranges[modifyStart + 1]) modifyStart += 2;
- if (ranges[modifyEnd] + ranges[modifyEnd + 1] > newEnd) break;
+ if (newStart >= this.ranges[modifyStart]
+ + this.ranges[modifyStart + 1])
+ modifyStart += 2;
+ if (this.ranges[modifyEnd] + this.ranges[modifyEnd + 1] > newEnd)
+ break;
modifyEnd += 2;
}
- if (ranges[modifyStart] < newStart && newStart < ranges[modifyStart] + ranges[modifyStart + 1]) {
- mergeStyles[mergeCount >> 1] = styles[modifyStart >> 1];
- mergeRanges[mergeCount] = ranges[modifyStart];
- mergeRanges[mergeCount + 1] = newStart - ranges[modifyStart];
+ if (this.ranges[modifyStart] < newStart
+ && newStart < this.ranges[modifyStart]
+ + this.ranges[modifyStart + 1]) {
+ mergeStyles[mergeCount >> 1] = this.styles[modifyStart >> 1];
+ mergeRanges[mergeCount] = this.ranges[modifyStart];
+ mergeRanges[mergeCount + 1] = newStart
+ - this.ranges[modifyStart];
mergeCount += 2;
}
- mergeStyles[mergeCount >> 1] = newStyles[i >> 1];
+ mergeStyles[mergeCount >> 1] = _newStyles[i >> 1];
mergeRanges[mergeCount] = newStart;
- mergeRanges[mergeCount + 1] = newRanges[i + 1];
+ mergeRanges[mergeCount + 1] = _newRanges[i + 1];
mergeCount += 2;
- if (modifyEnd < rangeCount && ranges[modifyEnd] < newEnd && newEnd < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
- mergeStyles[mergeCount >> 1] = styles[modifyEnd >> 1];
+ if (modifyEnd < rangeCount
+ && this.ranges[modifyEnd] < newEnd
+ && newEnd < this.ranges[modifyEnd]
+ + this.ranges[modifyEnd + 1]) {
+ mergeStyles[mergeCount >> 1] = this.styles[modifyEnd >> 1];
mergeRanges[mergeCount] = newEnd;
- mergeRanges[mergeCount + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - newEnd;
+ mergeRanges[mergeCount + 1] = this.ranges[modifyEnd]
+ + this.ranges[modifyEnd + 1] - newEnd;
mergeCount += 2;
modifyLast = 2;
}
- int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+ int grow = addMerge(mergeRanges, mergeStyles, mergeCount,
+ modifyStart, modifyEnd + modifyLast);
rangeCount += grow;
modifyStart = modifyEnd += grow;
}
} else {
- int start = newStyles[0].start;
- int modifyStart = getRangeIndex(start, -1, styleCount), modifyEnd;
- boolean insert = modifyStart == styleCount;
+ int start = _newStyles[0].start;
+ int modifyStart = getRangeIndex(start, -1, this.styleCount), modifyEnd;
+ boolean insert = modifyStart == this.styleCount;
if (!insert) {
- int end = newStyles[newStyles.length - 1].start + newStyles[newStyles.length - 1].length;
- modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
- insert = modifyStart == modifyEnd && styles[modifyStart].start >= end;
+ int end = _newStyles[_newStyles.length - 1].start
+ + _newStyles[_newStyles.length - 1].length;
+ modifyEnd = getRangeIndex(end, modifyStart - 1,
+ this.styleCount);
+ insert = modifyStart == modifyEnd
+ && this.styles[modifyStart].start >= end;
}
if (insert) {
- addMerge(newStyles, newStyles.length, modifyStart, modifyStart);
+ addMerge(_newStyles, _newStyles.length, modifyStart,
+ modifyStart);
return;
}
modifyEnd = modifyStart;
StyleRange[] mergeStyles = new StyleRange[3];
- for (int i = 0; i < newStyles.length; i++) {
- StyleRange newStyle = newStyles[i], style;
+ for (int i = 0; i < _newStyles.length; i++) {
+ StyleRange newStyle = _newStyles[i], style;
int newStart = newStyle.start;
int newEnd = newStart + newStyle.length;
- if (newStart == newEnd) continue;
+ if (newStart == newEnd)
+ continue;
int modifyLast = 0, mergeCount = 0;
- while (modifyEnd < styleCount) {
- if (newStart >= styles[modifyStart].start + styles[modifyStart].length) modifyStart++;
- if (styles[modifyEnd].start + styles[modifyEnd].length > newEnd) break;
+ while (modifyEnd < this.styleCount) {
+ if (newStart >= this.styles[modifyStart].start
+ + this.styles[modifyStart].length)
+ modifyStart++;
+ if (this.styles[modifyEnd].start
+ + this.styles[modifyEnd].length > newEnd)
+ break;
modifyEnd++;
}
- style = styles[modifyStart];
- if (style.start < newStart && newStart < style.start + style.length) {
- style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+ style = this.styles[modifyStart];
+ if (style.start < newStart
+ && newStart < style.start + style.length) {
+ style = mergeStyles[mergeCount++] = (StyleRange) style
+ .clone();
style.length = newStart - style.start;
}
mergeStyles[mergeCount++] = newStyle;
- if (modifyEnd < styleCount) {
- style = styles[modifyEnd];
- if (style.start < newEnd && newEnd < style.start + style.length) {
- style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+ if (modifyEnd < this.styleCount) {
+ style = this.styles[modifyEnd];
+ if (style.start < newEnd
+ && newEnd < style.start + style.length) {
+ style = mergeStyles[mergeCount++] = (StyleRange) style
+ .clone();
style.length += style.start - newEnd;
style.start = newEnd;
modifyLast = 1;
}
}
- int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+ int grow = addMerge(mergeStyles, mergeCount, modifyStart,
+ modifyEnd + modifyLast);
modifyStart = modifyEnd += grow;
}
}
+
+ System.err.println("DONE"); //$NON-NLS-1$
}
-
+
int[] getRanges(int start, int length) {
- if (length == 0) return null;
+ if (length == 0)
+ return null;
int[] newRanges;
int end = start + length - 1;
- if (ranges != null) {
- int rangeCount = styleCount << 1;
+ if (this.ranges != null) {
+ int rangeCount = this.styleCount << 1;
int rangeStart = getRangeIndex(start, -1, rangeCount);
- if (rangeStart >= rangeCount) return null;
- if (ranges[rangeStart] > end) return null;
- int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount));
- if (ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2);
+ if (rangeStart >= rangeCount)
+ return null;
+ if (this.ranges[rangeStart] > end)
+ return null;
+ int rangeEnd = Math.min(rangeCount - 2,
+ getRangeIndex(end, rangeStart - 1, rangeCount));
+ if (this.ranges[rangeEnd] > end)
+ rangeEnd = Math.max(rangeStart, rangeEnd - 2);
newRanges = new int[rangeEnd - rangeStart + 2];
- System.arraycopy(ranges, rangeStart, newRanges, 0, newRanges.length);
+ System.arraycopy(this.ranges, rangeStart, newRanges, 0,
+ newRanges.length);
} else {
- int rangeStart = getRangeIndex(start, -1, styleCount);
- if (rangeStart >= styleCount) return null;
- if (styles[rangeStart].start > end) return null;
- int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
- if (styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
+ int rangeStart = getRangeIndex(start, -1, this.styleCount);
+ if (rangeStart >= this.styleCount)
+ return null;
+ if (this.styles[rangeStart].start > end)
+ return null;
+ int rangeEnd = Math.min(this.styleCount - 1,
+ getRangeIndex(end, rangeStart - 1, this.styleCount));
+ if (this.styles[rangeEnd].start > end)
+ rangeEnd = Math.max(rangeStart, rangeEnd - 1);
newRanges = new int[(rangeEnd - rangeStart + 1) << 1];
for (int i = rangeStart, j = 0; i <= rangeEnd; i++, j += 2) {
- StyleRange style = styles[i];
+ StyleRange style = this.styles[i];
newRanges[j] = style.start;
newRanges[j + 1] = style.length;
}
@@ -522,417 +770,525 @@ public class StyledTextArea extends Control {
newRanges[1] = newRanges[0] + newRanges[1] - start;
newRanges[0] = start;
}
- if (end < newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1] - 1) {
- newRanges[newRanges.length - 1] = end - newRanges[newRanges.length - 2] + 1;
+ if (end < newRanges[newRanges.length - 2]
+ + newRanges[newRanges.length - 1] - 1) {
+ newRanges[newRanges.length - 1] = end
+ - newRanges[newRanges.length - 2] + 1;
}
return newRanges;
}
-
+
int getRangeIndex(int offset, int low, int high) {
- if (styleCount == 0) return 0;
- if (ranges != null) {
- while (high - low > 2) {
- int index = ((high + low) / 2) / 2 * 2;
- int end = ranges[index] + ranges[index + 1];
+ int _low = low;
+ int _high = high;
+ if (this.styleCount == 0)
+ return 0;
+ if (this.ranges != null) {
+ while (_high - _low > 2) {
+ int index = ((_high + _low) / 2) / 2 * 2;
+ int end = this.ranges[index] + this.ranges[index + 1];
if (end > offset) {
- high = index;
+ _high = index;
} else {
- low = index;
+ _low = index;
}
}
} else {
- while (high - low > 1) {
- int index = ((high + low) / 2);
- int end = styles[index].start + styles[index].length;
+ while (_high - _low > 1) {
+ int index = ((_high + _low) / 2);
+ int end = this.styles[index].start
+ + this.styles[index].length;
if (end > offset) {
- high = index;
+ _high = index;
} else {
- low = index;
+ _low = index;
}
}
}
- return high;
+ return _high;
}
-
+
void textChanging(TextChangingEvent event) {
int start = event.offset;
int newCharCount = event.newCharCount, replaceCharCount = event.replaceCharCount;
+ @SuppressWarnings("unused")
int newLineCount = event.newLineCount, replaceLineCount = event.replaceLineCount;
-
- updateRanges(start, replaceCharCount, newCharCount);
-//
-// int startLine = getContent().getLineAtOffset(start);
-// if (replaceCharCount == getContent().getCharCount()) lines = null;
-// if (replaceLineCount == lineCount) {
-// lineCount = newLineCount;
-// lineWidth = new int[lineCount];
-// lineHeight = new int[lineCount];
-// reset(0, lineCount);
-// } else {
-// int delta = newLineCount - replaceLineCount;
-// if (lineCount + delta > lineWidth.length) {
-// int[] newWidths = new int[lineCount + delta + GROW];
-// System.arraycopy(lineWidth, 0, newWidths, 0, lineCount);
-// lineWidth = newWidths;
-// int[] newHeights = new int[lineCount + delta + GROW];
-// System.arraycopy(lineHeight, 0, newHeights, 0, lineCount);
-// lineHeight = newHeights;
-// }
-// if (lines != null) {
-// if (lineCount + delta > lines.length) {
-// LineInfo[] newLines = new LineInfo[lineCount + delta + GROW];
-// System.arraycopy(lines, 0, newLines, 0, lineCount);
-// lines = newLines;
-// }
-// }
-// int startIndex = startLine + replaceLineCount + 1;
-// int endIndex = startLine + newLineCount + 1;
-// System.arraycopy(lineWidth, startIndex, lineWidth, endIndex, lineCount - startIndex);
-// System.arraycopy(lineHeight, startIndex, lineHeight, endIndex, lineCount - startIndex);
-// for (int i = startLine; i < endIndex; i++) {
-// lineWidth[i] = lineHeight[i] = -1;
-// }
-// for (int i = lineCount + delta; i < lineCount; i++) {
-// lineWidth[i] = lineHeight[i] = -1;
-// }
-// if (layouts != null) {
-// int layoutStartLine = startLine - topIndex;
-// int layoutEndLine = layoutStartLine + replaceLineCount + 1;
-// for (int i = layoutStartLine; i < layoutEndLine; i++) {
-// if (0 <= i && i < layouts.length) {
-// if (layouts[i] != null) layouts[i].dispose();
-// layouts[i] = null;
-// if (bullets != null && bulletsIndices != null) bullets[i] = null;
-// }
-// }
-// if (delta > 0) {
-// for (int i = layouts.length - 1; i >= layoutEndLine; i--) {
-// if (0 <= i && i < layouts.length) {
-// endIndex = i + delta;
-// if (0 <= endIndex && endIndex < layouts.length) {
-// layouts[endIndex] = layouts[i];
-// layouts[i] = null;
-// if (bullets != null && bulletsIndices != null) {
-// bullets[endIndex] = bullets[i];
-// bulletsIndices[endIndex] = bulletsIndices[i];
-// bullets[i] = null;
-// }
-// } else {
-// if (layouts[i] != null) layouts[i].dispose();
-// layouts[i] = null;
-// if (bullets != null && bulletsIndices != null) bullets[i] = null;
-// }
-// }
-// }
-// } else if (delta < 0) {
-// for (int i = layoutEndLine; i < layouts.length; i++) {
-// if (0 <= i && i < layouts.length) {
-// endIndex = i + delta;
-// if (0 <= endIndex && endIndex < layouts.length) {
-// layouts[endIndex] = layouts[i];
-// layouts[i] = null;
-// if (bullets != null && bulletsIndices != null) {
-// bullets[endIndex] = bullets[i];
-// bulletsIndices[endIndex] = bulletsIndices[i];
-// bullets[i] = null;
-// }
-// } else {
-// if (layouts[i] != null) layouts[i].dispose();
-// layouts[i] = null;
-// if (bullets != null && bulletsIndices != null) bullets[i] = null;
-// }
-// }
-// }
-// }
-// }
-// if (replaceLineCount != 0 || newLineCount != 0) {
-// int startLineOffset = getContent().getOffsetAtLine(startLine);
-// if (startLineOffset != start) startLine++;
-// updateBullets(startLine, replaceLineCount, newLineCount, true);
-// if (lines != null) {
-// startIndex = startLine + replaceLineCount;
-// endIndex = startLine + newLineCount;
-// System.arraycopy(lines, startIndex, lines, endIndex, lineCount - startIndex);
-// for (int i = startLine; i < endIndex; i++) {
-// lines[i] = null;
-// }
-// for (int i = lineCount + delta; i < lineCount; i++) {
-// lines[i] = null;
-// }
-// }
-// }
-// lineCount += delta;
-// if (maxWidthLineIndex != -1 && startLine <= maxWidthLineIndex && maxWidthLineIndex <= startLine + replaceLineCount) {
-// maxWidth = 0;
-// maxWidthLineIndex = -1;
-// for (int i = 0; i < lineCount; i++) {
-// if (lineWidth[i] > maxWidth) {
-// maxWidth = lineWidth[i];
-// maxWidthLineIndex = i;
-// }
-// }
-// }
-// }
+
+ updateRanges(start, replaceCharCount, newCharCount);
+ //
+ // int startLine = getContent().getLineAtOffset(start);
+ // if (replaceCharCount == getContent().getCharCount()) lines =
+ // null;
+ // if (replaceLineCount == lineCount) {
+ // lineCount = newLineCount;
+ // lineWidth = new int[lineCount];
+ // lineHeight = new int[lineCount];
+ // reset(0, lineCount);
+ // } else {
+ // int delta = newLineCount - replaceLineCount;
+ // if (lineCount + delta > lineWidth.length) {
+ // int[] newWidths = new int[lineCount + delta + GROW];
+ // System.arraycopy(lineWidth, 0, newWidths, 0, lineCount);
+ // lineWidth = newWidths;
+ // int[] newHeights = new int[lineCount + delta + GROW];
+ // System.arraycopy(lineHeight, 0, newHeights, 0, lineCount);
+ // lineHeight = newHeights;
+ // }
+ // if (lines != null) {
+ // if (lineCount + delta > lines.length) {
+ // LineInfo[] newLines = new LineInfo[lineCount + delta + GROW];
+ // System.arraycopy(lines, 0, newLines, 0, lineCount);
+ // lines = newLines;
+ // }
+ // }
+ // int startIndex = startLine + replaceLineCount + 1;
+ // int endIndex = startLine + newLineCount + 1;
+ // System.arraycopy(lineWidth, startIndex, lineWidth, endIndex,
+ // lineCount - startIndex);
+ // System.arraycopy(lineHeight, startIndex, lineHeight, endIndex,
+ // lineCount - startIndex);
+ // for (int i = startLine; i < endIndex; i++) {
+ // lineWidth[i] = lineHeight[i] = -1;
+ // }
+ // for (int i = lineCount + delta; i < lineCount; i++) {
+ // lineWidth[i] = lineHeight[i] = -1;
+ // }
+ // if (layouts != null) {
+ // int layoutStartLine = startLine - topIndex;
+ // int layoutEndLine = layoutStartLine + replaceLineCount + 1;
+ // for (int i = layoutStartLine; i < layoutEndLine; i++) {
+ // if (0 <= i && i < layouts.length) {
+ // if (layouts[i] != null) layouts[i].dispose();
+ // layouts[i] = null;
+ // if (bullets != null && bulletsIndices != null) bullets[i] = null;
+ // }
+ // }
+ // if (delta > 0) {
+ // for (int i = layouts.length - 1; i >= layoutEndLine; i--) {
+ // if (0 <= i && i < layouts.length) {
+ // endIndex = i + delta;
+ // if (0 <= endIndex && endIndex < layouts.length) {
+ // layouts[endIndex] = layouts[i];
+ // layouts[i] = null;
+ // if (bullets != null && bulletsIndices != null) {
+ // bullets[endIndex] = bullets[i];
+ // bulletsIndices[endIndex] = bulletsIndices[i];
+ // bullets[i] = null;
+ // }
+ // } else {
+ // if (layouts[i] != null) layouts[i].dispose();
+ // layouts[i] = null;
+ // if (bullets != null && bulletsIndices != null) bullets[i] = null;
+ // }
+ // }
+ // }
+ // } else if (delta < 0) {
+ // for (int i = layoutEndLine; i < layouts.length; i++) {
+ // if (0 <= i && i < layouts.length) {
+ // endIndex = i + delta;
+ // if (0 <= endIndex && endIndex < layouts.length) {
+ // layouts[endIndex] = layouts[i];
+ // layouts[i] = null;
+ // if (bullets != null && bulletsIndices != null) {
+ // bullets[endIndex] = bullets[i];
+ // bulletsIndices[endIndex] = bulletsIndices[i];
+ // bullets[i] = null;
+ // }
+ // } else {
+ // if (layouts[i] != null) layouts[i].dispose();
+ // layouts[i] = null;
+ // if (bullets != null && bulletsIndices != null) bullets[i] = null;
+ // }
+ // }
+ // }
+ // }
+ // }
+ // if (replaceLineCount != 0 || newLineCount != 0) {
+ // int startLineOffset = getContent().getOffsetAtLine(startLine);
+ // if (startLineOffset != start) startLine++;
+ // updateBullets(startLine, replaceLineCount, newLineCount, true);
+ // if (lines != null) {
+ // startIndex = startLine + replaceLineCount;
+ // endIndex = startLine + newLineCount;
+ // System.arraycopy(lines, startIndex, lines, endIndex, lineCount -
+ // startIndex);
+ // for (int i = startLine; i < endIndex; i++) {
+ // lines[i] = null;
+ // }
+ // for (int i = lineCount + delta; i < lineCount; i++) {
+ // lines[i] = null;
+ // }
+ // }
+ // }
+ // lineCount += delta;
+ // if (maxWidthLineIndex != -1 && startLine <= maxWidthLineIndex &&
+ // maxWidthLineIndex <= startLine + replaceLineCount) {
+ // maxWidth = 0;
+ // maxWidthLineIndex = -1;
+ // for (int i = 0; i < lineCount; i++) {
+ // if (lineWidth[i] > maxWidth) {
+ // maxWidth = lineWidth[i];
+ // maxWidthLineIndex = i;
+ // }
+ // }
+ // }
+ // }
}
-
- int addMerge(int[] mergeRanges, StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
- int rangeCount = styleCount << 1;
+
+ int addMerge(int[] mergeRanges, StyleRange[] mergeStyles,
+ int mergeCount, int modifyStart, int modifyEnd) {
+ int _mergeCount = mergeCount;
+ int _modifyEnd = modifyEnd;
+ int rangeCount = this.styleCount << 1;
StyleRange endStyle = null;
int endStart = 0, endLength = 0;
- if (modifyEnd < rangeCount) {
- endStyle = styles[modifyEnd >> 1];
- endStart = ranges[modifyEnd];
- endLength = ranges[modifyEnd + 1];
+ if (_modifyEnd < rangeCount) {
+ endStyle = this.styles[_modifyEnd >> 1];
+ endStart = this.ranges[_modifyEnd];
+ endLength = this.ranges[_modifyEnd + 1];
}
- int grow = mergeCount - (modifyEnd - modifyStart);
- if (rangeCount + grow >= ranges.length) {
- int[] tmpRanges = new int[ranges.length + grow + (GROW << 1)];
- System.arraycopy(ranges, 0, tmpRanges, 0, modifyStart);
- StyleRange[] tmpStyles = new StyleRange[styles.length + (grow >> 1) + GROW];
- System.arraycopy(styles, 0, tmpStyles, 0, modifyStart >> 1);
- if (rangeCount > modifyEnd) {
- System.arraycopy(ranges, modifyEnd, tmpRanges, modifyStart + mergeCount, rangeCount - modifyEnd);
- System.arraycopy(styles, modifyEnd >> 1, tmpStyles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+ int grow = _mergeCount - (_modifyEnd - modifyStart);
+ if (rangeCount + grow >= this.ranges.length) {
+ int[] tmpRanges = new int[this.ranges.length + grow
+ + (GROW << 1)];
+ System.arraycopy(this.ranges, 0, tmpRanges, 0, modifyStart);
+ StyleRange[] tmpStyles = new StyleRange[this.styles.length
+ + (grow >> 1) + GROW];
+ System.arraycopy(this.styles, 0, tmpStyles, 0, modifyStart >> 1);
+ if (rangeCount > _modifyEnd) {
+ System.arraycopy(this.ranges, _modifyEnd, tmpRanges,
+ modifyStart + _mergeCount, rangeCount - _modifyEnd);
+ System.arraycopy(this.styles, _modifyEnd >> 1, tmpStyles,
+ (modifyStart + _mergeCount) >> 1, this.styleCount
+ - (_modifyEnd >> 1));
}
- ranges = tmpRanges;
- styles = tmpStyles;
+ this.ranges = tmpRanges;
+ this.styles = tmpStyles;
} else {
- if (rangeCount > modifyEnd) {
- System.arraycopy(ranges, modifyEnd, ranges, modifyStart + mergeCount, rangeCount - modifyEnd);
- System.arraycopy(styles, modifyEnd >> 1, styles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+ if (rangeCount > _modifyEnd) {
+ System.arraycopy(this.ranges, _modifyEnd, this.ranges,
+ modifyStart + _mergeCount, rangeCount - _modifyEnd);
+ System.arraycopy(this.styles, _modifyEnd >> 1, this.styles,
+ (modifyStart + _mergeCount) >> 1, this.styleCount
+ - (_modifyEnd >> 1));
}
}
if (MERGE_STYLES) {
- int j = modifyStart;
- for (int i = 0; i < mergeCount; i += 2) {
- if (j > 0 && ranges[j - 2] + ranges[j - 1] == mergeRanges[i] && mergeStyles[i >> 1].similarTo(styles[(j - 2) >> 1])) {
- ranges[j - 1] += mergeRanges[i + 1];
+ int j = modifyStart;
+ for (int i = 0; i < _mergeCount; i += 2) {
+ if (j > 0
+ && this.ranges[j - 2] + this.ranges[j - 1] == mergeRanges[i]
+ && mergeStyles[i >> 1]
+ .similarTo(this.styles[(j - 2) >> 1])) {
+ this.ranges[j - 1] += mergeRanges[i + 1];
} else {
- styles[j >> 1] = mergeStyles[i >> 1];
- ranges[j++] = mergeRanges[i];
- ranges[j++] = mergeRanges[i + 1];
+ this.styles[j >> 1] = mergeStyles[i >> 1];
+ this.ranges[j++] = mergeRanges[i];
+ this.ranges[j++] = mergeRanges[i + 1];
}
}
- if (endStyle != null && ranges[j - 2] + ranges[j - 1] == endStart && endStyle.similarTo(styles[(j - 2) >> 1])) {
- ranges[j - 1] += endLength;
- modifyEnd += 2;
- mergeCount += 2;
+ if (endStyle != null
+ && this.ranges[j - 2] + this.ranges[j - 1] == endStart
+ && endStyle.similarTo(this.styles[(j - 2) >> 1])) {
+ this.ranges[j - 1] += endLength;
+ _modifyEnd += 2;
+ _mergeCount += 2;
}
- if (rangeCount > modifyEnd) {
- System.arraycopy(ranges, modifyStart + mergeCount, ranges, j, rangeCount - modifyEnd);
- System.arraycopy(styles, (modifyStart + mergeCount) >> 1, styles, j >> 1, styleCount - (modifyEnd >> 1));
+ if (rangeCount > _modifyEnd) {
+ System.arraycopy(this.ranges, modifyStart + _mergeCount,
+ this.ranges, j, rangeCount - _modifyEnd);
+ System.arraycopy(this.styles,
+ (modifyStart + _mergeCount) >> 1, this.styles,
+ j >> 1, this.styleCount - (_modifyEnd >> 1));
}
- grow = (j - modifyStart) - (modifyEnd - modifyStart);
+ grow = (j - modifyStart) - (_modifyEnd - modifyStart);
} else {
- System.arraycopy(mergeRanges, 0, ranges, modifyStart, mergeCount);
- System.arraycopy(mergeStyles, 0, styles, modifyStart >> 1, mergeCount >> 1);
+ System.arraycopy(mergeRanges, 0, this.ranges, modifyStart,
+ _mergeCount);
+ System.arraycopy(mergeStyles, 0, this.styles, modifyStart >> 1,
+ _mergeCount >> 1);
}
- styleCount += grow >> 1;
+ this.styleCount += grow >> 1;
return grow;
}
- int addMerge(StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
- int grow = mergeCount - (modifyEnd - modifyStart);
+
+ int addMerge(StyleRange[] mergeStyles, int mergeCount, int modifyStart,
+ int modifyEnd) {
+ int _mergeCount = mergeCount;
+ int _modifyEnd = modifyEnd;
+ int grow = _mergeCount - (_modifyEnd - modifyStart);
StyleRange endStyle = null;
- if (modifyEnd < styleCount) endStyle = styles[modifyEnd];
- if (styleCount + grow >= styles.length) {
- StyleRange[] tmpStyles = new StyleRange[styles.length + grow + GROW];
- System.arraycopy(styles, 0, tmpStyles, 0, modifyStart);
- if (styleCount > modifyEnd) {
- System.arraycopy(styles, modifyEnd, tmpStyles, modifyStart + mergeCount, styleCount - modifyEnd);
+ if (_modifyEnd < this.styleCount)
+ endStyle = this.styles[_modifyEnd];
+ if (this.styleCount + grow >= this.styles.length) {
+ StyleRange[] tmpStyles = new StyleRange[this.styles.length
+ + grow + GROW];
+ System.arraycopy(this.styles, 0, tmpStyles, 0, modifyStart);
+ if (this.styleCount > _modifyEnd) {
+ System.arraycopy(this.styles, _modifyEnd, tmpStyles,
+ modifyStart + _mergeCount, this.styleCount
+ - _modifyEnd);
}
- styles = tmpStyles;
+ this.styles = tmpStyles;
} else {
- if (styleCount > modifyEnd) {
- System.arraycopy(styles, modifyEnd, styles, modifyStart + mergeCount, styleCount - modifyEnd);
+ if (this.styleCount > _modifyEnd) {
+ System.arraycopy(this.styles, _modifyEnd, this.styles,
+ modifyStart + _mergeCount, this.styleCount
+ - _modifyEnd);
}
}
if (MERGE_STYLES) {
int j = modifyStart;
- for (int i = 0; i < mergeCount; i++) {
+ for (int i = 0; i < _mergeCount; i++) {
StyleRange newStyle = mergeStyles[i], style;
- if (j > 0 && (style = styles[j - 1]).start + style.length == newStyle.start && newStyle.similarTo(style)) {
+ if (j > 0
+ && (style = this.styles[j - 1]).start
+ + style.length == newStyle.start
+ && newStyle.similarTo(style)) {
style.length += newStyle.length;
} else {
- styles[j++] = newStyle;
+ this.styles[j++] = newStyle;
}
}
- StyleRange style = styles[j - 1];
- if (endStyle != null && style.start + style.length == endStyle.start && endStyle.similarTo(style)) {
+ StyleRange style = this.styles[j - 1];
+ if (endStyle != null
+ && style.start + style.length == endStyle.start
+ && endStyle.similarTo(style)) {
style.length += endStyle.length;
- modifyEnd++;
- mergeCount++;
+ _modifyEnd++;
+ _mergeCount++;
}
- if (styleCount > modifyEnd) {
- System.arraycopy(styles, modifyStart + mergeCount, styles, j, styleCount - modifyEnd);
+ if (this.styleCount > _modifyEnd) {
+ System.arraycopy(this.styles, modifyStart + _mergeCount,
+ this.styles, j, this.styleCount - _modifyEnd);
}
- grow = (j - modifyStart) - (modifyEnd - modifyStart);
+ grow = (j - modifyStart) - (_modifyEnd - modifyStart);
} else {
- System.arraycopy(mergeStyles, 0, styles, modifyStart, mergeCount);
+ System.arraycopy(mergeStyles, 0, this.styles, modifyStart,
+ _mergeCount);
}
- styleCount += grow;
+ this.styleCount += grow;
return grow;
}
-
+
void updateRanges(int start, int replaceCharCount, int newCharCount) {
- if (styleCount == 0 || (replaceCharCount == 0 && newCharCount == 0)) return;
- if (ranges != null) {
- int rangeCount = styleCount << 1;
+ if (this.styleCount == 0
+ || (replaceCharCount == 0 && newCharCount == 0))
+ return;
+ if (this.ranges != null) {
+ int rangeCount = this.styleCount << 1;
int modifyStart = getRangeIndex(start, -1, rangeCount);
- if (modifyStart == rangeCount) return;
+ if (modifyStart == rangeCount)
+ return;
int end = start + replaceCharCount;
int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
int offset = newCharCount - replaceCharCount;
- if (modifyStart == modifyEnd && ranges[modifyStart] < start && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+ if (modifyStart == modifyEnd
+ && this.ranges[modifyStart] < start
+ && end < this.ranges[modifyEnd]
+ + this.ranges[modifyEnd + 1]) {
if (newCharCount == 0) {
- ranges[modifyStart + 1] -= replaceCharCount;
+ this.ranges[modifyStart + 1] -= replaceCharCount;
modifyEnd += 2;
} else {
- if (rangeCount + 2 > ranges.length) {
- int[] newRanges = new int[ranges.length + (GROW << 1)];
- System.arraycopy(ranges, 0, newRanges, 0, rangeCount);
- ranges = newRanges;
- StyleRange[] newStyles = new StyleRange[styles.length + GROW];
- System.arraycopy(styles, 0, newStyles, 0, styleCount);
- styles = newStyles;
+ if (rangeCount + 2 > this.ranges.length) {
+ int[] newRanges = new int[this.ranges.length
+ + (GROW << 1)];
+ System.arraycopy(this.ranges, 0, newRanges, 0,
+ rangeCount);
+ this.ranges = newRanges;
+ StyleRange[] newStyles = new StyleRange[this.styles.length
+ + GROW];
+ System.arraycopy(this.styles, 0, newStyles, 0,
+ this.styleCount);
+ this.styles = newStyles;
}
- System.arraycopy(ranges, modifyStart + 2, ranges, modifyStart + 4, rangeCount - (modifyStart + 2));
- System.arraycopy(styles, (modifyStart + 2) >> 1, styles, (modifyStart + 4) >> 1, styleCount - ((modifyStart + 2) >> 1));
- ranges[modifyStart + 3] = ranges[modifyStart] + ranges[modifyStart + 1] - end;
- ranges[modifyStart + 2] = start + newCharCount;
- ranges[modifyStart + 1] = start - ranges[modifyStart];
- styles[(modifyStart >> 1) + 1] = styles[modifyStart >> 1];
+ System.arraycopy(this.ranges, modifyStart + 2,
+ this.ranges, modifyStart + 4, rangeCount
+ - (modifyStart + 2));
+ System.arraycopy(this.styles, (modifyStart + 2) >> 1,
+ this.styles, (modifyStart + 4) >> 1,
+ this.styleCount - ((modifyStart + 2) >> 1));
+ this.ranges[modifyStart + 3] = this.ranges[modifyStart]
+ + this.ranges[modifyStart + 1] - end;
+ this.ranges[modifyStart + 2] = start + newCharCount;
+ this.ranges[modifyStart + 1] = start
+ - this.ranges[modifyStart];
+ this.styles[(modifyStart >> 1) + 1] = this.styles[modifyStart >> 1];
rangeCount += 2;
- styleCount++;
+ this.styleCount++;
modifyEnd += 4;
}
if (offset != 0) {
for (int i = modifyEnd; i < rangeCount; i += 2) {
- ranges[i] += offset;
+ this.ranges[i] += offset;
}
}
} else {
- if (ranges[modifyStart] < start && start < ranges[modifyStart] + ranges[modifyStart + 1]) {
- ranges[modifyStart + 1] = start - ranges[modifyStart];
+ if (this.ranges[modifyStart] < start
+ && start < this.ranges[modifyStart]
+ + this.ranges[modifyStart + 1]) {
+ this.ranges[modifyStart + 1] = start
+ - this.ranges[modifyStart];
modifyStart += 2;
}
- if (modifyEnd < rangeCount && ranges[modifyEnd] < end && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
- ranges[modifyEnd + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - end;
- ranges[modifyEnd] = end;
+ if (modifyEnd < rangeCount
+ && this.ranges[modifyEnd] < end
+ && end < this.ranges[modifyEnd]
+ + this.ranges[modifyEnd + 1]) {
+ this.ranges[modifyEnd + 1] = this.ranges[modifyEnd]
+ + this.ranges[modifyEnd + 1] - end;
+ this.ranges[modifyEnd] = end;
}
if (offset != 0) {
for (int i = modifyEnd; i < rangeCount; i += 2) {
- ranges[i] += offset;
+ this.ranges[i] += offset;
}
}
- System.arraycopy(ranges, modifyEnd, ranges, modifyStart, rangeCount - modifyEnd);
- System.arraycopy(styles, modifyEnd >> 1, styles, modifyStart >> 1, styleCount - (modifyEnd >> 1));
- styleCount -= (modifyEnd - modifyStart) >> 1;
+ System.arraycopy(this.ranges, modifyEnd, this.ranges,
+ modifyStart, rangeCount - modifyEnd);
+ System.arraycopy(this.styles, modifyEnd >> 1, this.styles,
+ modifyStart >> 1, this.styleCount
+ - (modifyEnd >> 1));
+ this.styleCount -= (modifyEnd - modifyStart) >> 1;
}
} else {
- int modifyStart = getRangeIndex(start, -1, styleCount);
- if (modifyStart == styleCount) return;
+ int modifyStart = getRangeIndex(start, -1, this.styleCount);
+ if (modifyStart == this.styleCount)
+ return;
int end = start + replaceCharCount;
- int modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
+ int modifyEnd = getRangeIndex(end, modifyStart - 1,
+ this.styleCount);
int offset = newCharCount - replaceCharCount;
- if (modifyStart == modifyEnd && styles[modifyStart].start < start && end < styles[modifyEnd].start + styles[modifyEnd].length) {
+ if (modifyStart == modifyEnd
+ && this.styles[modifyStart].start < start
+ && end < this.styles[modifyEnd].start
+ + this.styles[modifyEnd].length) {
if (newCharCount == 0) {
- styles[modifyStart].length -= replaceCharCount;
+ this.styles[modifyStart].length -= replaceCharCount;
modifyEnd++;
} else {
- if (styleCount + 1 > styles.length) {
- StyleRange[] newStyles = new StyleRange[styles.length + GROW];
- System.arraycopy(styles, 0, newStyles, 0, styleCount);
- styles = newStyles;
+ if (this.styleCount + 1 > this.styles.length) {
+ StyleRange[] newStyles = new StyleRange[this.styles.length
+ + GROW];
+ System.arraycopy(this.styles, 0, newStyles, 0,
+ this.styleCount);
+ this.styles = newStyles;
}
- System.arraycopy(styles, modifyStart + 1, styles, modifyStart + 2, styleCount - (modifyStart + 1));
- styles[modifyStart + 1] = (StyleRange)styles[modifyStart].clone();
- styles[modifyStart + 1].length = styles[modifyStart].start + styles[modifyStart].length - end;
- styles[modifyStart + 1].start = start + newCharCount;
- styles[modifyStart].length = start - styles[modifyStart].start;
- styleCount++;
+ System.arraycopy(this.styles, modifyStart + 1,
+ this.styles, modifyStart + 2, this.styleCount
+ - (modifyStart + 1));
+ this.styles[modifyStart + 1] = (StyleRange) this.styles[modifyStart]
+ .clone();
+ this.styles[modifyStart + 1].length = this.styles[modifyStart].start
+ + this.styles[modifyStart].length - end;
+ this.styles[modifyStart + 1].start = start
+ + newCharCount;
+ this.styles[modifyStart].length = start
+ - this.styles[modifyStart].start;
+ this.styleCount++;
modifyEnd += 2;
}
if (offset != 0) {
- for (int i = modifyEnd; i < styleCount; i++) {
- styles[i].start += offset;
+ for (int i = modifyEnd; i < this.styleCount; i++) {
+ this.styles[i].start += offset;
}
}
} else {
- if (styles[modifyStart].start < start && start < styles[modifyStart].start + styles[modifyStart].length) {
- styles[modifyStart].length = start - styles[modifyStart].start;
+ if (this.styles[modifyStart].start < start
+ && start < this.styles[modifyStart].start
+ + this.styles[modifyStart].length) {
+ this.styles[modifyStart].length = start
+ - this.styles[modifyStart].start;
modifyStart++;
}
- if (modifyEnd < styleCount && styles[modifyEnd].start < end && end < styles[modifyEnd].start + styles[modifyEnd].length) {
- styles[modifyEnd].length = styles[modifyEnd].start + styles[modifyEnd].length - end;
- styles[modifyEnd].start = end;
+ if (modifyEnd < this.styleCount
+ && this.styles[modifyEnd].start < end
+ && end < this.styles[modifyEnd].start
+ + this.styles[modifyEnd].length) {
+ this.styles[modifyEnd].length = this.styles[modifyEnd].start
+ + this.styles[modifyEnd].length - end;
+ this.styles[modifyEnd].start = end;
}
if (offset != 0) {
- for (int i = modifyEnd; i < styleCount; i++) {
- styles[i].start += offset;
+ for (int i = modifyEnd; i < this.styleCount; i++) {
+ this.styles[i].start += offset;
}
}
- System.arraycopy(styles, modifyEnd, styles, modifyStart, styleCount - modifyEnd);
- styleCount -= modifyEnd - modifyStart;
+ System.arraycopy(this.styles, modifyEnd, this.styles,
+ modifyStart, this.styleCount - modifyEnd);
+ this.styleCount -= modifyEnd - modifyStart;
}
}
}
-
+
StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) {
- if (length == 0) return null;
+ if (length == 0)
+ return null;
StyleRange[] newStyles;
int end = start + length - 1;
- if (ranges != null) {
- int rangeCount = styleCount << 1;
+ if (this.ranges != null) {
+ int rangeCount = this.styleCount << 1;
int rangeStart = getRangeIndex(start, -1, rangeCount);
- if (rangeStart >= rangeCount) return null;
- if (ranges[rangeStart] > end) return null;
- int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount));
- if (ranges[rangeEnd] > end) rangeEnd = Math.max(rangeStart, rangeEnd - 2);
+ if (rangeStart >= rangeCount)
+ return null;
+ if (this.ranges[rangeStart] > end)
+ return null;
+ int rangeEnd = Math.min(rangeCount - 2,
+ getRangeIndex(end, rangeStart - 1, rangeCount));
+ if (this.ranges[rangeEnd] > end)
+ rangeEnd = Math.max(rangeStart, rangeEnd - 2);
newStyles = new StyleRange[((rangeEnd - rangeStart) >> 1) + 1];
if (includeRanges) {
for (int i = rangeStart, j = 0; i <= rangeEnd; i += 2, j++) {
- newStyles[j] = (StyleRange)styles[i >> 1].clone();
- newStyles[j].start = ranges[i];
- newStyles[j].length = ranges[i + 1];
+ newStyles[j] = (StyleRange) this.styles[i >> 1].clone();
+ newStyles[j].start = this.ranges[i];
+ newStyles[j].length = this.ranges[i + 1];
}
} else {
- System.arraycopy(styles, rangeStart >> 1, newStyles, 0, newStyles.length);
+ System.arraycopy(this.styles, rangeStart >> 1, newStyles,
+ 0, newStyles.length);
}
} else {
- int rangeStart = getRangeIndex(start, -1, styleCount);
- if (rangeStart >= styleCount) return null;
- if (styles[rangeStart].start > end) return null;
- int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
- if (styles[rangeEnd].start > end) rangeEnd = Math.max(rangeStart, rangeEnd - 1);
+ int rangeStart = getRangeIndex(start, -1, this.styleCount);
+ if (rangeStart >= this.styleCount)
+ return null;
+ if (this.styles[rangeStart].start > end)
+ return null;
+ int rangeEnd = Math.min(this.styleCount - 1,
+ getRangeIndex(end, rangeStart - 1, this.styleCount));
+ if (this.styles[rangeEnd].start > end)
+ rangeEnd = Math.max(rangeStart, rangeEnd - 1);
newStyles = new StyleRange[rangeEnd - rangeStart + 1];
- System.arraycopy(styles, rangeStart, newStyles, 0, newStyles.length);
+ System.arraycopy(this.styles, rangeStart, newStyles, 0,
+ newStyles.length);
}
- if (includeRanges || ranges == null) {
+ if (includeRanges || this.ranges == null) {
StyleRange style = newStyles[0];
if (start > style.start) {
- newStyles[0] = style = (StyleRange)style.clone();
+ newStyles[0] = style = (StyleRange) style.clone();
style.length = style.start + style.length - start;
style.start = start;
}
style = newStyles[newStyles.length - 1];
if (end < style.start + style.length - 1) {
- newStyles[newStyles.length - 1] = style = (StyleRange)style.clone();
+ newStyles[newStyles.length - 1] = style = (StyleRange) style
+ .clone();
style.length = end - style.start + 1;
}
}
return newStyles;
}
}
-
+
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
+ * Copyright (c) 2000, 2011 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
+ * Contributors: IBM Corporation - initial API and implementation
*******************************************************************************/
static class DefaultContent implements StyledTextContent {
@@ -942,68 +1298,76 @@ public class StyledTextArea extends Control {
private int expandExp = 1;
private int replaceExpandExp;
-// private List<TextChangeListener> textChangeListeners= new ArrayList<>(1);
-
+ // private List<TextChangeListener> textChangeListeners= new
+ // ArrayList<>(1);
+
@Override
public void setText(String text) {
- textStore = text.toCharArray();
+ this.textStore = text.toCharArray();
indexLines();
}
-
+
@Override
public void addTextChangeListener(TextChangeListener listener) {
// TODO Auto-generated method stub
-
+
}
-
+
@Override
public void removeTextChangeListener(TextChangeListener listener) {
// TODO Auto-generated method stub
-
+
}
-
+
+ @Override
public int getCharCount() {
-// int length = gapEnd - gapStart;
-// return (textStore.length - length);
- return textStore.length;
+ // int length = gapEnd - gapStart;
+ // return (textStore.length - length);
+ return this.textStore.length;
}
+ @Override
public String getTextRange(int start, int length) {
- return new String(textStore,start,length);
+ return new String(this.textStore, start, length);
}
-
+
+ @Override
public String getLine(int index) {
- int start = lines[index][0];
- int length = lines[index][1];
-
- return new String(textStore,start,length);
+ int start = this.lines[index][0];
+ int length = this.lines[index][1];
+
+ return new String(this.textStore, start, length);
}
-
- public int getLineCount(){
- return lineCount;
+
+ @Override
+ public int getLineCount() {
+ return this.lineCount;
}
-
+
+ @Override
public int getOffsetAtLine(int lineIndex) {
- int start = lines[lineIndex][0];
+ int start = this.lines[lineIndex][0];
return start;
}
-
+
+ @Override
public int getLineAtOffset(int charPosition) {
int position = charPosition;
-
- if (lineCount > 0) {
- int lastLine = lineCount - 1;
- if (position == lines[lastLine][0] + lines[lastLine][1])
+
+ if (this.lineCount > 0) {
+ int lastLine = this.lineCount - 1;
+ if (position == this.lines[lastLine][0]
+ + this.lines[lastLine][1])
return lastLine;
}
-
- int high = lineCount;
+
+ int high = this.lineCount;
int low = -1;
- int index = lineCount;
+ int index = this.lineCount;
while (high - low > 1) {
index = (high + low) / 2;
- int lineStart = lines[index][0];
- int lineEnd = lineStart + lines[index][1] - 1;
+ int lineStart = this.lines[index][0];
+ int lineEnd = lineStart + this.lines[index][1] - 1;
if (position <= lineStart) {
high = index;
} else if (position <= lineEnd) {
@@ -1015,18 +1379,18 @@ public class StyledTextArea extends Control {
}
return high;
}
-
- void indexLines(){
+
+ void indexLines() {
int start = 0;
- lineCount = 0;
- int textLength = textStore.length;
+ this.lineCount = 0;
+ int textLength = this.textStore.length;
int i;
for (i = start; i < textLength; i++) {
- char ch = textStore[i];
+ char ch = this.textStore[i];
if (ch == '\r') {
// see if the next character is a LF
if (i + 1 < textLength) {
- ch = textStore[i+1];
+ ch = this.textStore[i + 1];
if (ch == '\n') {
i++;
}
@@ -1040,159 +1404,166 @@ public class StyledTextArea extends Control {
}
addLineIndex(start, i - start);
}
-
+
void addLineIndex(int start, int length) {
- int size = lines.length;
- if (lineCount == size) {
+ int size = this.lines.length;
+ if (this.lineCount == size) {
// expand the lines by powers of 2
- int[][] newLines = new int[size+pow2(expandExp)][2];
- System.arraycopy(lines, 0, newLines, 0, size);
- lines = newLines;
- expandExp++;
+ int[][] newLines = new int[size + pow2(this.expandExp)][2];
+ System.arraycopy(this.lines, 0, newLines, 0, size);
+ this.lines = newLines;
+ this.expandExp++;
}
- int[] range = new int[] {start, length};
- lines[lineCount] = range;
- lineCount++;
+ int[] range = new int[] { start, length };
+ this.lines[this.lineCount] = range;
+ this.lineCount++;
}
-
- public void replaceTextRange(int start, int replaceLength, String newText){
+
+ @Override
+ public void replaceTextRange(int start, int replaceLength,
+ String newText) {
// first delete the text to be replaced
-// delete(start, replaceLength, event.replaceLineCount + 1);
-
+ // delete(start, replaceLength, event.replaceLineCount + 1);
+
// then insert the new text
insert(start, newText);
}
-
- void insert(int position, String text) {
- if (text.length() == 0) return;
-
+
+ void insert(int position, String text) {
+ if (text.length() == 0)
+ return;
+
int startLine = getLineAtOffset(position);
int change = text.length();
boolean endInsert = position == getCharCount();
// during an insert the gap will be adjusted to start at
// position and it will be associated with startline, the
- // inserted text will be placed in the gap
+ // inserted text will be placed in the gap
int startLineOffset = getOffsetAtLine(startLine);
// at this point, startLineLength will include the start line
// and all of the newly inserted text
- int startLineLength = getPhysicalLine(startLine).length();
-
+ int startLineLength = getPhysicalLine(startLine).length();
+
if (change > 0) {
- // shrink gap
-// gapStart += (change);
+ // shrink gap
+ // gapStart += (change);
for (int i = 0; i < text.length(); i++) {
- textStore[position + i]= text.charAt(i);
+ this.textStore[position + i] = text.charAt(i);
}
}
-
+
// figure out the number of new lines that have been inserted
- int [][] newLines = indexLines(startLineOffset, startLineLength, 10);
+ int[][] newLines = indexLines(startLineOffset, startLineLength, 10);
// only insert an empty line if it is the last line in the text
int numNewLines = newLines.length - 1;
if (newLines[numNewLines][1] == 0) {
// last inserted line is a new line
if (endInsert) {
// insert happening at end of the text, leave numNewLines as
- // is since the last new line will not be concatenated with another
- // line
+ // is since the last new line will not be concatenated with
+ // another
+ // line
numNewLines += 1;
} else {
numNewLines -= 1;
}
}
-
+
// make room for the new lines
expandLinesBy(numNewLines);
// shift down the lines after the replace line
- for (int i = lineCount - 1; i > startLine; i--) {
- lines[i + numNewLines]=lines[i];
+ for (int i = this.lineCount - 1; i > startLine; i--) {
+ this.lines[i + numNewLines] = this.lines[i];
}
// insert the new lines
for (int i = 0; i < numNewLines; i++) {
newLines[i][0] += startLineOffset;
- lines[startLine + i]=newLines[i];
+ this.lines[startLine + i] = newLines[i];
}
// update the last inserted line
if (numNewLines < newLines.length) {
newLines[numNewLines][0] += startLineOffset;
- lines[startLine + numNewLines] = newLines[numNewLines];
+ this.lines[startLine + numNewLines] = newLines[numNewLines];
}
-
- lineCount += numNewLines;
-// gapLine = getLineAtPhysicalOffset(gapStart);
+
+ this.lineCount += numNewLines;
+ // gapLine = getLineAtPhysicalOffset(gapStart);
}
-
+
void expandLinesBy(int numLines) {
- int size = lines.length;
- if (size - lineCount >= numLines) {
+ int size = this.lines.length;
+ if (size - this.lineCount >= numLines) {
return;
}
- int[][] newLines = new int[size+Math.max(10, numLines)][2];
- System.arraycopy(lines, 0, newLines, 0, size);
- lines = newLines;
+ int[][] newLines = new int[size + Math.max(10, numLines)][2];
+ System.arraycopy(this.lines, 0, newLines, 0, size);
+ this.lines = newLines;
}
-
+
String getPhysicalLine(int index) {
- int start = lines[index][0];
- int length = lines[index][1];
+ int start = this.lines[index][0];
+ int length = this.lines[index][1];
return getPhysicalText(start, length);
}
-
+
String getPhysicalText(int start, int length) {
- return new String(textStore, start, length);
+ return new String(this.textStore, start, length);
}
-
- int[][] indexLines(int offset, int length, int numLines){
+
+ int[][] indexLines(int offset, int length, int numLines) {
int[][] indexedLines = new int[numLines][2];
int start = 0;
int lineCount = 0;
int i;
- replaceExpandExp = 1;
+ this.replaceExpandExp = 1;
for (i = start; i < length; i++) {
- int location = i + offset;
-// if ((location >= gapStart) && (location < gapEnd)) {
-// // ignore the gap
-// } else {
- char ch = textStore[location];
- if (ch == '\r') {
- // see if the next character is a LF
- if (location+1 < textStore.length) {
- ch = textStore[location+1];
- if (ch == '\n') {
- i++;
- }
+ int location = i + offset;
+ // if ((location >= gapStart) && (location < gapEnd)) {
+ // // ignore the gap
+ // } else {
+ char ch = this.textStore[location];
+ if (ch == '\r') {
+ // see if the next character is a LF
+ if (location + 1 < this.textStore.length) {
+ ch = this.textStore[location + 1];
+ if (ch == '\n') {
+ i++;
}
- indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
- lineCount++;
- start = i + 1;
- } else if (ch == '\n') {
- indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
- lineCount++;
- start = i + 1;
}
-// }
+ indexedLines = addLineIndex(start, i - start + 1,
+ indexedLines, lineCount);
+ lineCount++;
+ start = i + 1;
+ } else if (ch == '\n') {
+ indexedLines = addLineIndex(start, i - start + 1,
+ indexedLines, lineCount);
+ lineCount++;
+ start = i + 1;
+ }
+ // }
}
- int[][] newLines = new int[lineCount+1][2];
+ int[][] newLines = new int[lineCount + 1][2];
System.arraycopy(indexedLines, 0, newLines, 0, lineCount);
- int[] range = new int[] {start, i - start};
+ int[] range = new int[] { start, i - start };
newLines[lineCount] = range;
- return newLines;
+ return newLines;
}
-
- int[][] addLineIndex(int start, int length, int[][] linesArray, int count) {
+
+ int[][] addLineIndex(int start, int length, int[][] linesArray,
+ int count) {
int size = linesArray.length;
int[][] newLines = linesArray;
if (count == size) {
- newLines = new int[size+pow2(replaceExpandExp)][2];
- replaceExpandExp++;
+ newLines = new int[size + pow2(this.replaceExpandExp)][2];
+ this.replaceExpandExp++;
System.arraycopy(linesArray, 0, newLines, 0, size);
}
- int[] range = new int[] {start, length};
+ int[] range = new int[] { start, length };
newLines[count] = range;
return newLines;
}
-
+
public static int pow2(int n) {
if (n >= 1 && n <= 30)
return 2 << (n - 1);
@@ -1203,86 +1574,202 @@ public class StyledTextArea extends Control {
}
}
- public void setTabs(int tabWidth) {
- // TODO Auto-generated method stub
- System.err.println("NOT IMPLEMETNED");
- Thread.dumpStack();
- }
+ // public void setTabs(int tabWidth) {
+ // // keep empty
+ // }
+ //
+ // public void setRedraw(boolean b) {
+ // // keep empty
+ // }
- public void setRedraw(boolean b) {
- // TODO Auto-generated method stub
- System.err.println("NOT IMPLEMETNED");
- Thread.dumpStack();
+ /**
+ * @return the current selection
+ */
+ public @NonNull TextSelection getSelection() {
+ TextSelection textSelection = this.currentSelection.get();
+ if (textSelection == null) {
+ textSelection = new TextSelection(getCaretOffset(), 0);
+ }
+ return textSelection;
}
- public TextSelection getSelection() {
- // TODO Auto-generated method stub
- return new TextSelection(getCaretOffset(), 0);
+ /**
+ * @return the selection property
+ */
+ public @NonNull ObjectProperty<TextSelection> selectionProperty() {
+ return this.currentSelection;
}
-
- public void setSelection(TextSelection selection) {
- if( selection.length == 0 ) {
+
+ /**
+ * Set the current selection
+ *
+ * @param selection
+ * the selection
+ */
+ public void setSelection(@NonNull TextSelection selection) {
+ if (selection.length == 0) {
setCaretOffset(selection.offset);
+ } else {
+ // this.caretOffsetProperty.set(selection.offset+selection.length);
+ this.currentSelection.set(selection);
}
}
-
+
+ /**
+ * Clear the current selection
+ */
+ public void clearSelection() {
+ this.currentSelection.set(null);
+ }
+
+ /**
+ * Set the selection
+ *
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ */
public void setSelectionRange(int offset, int length) {
setSelection(new TextSelection(offset, length));
}
- private BooleanProperty editableProperty = new SimpleBooleanProperty(this, "editableProperty", true);
-
+ @NonNull
+ private final BooleanProperty editableProperty = new SimpleBooleanProperty(
+ this, "editableProperty", true); //$NON-NLS-1$
+
+ /**
+ * Mark the editor editable
+ *
+ * <p>
+ * Default is <code>true</code>
+ * </p>
+ *
+ * @param editable
+ * the new value
+ */
public void setEditable(boolean editable) {
- editableProperty.set(editable);
+ editableProperty().set(editable);
}
-
+
+ /**
+ * Check if editable
+ * <p>
+ * Default is <code>true</code>
+ * </p>
+ *
+ * @return the current value
+ */
public boolean getEditable() {
- return editableProperty.get();
+ return editableProperty().get();
}
-
- private ObjectProperty<Font> fontProperty = new SimpleObjectProperty<>(this, "fontProperty", Font.font("Courier", FontWeight.NORMAL, 15));
-
- public void setFont(Font font) {
- fontProperty.set(font);
- }
-
- public Font getFont() {
- return fontProperty.get();
+ /**
+ * The editable property
+ * <p>
+ * Default is <code>true</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty editableProperty() {
+ return this.editableProperty;
}
-
- public ObjectProperty<Font> fontProperty() {
- return fontProperty;
- }
-
- public Point2D getLocationAtOffset(int offset) {
+
+ /**
+ * Check the location at the given offset
+ *
+ * @param offset
+ * the offset
+ * @return the point
+ */
+ public @Nullable Point2D getLocationAtOffset(int offset) {
if (offset < 0 || offset > getCharCount()) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
}
- return ((StyledTextSkin)getSkin()).getCaretLocation(offset);
+ return ((StyledTextSkin) getSkin()).getCaretLocation(offset);
}
+ /**
+ * Get the line height
+ *
+ * @param offset
+ * the offset
+ * @return the height
+ */
public double getLineHeight(int offset) {
if (offset < 0 || offset > getCharCount()) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException();
}
- return ((StyledTextSkin)getSkin()).getLineHeight(offset);
+ return ((StyledTextSkin) getSkin()).getLineHeight(offset);
}
- public void showSelection() {
- // TODO Auto-generated method stub
-
- }
+ // public void showSelection() {
+ // // TODO Auto-generated method stub
+ //
+ // }
+ /**
+ * Get the line index for the caret
+ *
+ * @param caretOffset
+ * the caret offset
+ * @return the line index
+ */
public int getLineAtOffset(int caretOffset) {
- return contentProperty.get().getLineAtOffset(caretOffset);
+ return getContent().getLineAtOffset(caretOffset);
}
+ /**
+ * Get the initial offset of the line
+ *
+ * @param lineNumber
+ * the line number
+ * @return the offset
+ */
public int getOffsetAtLine(int lineNumber) {
- return contentProperty.get().getOffsetAtLine(lineNumber);
+ return getContent().getOffsetAtLine(lineNumber);
+ }
+
+ /**
+ * Get the text for the given range
+ *
+ * @param start
+ * the start
+ * @param end
+ * the end
+ * @return the text
+ */
+ public @NonNull String getText(int start, int end) {
+ return getContent().getTextRange(start, end - start + 1);
}
- public String getText(int start, int end) {
- return contentProperty.get().getTextRange(start, end - start + 1);
+ /**
+ * Paste the clipboard content
+ */
+ public void paste() {
+ final Clipboard clipboard = Clipboard.getSystemClipboard();
+ if (clipboard.hasString()) {
+ final String text = clipboard.getString();
+ if (text != null) {
+ // TODO Once we have a real selection we need
+ getContent().replaceTextRange(getCaretOffset(), 0, text);
+ setCaretOffset(getCaretOffset() + text.length());
+ }
+ }
+ }
+
+ /**
+ * Copy the current selection into the clipboard
+ */
+ @SuppressWarnings("null")
+ public void copy() {
+ if (getSelection().length > 0) {
+ final Clipboard clipboard = Clipboard.getSystemClipboard();
+ clipboard.setContent(Collections.singletonMap(
+ DataFormat.PLAIN_TEXT,
+ getContent().getTextRange(getSelection().offset,
+ getSelection().length)));
+ }
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextContent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextContent.java
index e63156465..5fcd3dd11 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextContent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/StyledTextContent.java
@@ -11,34 +11,122 @@
*******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
+import org.eclipse.jdt.annotation.NonNull;
-
+/**
+ * Content of the styled text area
+ */
public interface StyledTextContent {
- public String getLine(int index);
-
- public String getTextRange(int start, int length);
-
- public void setText (String text);
-
+ /**
+ * Get the content of the line with the given index
+ *
+ * @param index
+ * the index
+ * @return the line content
+ */
+ public @NonNull String getLine(int index);
+
+ /**
+ * Get the content for the given range
+ *
+ * @param start
+ * the start
+ * @param length
+ * the length
+ * @return the content
+ */
+ public @NonNull String getTextRange(int start, int length);
+
+ /**
+ * Set a new text content
+ *
+ * @param text
+ * the text
+ */
+ public void setText(@NonNull String text);
+
+ /**
+ * @return number of chars
+ */
public int getCharCount();
-
+
+ /**
+ * @return number of lines
+ */
public int getLineCount();
-
+
+ /**
+ * Get the offset of the line
+ *
+ * @param lineIndex
+ * the line index
+ * @return the offset
+ */
public int getOffsetAtLine(int lineIndex);
-
+
+ /**
+ * Get the line index for the char
+ *
+ * @param charPosition
+ * the char position
+ * @return the line index
+ */
public int getLineAtOffset(int charPosition);
-
- public void replaceTextRange(int start, int replaceLength, String newText);
-
+
+ /**
+ * Replace the content in range
+ *
+ * @param start
+ * the start
+ * @param replaceLength
+ * the replaced length
+ * @param newText
+ * the new text
+ */
+ public void replaceTextRange(int start, int replaceLength, @NonNull String newText);
+
+ /**
+ * Attach a change listener
+ *
+ * @param listener
+ * the listener
+ */
public void addTextChangeListener(TextChangeListener listener);
-
+
+ /**
+ * Remove a change listener
+ *
+ * @param listener
+ * the listener
+ */
public void removeTextChangeListener(TextChangeListener listener);
-
- interface TextChangeListener {
+
+ /**
+ * Listener informed above modifications
+ */
+ public interface TextChangeListener {
+ /**
+ * Called after the text has changed
+ *
+ * @param event
+ * the event
+ */
public void textChanged(TextChangedEvent event);
+ /**
+ * Called after the text has been set
+ *
+ * @param event
+ * the event
+ */
public void textSet(TextChangedEvent event);
+ /**
+ * Called when the text is changing
+ *
+ * @param event
+ * the event
+ */
public void textChanging(TextChangingEvent event);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangedEvent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangedEvent.java
index 2a8d916bb..0079faad0 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangedEvent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangedEvent.java
@@ -1,28 +1,51 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
-
+/**
+ * Event sent when text has changed
+ */
public class TextChangedEvent {
+ /**
+ * The source
+ */
public final StyledTextContent source;
-
+
+ /**
+ * The offset
+ */
public final int offset;
+ /**
+ * The number of replaced chars
+ */
public final int replaceCharCount;
+ /**
+ * The number of replaced lines
+ */
public final int replaceLineCount;
+ /**
+ * The new text
+ */
public final String newText;
+ /**
+ * The new char count
+ */
public final int newCharCount;
+ /**
+ * The new line count
+ */
public final int newLineCount;
-
- private TextChangedEvent(StyledTextContent source,int offset, int replaceCharCount, int replaceLineCount, String newText, int newCharCount, int newLineCount) {
+
+ private TextChangedEvent(StyledTextContent source, int offset, int replaceCharCount, int replaceLineCount, String newText, int newCharCount, int newLineCount) {
this.source = source;
this.offset = offset;
this.replaceCharCount = replaceCharCount;
@@ -31,13 +54,27 @@ public class TextChangedEvent {
this.newCharCount = newCharCount;
this.newLineCount = newLineCount;
}
-
+
+ /**
+ * Create a text changed event
+ *
+ * @param source
+ * the source
+ * @return the event
+ */
public static TextChangedEvent textChanged(StyledTextContent source) {
return new TextChangedEvent(source, 0, 0, 0, null, 0, 0);
}
-
+
+ /**
+ * Create the text set event
+ *
+ * @param source
+ * the source
+ * @return the event
+ */
public static TextChangedEvent textSet(StyledTextContent source) {
return new TextChangedEvent(source, 0, 0, 0, null, 0, 0);
}
-
+
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangingEvent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangingEvent.java
index 027faea1e..db1206fd0 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangingEvent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextChangingEvent.java
@@ -1,28 +1,51 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
-
+/**
+ * Event informing about text changing
+ */
public class TextChangingEvent {
+ /**
+ * The source
+ */
public final StyledTextContent source;
-
+
+ /**
+ * The offset
+ */
public int offset;
+ /**
+ * The number of replaced chars
+ */
public int replaceCharCount;
+ /**
+ * The number of replaced lines
+ */
public final int replaceLineCount;
+ /**
+ * The new text
+ */
public final String newText;
+ /**
+ * The new char count
+ */
public final int newCharCount;
+ /**
+ * The new line count
+ */
public final int newLineCount;
-
- private TextChangingEvent(StyledTextContent source,int offset, int replaceCharCount, int replaceLineCount, String newText, int newCharCount, int newLineCount) {
+
+ private TextChangingEvent(StyledTextContent source, int offset, int replaceCharCount, int replaceLineCount, String newText, int newCharCount, int newLineCount) {
this.source = source;
this.offset = offset;
this.replaceCharCount = replaceCharCount;
@@ -31,7 +54,26 @@ public class TextChangingEvent {
this.newCharCount = newCharCount;
this.newLineCount = newLineCount;
}
-
+
+ /**
+ * Create a new event
+ *
+ * @param source
+ * the source
+ * @param offset
+ * the offset
+ * @param replaceCharCount
+ * the number of replaced chars
+ * @param replaceLineCount
+ * the number of replaced lines
+ * @param newText
+ * the new text
+ * @param newCharCount
+ * the new char count
+ * @param newLineCount
+ * the new line count
+ * @return the event
+ */
public static TextChangingEvent textChanging(StyledTextContent source, int offset, int replaceCharCount, int replaceLineCount, String newText, int newCharCount, int newLineCount) {
return new TextChangingEvent(source, offset, replaceCharCount, replaceLineCount, newText, newCharCount, newLineCount);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextSelection.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextSelection.java
index 5910b86d2..98d4881b6 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextSelection.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextSelection.java
@@ -1,19 +1,36 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
+/**
+ * Represent a text selection
+ */
public class TextSelection {
+ /**
+ * The offset
+ */
public final int offset;
+ /**
+ * The length
+ */
public final int length;
-
+
+ /**
+ * Create a new selection
+ *
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ */
public TextSelection(int offset, int length) {
this.offset = offset;
this.length = length;
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextStyle.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextStyle.java
index 3c3f97579..f2bcfe7d7 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextStyle.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/TextStyle.java
@@ -14,36 +14,42 @@ import javafx.scene.paint.Color;
import javafx.scene.text.Font;
/**
- * <code>TextStyle</code> defines a set of styles that can be applied
- * to a range of text.
+ * <code>TextStyle</code> defines a set of styles that can be applied to a range
+ * of text.
* <p>
- * The hashCode() method in this class uses the values of the public
- * fields to compute the hash value. When storing instances of the
- * class in hashed collections, do not modify these fields after the
- * object has been inserted.
+ * The hashCode() method in this class uses the values of the public fields to
+ * compute the hash value. When storing instances of the class in hashed
+ * collections, do not modify these fields after the object has been inserted.
* </p>
* <p>
- * Application code does <em>not</em> need to explicitly release the
- * resources managed by each instance when those instances are no longer
- * required, and thus no <code>dispose()</code> method is provided.
+ * Application code does <em>not</em> need to explicitly release the resources
+ * managed by each instance when those instances are no longer required, and
+ * thus no <code>dispose()</code> method is provided.
* </p>
*
- * @see TextLayout
* @see Font
* @see Color
- * @see <a href="http://www.eclipse.org/swt/snippets/#textlayout">TextLayout, TextStyle snippets</a>
- * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
- *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#textlayout">TextLayout,
+ * TextStyle snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further
+ * information</a>
+ *
* @since 3.0
*/
public class TextStyle {
+ /**
+ * No styling
+ */
public static final int NONE = 0;
-
+
/**
* Style constant to indicate single underline (value is 0).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
@@ -51,47 +57,59 @@ public class TextStyle {
/**
* Style constant to indicate double underline (value is 1).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
public static final int UNDERLINE_DOUBLE = 1;
-
+
/**
* Style constant to indicate error underline (value is 2).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
public static final int UNDERLINE_ERROR = 2;
-
+
/**
* Style constant to indicate squiggle underline (value is 3).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
public static final int UNDERLINE_SQUIGGLE = 3;
-
+
/**
* Style constant to indicate link underline (value is 0).
* <p>
- * If the text color or the underline color are not set in the range
- * the usage of <code>UNDERLINE_LINK</code> will change these colors
- * to the preferred link color of the platform.<br>
+ * If the text color or the underline color are not set in the range the
+ * usage of <code>UNDERLINE_LINK</code> will change these colors to the
+ * preferred link color of the platform.<br>
* Note that clients that use this style, such as <code>StyledText</code>,
* will include code to track the mouse and change the cursor to the hand
* cursor when mouse is over the link.
* </p>
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.5
*/
@@ -99,9 +117,12 @@ public class TextStyle {
/**
* Style constant to indicate solid border (value is 1).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
@@ -109,24 +130,30 @@ public class TextStyle {
/**
* Style constant to indicate dashed border (value is 2).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
public static final int BORDER_DASH = 2;
-
+
/**
* Style constant to indicate dotted border (value is 4).
- * <p><b>Used By:</b><ul>
+ * <p>
+ * <b>Used By:</b>
+ * <ul>
* <li><code>TextStyle</code></li>
- * </ul></p>
+ * </ul>
+ * </p>
*
* @since 3.4
*/
public static final int BORDER_DOT = 4;
-
+
/**
* the font of the style
*/
@@ -143,343 +170,446 @@ public class TextStyle {
public Color background;
/**
- * the underline flag of the style. The default underline
- * style is <code>SWT.UNDERLINE_SINGLE</code>.
+ * the underline flag of the style. The default underline style is
+ * <code>TextStyle.UNDERLINE_SINGLE</code>.
*
*
* @since 3.1
- */
+ */
public boolean underline;
-
+
/**
* the underline color of the style
*
* @since 3.4
- */
+ */
public Color underlineColor;
/**
- * the underline style. This style is ignored when
- * <code>underline</code> is false.
- * <p>
- * This value should be one of <code>SWT.UNDERLINE_SINGLE</code>,
- * <code>SWT.UNDERLINE_DOUBLE</code>, <code>SWT.UNDERLINE_ERROR</code>,
- * <code>SWT.UNDERLINE_SQUIGGLE</code>, or <code>SWT.UNDERLINE_LINK</code>.
- * </p>
+ * the underline style. This style is ignored when <code>underline</code> is
+ * false.
*
- * @see SWT#UNDERLINE_SINGLE
- * @see SWT#UNDERLINE_DOUBLE
- * @see SWT#UNDERLINE_ERROR
- * @see SWT#UNDERLINE_SQUIGGLE
- * @see SWT#UNDERLINE_LINK
+ * @see TextStyle#UNDERLINE_SINGLE
+ * @see TextStyle#UNDERLINE_DOUBLE
+ * @see TextStyle#UNDERLINE_ERROR
+ * @see TextStyle#UNDERLINE_SQUIGGLE
+ * @see TextStyle#UNDERLINE_LINK
*
* @since 3.4
- */
+ */
public int underlineStyle;
/**
* the strikeout flag of the style
*
* @since 3.1
- */
+ */
public boolean strikeout;
-
+
/**
* the strikeout color of the style
*
* @since 3.4
- */
+ */
public Color strikeoutColor;
-
+
/**
* the border style. The default border style is <code>SWT.NONE</code>.
- * <p>
+ * <p>
* This value should be one of <code>SWT.BORDER_SOLID</code>,
* <code>SWT.BORDER_DASH</code>,<code>SWT.BORDER_DOT</code> or
* <code>SWT.NONE</code>.
* </p>
*
- * @see SWT#BORDER_SOLID
- * @see SWT#BORDER_DASH
- * @see SWT#BORDER_DOT
- * @see SWT#NONE
- *
* @since 3.4
- */
+ */
public int borderStyle;
-
+
/**
* the border color of the style
*
* @since 3.4
- */
+ */
public Color borderColor;
-
-// /**
-// * the GlyphMetrics of the style
-// *
-// * @since 3.2
-// */
-// public GlyphMetrics metrics;
-
+
+ // /**
+ // * the GlyphMetrics of the style
+ // *
+ // * @since 3.2
+ // */
+ // public GlyphMetrics metrics;
+
/**
- * the baseline rise of the style.
+ * the baseline rise of the style.
*
* @since 3.2
- */
+ */
public int rise;
-
-
+
/**
- * the data. An user data field. It can be used to hold the HREF when the range
- * is used as a link or the embed object when the range is used with <code>GlyphMetrics</code>.
+ * the data. An user data field. It can be used to hold the HREF when the
+ * range is used as a link or the embed object when the range is used with
+ * <code>GlyphMetrics</code>.
* <p>
*
* @since 3.5
*/
public Object data;
-
-/**
- * Create an empty text style.
- *
- * @since 3.4
- */
-public TextStyle () {
-}
+ /**
+ * The css stylename to use
+ */
+ public String stylename;
-/**
- * Create a new text style with the specified font, foreground
- * and background.
- *
- * @param font the font of the style, <code>null</code> if none
- * @param foreground the foreground color of the style, <code>null</code> if none
- * @param background the background color of the style, <code>null</code> if none
- */
-public TextStyle (Font font, Color foreground, Color background) {
-// if (font != null && font.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-// if (foreground != null && foreground.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-// if (background != null && background.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- this.font = font;
- this.foreground = foreground;
- this.background = background;
-}
+ /**
+ * The style named to used for hovering
+ */
+ public String hoverStylename;
+ /**
+ * Create an empty text style.
+ *
+ * @param stylename
+ * the css stylename
+ *
+ * @since 3.4
+ */
+ public TextStyle(String stylename) {
+ this.stylename = stylename;
+ }
-/**
- * Create a new text style from an existing text style.
- *
- * @param style the style to copy
- *
- * @since 3.4
- */
-public TextStyle (TextStyle style) {
- if (style == null) throw new IllegalStateException();
- font = style.font;
- foreground = style.foreground;
- background = style.background;
- underline = style.underline;
- underlineColor = style.underlineColor;
- underlineStyle = style.underlineStyle;
- strikeout = style.strikeout;
- strikeoutColor = style.strikeoutColor;
- borderStyle = style.borderStyle;
- borderColor = style.borderColor;
-// metrics = style.metrics;
- rise = style.rise;
- data = style.data;
-}
+ /**
+ * Create a new text style with the specified font, foreground and
+ * background.
+ *
+ * @param stylename
+ * the css stylename
+ *
+ * @param font
+ * the font of the style, <code>null</code> if none
+ * @param foreground
+ * the foreground color of the style, <code>null</code> if none
+ * @param background
+ * the background color of the style, <code>null</code> if none
+ */
+ public TextStyle(String stylename, Font font, Color foreground,
+ Color background) {
+ // if (font != null && font.isDisposed()) SWT.error
+ // (SWT.ERROR_INVALID_ARGUMENT);
+ // if (foreground != null && foreground.isDisposed()) SWT.error
+ // (SWT.ERROR_INVALID_ARGUMENT);
+ // if (background != null && background.isDisposed()) SWT.error
+ // (SWT.ERROR_INVALID_ARGUMENT);
+ this.stylename = stylename;
+ this.font = font;
+ this.foreground = foreground;
+ this.background = background;
+ }
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode()
- */
-public boolean equals(Object object) {
- if (object == this) return true;
- if (object == null) return false;
- if (!(object instanceof TextStyle)) return false;
- TextStyle style = (TextStyle)object;
- if (foreground != null) {
- if (!foreground.equals(style.foreground)) return false;
- } else if (style.foreground != null) return false;
- if (background != null) {
- if (!background.equals(style.background)) return false;
- } else if (style.background != null) return false;
- if (font != null) {
- if (!font.equals(style.font)) return false;
- } else if (style.font != null) return false;
-// if (metrics != null || style.metrics != null) return false;
- if (underline != style.underline) return false;
- if (underlineStyle != style.underlineStyle) return false;
- if (borderStyle != style.borderStyle) return false;
- if (strikeout != style.strikeout) return false;
- if (rise != style.rise) return false;
- if (underlineColor != null) {
- if (!underlineColor.equals(style.underlineColor)) return false;
- } else if (style.underlineColor != null) return false;
- if (strikeoutColor != null) {
- if (!strikeoutColor.equals(style.strikeoutColor)) return false;
- } else if (style.strikeoutColor != null) return false;
- if (underlineStyle != style.underlineStyle) return false;
- if (borderColor != null) {
- if (!borderColor.equals(style.borderColor)) return false;
- } else if (style.borderColor != null) return false;
- if (data != null) {
- if (!data.equals(style.data)) return false;
- } else if (style.data != null) return false;
- return true;
-}
+ /**
+ * Create a new text style from an existing text style.
+ *
+ * @param style
+ * the style to copy
+ *
+ * @since 3.4
+ */
+ public TextStyle(TextStyle style) {
+ if (style == null)
+ throw new IllegalStateException();
+ this.stylename = style.stylename;
+ this.font = style.font;
+ this.foreground = style.foreground;
+ this.background = style.background;
+ this.underline = style.underline;
+ this.underlineColor = style.underlineColor;
+ this.underlineStyle = style.underlineStyle;
+ this.strikeout = style.strikeout;
+ this.strikeoutColor = style.strikeoutColor;
+ this.borderStyle = style.borderStyle;
+ this.borderColor = style.borderColor;
+ // metrics = style.metrics;
+ this.rise = style.rise;
+ this.data = style.data;
+ }
-/**
- * Returns an integer hash code for the receiver. Any two
- * objects that return <code>true</code> when passed to
- * <code>equals</code> must return the same value for this
- * method.
- *
- * @return the receiver's hash
- *
- * @see #equals(Object)
- */
-public int hashCode() {
- int hash = 0;
- if (foreground != null) hash ^= foreground.hashCode();
- if (background != null) hash ^= background.hashCode();
- if (font != null) hash ^= font.hashCode();
-// if (metrics != null) hash ^= metrics.hashCode();
- if (underline) hash ^= (hash << 1);
- if (strikeout) hash ^= (hash << 2);
- hash ^= rise;
- if (underlineColor != null) hash ^= underlineColor.hashCode();
- if (strikeoutColor != null) hash ^= strikeoutColor.hashCode();
- if (borderColor != null) hash ^= borderColor.hashCode();
- hash ^= underlineStyle;
- return hash;
-}
+ /**
+ * Compares the argument to the receiver, and returns true if they represent
+ * the <em>same</em> object using a class specific comparison.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and
+ * <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (object == this)
+ return true;
+ if (object == null)
+ return false;
+ if (!(object instanceof TextStyle))
+ return false;
+ TextStyle style = (TextStyle) object;
-boolean isAdherentBorder(TextStyle style) {
- if (this == style) return true;
- if (style == null) return false;
- if (borderStyle != style.borderStyle) return false;
- if (borderColor != null) {
- if (!borderColor.equals(style.borderColor)) return false;
- } else {
- if (style.borderColor != null) return false;
- if (foreground != null) {
- if (!foreground.equals(style.foreground)) return false;
- } else if (style.foreground != null) return false;
- }
- return true;
-}
+ if (this.stylename != null) {
+ if (!this.stylename.equals(style.stylename))
+ return false;
+ } else if (style.stylename != null) {
+ return false;
+ }
-boolean isAdherentUnderline(TextStyle style) {
- if (this == style) return true;
- if (style == null) return false;
- if (underline != style.underline) return false;
- if (underlineStyle != style.underlineStyle) return false;
- if (underlineColor != null) {
- if (!underlineColor.equals(style.underlineColor)) return false;
- } else {
- if (style.underlineColor != null) return false;
- if (foreground != null) {
- if (!foreground.equals(style.foreground)) return false;
- } else if (style.foreground != null) return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground))
+ return false;
+ } else if (style.foreground != null)
+ return false;
+ if (this.background != null) {
+ if (!this.background.equals(style.background))
+ return false;
+ } else if (style.background != null)
+ return false;
+ if (this.font != null) {
+ if (!this.font.equals(style.font))
+ return false;
+ } else if (style.font != null)
+ return false;
+ // if (metrics != null || style.metrics != null) return false;
+ if (this.underline != style.underline)
+ return false;
+ if (this.underlineStyle != style.underlineStyle)
+ return false;
+ if (this.borderStyle != style.borderStyle)
+ return false;
+ if (this.strikeout != style.strikeout)
+ return false;
+ if (this.rise != style.rise)
+ return false;
+ if (this.underlineColor != null) {
+ if (!this.underlineColor.equals(style.underlineColor))
+ return false;
+ } else if (style.underlineColor != null)
+ return false;
+ if (this.strikeoutColor != null) {
+ if (!this.strikeoutColor.equals(style.strikeoutColor))
+ return false;
+ } else if (style.strikeoutColor != null)
+ return false;
+ if (this.underlineStyle != style.underlineStyle)
+ return false;
+ if (this.borderColor != null) {
+ if (!this.borderColor.equals(style.borderColor))
+ return false;
+ } else if (style.borderColor != null)
+ return false;
+ if (this.data != null) {
+ if (!this.data.equals(style.data))
+ return false;
+ } else if (style.data != null)
+ return false;
+ return true;
}
- return true;
-}
-boolean isAdherentStrikeout(TextStyle style) {
- if (this == style) return true;
- if (style == null) return false;
- if (strikeout != style.strikeout) return false;
- if (strikeoutColor != null) {
- if (!strikeoutColor.equals(style.strikeoutColor)) return false;
- } else {
- if (style.strikeoutColor != null) return false;
- if (foreground != null) {
- if (!foreground.equals(style.foreground)) return false;
- } else if (style.foreground != null) return false;
+ /**
+ * Returns an integer hash code for the receiver. Any two objects that
+ * return <code>true</code> when passed to <code>equals</code> must return
+ * the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ if (this.stylename != null)
+ hash ^= this.stylename.hashCode();
+ if (this.foreground != null)
+ hash ^= this.foreground.hashCode();
+ if (this.background != null)
+ hash ^= this.background.hashCode();
+ if (this.font != null)
+ hash ^= this.font.hashCode();
+ // if (metrics != null) hash ^= metrics.hashCode();
+ if (this.underline)
+ hash ^= (hash << 1);
+ if (this.strikeout)
+ hash ^= (hash << 2);
+ hash ^= this.rise;
+ if (this.underlineColor != null)
+ hash ^= this.underlineColor.hashCode();
+ if (this.strikeoutColor != null)
+ hash ^= this.strikeoutColor.hashCode();
+ if (this.borderColor != null)
+ hash ^= this.borderColor.hashCode();
+ hash ^= this.underlineStyle;
+ return hash;
}
- return true;
-}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the <code>TextStyle</code>
- */
-public String toString () {
- StringBuffer buffer = new StringBuffer("TextStyle {"); //$NON-NLS-1$
- int startLength = buffer.length();
- if (font != null) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("font="); //$NON-NLS-1$
- buffer.append(font);
+ boolean isAdherentBorder(TextStyle style) {
+ if (this == style)
+ return true;
+ if (style == null)
+ return false;
+ if (this.borderStyle != style.borderStyle)
+ return false;
+ if (this.borderColor != null) {
+ if (!this.borderColor.equals(style.borderColor))
+ return false;
+ } else {
+ if (style.borderColor != null)
+ return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground))
+ return false;
+ } else if (style.foreground != null)
+ return false;
+ }
+ return true;
}
- if (foreground != null) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("foreground="); //$NON-NLS-1$
- buffer.append(foreground);
+
+ boolean isAdherentUnderline(TextStyle style) {
+ if (this == style)
+ return true;
+ if (style == null)
+ return false;
+ if (this.underline != style.underline)
+ return false;
+ if (this.underlineStyle != style.underlineStyle)
+ return false;
+ if (this.underlineColor != null) {
+ if (!this.underlineColor.equals(style.underlineColor))
+ return false;
+ } else {
+ if (style.underlineColor != null)
+ return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground))
+ return false;
+ } else if (style.foreground != null)
+ return false;
+ }
+ return true;
}
- if (background != null) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("background="); //$NON-NLS-1$
- buffer.append(background);
+
+ boolean isAdherentStrikeout(TextStyle style) {
+ if (this == style)
+ return true;
+ if (style == null)
+ return false;
+ if (this.strikeout != style.strikeout)
+ return false;
+ if (this.strikeoutColor != null) {
+ if (!this.strikeoutColor.equals(style.strikeoutColor))
+ return false;
+ } else {
+ if (style.strikeoutColor != null)
+ return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground))
+ return false;
+ } else if (style.foreground != null)
+ return false;
+ }
+ return true;
}
- if (underline) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("underline="); //$NON-NLS-1$
- switch (underlineStyle) {
- case UNDERLINE_SINGLE: buffer.append("single"); break; //$NON-NLS-1$
- case UNDERLINE_DOUBLE: buffer.append("double"); break; //$NON-NLS-1$
- case UNDERLINE_SQUIGGLE: buffer.append("squiggle"); break; //$NON-NLS-1$
- case UNDERLINE_ERROR: buffer.append("error"); break; //$NON-NLS-1$
- case UNDERLINE_LINK: buffer.append("link"); break; //$NON-NLS-1$
+
+ /**
+ * Returns a string containing a concise, human-readable description of the
+ * receiver.
+ *
+ * @return a string representation of the <code>TextStyle</code>
+ */
+ @Override
+ public String toString() {
+ StringBuffer buffer = new StringBuffer("TextStyle {"); //$NON-NLS-1$
+ int startLength = buffer.length();
+ if (this.stylename != null) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("stylename="); //$NON-NLS-1$
+ buffer.append(this.stylename);
}
- if (underlineColor != null) {
- buffer.append(", underlineColor="); //$NON-NLS-1$
- buffer.append(underlineColor);
+ if (this.font != null) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("font="); //$NON-NLS-1$
+ buffer.append(this.font);
}
- }
- if (strikeout) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("striked out"); //$NON-NLS-1$
- if (strikeoutColor != null) {
- buffer.append(", strikeoutColor="); //$NON-NLS-1$
- buffer.append(strikeoutColor);
+ if (this.foreground != null) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("foreground="); //$NON-NLS-1$
+ buffer.append(this.foreground);
}
- }
- if (borderStyle != NONE) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("border="); //$NON-NLS-1$
- switch (borderStyle) {
- case BORDER_SOLID: buffer.append("solid"); break; //$NON-NLS-1$
- case BORDER_DOT: buffer.append("dot"); break; //$NON-NLS-1$
- case BORDER_DASH: buffer.append("dash"); break; //$NON-NLS-1$
+ if (this.background != null) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("background="); //$NON-NLS-1$
+ buffer.append(this.background);
}
- if (borderColor != null) {
- buffer.append(", borderColor="); //$NON-NLS-1$
- buffer.append(borderColor);
+ if (this.underline) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("underline="); //$NON-NLS-1$
+ switch (this.underlineStyle) {
+ case UNDERLINE_SINGLE:
+ buffer.append("single");break; //$NON-NLS-1$
+ case UNDERLINE_DOUBLE:
+ buffer.append("double");break; //$NON-NLS-1$
+ case UNDERLINE_SQUIGGLE:
+ buffer.append("squiggle");break; //$NON-NLS-1$
+ case UNDERLINE_ERROR:
+ buffer.append("error");break; //$NON-NLS-1$
+ case UNDERLINE_LINK:
+ buffer.append("link");break; //$NON-NLS-1$
+ }
+ if (this.underlineColor != null) {
+ buffer.append(", underlineColor="); //$NON-NLS-1$
+ buffer.append(this.underlineColor);
+ }
}
+ if (this.strikeout) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("striked out"); //$NON-NLS-1$
+ if (this.strikeoutColor != null) {
+ buffer.append(", strikeoutColor="); //$NON-NLS-1$
+ buffer.append(this.strikeoutColor);
+ }
+ }
+ if (this.borderStyle != NONE) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("border="); //$NON-NLS-1$
+ switch (this.borderStyle) {
+ case BORDER_SOLID:
+ buffer.append("solid");break; //$NON-NLS-1$
+ case BORDER_DOT:
+ buffer.append("dot");break; //$NON-NLS-1$
+ case BORDER_DASH:
+ buffer.append("dash");break; //$NON-NLS-1$
+ }
+ if (this.borderColor != null) {
+ buffer.append(", borderColor="); //$NON-NLS-1$
+ buffer.append(this.borderColor);
+ }
+ }
+ if (this.rise != 0) {
+ if (buffer.length() > startLength)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append("rise="); //$NON-NLS-1$
+ buffer.append(this.rise);
+ }
+ // if (metrics != null) {
+ // if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
+ // buffer.append("metrics="); //$NON-NLS-1$
+ // buffer.append(metrics);
+ // }
+ buffer.append("}"); //$NON-NLS-1$
+ return buffer.toString();
}
- if (rise != 0) {
- if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
- buffer.append("rise="); //$NON-NLS-1$
- buffer.append(rise);
- }
-// if (metrics != null) {
-// if (buffer.length() > startLength) buffer.append(", "); //$NON-NLS-1$
-// buffer.append("metrics="); //$NON-NLS-1$
-// buffer.append(metrics);
-// }
- buffer.append("}"); //$NON-NLS-1$
- return buffer.toString();
-}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/VerifyEvent.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/VerifyEvent.java
index 54c034945..0083a528f 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/VerifyEvent.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/VerifyEvent.java
@@ -1,13 +1,13 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
import javafx.event.EventTarget;
@@ -16,9 +16,14 @@ import javafx.scene.input.InputEvent;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
+/**
+ * Key event sent
+ */
public class VerifyEvent extends InputEvent {
- public static final EventType<VerifyEvent> VERIFY =
- new EventType<VerifyEvent>(InputEvent.ANY, "VERIFY");
+ /**
+ * the event type
+ */
+ public static final EventType<VerifyEvent> VERIFY = new EventType<VerifyEvent>(InputEvent.ANY, "VERIFY"); //$NON-NLS-1$
/**
*
*/
@@ -29,46 +34,77 @@ public class VerifyEvent extends InputEvent {
private boolean shiftDown;
private boolean controlDown;
private boolean altDown;
- private boolean metaDown;
-
+ private boolean metaDown;
+
+ /**
+ * The event
+ *
+ * @param source
+ * the source
+ * @param target
+ * the target
+ * @param event
+ * the key
+ */
public VerifyEvent(Object source, EventTarget target, KeyEvent event) {
- super(source,target,VERIFY);
+ super(source, target, VERIFY);
boolean isKeyTyped = event.getEventType() == KeyEvent.KEY_TYPED;
-
+
this.character = isKeyTyped ? event.getCharacter() : KeyEvent.CHAR_UNDEFINED;
- this.text = isKeyTyped ? "" : event.getText();
- this.code = isKeyTyped ? KeyCode.UNDEFINED : event.getCode();
- this.shiftDown = event.isShiftDown();
- this.controlDown = event.isControlDown();
- this.altDown = event.isAltDown();
- this.metaDown = event.isMetaDown();
+ this.text = isKeyTyped ? "" : event.getText(); //$NON-NLS-1$
+ this.code = isKeyTyped ? KeyCode.UNDEFINED : event.getCode();
+ this.shiftDown = event.isShiftDown();
+ this.controlDown = event.isControlDown();
+ this.altDown = event.isAltDown();
+ this.metaDown = event.isMetaDown();
}
+ /**
+ * @return the character
+ */
public String getCharacter() {
- return character;
+ return this.character;
}
-
+
+ /**
+ * @return the text
+ */
public String getText() {
- return text;
+ return this.text;
}
-
+
+ /**
+ * @return the key code
+ */
public KeyCode getCode() {
- return code;
+ return this.code;
}
-
+
+ /**
+ * @return <code>true</code> when shift key is down
+ */
public boolean isShiftDown() {
- return shiftDown;
+ return this.shiftDown;
}
+ /**
+ * @return <code>true</code> when control key is down
+ */
public boolean isControlDown() {
- return controlDown;
+ return this.controlDown;
}
+ /**
+ * @return <code>true</code> when alt key is down
+ */
public boolean isAltDown() {
- return altDown;
+ return this.altDown;
}
-
+
+ /**
+ * @return <code>true</code> when meta key is down
+ */
public boolean isMetaDown() {
- return metaDown;
+ return this.metaDown;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
index 1372f25f3..0fb9a0939 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/behavior/StyledTextBehavior.java
@@ -1,26 +1,19 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext.behavior;
import static javafx.scene.input.KeyEvent.KEY_PRESSED;
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
-
-import org.eclipse.fx.ui.controls.styledtext.ActionEvent;
-import org.eclipse.fx.ui.controls.styledtext.ActionEvent.ActionType;
-import org.eclipse.fx.ui.controls.styledtext.StyledTextArea;
-import org.eclipse.fx.ui.controls.styledtext.VerifyEvent;
-import org.eclipse.fx.ui.controls.styledtext.skin.StyledTextSkin.LineCell;
import javafx.event.Event;
import javafx.geometry.Point2D;
@@ -31,230 +24,283 @@ import javafx.scene.layout.Region;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
+import org.eclipse.fx.ui.controls.styledtext.ActionEvent;
+import org.eclipse.fx.ui.controls.styledtext.ActionEvent.ActionType;
+import org.eclipse.fx.ui.controls.styledtext.StyledTextArea;
+import org.eclipse.fx.ui.controls.styledtext.VerifyEvent;
+import org.eclipse.fx.ui.controls.styledtext.skin.StyledTextSkin.LineCell;
+
import com.sun.javafx.scene.control.behavior.BehaviorBase;
import com.sun.javafx.scene.control.behavior.KeyBinding;
import com.sun.javafx.scene.text.HitInfo;
+/**
+ * Behavior for styled text
+ */
@SuppressWarnings("restriction")
public class StyledTextBehavior extends BehaviorBase<StyledTextArea> {
private static final List<KeyBinding> KEY_BINDINGS = new ArrayList<KeyBinding>();
-
+
static {
- KEY_BINDINGS.add(new KeyBinding(null, KEY_PRESSED, "Consume"));
+ KEY_BINDINGS.add(new KeyBinding(null, KEY_PRESSED, "Consume")); //$NON-NLS-1$
}
-
+
+ /**
+ * Create a new behavior
+ *
+ * @param styledText
+ * the styled text control
+ */
public StyledTextBehavior(StyledTextArea styledText) {
super(styledText, KEY_BINDINGS);
}
@Override
protected void callActionForEvent(KeyEvent arg0) {
- System.err.println("ACTION CALL: " + arg0);
- if( arg0.getEventType() == KeyEvent.KEY_PRESSED ) {
+ if (arg0.getEventType() == KeyEvent.KEY_PRESSED) {
keyPressed(arg0, getControl().getContent().getLineAtOffset(getControl().getCaretOffset()));
}
super.callActionForEvent(arg0);
}
-
+
@Override
protected void callAction(String arg0) {
super.callAction(arg0);
}
-
+
@Override
public void mousePressed(MouseEvent arg0) {
super.mousePressed(arg0);
getControl().requestFocus();
}
-
+
+ /**
+ * Invoke an action
+ *
+ * @param action
+ * the action
+ * @return true is consumed
+ */
public boolean invokeAction(ActionType action) {
ActionEvent evt = new ActionEvent(getControl(), getControl(), action);
Event.fireEvent(getControl(), evt);
return evt.isConsumed();
}
-
+
private void keyPressed(KeyEvent event, int currentRowIndex) {
- System.err.println("============> KEYPRESSED: " + event);
VerifyEvent evt = new VerifyEvent(getControl(), getControl(), event);
Event.fireEvent(getControl(), evt);
-
- if( evt.isConsumed() ) {
+
+ if (evt.isConsumed()) {
event.consume();
return;
}
-
+
final int offset = getControl().getCaretOffset();
-
+
switch (event.getCode()) {
case SHIFT:
case ALT:
case CONTROL:
break;
- case LEFT:
- {
- if( event.isAltDown() ) {
+ case LEFT: {
+ if (event.isAltDown()) {
invokeAction(ActionType.WORD_PREVIOUS);
} else {
- if( offset == 0 ) {
+ if (offset == 0) {
+ event.consume();
break;
}
- int newOffset = offset-1;
+ int newOffset = offset - 1;
+ @SuppressWarnings("unused")
int currentLine = getControl().getContent().getLineAtOffset(offset);
+ @SuppressWarnings("unused")
int newLine = getControl().getContent().getLineAtOffset(newOffset);
- getControl().setCaretOffset(newOffset);
+ getControl().setCaretOffset(newOffset,event.isShiftDown());
+ event.consume();
}
break;
}
- case RIGHT:
- {
- if( event.isAltDown() ) {
+ case RIGHT: {
+ if (event.isAltDown()) {
invokeAction(ActionType.WORD_NEXT);
- } else if(event.isMetaDown()) {
+ } else if (event.isMetaDown()) {
int currentLine = getControl().getContent().getLineAtOffset(offset);
int lineOffset = getControl().getContent().getOffsetAtLine(currentLine);
String lineContent = getControl().getContent().getLine(currentLine);
-
- getControl().setCaretOffset(lineOffset + lineContent.length());
+
+ getControl().setCaretOffset(lineOffset + lineContent.length(),event.isShiftDown());
+ event.consume();
} else {
- if( offset+1 > getControl().getContent().getCharCount() ) {
+ if (offset + 1 > getControl().getContent().getCharCount()) {
break;
}
- int newOffset = offset+1;
- int currentLine = getControl().getContent().getLineAtOffset(offset);
- int newLine = getControl().getContent().getLineAtOffset(newOffset);
- getControl().setCaretOffset(newOffset);
+ int newOffset = offset + 1;
+// @SuppressWarnings("unused")
+// int currentLine = getControl().getContent().getLineAtOffset(offset);
+// @SuppressWarnings("unused")
+// int newLine = getControl().getContent().getLineAtOffset(newOffset);
+ getControl().setCaretOffset(newOffset,event.isShiftDown());
+ event.consume();
}
break;
}
- case UP:
- {
+ case UP: {
int rowIndex = currentRowIndex;
-
- if( rowIndex == 0 ) {
+
+ if (rowIndex == 0) {
break;
}
-
+
int colIdx = offset - getControl().getContent().getOffsetAtLine(rowIndex);
rowIndex -= 1;
-
+
int lineOffset = getControl().getContent().getOffsetAtLine(rowIndex);
int newCaretPosition = lineOffset + colIdx;
- int maxPosition = lineOffset + getControl().getContent().getLine(rowIndex).length();
-
- getControl().setCaretOffset(Math.min(newCaretPosition, maxPosition));
+ int maxPosition = lineOffset + getControl().getContent().getLine(rowIndex).length();
+
+ getControl().setCaretOffset(Math.min(newCaretPosition, maxPosition),event.isShiftDown());
break;
}
- case DOWN:
- {
+ case DOWN: {
int rowIndex = currentRowIndex;
- if( rowIndex+1 == getControl().getContent().getLineCount() ) {
+ if (rowIndex + 1 == getControl().getContent().getLineCount()) {
break;
}
-
+
int colIdx = offset - getControl().getContent().getOffsetAtLine(rowIndex);
rowIndex += 1;
-
+
int lineOffset = getControl().getContent().getOffsetAtLine(rowIndex);
int newCaretPosition = lineOffset + colIdx;
- int maxPosition = lineOffset + getControl().getContent().getLine(rowIndex).length();
-
- getControl().setCaretOffset(Math.min(newCaretPosition, maxPosition));
+ int maxPosition = lineOffset + getControl().getContent().getLine(rowIndex).length();
+
+ getControl().setCaretOffset(Math.min(newCaretPosition, maxPosition),event.isShiftDown());
break;
}
case ENTER:
int line = getControl().getContent().getLineAtOffset(getControl().getCaretOffset());
String lineContent = getControl().getContent().getLine(line);
-
- //FIXME Temp hack
+
+ // FIXME Temp hack
char[] chars = lineContent.toCharArray();
- String prefix = "";
- for( int i = 0; i < chars.length; i++ ) {
- if( chars[i] == ' ' ) {
- prefix += " ";
+ String prefix = ""; //$NON-NLS-1$
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] == ' ') {
+ prefix += " "; //$NON-NLS-1$
} else {
break;
}
}
-
- getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, event.getText()+prefix);
-// listView.getSelectionModel().select(listView.getSelectionModel().getSelectedIndex()+1);
- getControl().setCaretOffset(offset+1+prefix.length());
+
+ getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, event.getText() + prefix);
+ // listView.getSelectionModel().select(listView.getSelectionModel().getSelectedIndex()+1);
+ getControl().setCaretOffset(offset + 1 + prefix.length());
break;
case DELETE:
- if( event.isMetaDown() ) {
+ if (event.isMetaDown()) {
invokeAction(ActionType.DELETE_WORD_NEXT);
} else {
- getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 1, "");
- getControl().setCaretOffset(offset);
+ getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 1, ""); //$NON-NLS-1$
+ getControl().setCaretOffset(offset);
}
break;
case BACK_SPACE:
- if( event.isMetaDown() ) {
+ if (event.isMetaDown()) {
invokeAction(ActionType.DELETE_WORD_PREVIOUS);
} else {
- getControl().getContent().replaceTextRange(getControl().getCaretOffset()-1, 1, "");
- getControl().setCaretOffset(offset-1);
+ getControl().getContent().replaceTextRange(getControl().getCaretOffset() - 1, 1, ""); //$NON-NLS-1$
+ getControl().setCaretOffset(offset - 1);
}
break;
case TAB:
event.consume();
- if( event.isShiftDown() ) {
- //TODO Remove first 4 white space chars???
+ if (event.isShiftDown()) {
+ // TODO Remove first 4 white space chars???
break;
} else {
- //FIXME Need to should fix this but it currently completely break cursor positioning
- getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, " ");
- getControl().setCaretOffset(offset+4);
+ // FIXME Need to should fix this but it currently completely
+ // break cursor positioning
+ getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, " "); //$NON-NLS-1$
+ getControl().setCaretOffset(offset + 4);
+ break;
+ }
+ case V:
+ if( event.isShortcutDown() ) {
+ getControl().paste();
+ event.consume();
+ break;
+ }
+ case C:
+ if( event.isShortcutDown() ) {
+ getControl().copy();
+ event.consume();
break;
}
default:
- if( event.isMetaDown() || event.isControlDown() ) {
+ if (event.isMetaDown() || event.isControlDown()) {
// exclude meta keys
} else {
-
- if( event.getText().length() > 0 ) {
- getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, event.getText());
- getControl().setCaretOffset(offset+1);
+ String text = event.getText();
+ if (text.length() > 0) {
+ getControl().getContent().replaceTextRange(getControl().getCaretOffset(), 0, text);
+ getControl().setCaretOffset(offset + 1);
}
}
-
+
break;
}
-
-// Event.fireEvent(getControl(), event.copyFor(getControl(), getControl()));
+
+ // Event.fireEvent(getControl(), event.copyFor(getControl(),
+ // getControl()));
}
-
+
+ /**
+ * Send a mouse pressed
+ *
+ * @param event
+ * the event
+ * @param visibleCells
+ * the visible cells
+ */
public void mousePressed(MouseEvent event, List<LineCell> visibleCells) {
Point2D p = new Point2D(event.getX(), event.getY());
- for( LineCell cell : visibleCells ) {
- if( cell.getBoundsInParent().contains(p) ) {
- if( cell.getDomainElement() != null ) {
+ for (LineCell cell : visibleCells) {
+ if (cell.getBoundsInParent().contains(p)) {
+ if (cell.getDomainElement() != null) {
// Calculate to cell relative
p = p.subtract(cell.getLayoutX(), cell.getLayoutY());
Region g = (Region) cell.getGraphic();
p = p.subtract(g.getLayoutX(), g.getLayoutY());
-
+
TextFlow flow = (TextFlow) g.getChildrenUnmodifiable().get(0);
// Calculate to text flow
p = p.subtract(flow.getLayoutX(), flow.getLayoutY());
- for( Node n : flow.getChildren() ) {
- Text text = (Text) n;
- if( text.getBoundsInParent().contains(p) ) {
- HitInfo info = text.impl_hitTestChar(new Point2D(p.getX()-text.getLayoutX(), 0 /* See RT-28485 text.getLayoutY()*/));
- if( info.getInsertionIndex() >= 0 ) {
-// System.err.println("Text: " + text.getText());
-// System.err.println("Text-Offset: " + text.getUserData());
-// System.err.println("INSERT INDEX: " + info.getInsertionIndex());
- int offset = ((Integer)text.getUserData()).intValue()+info.getInsertionIndex();
-// System.err.println("NEW OFFSET AT: " + offset);
- getControl().setCaretOffset(offset);
+ for (Node n : flow.getChildren()) {
+ TextFlow text = (TextFlow) n;
+
+ if (text.getBoundsInParent().contains(p)) {
+ @SuppressWarnings("deprecation")
+ HitInfo info = ((Text)text.getChildren().get(0)).impl_hitTestChar(new Point2D(p.getX() - text.getLayoutX(), 0 ));
+ if (info.getInsertionIndex() >= 0) {
+ // System.err.println("Text: " +
+ // text.getText());
+ // System.err.println("Text-Offset: " +
+ // text.getUserData());
+ // System.err.println("INSERT INDEX: " +
+ // info.getInsertionIndex());
+ int offset = ((Integer) text.getUserData()).intValue() + info.getInsertionIndex();
+ // System.err.println("NEW OFFSET AT: " +
+ // offset);
+ getControl().setCaretOffset(offset, event.isShiftDown());
return;
}
}
}
-
+
int offset = cell.getDomainElement().getLineOffset() + cell.getDomainElement().getLineLength();
- getControl().setCaretOffset(offset);
+ getControl().setCaretOffset(offset, event.isShiftDown());
+
}
break;
}
@@ -262,4 +308,8 @@ public class StyledTextBehavior extends BehaviorBase<StyledTextArea> {
getControl().requestFocus();
Event.fireEvent(getControl(), event.copyFor(getControl(), getControl()));
}
+
+// public void mouseDragged(MouseEvent event, List<LineCell> visibleCells) {
+//
+// }
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/skin/StyledTextSkin.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/skin/StyledTextSkin.java
index b07f0fc93..fa8cee384 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/skin/StyledTextSkin.java
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/skin/StyledTextSkin.java
@@ -1,13 +1,13 @@
/*******************************************************************************
-* Copyright (c) 2014 BestSolution.at 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:
-* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
-*******************************************************************************/
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext.skin;
import java.util.ArrayList;
@@ -18,13 +18,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
-import javafx.beans.InvalidationListener;
-import javafx.beans.Observable;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
@@ -44,13 +42,9 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
-import javafx.scene.paint.Color;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.PathElement;
-import javafx.scene.text.Font;
-import javafx.scene.text.FontPosture;
-import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.util.Callback;
@@ -58,403 +52,430 @@ import javafx.util.Duration;
import org.eclipse.fx.ui.controls.styledtext.StyleRange;
import org.eclipse.fx.ui.controls.styledtext.StyledTextArea;
+import org.eclipse.fx.ui.controls.styledtext.TextSelection;
import org.eclipse.fx.ui.controls.styledtext.behavior.StyledTextBehavior;
import com.sun.javafx.scene.control.skin.BehaviorSkinBase;
import com.sun.javafx.scene.control.skin.ListViewSkin;
import com.sun.javafx.scene.control.skin.VirtualFlow;
+/**
+ * Styled text skin
+ */
@SuppressWarnings("restriction")
public class StyledTextSkin extends BehaviorSkinBase<StyledTextArea, StyledTextBehavior> {
- private ListView<Line> contentView;
- private StackPane lineRuler;
-
- private ObservableList<Line> lineList = FXCollections.observableArrayList();
-
-// private Set<LineCell> visibleCells = new HashSet<>();
- private Map<LineCell, LineInfo> lineInfoMap = new HashMap<>();
+ ListView<Line> contentView;
+ StackPane lineRuler;
- private Font boldFont;
-
- private Font boldItalicFont;
-
- private Font italicFont;
- private HBox rootContainer;
-
+ ObservableList<Line> lineList = FXCollections.observableArrayList();
+
+ // private Set<LineCell> visibleCells = new HashSet<>();
+ Map<LineCell, LineInfo> lineInfoMap = new HashMap<>();
+
+ HBox rootContainer;
+
+ /**
+ * Create a new skin
+ *
+ * @param styledText
+ * the control
+ */
public StyledTextSkin(StyledTextArea styledText) {
super(styledText, new StyledTextBehavior(styledText));
- rootContainer = new HBox();
- rootContainer.setSpacing(0);
+ this.rootContainer = new HBox();
+ this.rootContainer.setSpacing(0);
- lineRuler = new LineRuler();
- lineRuler.visibleProperty().bind(getSkinnable().lineRulerVisibleProperty());
- lineRuler.managedProperty().bind(getSkinnable().lineRulerVisibleProperty());
- rootContainer.getChildren().add(lineRuler);
-
- contentView = new ListView<Line>() {
+ this.lineRuler = new LineRuler();
+ this.lineRuler.visibleProperty().bind(getSkinnable().lineRulerVisibleProperty());
+ this.lineRuler.managedProperty().bind(getSkinnable().lineRulerVisibleProperty());
+ this.rootContainer.getChildren().add(this.lineRuler);
+
+ this.contentView = new ListView<Line>() {
@Override
protected Skin<?> createDefaultSkin() {
return new MyListViewSkin(this);
}
};
- contentView.getStyleClass().add("styled-text-area");
-// listView.setFocusTraversable(false);
- contentView.focusedProperty().addListener(new ChangeListener<Boolean>() {
+ this.contentView.getStyleClass().add("styled-text-area"); //$NON-NLS-1$
+ // listView.setFocusTraversable(false);
+ this.contentView.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
- public void changed(ObservableValue<? extends Boolean> observable,
- Boolean oldValue, Boolean newValue) {
- if( newValue ) {
+ public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
+ if (newValue.booleanValue()) {
getSkinnable().requestFocus();
}
}
});
-// listView.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
-// });
- contentView.setCellFactory(new Callback<ListView<Line>, ListCell<Line>>() {
-
+ // listView.addEventHandler(KeyEvent.KEY_PRESSED, new
+ // EventHandler<KeyEvent>() {
+ // });
+ this.contentView.setCellFactory(new Callback<ListView<Line>, ListCell<Line>>() {
+
@Override
public ListCell<Line> call(ListView<Line> arg0) {
return new LineCell();
}
});
- contentView.setMinHeight(0);
- contentView.setMinWidth(0);
- contentView.setOnMousePressed(new EventHandler<MouseEvent>() {
+ this.contentView.setMinHeight(0);
+ this.contentView.setMinWidth(0);
+ this.contentView.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
getBehavior().mousePressed(event, getCurrentVisibleCells());
// The consuming does not help because it looks like the
- // selection change happens earlier => should be push a new ListViewBehavior?
+ // selection change happens earlier => should be push a new
+ // ListViewBehavior?
event.consume();
}
});
-
+
recalculateItems();
-
-
-
- contentView.setItems(lineList);
-
- HBox.setHgrow(contentView,Priority.ALWAYS);
-
-// b.getChildren().addAll(lineView);
- rootContainer.getChildren().addAll(contentView);
- getChildren().addAll(rootContainer);
-
+
+ this.contentView.setItems(this.lineList);
+
+ HBox.setHgrow(this.contentView, Priority.ALWAYS);
+
+ // b.getChildren().addAll(lineView);
+ this.rootContainer.getChildren().addAll(this.contentView);
+ getChildren().addAll(this.rootContainer);
+
styledText.caretOffsetProperty().addListener(new ChangeListener<Number>() {
@Override
- public void changed(ObservableValue<? extends Number> observable,
- Number oldValue, Number newValue) {
+ public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
int lineIndex = getSkinnable().getContent().getLineAtOffset(newValue.intValue());
- Line lineObject = lineList.get(lineIndex);
+ Line lineObject = StyledTextSkin.this.lineList.get(lineIndex);
getFlow().show(lineIndex);
- for( LineCell c : getCurrentVisibleCells() ) {
- if( c.domainElement == lineObject ) {
+ for (LineCell c : getCurrentVisibleCells()) {
+ if (c.domainElement == lineObject) {
// Adjust the selection
- if( contentView.getSelectionModel().getSelectedItem() != c.domainElement ) {
- contentView.getSelectionModel().select(lineObject);
+ if (StyledTextSkin.this.contentView.getSelectionModel().getSelectedItem() != c.domainElement) {
+ StyledTextSkin.this.contentView.getSelectionModel().select(lineObject);
}
-
- RegionImpl container = (RegionImpl)c.getGraphic();
- TextFlow flow = (TextFlow)container.getChildren().get(0);
-
+
+ RegionImpl container = (RegionImpl) c.getGraphic();
+ TextFlow flow = (TextFlow) container.getChildren().get(0);
+
flow.requestLayout();
-
+
return;
}
}
-
+
+ }
+ });
+ styledText.selectionProperty().addListener(new ChangeListener<TextSelection>() {
+
+ @Override
+ public void changed(
+ ObservableValue<? extends TextSelection> observable,
+ TextSelection oldValue, TextSelection newValue) {
+ recalculateItems();
}
});
}
-
- private MyVirtualFlow getFlow() {
- if( contentView == null || contentView.getSkin() == null ) {
+
+ MyVirtualFlow getFlow() {
+ if (this.contentView == null || this.contentView.getSkin() == null) {
return null;
}
- return ((MyListViewSkin)contentView.getSkin()).getFlow();
+ return ((MyListViewSkin) this.contentView.getSkin()).getFlow();
}
-
+
+ /**
+ * The line height at the care position
+ *
+ * @param caretPosition
+ * the position
+ * @return the line height
+ */
public double getLineHeight(int caretPosition) {
int lineIndex = getSkinnable().getContent().getLineAtOffset(caretPosition);
- Line lineObject = lineList.get(lineIndex);
-
- for( LineCell c : getCurrentVisibleCells() ) {
- if( c.domainElement == lineObject ) {
+ Line lineObject = this.lineList.get(lineIndex);
+
+ for (LineCell c : getCurrentVisibleCells()) {
+ if (c.domainElement == lineObject) {
return c.getHeight();
}
}
return 0;
}
-
+
+ /**
+ * Get the point for the caret position
+ *
+ * @param caretPosition
+ * the position
+ * @return the point
+ */
@SuppressWarnings("deprecation")
public Point2D getCaretLocation(int caretPosition) {
- if( caretPosition < 0 ) {
+ if (caretPosition < 0) {
return null;
}
-
+
int lineIndex = getSkinnable().getContent().getLineAtOffset(caretPosition);
- Line lineObject = lineList.get(lineIndex);
- for( LineCell c : getCurrentVisibleCells() ) {
- if( c.domainElement == lineObject ) {
- RegionImpl container = (RegionImpl)c.getGraphic();
- TextFlow flow = (TextFlow)container.getChildren().get(0);
-// System.err.println("STARTING SCAN");
+ Line lineObject = this.lineList.get(lineIndex);
+ for (LineCell c : getCurrentVisibleCells()) {
+ if (c.domainElement == lineObject) {
+ RegionImpl container = (RegionImpl) c.getGraphic();
+ TextFlow flow = (TextFlow) container.getChildren().get(0);
+ // System.err.println("STARTING SCAN");
Text textNode = null;
int relativePos = 0;
- for( int i = flow.getChildren().size()-1; i >= 0; i-- ) {
+ for (int i = flow.getChildren().size() - 1; i >= 0; i--) {
Node n = flow.getChildren().get(i);
-// System.err.println(((Text)n).getText() + " => " + n.getLayoutX());
+ // System.err.println(((Text)n).getText() + " => " +
+ // n.getLayoutX());
int offset = ((Integer) n.getUserData()).intValue();
- if( offset <= caretPosition ) {
+ if (offset <= caretPosition) {
relativePos = caretPosition - offset;
textNode = (Text) n;
break;
}
}
-
- if( textNode != null ) {
+
+ if (textNode != null) {
textNode.setImpl_caretPosition(relativePos);
PathElement[] elements = textNode.getImpl_caretShape();
double xShift = textNode.getLayoutX();
-// System.err.println(textNode.getText() + " ====> " + xShift);
- for( PathElement e : elements ) {
- if( e instanceof MoveTo ) {
- xShift +=((MoveTo)e).getX();
+ // System.err.println(textNode.getText() + " ====> " +
+ // xShift);
+ for (PathElement e : elements) {
+ if (e instanceof MoveTo) {
+ xShift += ((MoveTo) e).getX();
}
}
-// System.err.println("==> " + xShift);
-
+ // System.err.println("==> " + xShift);
+
Point2D rv = new Point2D(xShift, c.getLayoutY());
return rv;
-// final Path p = (Path)container.getChildren().get(1);
-//
-// p.getElements().clear();
-// p.getElements().addAll(textNode.getImpl_caretShape());
-//
-// p.setLayoutX(textNode.getLayoutX());
-// p.setLayoutY(textNode.getBaselineOffset());
+ // final Path p = (Path)container.getChildren().get(1);
+ //
+ // p.getElements().clear();
+ // p.getElements().addAll(textNode.getImpl_caretShape());
+ //
+ // p.setLayoutX(textNode.getLayoutX());
+ // p.setLayoutY(textNode.getBaselineOffset());
}
-
-
-// RegionImpl container = (RegionImpl)c.getGraphic();
-//
-// final Path p = (Path)container.getChildren().get(1);
-// Point2D rv = new Point2D(p.getLayoutX(),container.getLayoutY());
-// System.err.println("CARE-LOC: " + rv);
-// return rv;
+
+ // RegionImpl container = (RegionImpl)c.getGraphic();
+ //
+ // final Path p = (Path)container.getChildren().get(1);
+ // Point2D rv = new
+ // Point2D(p.getLayoutX(),container.getLayoutY());
+ // System.err.println("CARE-LOC: " + rv);
+ // return rv;
}
}
-
+
return null;
}
-
- protected double computeMinHeight(double arg0) {
- return contentView.minHeight(arg0);
+
+ /**
+ * Compute the min height
+ *
+ * @param width
+ * the width that should be used if minimum height depends on it
+ * @return the min height
+ */
+ protected double computeMinHeight(double width) {
+ return this.contentView.minHeight(width);
}
-
- protected double computeMinWidth(double arg0) {
- return contentView.minWidth(arg0);
+
+ /**
+ * Compute the min width
+ *
+ * @param height
+ * the height that should be used if minimum width depends on it
+ * @return the min width
+ */
+ protected double computeMinWidth(double height) {
+ return this.contentView.minWidth(height);
}
-
+
+ /**
+ * recalculate the line items
+ */
public void recalculateItems() {
- if( lineList.size() != getSkinnable().getContent().getLineCount() ) {
- if( lineList.size() > getSkinnable().getContent().getLineCount() ) {
- lineList.remove(getSkinnable().getContent().getLineCount(), lineList.size());
+ if (this.lineList.size() != getSkinnable().getContent().getLineCount()) {
+ if (this.lineList.size() > getSkinnable().getContent().getLineCount()) {
+ this.lineList.remove(getSkinnable().getContent().getLineCount(), this.lineList.size());
} else {
- List<Line> tmp = new ArrayList<>(getSkinnable().getContent().getLineCount()-lineList.size());
- for( int i = lineList.size(); i < getSkinnable().getContent().getLineCount(); i++ ) {
+ List<Line> tmp = new ArrayList<>(getSkinnable().getContent().getLineCount() - this.lineList.size());
+ for (int i = this.lineList.size(); i < getSkinnable().getContent().getLineCount(); i++) {
tmp.add(new Line());
}
- lineList.addAll(tmp);
+ this.lineList.addAll(tmp);
}
}
-
+
redraw();
}
+ /**
+ * Redraw the lines
+ */
public void redraw() {
- for( LineCell l : getCurrentVisibleCells() ) {
- l.update();
+ for (LineCell l : getCurrentVisibleCells()) {
+ if( l != null )
+ l.update();
}
}
-
+
List<LineCell> getCurrentVisibleCells() {
- if( contentView == null || contentView.getSkin() == null ) {
+ if (this.contentView == null || this.contentView.getSkin() == null) {
return Collections.emptyList();
}
- return ((MyListViewSkin)contentView.getSkin()).getFlow().getCells();
+ return ((MyListViewSkin) this.contentView.getSkin()).getFlow().getCells();
}
-
- Font getFontByStyle(int style) {
- switch (style) {
- case StyleRange.BOLD:
- if (boldFont != null) return boldFont;
- return boldFont = createFont(style);
- case StyleRange.ITALIC:
- if (italicFont != null) return italicFont;
- return italicFont = createFont(style);
- case StyleRange.BOLD | StyleRange.ITALIC:
- if (boldItalicFont != null) return boldItalicFont;
- return boldItalicFont = createFont(style);
- default:
- return getSkinnable().fontProperty().get();
- }
- }
-
- Font createFont(int style) {
- switch (style) {
- case StyleRange.BOLD:
- {
- Font f = Font.font(getSkinnable().getFont().getFamily(), FontWeight.BOLD, getSkinnable().getFont().getSize());
- return f;
- }
- case StyleRange.ITALIC:
- {
- Font f = Font.font(getSkinnable().getFont().getFamily(), FontPosture.ITALIC, getSkinnable().getFont().getSize());
- return f;
- }
- case StyleRange.BOLD | StyleRange.ITALIC:
- {
- Font f = Font.font(getSkinnable().getFont().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, getSkinnable().getFont().getSize());
- return f;
- }
- }
- return null;
- }
-
+
+ /**
+ * A line cell
+ */
public class LineCell extends ListCell<Line> {
- private Line domainElement;
+ Line domainElement;
private BooleanBinding caretVisible;
- private BooleanProperty flashProperty;
- private Timeline flashTimeline;
-
+ BooleanProperty flashProperty;
+ Timeline flashTimeline;
+
+ /**
+ * A line cell instance
+ */
public LineCell() {
- getStyleClass().add("styled-text-line");
- flashProperty = new SimpleBooleanProperty(this,"flash",false);
- flashTimeline = new Timeline();
- flashTimeline.setCycleCount(Timeline.INDEFINITE);
-
+ getStyleClass().add("styled-text-line"); //$NON-NLS-1$
+ this.flashProperty = new SimpleBooleanProperty(this, "flash", false); //$NON-NLS-1$
+ this.flashTimeline = new Timeline();
+ this.flashTimeline.setCycleCount(Animation.INDEFINITE);
+
EventHandler<ActionEvent> startEvent = new EventHandler<ActionEvent>() {
-
+
@Override
public void handle(ActionEvent arg0) {
- flashProperty.set(true);
+ LineCell.this.flashProperty.set(true);
}
};
-
+
EventHandler<ActionEvent> endEvent = new EventHandler<ActionEvent>() {
-
+
@Override
public void handle(ActionEvent arg0) {
- flashProperty.set(false);
+ LineCell.this.flashProperty.set(false);
}
};
-
- flashTimeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, startEvent), new KeyFrame(Duration.millis(500), endEvent), new KeyFrame(Duration.millis(1000)));
- caretVisible = new BooleanBinding() {
+
+ this.flashTimeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, startEvent), new KeyFrame(Duration.millis(500), endEvent), new KeyFrame(Duration.millis(1000)));
+ this.caretVisible = new BooleanBinding() {
{
- bind(selectedProperty(), flashProperty);
+ bind(selectedProperty(), LineCell.this.flashProperty);
}
+
@Override
protected boolean computeValue() {
- return selectedProperty().get() && flashProperty.get();
+ return selectedProperty().get() && LineCell.this.flashProperty.get();
}
};
selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
- public void changed(ObservableValue<? extends Boolean> arg0,
- Boolean arg1, Boolean arg2) {
- if( arg2.booleanValue() ) {
- flashTimeline.play();
+ public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
+ if (arg2.booleanValue()) {
+ LineCell.this.flashTimeline.play();
} else {
- flashTimeline.stop();
+ LineCell.this.flashTimeline.stop();
}
}
});
}
-
+
+ /**
+ * @return the domain element
+ */
public Line getDomainElement() {
- return domainElement;
+ return this.domainElement;
}
-
+
+ /**
+ * Update the item
+ */
public void update() {
- if( domainElement != null ) {
- updateItem(domainElement, false);
+ if (this.domainElement != null) {
+ updateItem(this.domainElement, false);
}
}
-
+
+ /**
+ * Update the caret
+ */
+ @SuppressWarnings("deprecation")
public void updateCaret() {
- //FIXME Could not pass on the Region?
int caretPosition = getSkinnable().getCaretOffset();
-
- if( caretPosition < 0 ) {
+
+ if (caretPosition < 0) {
return;
}
-
+
int lineIndex = getSkinnable().getContent().getLineAtOffset(caretPosition);
- Line lineObject = lineList.get(lineIndex);
- for( LineCell c : getCurrentVisibleCells() ) {
- if( c.domainElement == lineObject ) {
- RegionImpl container = (RegionImpl)c.getGraphic();
- TextFlow flow = (TextFlow)container.getChildren().get(0);
-
-
- Text textNode = null;
+ Line lineObject = StyledTextSkin.this.lineList.get(lineIndex);
+ for (LineCell c : getCurrentVisibleCells()) {
+ if (c.domainElement == lineObject) {
+ RegionImpl container = (RegionImpl) c.getGraphic();
+ TextFlow flow = (TextFlow) container.getChildren().get(0);
+
+ TextFlow textNode = null;
int relativePos = 0;
- for( int i = flow.getChildren().size()-1; i >= 0; i-- ) {
+ for (int i = flow.getChildren().size() - 1; i >= 0; i--) {
Node n = flow.getChildren().get(i);
int offset = ((Integer) n.getUserData()).intValue();
- if( offset <= caretPosition ) {
+ if (offset <= caretPosition) {
relativePos = caretPosition - offset;
- textNode = (Text) n;
+ textNode = (TextFlow) n;
break;
}
}
-
- if( textNode != null ) {
- textNode.setImpl_caretPosition(relativePos);
-
- final Path p = (Path)container.getChildren().get(1);
-
+
+ if (textNode != null) {
+// System.err.println("THE NODE: " + textNode.getText());
+ ((Text)textNode.getChildren().get(0)).setImpl_caretPosition(relativePos);
+
+ final Path p = (Path) container.getChildren().get(1);
+
p.getElements().clear();
- p.getElements().addAll(textNode.getImpl_caretShape());
-
- p.setLayoutX(textNode.getLayoutX());
- p.setLayoutY(textNode.getLayoutY());
+ p.getElements().addAll(((Text)textNode.getChildren().get(0)).getImpl_caretShape());
+
+ p.setLayoutX(textNode.getChildren().get(0).getLayoutX() + textNode.getLayoutX());
+ p.setLayoutY(textNode.getChildren().get(0).getLayoutY() + textNode.getLayoutY());
}
-
+
break;
}
}
}
-
+
@Override
protected void updateItem(Line arg0, boolean arg1) {
- if( ! arg1 ) {
- domainElement = arg0;
- LineInfo lineInfo = lineInfoMap.get(this);
- if( lineInfo == null ) {
+ if (!arg1) {
+ this.domainElement = arg0;
+ LineInfo lineInfo = StyledTextSkin.this.lineInfoMap.get(this);
+ if (lineInfo == null) {
lineInfo = new LineInfo();
- lineInfo.setDomainElement(domainElement);
- lineInfoMap.put(this, lineInfo);
- lineRuler.getChildren().add(lineInfo);
- lineRuler.requestLayout();
+ lineInfo.setDomainElement(this.domainElement);
+ StyledTextSkin.this.lineInfoMap.put(this, lineInfo);
+ StyledTextSkin.this.lineRuler.getChildren().add(lineInfo);
+ StyledTextSkin.this.lineRuler.requestLayout();
} else {
- lineInfo.setDomainElement(domainElement);
- lineRuler.requestLayout();
+ lineInfo.setDomainElement(this.domainElement);
+ StyledTextSkin.this.lineRuler.requestLayout();
}
lineInfo.setLayoutY(getLayoutY());
-
+
RegionImpl stack = (RegionImpl) getGraphic();
TextFlow flow;
-
- if( stack == null ) {
+
+ if (stack == null) {
flow = new TextFlow() {
@Override
protected void layoutChildren() {
@@ -463,169 +484,298 @@ public class StyledTextSkin extends BehaviorSkinBase<StyledTextArea, StyledTextB
}
};
Path caretPath = new Path();
+ caretPath.getStyleClass().add("text-caret"); //$NON-NLS-1$
caretPath.setManaged(false);
- caretPath.setStrokeWidth(1);
- caretPath.setFill((Color.BLACK));
- caretPath.setStroke((Color.BLACK));
- caretPath.visibleProperty().bind(caretVisible);
- stack = new RegionImpl(flow,caretPath);
+ caretPath.setStrokeWidth(2);
+ caretPath.visibleProperty().bind(this.caretVisible);
+ stack = new RegionImpl(flow, caretPath);
setGraphic(stack);
} else {
flow = (TextFlow) stack.getChildren().get(0);
}
-
- List<Text> texts = new ArrayList<>();
- for( final Segment seg : arg0.getSegments() ) {
+
+ List<TextFlow> texts = new ArrayList<>();
+ for (final Segment seg : arg0.getSegments()) {
+// System.err.println("SEGMENT: " + seg.text + " => " + seg.style.stylename);
final Text t = new Text(seg.text);
- t.setUserData(seg.style.start);
- if( seg.style.foreground != null ) {
+
+ if( seg.style.stylename != null ) {
+ t.getStyleClass().setAll("source-segment",seg.style.stylename); //$NON-NLS-1$
+ } else {
+ t.getStyleClass().setAll("source-segment"); //$NON-NLS-1$
+ }
+
+ if (seg.style.foreground != null) {
t.setFill(seg.style.foreground);
}
- if( seg.style.font != null ) {
+ if (seg.style.font != null) {
t.setFont(seg.style.font);
- } else {
- t.setFont(getFontByStyle(seg.style.fontStyle));
}
-
- if( seg.style.underline ) {
- System.err.println("=====================> UNDERLINEING");
+
+ if (seg.style.underline) {
+// System.err.println("=====================> UNDERLINEING");
}
+
- texts.add(t);
+ TextFlow f = new TextFlow(t);
+ f.setUserData(Integer.valueOf(seg.style.start));
+ if( seg.style.hoverStylename != null ) {
+ f.getStyleClass().setAll("source-segment-container", seg.style.hoverStylename); //$NON-NLS-1$
+ texts.add(f);
+ } else {
+ f.getStyleClass().setAll("source-segment-container"); //$NON-NLS-1$
+ texts.add(f);
+ }
}
-
- if( texts.isEmpty() ) {
- Text t = new Text("");
- t.setUserData(arg0.getLineOffset());
- texts.add(t);
+
+ if (texts.isEmpty()) {
+ Text t = new Text(""); //$NON-NLS-1$
+ t.getStyleClass().setAll("source-segment"); //$NON-NLS-1$
+ TextFlow f = new TextFlow(t);
+ f.setUserData(Integer.valueOf(arg0.getLineOffset()));
+ texts.add(f);
}
-
+
flow.getChildren().setAll(texts);
- stack.requestLayout();
} else {
setGraphic(null);
- domainElement = null;
- LineInfo lineInfo = lineInfoMap.remove(this);
- if( lineInfo != null ) {
+ this.domainElement = null;
+ LineInfo lineInfo = StyledTextSkin.this.lineInfoMap.remove(this);
+ if (lineInfo != null) {
lineInfo.setDomainElement(null);
- lineRuler.getChildren().remove(lineInfo);
+ StyledTextSkin.this.lineRuler.getChildren().remove(lineInfo);
}
}
super.updateItem(arg0, arg1);
}
}
-
+
static class RegionImpl extends Region {
public RegionImpl(Node... nodes) {
getChildren().addAll(nodes);
}
-
+
@Override
public ObservableList<Node> getChildren() {
- // TODO Auto-generated method stub
return super.getChildren();
}
}
-
+
+ /**
+ * The line domain object
+ */
public class Line {
+ /**
+ * @return the current text
+ */
public String getText() {
- return removeLineending(getSkinnable().getContent().getLine(lineList.indexOf(this)));
+ return removeLineending(getSkinnable().getContent().getLine(StyledTextSkin.this.lineList.indexOf(this)));
}
-
+
+ /**
+ * @return the line offset
+ */
public int getLineOffset() {
- int idx = lineList.indexOf(this);
+ int idx = StyledTextSkin.this.lineList.indexOf(this);
return getSkinnable().getContent().getOffsetAtLine(idx);
}
-
+
+ /**
+ * @return the line length
+ */
public int getLineLength() {
- int idx = lineList.indexOf(this);
+ int idx = StyledTextSkin.this.lineList.indexOf(this);
String s = getSkinnable().getContent().getLine(idx);
- return s == null ? 0 : s.length();
+ return s.length();
}
-
+
+ /**
+ * @return the different segments
+ */
+ @SuppressWarnings("null")
public List<Segment> getSegments() {
- int idx = lineList.indexOf(this);
+ int idx = StyledTextSkin.this.lineList.indexOf(this);
List<Segment> segments = new ArrayList<>();
-
+
String line = getSkinnable().getContent().getLine(idx);
-// System.err.println("LINE: " + line);
- if( line != null ) {
+ // System.err.println("LINE: " + line);
+ if (line != null) {
int start = getSkinnable().getContent().getOffsetAtLine(idx);
int length = line.length();
-
+
StyleRange[] ranges = getSkinnable().getStyleRanges(start, length, true);
-// System.err.println("RANGES: " + ranges);
- if( ranges == null ) {
+ // System.err.println("RANGES: " + ranges);
+ if (ranges == null) {
return Collections.emptyList();
}
+
+ TextSelection selection = getSkinnable().getSelection();
+
+ int selectionStart = selection.offset - start;
+ int selectionEnd = selection.offset+selection.length - start;
+
+// System.err.println("Line: " + line);
+// System.err.println("SELECTION: " + selectionStart + " => " + selectionEnd);
int lastIndex = -1;
- for( StyleRange r : ranges ) {
- int begin = r.start-start;
- int end = r.start-start+r.length;
- if( lastIndex != -1 && lastIndex != begin ) {
- Segment seg = new Segment();
- seg.text = line.substring(lastIndex, begin);
- seg.style = new StyleRange();
- segments.add(seg);
+ for (StyleRange r : ranges) {
+ int begin = r.start - start;
+ int end = r.start - start + r.length;
+
+ if (lastIndex != -1 && lastIndex != begin) {
+ segments.addAll(createSegments(line, new StyleRange((String)null), selectionStart, selectionEnd, lastIndex, begin));
}
+
+ segments.addAll(createSegments(line, r, selectionStart, selectionEnd, begin, end));
+ lastIndex = end;
+ }
+
+ // System.err.println("SEGEMENTS: " + segments);
+ }
+
+ return segments;
+ }
+
+ private List<Segment> createSegments(String line, StyleRange r, int selectionStart, int selectionEnd, int begin, int end) {
+// System.err.println("LINE: " + line);
+ if( selectionStart != selectionEnd ) {
+ if( selectionStart <= begin && selectionEnd >= end ) {
+ // whole entry is selected
Segment seg = new Segment();
seg.text = removeLineending(line.substring(begin, end));
- seg.style = r;
- segments.add(seg);
- lastIndex = end;
+ seg.style = new StyleRange(r);
+ seg.style.hoverStylename = "hover"; //$NON-NLS-1$
+ return Collections.singletonList(seg);
+ } else if( selectionStart <= begin && selectionEnd >= begin && selectionEnd <= end ) {
+ // selection start before and ends inside
+ List<Segment> rv = new ArrayList<StyledTextSkin.Segment>();
+
+ Segment seg = new Segment();
+ seg.text = removeLineending(line.substring(begin, selectionEnd));
+ seg.style = new StyleRange(r);
+ seg.style.hoverStylename = "hover"; //$NON-NLS-1$
+ seg.style.start = r.start;
+ rv.add(seg);
+
+ seg = new Segment();
+ seg.text = removeLineending(line.substring(selectionEnd, end));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start + selectionEnd-begin;
+ rv.add(seg);
+
+ return rv;
+ } else if( begin < selectionStart && selectionStart <= end && selectionEnd >= end ) {
+ // selection starts inside and ends outside
+ List<Segment> rv = new ArrayList<StyledTextSkin.Segment>();
+
+ Segment seg = new Segment();
+ seg.text = removeLineending(line.substring(begin, selectionStart));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start;
+ rv.add(seg);
+
+ seg = new Segment();
+ seg.text = removeLineending(line.substring(selectionStart, end));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start + selectionStart-begin;
+ seg.style.hoverStylename = "hover"; //$NON-NLS-1$
+ rv.add(seg);
+
+ return rv;
+ } else if( between(selectionStart, begin, end) && between(selectionEnd, begin, end) ) {
+// System.err.println("A BETWEEN MATCH!!!!");
+ // selection starts and ends inside
+ List<Segment> rv = new ArrayList<StyledTextSkin.Segment>();
+
+ Segment seg = new Segment();
+ seg.text = removeLineending(line.substring(begin, selectionStart));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start;
+ rv.add(seg);
+
+ seg = new Segment();
+ seg.text = removeLineending(line.substring(selectionStart, selectionEnd));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start + selectionStart-begin;
+ seg.style.hoverStylename = "hover"; //$NON-NLS-1$
+ rv.add(seg);
+
+ seg = new Segment();
+ seg.text = removeLineending(line.substring(selectionEnd, end));
+ seg.style = new StyleRange(r);
+ seg.style.start = r.start + selectionEnd-begin;
+ rv.add(seg);
+ return rv;
+ } else {
+// System.err.println("UNMATCHED CASE");
+// System.err.println("Sel: "+ selectionStart + "/" + selectionEnd);
+// System.err.println("Segment:" + begin + "/" + end);
}
-
-// System.err.println("SEGEMENTS: " + segments);
}
- return segments;
+ Segment seg = new Segment();
+ seg.text = removeLineending(line.substring(begin, end));
+ seg.style = r;
+ return Collections.singletonList(seg);
+ }
+
+ private boolean between(int x, int min, int max) {
+ return x > min && x < max;
}
}
-
+
class Segment {
public String text;
public StyleRange style;
-
+
@Override
public String toString() {
- return text + " => " + style;
+ return this.text + " => " + this.style; //$NON-NLS-1$
}
}
-
+
static String removeLineending(String s) {
- return s.replace("\n","").replace("\r", "");
+ return s.replace("\n", "").replace("\r", ""); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
-
+
class LineInfo extends HBox {
private Label markerLabel;
private Label lineText;
private Line line;
-
+
public LineInfo() {
- markerLabel = new Label();
- markerLabel.setPrefWidth(20);
- lineText = new Label();
- lineText.setMaxWidth(Double.MAX_VALUE);
- lineText.setMaxHeight(Double.MAX_VALUE);
- lineText.setAlignment(Pos.CENTER_RIGHT);
- HBox.setHgrow(lineText, Priority.ALWAYS);
- getChildren().addAll(markerLabel, lineText);
+ this.markerLabel = new Label();
+ this.markerLabel.setPrefWidth(20);
+ this.lineText = new Label();
+ this.lineText.getStyleClass().add("line-ruler-text"); //$NON-NLS-1$
+ this.lineText.setMaxWidth(Double.MAX_VALUE);
+ this.lineText.setMaxHeight(Double.MAX_VALUE);
+ this.lineText.setAlignment(Pos.CENTER_RIGHT);
+ HBox.setHgrow(this.lineText, Priority.ALWAYS);
+ getChildren().addAll(this.markerLabel, this.lineText);
}
-
+
public void setDomainElement(Line line) {
- if( line == null ) {
+ if (line == null) {
setVisible(false);
} else {
setVisible(true);
- if( line != this.line ) {
- lineText.setText(lineList.indexOf(line)+1+"");
- rootContainer.layout();
+ if (line != this.line) {
+ String newText = StyledTextSkin.this.lineList.indexOf(line) + 1 + ""; //$NON-NLS-1$
+ String oldText = this.lineText.getText();
+ if( oldText == null ) {
+ oldText = ""; //$NON-NLS-1$
+ }
+ this.lineText.setText(newText);
+ if( newText.length() != oldText.length() ) {
+ StyledTextSkin.this.rootContainer.layout();
+ }
+ StyledTextSkin.this.lineRuler.layout();
}
}
}
}
-
+
class LineRuler extends StackPane {
@Override
protected void layoutChildren() {
@@ -633,9 +783,9 @@ public class StyledTextSkin extends BehaviorSkinBase<StyledTextArea, StyledTextB
Set<Node> children = new HashSet<Node>(getChildren());
List<LineInfo> layouted = new ArrayList<>();
double maxWidth = 0;
- for( LineCell c : ((MyListViewSkin)contentView.getSkin()).getFlow().getCells() ) {
- LineInfo lineInfo = lineInfoMap.get(c);
- if( lineInfo != null ) {
+ for (LineCell c : ((MyListViewSkin) StyledTextSkin.this.contentView.getSkin()).getFlow().getCells()) {
+ LineInfo lineInfo = StyledTextSkin.this.lineInfoMap.get(c);
+ if (lineInfo != null) {
layouted.add(lineInfo);
maxWidth = Math.max(maxWidth, lineInfo.getWidth());
lineInfo.relocate(0, c.getLayoutY());
@@ -644,49 +794,49 @@ public class StyledTextSkin extends BehaviorSkinBase<StyledTextArea, StyledTextB
children.remove(lineInfo);
}
}
-
- for( LineInfo l : layouted ) {
+
+ for (LineInfo l : layouted) {
l.resize(maxWidth, l.getHeight());
}
-
- for( Node n : children ) {
+
+ for (Node n : children) {
n.setVisible(false);
- }
+ }
}
}
- class MyListViewSkin extends ListViewSkin<Line>{
+ class MyListViewSkin extends ListViewSkin<Line> {
private MyVirtualFlow flow;
public MyListViewSkin(ListView<Line> listView) {
super(listView);
}
-
+
public MyVirtualFlow getFlow() {
- return flow;
+ return this.flow;
}
-
+
@SuppressWarnings("unchecked")
@Override
protected VirtualFlow<ListCell<Line>> createVirtualFlow() {
this.flow = new MyVirtualFlow();
- return (VirtualFlow<ListCell<Line>>) ((VirtualFlow<?>)flow);
+ return (VirtualFlow<ListCell<Line>>) ((VirtualFlow<?>) this.flow);
}
-
+
}
-
+
class MyVirtualFlow extends VirtualFlow<LineCell> {
@Override
protected void positionCell(LineCell cell, double position) {
super.positionCell(cell, position);
- LineInfo lineInfo = lineInfoMap.get(cell);
- if( lineInfo != null ) {
+ LineInfo lineInfo = StyledTextSkin.this.lineInfoMap.get(cell);
+ if (lineInfo != null) {
lineInfo.setDomainElement(cell.domainElement);
lineInfo.setLayoutY(cell.getLayoutY());
}
- lineRuler.requestLayout();
+ StyledTextSkin.this.lineRuler.requestLayout();
}
-
+
@Override
public List<LineCell> getCells() {
return super.getCells();
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/styledtextarea.css b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/styledtextarea.css
index f3ffe19cd..012dbc6bc 100644
--- a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/styledtextarea.css
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/styledtext/styledtextarea.css
@@ -1,3 +1,15 @@
+.source-segment {
+ -fx-font-family: Courier;
+ -fx-font-size: 15;
+ -styled-text-color: black;
+ -fx-fill: -styled-text-color;
+}
+
+.line-ruler-text {
+ -fx-font-family: Courier;
+ -fx-font-size: 15;
+}
+
.list-cell:filled:focused:selected {
-fx-background-color: #e8f2fe;
}
@@ -6,10 +18,31 @@
-fx-background-color: transparent;
}
+.list-cell:even {
+ -fx-background-color: transparent;
+}
+
.list-cell:filled:hover {
-fx-background-color: transparent;
}
+.list-cell {
+ -fx-padding: 0;
+}
+
+.source-segment-container {
+ -fx-padding: 3 0 3 0;
+}
+
.sheet {
-fx-cursor: text;
+}
+
+.text-caret {
+ -fx-fill: black;
+ -fx-stroke: black;
+}
+
+.hover {
+ -fx-background-color: #b5d5ff;
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java
new file mode 100644
index 000000000..d530a06c0
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/DndTabPaneFactory.java
@@ -0,0 +1,495 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.controls.tabpane;
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import javafx.geometry.BoundingBox;
+import javafx.geometry.Bounds;
+import javafx.scene.Node;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.input.DragEvent;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.StackPane;
+
+import org.eclipse.fx.ui.controls.markers.PositionMarker;
+import org.eclipse.fx.ui.controls.markers.TabOutlineMarker;
+import org.eclipse.fx.ui.controls.tabpane.skin.DnDTabPaneSkin;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * Factory to create a tab pane who support DnD
+ */
+public final class DndTabPaneFactory {
+ private static MarkerFeedback CURRENT_FEEDBACK;
+// private static Map<TabSerializationStrategy<?>, Boolean> SERIALIZERS = new WeakHashMap<>();
+
+ private DndTabPaneFactory() {
+
+ }
+
+// public static final class TabSerializationStrategy<O> {
+// private final Function<Tab, String> serializationFunction;
+// private final Function<String, O> deserializationFunction;
+// final String prefix = UUID.randomUUID().toString();
+//
+// public TabSerializationStrategy(Function<Tab, String> serializationFunction, Function<String, O> deserializationFunction) {
+// this.serializationFunction = serializationFunction;
+// this.deserializationFunction = deserializationFunction;
+// }
+//
+// public final String toString(Tab tab) {
+// return this.prefix + "#" + this.serializationFunction.apply(tab); //$NON-NLS-1$
+// }
+//
+// public final O toData(String data) {
+// return deserializationFunction.apply(data.substring(prefix.length() + 1));
+// }
+// }
+//
+// public static <O> TabSerializationStrategy<O> register(Function<Tab, String> serializationFunction, Function<String, O> deserializationFunction) {
+// TabSerializationStrategy<O> t = new TabSerializationStrategy<O>(serializationFunction, deserializationFunction);
+// SERIALIZERS.put(t, Boolean.TRUE);
+// return t;
+// }
+
+ /**
+ * Create a tab pane and set the drag strategy
+ *
+ * @param setup
+ * the setup instance for the pane
+ * @return the tab pane
+ */
+ public static TabPane createDndTabPane(Consumer<DragSetup> setup) {
+ return new TabPane() {
+ @Override
+ protected javafx.scene.control.Skin<?> createDefaultSkin() {
+ DnDTabPaneSkin skin = new DnDTabPaneSkin(this);
+ setup.accept(skin);
+ return skin;
+ }
+ };
+ }
+
+ /**
+ * Create a tab pane with a default setup for drag feedback
+ *
+ * @param feedbackType
+ * the feedback type
+ * @param setup
+ * consumer to set up the tab pane
+ * @return a pane containing the TabPane
+ */
+ public static Pane createDefaultDnDPane(FeedbackType feedbackType, Consumer<TabPane> setup) {
+ StackPane pane = new StackPane();
+ TabPane tabPane = new TabPane() {
+ @Override
+ protected javafx.scene.control.Skin<?> createDefaultSkin() {
+ DnDTabPaneSkin skin = new DnDTabPaneSkin(this);
+ setup(feedbackType, pane, skin);
+
+ return skin;
+ }
+ };
+ setup.accept(tabPane);
+ pane.getChildren().add(tabPane);
+ return pane;
+ }
+
+ /**
+ * Extract the tab content
+ *
+ * @param e
+ * the event
+ * @return the content
+ */
+ public static boolean hasDnDContent(DragEvent e) {
+ return e.getDragboard().hasContent(DnDTabPaneSkin.TAB_MOVE);
+ }
+
+// /**
+// * Extract the tab content
+// *
+// * @param e
+// * the event
+// * @param clazz
+// * the type
+// * @return the content
+// */
+// public static <O> O getDnDContent(DragEvent e, Class<O> clazz) {
+// String data = (String) e.getDragboard().getContent(DnDTabPaneSkin.TAB_MOVE);
+// Object rv = null;
+// for (TabSerializationStrategy<?> s : SERIALIZERS.keySet()) {
+// if (data.startsWith(s.prefix + "#")) { //$NON-NLS-1$
+// rv = s.toData(data);
+// }
+// }
+//
+// if (rv == null) {
+// return (O) null;
+// } else {
+// if (clazz.isAssignableFrom(rv.getClass())) {
+// return (O) rv;
+// }
+// }
+//
+// return (O) null;
+// }
+
+ /**
+ * Extract the content
+ *
+ * @param e
+ * the event
+ * @return the return value
+ */
+ public static String getDnDContent(DragEvent e) {
+ return (String) e.getDragboard().getContent(DnDTabPaneSkin.TAB_MOVE);
+ }
+
+ /**
+ * Setup insert marker
+ *
+ * @param layoutNode
+ * the layout node used to position
+ * @param setup
+ * the setup
+ */
+ @SuppressWarnings("null")
+ static void setup(FeedbackType type, Pane layoutNode, DragSetup setup) {
+ setup.setStartFunction((t) -> Boolean.TRUE);
+ setup.setFeedbackConsumer((d) -> handleFeedback(type, layoutNode, d));
+ setup.setDropConsumer(DndTabPaneFactory::handleDropped);
+ setup.setDragFinishedConsumer(DndTabPaneFactory::handleFinished);
+ }
+
+ private static void handleDropped(DroppedData data) {
+ TabPane targetPane = data.targetTab.getTabPane();
+ data.draggedTab.getTabPane().getTabs().remove(data.draggedTab);
+ int idx = targetPane.getTabs().indexOf(data.targetTab);
+ if (data.dropType == DropType.AFTER) {
+ if (idx + 1 <= targetPane.getTabs().size()) {
+ targetPane.getTabs().add(idx + 1, data.draggedTab);
+ } else {
+ targetPane.getTabs().add(data.draggedTab);
+ }
+ } else {
+ targetPane.getTabs().add(idx, data.draggedTab);
+ }
+ data.draggedTab.getTabPane().getSelectionModel().select(data.draggedTab);
+ }
+
+ private static void handleFeedback(FeedbackType type, Pane layoutNode, FeedbackData data) {
+ if (data.dropType == DropType.NONE) {
+ cleanup();
+ return;
+ }
+
+ MarkerFeedback f = CURRENT_FEEDBACK;
+ if (f == null || !f.equals(data)) {
+ cleanup();
+ if (type == FeedbackType.MARKER) {
+ CURRENT_FEEDBACK = handleMarker(layoutNode, data);
+ } else {
+ CURRENT_FEEDBACK = handleOutline(layoutNode, data);
+ }
+ }
+ }
+
+ private static void handleFinished(Tab tab) {
+ cleanup();
+ }
+
+ static void cleanup() {
+ if (CURRENT_FEEDBACK != null) {
+ CURRENT_FEEDBACK.hide();
+ CURRENT_FEEDBACK = null;
+ }
+ }
+
+ private static MarkerFeedback handleMarker(Pane layoutNode, FeedbackData data) {
+ PositionMarker marker = null;
+ for (Node n : layoutNode.getChildren()) {
+ if (n instanceof PositionMarker) {
+ marker = (PositionMarker) n;
+ }
+ }
+
+ if (marker == null) {
+ marker = new PositionMarker();
+ marker.setManaged(false);
+ layoutNode.getChildren().add(marker);
+ } else {
+ marker.setVisible(true);
+ }
+
+ double w = marker.getBoundsInLocal().getWidth();
+ double h = marker.getBoundsInLocal().getHeight();
+
+ double ratio = data.bounds.getHeight() / h;
+ ratio += 0.1;
+ marker.setScaleX(ratio);
+ marker.setScaleY(ratio);
+
+ double wDiff = w / 2;
+ double hDiff = (h - h * ratio) / 2;
+
+ if (data.dropType == DropType.AFTER) {
+ marker.relocate(data.bounds.getMinX() + data.bounds.getWidth() - wDiff, data.bounds.getMinY() - hDiff);
+ } else {
+ marker.relocate(data.bounds.getMinX() - wDiff, data.bounds.getMinY() - hDiff);
+ }
+
+ final PositionMarker fmarker = marker;
+
+ return new MarkerFeedback(data) {
+
+ @Override
+ public void hide() {
+ fmarker.setVisible(false);
+ }
+ };
+ }
+
+ @SuppressWarnings("null")
+ private static MarkerFeedback handleOutline(Pane layoutNode, FeedbackData data) {
+ TabOutlineMarker marker = null;
+
+ for (Node n : layoutNode.getChildren()) {
+ if (n instanceof TabOutlineMarker) {
+ marker = (TabOutlineMarker) n;
+ }
+ }
+
+ if (marker == null) {
+ marker = new TabOutlineMarker(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
+ marker.setManaged(false);
+ marker.setMouseTransparent(true);
+ layoutNode.getChildren().add(marker);
+ } else {
+ marker.updateBounds(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
+ marker.setVisible(true);
+ }
+
+ final TabOutlineMarker fmarker = marker;
+
+ return new MarkerFeedback(data) {
+
+ @Override
+ public void hide() {
+ fmarker.setVisible(false);
+ }
+ };
+ }
+
+ private abstract static class MarkerFeedback {
+ public final FeedbackData data;
+
+ public MarkerFeedback(FeedbackData data) {
+ this.data = data;
+ }
+
+ public abstract void hide();
+ }
+
+ /**
+ * The drop type
+ */
+ public enum DropType {
+ /**
+ * No dropping
+ */
+ NONE,
+ /**
+ * Dropped before a reference tab
+ */
+ BEFORE,
+ /**
+ * Dropped after a reference tab
+ */
+ AFTER
+ }
+
+ /**
+ * The feedback type to use
+ */
+ public enum FeedbackType {
+ /**
+ * Show a marker
+ */
+ MARKER,
+ /**
+ * Show an outline
+ */
+ OUTLINE
+ }
+
+ /**
+ * Data to create a feedback
+ */
+ public static class FeedbackData {
+ /**
+ * The tab dragged
+ */
+ public final @NonNull Tab draggedTab;
+ /**
+ * The reference tab
+ */
+ public final Tab targetTab;
+ /**
+ * The bounds of the reference tab
+ */
+ public final Bounds bounds;
+ /**
+ * The drop type
+ */
+ public final @NonNull DropType dropType;
+
+ /**
+ * Create a feedback data
+ *
+ * @param draggedTab
+ * the dragged tab
+ * @param targetTab
+ * the reference tab
+ * @param bounds
+ * the bounds of the reference tab
+ * @param dropType
+ * the drop type
+ */
+ public FeedbackData(@NonNull Tab draggedTab, Tab targetTab, Bounds bounds, @NonNull DropType dropType) {
+ this.draggedTab = draggedTab;
+ this.targetTab = targetTab;
+ this.bounds = bounds;
+ this.dropType = dropType;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((this.bounds == null) ? 0 : this.bounds.hashCode());
+ result = prime * result + this.draggedTab.hashCode();
+ result = prime * result + this.dropType.hashCode();
+ result = prime * result + ((this.targetTab == null) ? 0 : this.targetTab.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FeedbackData other = (FeedbackData) obj;
+ if (this.bounds == null) {
+ if (other.bounds != null)
+ return false;
+ } else if (!this.bounds.equals(other.bounds))
+ return false;
+ if (!this.draggedTab.equals(other.draggedTab))
+ return false;
+ if (this.dropType != other.dropType)
+ return false;
+ if (this.targetTab == null) {
+ if (other.targetTab != null)
+ return false;
+ } else if (!this.targetTab.equals(other.targetTab))
+ return false;
+ return true;
+ }
+
+ }
+
+ /**
+ * The drop data
+ */
+ public static class DroppedData {
+ /**
+ * The dragged tab
+ */
+ public final @NonNull Tab draggedTab;
+ /**
+ * The reference tab
+ */
+ public final @NonNull Tab targetTab;
+ /**
+ * The drop type
+ */
+ public final @NonNull DropType dropType;
+
+ /**
+ * Create drop data
+ *
+ * @param draggedTab
+ * the dragged tab
+ * @param targetTab
+ * the target tab
+ * @param dropType
+ * the drop type
+ */
+ public DroppedData(@NonNull Tab draggedTab, @NonNull Tab targetTab, @NonNull DropType dropType) {
+ this.draggedTab = draggedTab;
+ this.targetTab = targetTab;
+ this.dropType = dropType;
+ }
+ }
+
+ /**
+ * Setup of the drag and drop
+ */
+ public interface DragSetup {
+ /**
+ * Function to handle the starting of the the drag
+ *
+ * @param startFunction
+ * the function
+ */
+ public void setStartFunction(@Nullable Function<@NonNull Tab, @NonNull Boolean> startFunction);
+
+ /**
+ * Consumer called to handle the finishing of the drag process
+ *
+ * @param dragFinishedConsumer
+ * the consumer
+ */
+ public void setDragFinishedConsumer(@Nullable Consumer<@NonNull Tab> dragFinishedConsumer);
+
+ /**
+ * Consumer called to present drag feedback
+ *
+ * @param feedbackConsumer
+ * the consumer to call
+ */
+ public void setFeedbackConsumer(@Nullable Consumer<@NonNull FeedbackData> feedbackConsumer);
+
+ /**
+ * Consumer called when the drop has to be handled
+ *
+ * @param dropConsumer
+ * the consumer
+ */
+ public void setDropConsumer(@Nullable Consumer<@NonNull DroppedData> dropConsumer);
+
+ /**
+ * Function to translate the tab content into clipboard content
+ *
+ * @param clipboardDataFunction
+ * the function
+ */
+ public void setClipboardDataFunction(@Nullable Function<@NonNull Tab, @NonNull String> clipboardDataFunction);
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/skin/DnDTabPaneSkin.java b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/skin/DnDTabPaneSkin.java
new file mode 100644
index 000000000..9cd6d48b8
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.controls/src/org/eclipse/fx/ui/controls/tabpane/skin/DnDTabPaneSkin.java
@@ -0,0 +1,426 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.controls.tabpane.skin;
+
+import java.lang.reflect.Field;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import javafx.css.StyleOrigin;
+import javafx.css.StyleableProperty;
+import javafx.event.EventHandler;
+import javafx.geometry.Bounds;
+import javafx.scene.Node;
+import javafx.scene.SnapshotParameters;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.image.PixelReader;
+import javafx.scene.image.PixelWriter;
+import javafx.scene.image.WritableImage;
+import javafx.scene.input.ClipboardContent;
+import javafx.scene.input.DataFormat;
+import javafx.scene.input.DragEvent;
+import javafx.scene.input.Dragboard;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.input.TransferMode;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.DragSetup;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.DropType;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.DroppedData;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.FeedbackData;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+import com.sun.javafx.scene.control.skin.TabPaneSkin;
+
+/**
+ * Skin for TabPane which support DnD
+ */
+@SuppressWarnings("restriction")
+public class DnDTabPaneSkin extends TabPaneSkin implements DragSetup {
+ private static Tab DRAGGED_TAB;
+ /**
+ * Custom data format for move data
+ */
+ public static final DataFormat TAB_MOVE = new DataFormat("DnDTabPane:tabMove"); //$NON-NLS-1$
+
+ private Object noneEnum;
+ private StyleableProperty<Object> openAnimation;
+ private StyleableProperty<Object> closeAnimation;
+
+ /**
+ * Create a new skin
+ *
+ * @param tabPane
+ * the tab pane
+ */
+ public DnDTabPaneSkin(TabPane tabPane) {
+ super(tabPane);
+ hookTabFolderSkin();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void hookTabFolderSkin() {
+ try {
+ Field f_tabHeaderArea = TabPaneSkin.class.getDeclaredField("tabHeaderArea"); //$NON-NLS-1$
+ f_tabHeaderArea.setAccessible(true);
+
+ Pane tabHeaderArea = (StackPane) f_tabHeaderArea.get(this);
+ tabHeaderArea.setOnDragOver((e) -> e.consume());
+
+ Field f_headersRegion = tabHeaderArea.getClass().getDeclaredField("headersRegion"); //$NON-NLS-1$
+ f_headersRegion.setAccessible(true);
+
+ Pane headersRegion = (StackPane) f_headersRegion.get(tabHeaderArea);
+ EventHandler<MouseEvent> handler = this::tabPane_handleDragStart;
+ EventHandler<DragEvent> handlerFinished = this::tabPane_handleDragDone;
+
+ for (Node tabHeaderSkin : headersRegion.getChildren()) {
+ tabHeaderSkin.addEventHandler(MouseEvent.DRAG_DETECTED, handler);
+ tabHeaderSkin.addEventHandler(DragEvent.DRAG_DONE, handlerFinished);
+ }
+
+ headersRegion.getChildren().addListener((javafx.collections.ListChangeListener.Change<? extends Node> change) -> {
+ while (change.next()) {
+ if (change.wasRemoved()) {
+ change.getRemoved().forEach((e) -> e.removeEventHandler(MouseEvent.DRAG_DETECTED, handler));
+ change.getRemoved().forEach((e) -> e.removeEventHandler(DragEvent.DRAG_DONE, handlerFinished));
+ }
+ if (change.wasAdded()) {
+ change.getAddedSubList().forEach((e) -> e.addEventHandler(MouseEvent.DRAG_DETECTED, handler));
+ change.getAddedSubList().forEach((e) -> e.addEventHandler(DragEvent.DRAG_DONE, handlerFinished));
+ }
+ }
+ });
+
+ tabHeaderArea.addEventHandler(DragEvent.DRAG_OVER, (e) -> tabPane_handleDragOver(tabHeaderArea, headersRegion, e));
+ tabHeaderArea.addEventHandler(DragEvent.DRAG_DROPPED, (e) -> tabPane_handleDragDropped(tabHeaderArea, headersRegion, e));
+ tabHeaderArea.addEventHandler(DragEvent.DRAG_EXITED, this::tabPane_handleDragDone);
+
+ Field field = TabPaneSkin.class.getDeclaredField("openTabAnimation"); //$NON-NLS-1$
+ field.setAccessible(true);
+ this.openAnimation = (StyleableProperty<Object>) field.get(this);
+
+ field = TabPaneSkin.class.getDeclaredField("closeTabAnimation"); //$NON-NLS-1$
+ field.setAccessible(true);
+ this.closeAnimation = (StyleableProperty<Object>) field.get(this);
+
+ for (Class<?> cl : getClass().getDeclaredClasses()) {
+ if ("TabAnimation".equals(cl.getSimpleName())) { //$NON-NLS-1$
+ for (Enum<?> enumConstant : (Enum<?>[]) cl.getEnumConstants()) {
+ if ("NONE".equals(enumConstant.name())) { //$NON-NLS-1$
+ this.noneEnum = enumConstant;
+ break;
+ }
+ }
+ break;
+ }
+
+ }
+ } catch (Throwable t) {
+ // // TODO Auto-generated catch block
+ t.printStackTrace();
+ }
+ }
+
+ void tabPane_handleDragStart(MouseEvent event) {
+ try {
+ Field f_tab = event.getSource().getClass().getDeclaredField("tab"); //$NON-NLS-1$
+ f_tab.setAccessible(true);
+ Tab t = (Tab) f_tab.get(event.getSource());
+
+ if (t != null && efx_canStartDrag(t)) {
+ DRAGGED_TAB = t;
+ Node node = (Node) event.getSource();
+ Dragboard db = node.startDragAndDrop(TransferMode.MOVE);
+
+ WritableImage snapShot = node.snapshot(new SnapshotParameters(), null);
+ PixelReader reader = snapShot.getPixelReader();
+ int padX = 10;
+ int padY = 10;
+ int width = (int) snapShot.getWidth();
+ int height = (int) snapShot.getHeight();
+ WritableImage image = new WritableImage(width + padX, height + padY);
+ PixelWriter writer = image.getPixelWriter();
+
+ int h = 0;
+ int v = 0;
+ while (h < width + padX) {
+ v = 0;
+ while (v < height + padY) {
+ if (h >= padX && h <= width + padX && v >= padY && v <= height + padY) {
+ writer.setColor(h, v, reader.getColor(h - padX, v - padY));
+ } else {
+ writer.setColor(h, v, Color.TRANSPARENT);
+ }
+
+ v++;
+ }
+ h++;
+ }
+
+ db.setDragView(image, image.getWidth(), image.getHeight() * -1);
+
+ ClipboardContent content = new ClipboardContent();
+ String data = efx_getClipboardContent(t);
+ if (data != null) {
+ content.put(TAB_MOVE, data);
+ }
+ db.setContent(content);
+ }
+ } catch (Throwable t) {
+ // // TODO Auto-generated catch block
+ t.printStackTrace();
+ }
+ }
+
+ @SuppressWarnings("all")
+ void tabPane_handleDragOver(Pane tabHeaderArea, Pane headersRegion, DragEvent event) {
+ Tab draggedTab = DRAGGED_TAB;
+ if (draggedTab == null) {
+ return;
+ }
+
+ // Consume the drag in any case
+ event.consume();
+
+ double x = event.getX() - headersRegion.getBoundsInParent().getMinX();
+
+ Node referenceNode = null;
+ DropType type = DropType.AFTER;
+ for (Node n : headersRegion.getChildren()) {
+ Bounds b = n.getBoundsInParent();
+ if (b.getMaxX() > x) {
+ if (b.getMinX() + b.getWidth() / 2 > x) {
+ referenceNode = n;
+ type = DropType.BEFORE;
+ } else {
+ referenceNode = n;
+ type = DropType.AFTER;
+ }
+ break;
+ }
+ }
+
+ if (referenceNode == null && headersRegion.getChildren().size() > 0) {
+ referenceNode = headersRegion.getChildren().get(headersRegion.getChildren().size() - 1);
+ type = DropType.AFTER;
+ }
+
+ if (referenceNode != null) {
+ try {
+ Field field = referenceNode.getClass().getDeclaredField("tab"); //$NON-NLS-1$
+ field.setAccessible(true);
+ Tab tab = (Tab) field.get(referenceNode);
+
+ boolean noMove = false;
+ if (tab == draggedTab) {
+ noMove = true;
+ } else if (type == DropType.BEFORE) {
+ int idx = getSkinnable().getTabs().indexOf(tab);
+ if (idx > 0) {
+ if (getSkinnable().getTabs().get(idx - 1) == draggedTab) {
+ noMove = true;
+ }
+ }
+ } else {
+ int idx = getSkinnable().getTabs().indexOf(tab);
+
+ if (idx + 1 < getSkinnable().getTabs().size()) {
+ if (getSkinnable().getTabs().get(idx + 1) == draggedTab) {
+ noMove = true;
+ }
+ }
+ }
+
+ if (noMove) {
+ efx_dragFeedback(draggedTab, null, null, DropType.NONE);
+ return;
+ }
+
+ Bounds b = referenceNode.getBoundsInLocal();
+ b = referenceNode.localToScene(b);
+ b = getSkinnable().sceneToLocal(b);
+
+ efx_dragFeedback(draggedTab, tab, b, type);
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ event.acceptTransferModes(TransferMode.MOVE);
+ } else {
+ efx_dragFeedback(draggedTab, null, null, DropType.NONE);
+ }
+ }
+
+ @SuppressWarnings("all")
+ void tabPane_handleDragDropped(Pane tabHeaderArea, Pane headersRegion, DragEvent event) {
+ Tab draggedTab = DRAGGED_TAB;
+ if (draggedTab == null) {
+ return;
+ }
+
+ double x = event.getX() - headersRegion.getBoundsInParent().getMinX();
+
+ Node referenceNode = null;
+ DropType type = DropType.AFTER;
+ for (Node n : headersRegion.getChildren()) {
+ Bounds b = n.getBoundsInParent();
+ if (b.getMaxX() > x) {
+ if (b.getMinX() + b.getWidth() / 2 > x) {
+ referenceNode = n;
+ type = DropType.BEFORE;
+ } else {
+ referenceNode = n;
+ type = DropType.AFTER;
+ }
+ break;
+ }
+ }
+
+ if (referenceNode == null && headersRegion.getChildren().size() > 0) {
+ referenceNode = headersRegion.getChildren().get(headersRegion.getChildren().size() - 1);
+ type = DropType.AFTER;
+ }
+
+ if (referenceNode != null) {
+ try {
+ Field field = referenceNode.getClass().getDeclaredField("tab"); //$NON-NLS-1$
+ field.setAccessible(true);
+ Tab tab = (Tab) field.get(referenceNode);
+
+ boolean noMove = false;
+ if( tab == null ) {
+ event.setDropCompleted(false);
+ return;
+ } else if (tab == draggedTab) {
+ noMove = true;
+ } else if (type == DropType.BEFORE) {
+ int idx = getSkinnable().getTabs().indexOf(tab);
+ if (idx > 0) {
+ if (getSkinnable().getTabs().get(idx - 1) == draggedTab) {
+ noMove = true;
+ }
+ }
+ } else {
+ int idx = getSkinnable().getTabs().indexOf(tab);
+
+ if (idx + 1 < getSkinnable().getTabs().size()) {
+ if (getSkinnable().getTabs().get(idx + 1) == draggedTab) {
+ noMove = true;
+ }
+ }
+ }
+
+ if (!noMove) {
+ StyleOrigin openOrigin = this.openAnimation.getStyleOrigin();
+ StyleOrigin closeOrigin = this.closeAnimation.getStyleOrigin();
+ Object openValue = this.openAnimation.getValue();
+ Object closeValue = this.closeAnimation.getValue();
+ try {
+ this.openAnimation.setValue(this.noneEnum);
+ this.closeAnimation.setValue(this.noneEnum);
+ efx_dropped(draggedTab, tab, type);
+ event.setDropCompleted(true);
+ } finally {
+ this.openAnimation.applyStyle(openOrigin, openValue);
+ this.closeAnimation.applyStyle(closeOrigin, closeValue);
+ }
+
+ } else {
+ event.setDropCompleted(false);
+ }
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ event.consume();
+ }
+ }
+
+ void tabPane_handleDragDone(DragEvent event) {
+ Tab tab = DRAGGED_TAB;
+ if (tab == null) {
+ return;
+ }
+
+ efx_dragFinished(tab);
+ }
+
+ private @Nullable Function<@NonNull Tab, @NonNull Boolean> startFunction;
+ private @Nullable Consumer<@NonNull Tab> dragFinishedConsumer;
+ private @Nullable Consumer<@NonNull FeedbackData> feedbackConsumer;
+ private @Nullable Consumer<@NonNull DroppedData> dropConsumer;
+ private @Nullable Function<@NonNull Tab, @NonNull String> clipboardDataFunction;
+
+ @Override
+ public void setClipboardDataFunction(@Nullable Function<@NonNull Tab, @NonNull String> clipboardDataFunction) {
+ this.clipboardDataFunction = clipboardDataFunction;
+ }
+
+ @Override
+ public void setStartFunction(@Nullable Function<@NonNull Tab, @NonNull Boolean> startFunction) {
+ this.startFunction = startFunction;
+ }
+
+ @Override
+ public void setDragFinishedConsumer(@Nullable Consumer<@NonNull Tab> dragFinishedConsumer) {
+ this.dragFinishedConsumer = dragFinishedConsumer;
+ }
+
+ @Override
+ public void setFeedbackConsumer(@Nullable Consumer<@NonNull FeedbackData> feedbackConsumer) {
+ this.feedbackConsumer = feedbackConsumer;
+ }
+
+ @Override
+ public void setDropConsumer(@Nullable Consumer<@NonNull DroppedData> dropConsumer) {
+ this.dropConsumer = dropConsumer;
+ }
+
+ private boolean efx_canStartDrag(@NonNull Tab tab) {
+ if (this.startFunction != null) {
+ return this.startFunction.apply(tab).booleanValue();
+ }
+ return true;
+ }
+
+ private void efx_dragFeedback(@NonNull Tab draggedTab, Tab targetTab, Bounds bounds, @NonNull DropType dropType) {
+ if (this.feedbackConsumer != null) {
+ this.feedbackConsumer.accept(new FeedbackData(draggedTab, targetTab, bounds, dropType));
+ }
+ }
+
+ private void efx_dropped(@NonNull Tab draggedTab, @NonNull Tab targetTab, @NonNull DropType dropType) {
+ if (this.dropConsumer != null) {
+ this.dropConsumer.accept(new DroppedData(draggedTab, targetTab, dropType));
+ }
+ }
+
+ private void efx_dragFinished(@NonNull Tab tab) {
+ if (this.dragFinishedConsumer != null) {
+ this.dragFinishedConsumer.accept(tab);
+ }
+ }
+
+ private String efx_getClipboardContent(@NonNull Tab t) {
+ if (this.clipboardDataFunction != null) {
+ return this.clipboardDataFunction.apply(t);
+ }
+ return System.identityHashCode(t) + ""; //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/PropertyTableCellFactory.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/PropertyTableCellFactory.java
index 33216d27d..af8a474e8 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/PropertyTableCellFactory.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/PropertyTableCellFactory.java
@@ -16,11 +16,7 @@ import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.util.Callback;
-import org.eclipse.core.databinding.observable.value.ComputedValue;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.property.value.IValueProperty;
-import org.eclipse.fx.core.databinding.AdapterFactory;
-import org.eclipse.fx.core.databinding.ObservableWritableValue;
import org.eclipse.fx.ui.databinding.internal.TemplateTextOnlyPropertyTableCell;
import org.eclipse.fx.ui.databinding.internal.TextOnlyPropertyTableCell;
import org.eclipse.jdt.annotation.NonNull;
@@ -74,7 +70,7 @@ public interface PropertyTableCellFactory<S, T> extends
* @return the table cell
*/
@NonNull
- public static <S, T> TableCell<S, T> textCell(IValueProperty property) {
+ public static <S, T> TableCell<S, T> textCell(@NonNull IValueProperty property) {
return new TextOnlyPropertyTableCell<>(property);
}
@@ -89,8 +85,8 @@ public interface PropertyTableCellFactory<S, T> extends
* @return the table cell
*/
@NonNull
- public static <S, T> TableCell<S, T> textCell(String template,
- IValueProperty... property) {
+ public static <S, T> TableCell<S, T> textCell(@NonNull String template,
+ @NonNull IValueProperty... property) {
return new TemplateTextOnlyPropertyTableCell<>(template, property);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
index e8080f77a..5a28120de 100755
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/TreeUtil.java
@@ -81,10 +81,11 @@ public class TreeUtil {
// return super.getChildren().isEmpty();
// }
+ @SuppressWarnings("null")
private void loadChildren() {
this.hasLoadedChildren = true;
if (this.list != null) {
- final ObservableList<TreeItem<T>> itemList = getChildren();
+ final ObservableList<@NonNull TreeItem<@NonNull T>> itemList = getChildren();
this.list.addListChangeListener(new IListChangeListener() {
@Override
@@ -110,14 +111,14 @@ public class TreeUtil {
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked" })
@Override
public void handleAdd(int index, Object element) {
if (itemList.size() > index) {
- itemList.add(index, new TreeItemImpl<T>(
+ itemList.add(index, new TreeItemImpl<@NonNull T>(
(T) element, TreeItemImpl.this.factory));
} else {
- itemList.add(new TreeItemImpl<T>(
+ itemList.add(new TreeItemImpl<@NonNull T>(
(T) element, TreeItemImpl.this.factory));
}
}
@@ -127,7 +128,7 @@ public class TreeUtil {
for (Object o : this.list) {
@SuppressWarnings("unchecked")
T t = (T) o;
- itemList.add(new TreeItemImpl<T>(t, this.factory));
+ itemList.add(new TreeItemImpl<@NonNull T>(t, this.factory));
}
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlReadOnlyPropertyValueProperty.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlReadOnlyPropertyValueProperty.java
index 04a35fbaf..a44e4935b 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlReadOnlyPropertyValueProperty.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlReadOnlyPropertyValueProperty.java
@@ -19,20 +19,28 @@ import org.eclipse.core.databinding.property.INativePropertyListener;
import org.eclipse.core.databinding.property.IProperty;
import org.eclipse.core.databinding.property.ISimplePropertyListener;
import org.eclipse.core.databinding.property.NativePropertyListener;
+import org.eclipse.jdt.annotation.NonNull;
/**
* @param <O>
*/
public abstract class ControlReadOnlyPropertyValueProperty<O> extends ControlValueProperty {
-
+
@Override
protected Object doGetValue(Object source) {
ReadOnlyProperty<O> p = getProperty(source);
- return p != null ? p.getValue() : null;
+ return p.getValue();
}
-
- protected abstract ReadOnlyProperty<O> getProperty(Object source);
-
+
+ /**
+ * Get the property
+ *
+ * @param source
+ * the source
+ * @return the property
+ */
+ protected abstract @NonNull ReadOnlyProperty<O> getProperty(Object source);
+
@Override
public INativePropertyListener adaptListener(ISimplePropertyListener listener) {
return new ListenerImpl(this, listener);
@@ -40,7 +48,7 @@ public abstract class ControlReadOnlyPropertyValueProperty<O> extends ControlVal
class ListenerImpl extends NativePropertyListener implements ChangeListener<Object> {
private Object owner;
-
+
public ListenerImpl(IProperty property, ISimplePropertyListener listener) {
super(property, listener);
}
@@ -54,18 +62,14 @@ public abstract class ControlReadOnlyPropertyValueProperty<O> extends ControlVal
protected void doAddTo(Object source) {
this.owner = source;
ReadOnlyProperty<O> p = getProperty(source);
- if( p != null ) {
- p.addListener(this);
- }
+ p.addListener(this);
}
@Override
protected void doRemoveFrom(Object source) {
this.owner = null;
ReadOnlyProperty<O> p = getProperty(source);
- if( p != null ) {
- p.removeListener(this);
- }
- }
+ p.removeListener(this);
+ }
}
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlValueProperty.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlValueProperty.java
index 772a030ee..9723378a1 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlValueProperty.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/ControlValueProperty.java
@@ -44,11 +44,20 @@ public abstract class ControlValueProperty extends SimpleValueProperty implement
@Override
public IJFXControlValueObservable observe(Realm realm, Object source) {
+ if( realm == null ) {
+ throw new IllegalArgumentException("Realm can not be null"); //$NON-NLS-1$
+ }
+ if( source == null ) {
+ throw new IllegalArgumentException("Source can not be null"); //$NON-NLS-1$
+ }
return observe(realm, (Control)source);
}
@Override
public IJFXControlValueObservable observe(Object source) {
+ if( source == null ) {
+ throw new IllegalArgumentException("Source can not be null"); //$NON-NLS-1$
+ }
return observe((Control)source);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/DatePickerValueProperty.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/DatePickerValueProperty.java
index 802de2984..eedaea80b 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/DatePickerValueProperty.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/DatePickerValueProperty.java
@@ -15,6 +15,7 @@ public class DatePickerValueProperty extends ControlPropertyValueProperty<LocalD
return LocalDate.class;
}
+ @SuppressWarnings("null")
@Override
protected Property<LocalDate> getProperty(Object source) {
DatePicker p = (DatePicker) source;
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/SingleSelectionProperty.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/SingleSelectionProperty.java
index 779f3eb6d..fdbb24051 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/SingleSelectionProperty.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/SingleSelectionProperty.java
@@ -27,10 +27,14 @@ public class SingleSelectionProperty extends ControlReadOnlyPropertyValuePropert
return null;
}
+ @SuppressWarnings("null")
@Override
protected ReadOnlyProperty<Object> getProperty(Object source) {
SelectionModel<Object> model = getSelectionModel(source);
- return model == null ? null : model.selectedItemProperty();
+ if( model == null ) {
+ throw new IllegalStateException("Unable to find selection model for '"+source+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ return model.selectedItemProperty();
}
@SuppressWarnings("unchecked")
diff --git a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/TemplateComputedValue.java b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/TemplateComputedValue.java
index 86cb1071d..a93c1ec7e 100644
--- a/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/TemplateComputedValue.java
+++ b/bundles/runtime/org.eclipse.fx.ui.databinding/src/org/eclipse/fx/ui/databinding/internal/TemplateComputedValue.java
@@ -11,6 +11,9 @@
package org.eclipse.fx.ui.databinding.internal;
import java.text.MessageFormat;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.eclipse.core.databinding.observable.value.ComputedValue;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -22,7 +25,7 @@ import org.eclipse.jdt.annotation.NonNull;
*/
public final class TemplateComputedValue extends ComputedValue {
@NonNull
- private IObservableValue[] values;
+ private List<@NonNull IObservableValue> values;
@NonNull
private String template;
@@ -36,28 +39,21 @@ public final class TemplateComputedValue extends ComputedValue {
* @param properties
* the properties
*/
+ @SuppressWarnings("null")
public TemplateComputedValue(@NonNull Object o, @NonNull String template, @NonNull IValueProperty[] properties) {
this.template = template;
- this.values = new IObservableValue[properties.length];
- for (int i = 0; i < this.values.length; i++) {
- this.values[i] = properties[i].observe(o);
- }
+ this.values = Stream.of(properties).map((p) -> p.observe(o)).collect(Collectors.toList());
}
@Override
protected Object calculate() {
- Object[] v = new Object[this.values.length];
- for (int i = 0; i < this.values.length; i++) {
- v[i] = this.values[i].getValue();
- }
+ Object[] v = this.values.stream().map((o) -> o.getValue()).toArray();
return MessageFormat.format(this.template, v);
}
@Override
public synchronized void dispose() {
super.dispose();
- for (IObservableValue v : this.values) {
- v.dispose();
- }
+ this.values.forEach((v) -> v.dispose());
}
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/BasicResourceProvider.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/BasicResourceProvider.java
index 91022575c..68b25ebba 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/BasicResourceProvider.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/BasicResourceProvider.java
@@ -42,6 +42,7 @@ public abstract class BasicResourceProvider implements ResourceProviderService {
/**
* A logger instance
*/
+ @SuppressWarnings("null")
protected Logger logger = LoggerCreator.createLogger(getClass());
/**
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/DIApplication.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/DIApplication.java
index e245ad929..7cf0f6762 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/DIApplication.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/DIApplication.java
@@ -46,6 +46,7 @@ public class DIApplication extends AbstractJFXApplication implements
@Nullable
private String applicationClass;
+ @SuppressWarnings("null")
@Override
protected void jfxStart(IApplicationContext applicationContext,
Application jfxApplication, Stage primaryStage) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/FXMLLoaderFactory.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/FXMLLoaderFactory.java
index d8d06ce17..e3b4a27d6 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/FXMLLoaderFactory.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/FXMLLoaderFactory.java
@@ -11,7 +11,6 @@
package org.eclipse.fx.ui.di;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* Factory to build an {@link FXMLLoader}
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/InjectingFXMLLoader.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/InjectingFXMLLoader.java
index 7309d5231..a7040540d 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/InjectingFXMLLoader.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/InjectingFXMLLoader.java
@@ -38,7 +38,7 @@ import org.osgi.framework.wiring.BundleWiring;
public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
@Nullable
ResourceBundle resourceBundle;
-
+
@Nullable
BuilderFactory builderFactory;
@@ -54,10 +54,7 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
* @return the loader
*/
@NonNull
- public static <N> InjectingFXMLLoader<N> create(
- @NonNull final IEclipseContext context,
- @NonNull final Class<?> requester,
- @NonNull final String relativeFxmlPath) {
+ public static <N> InjectingFXMLLoader<N> create(@NonNull final IEclipseContext context, @NonNull final Class<?> requester, @NonNull final String relativeFxmlPath) {
return create(context, requester, relativeFxmlPath, false);
}
@@ -75,36 +72,22 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
* <code>true</code> to use the {@link ExtendedFXMLLoader}
* @return the loader
*/
+ @SuppressWarnings("null")
@NonNull
- public static <N> InjectingFXMLLoader<N> create(
- @NonNull final IEclipseContext context,
- @NonNull final Class<?> requester,
- @NonNull final String relativeFxmlPath,
- boolean useExtendedFXMLLoader) {
+ public static <N> InjectingFXMLLoader<N> create(@NonNull final IEclipseContext context, @NonNull final Class<?> requester, @NonNull final String relativeFxmlPath, boolean useExtendedFXMLLoader) {
if (useExtendedFXMLLoader) {
- return create(
- context,
- FrameworkUtil.getBundle(requester),
- requester.getName()
- .substring(0, requester.getName().lastIndexOf('.'))
- .replace('.', '/')
- + "/" + relativeFxmlPath, useExtendedFXMLLoader); //$NON-NLS-1$
+ return create(context, FrameworkUtil.getBundle(requester), requester.getName().substring(0, requester.getName().lastIndexOf('.')).replace('.', '/') + "/" + relativeFxmlPath, useExtendedFXMLLoader); //$NON-NLS-1$
} else {
return new InjectingFXMLLoader<N>() {
@Override
public N load() throws IOException {
- return OSGiFXMLLoader.load(requester, relativeFxmlPath,
- this.resourceBundle, this.builderFactory,
- new ControllerFactory(context));
+ return OSGiFXMLLoader.load(requester, relativeFxmlPath, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
}
@Override
public <C> Data<N, C> loadWithController() throws IOException {
- final FXMLData<N, C> d = OSGiFXMLLoader
- .loadWithController(requester, relativeFxmlPath,
- this.resourceBundle, this.builderFactory,
- new ControllerFactory(context));
+ final FXMLData<N, C> d = OSGiFXMLLoader.loadWithController(requester, relativeFxmlPath, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
return new Data<N, C>() {
@Override
public C getController() {
@@ -132,9 +115,7 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
* the relative path in the bundle
* @return the loader
*/
- public static <N> InjectingFXMLLoader<N> create(
- final IEclipseContext context, final Bundle bundle,
- final String bundleRelativeFxmlPath) {
+ public static <N> InjectingFXMLLoader<N> create(@NonNull final IEclipseContext context, @NonNull final Bundle bundle, @NonNull final String bundleRelativeFxmlPath) {
return create(context, bundle, bundleRelativeFxmlPath, false);
}
@@ -153,31 +134,20 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
* @return the loader
*/
@NonNull
- public static <N> InjectingFXMLLoader<N> create(
- @NonNull final IEclipseContext context,
- @NonNull final Bundle bundle,
- @NonNull final String bundleRelativeFxmlPath,
- boolean useExtendedFXMLLoader) {
+ public static <N> InjectingFXMLLoader<N> create(@NonNull final IEclipseContext context, @NonNull final Bundle bundle, @NonNull final String bundleRelativeFxmlPath, boolean useExtendedFXMLLoader) {
if (useExtendedFXMLLoader) {
return new InjectingFXMLLoader<N>() {
+ @SuppressWarnings("null")
@Override
public N load() throws IOException {
- return ExtendedFXMLLoader.<N, Object> loadWithController(
- bundle.adapt(BundleWiring.class).getClassLoader(),
- this.resourceBundle,
- new ControllerFactory(context),
- bundleRelativeFxmlPath).getNode();
+ return ExtendedFXMLLoader.<N, Object> loadWithController(bundle.adapt(BundleWiring.class).getClassLoader(), this.resourceBundle, new ControllerFactory(context), bundleRelativeFxmlPath).getNode();
}
@Override
public <C> Data<N, C> loadWithController() throws IOException {
- final org.eclipse.fx.core.fxml.ExtendedFXMLLoader.Data<N, C> data = ExtendedFXMLLoader
- .<N, C> loadWithController(
- bundle.adapt(BundleWiring.class)
- .getClassLoader(),
- this.resourceBundle, new ControllerFactory(
- context), bundleRelativeFxmlPath);
+ @SuppressWarnings("null")
+ final org.eclipse.fx.core.fxml.ExtendedFXMLLoader.Data<N, C> data = ExtendedFXMLLoader.<N, C> loadWithController(bundle.adapt(BundleWiring.class).getClassLoader(), this.resourceBundle, new ControllerFactory(context), bundleRelativeFxmlPath);
return new Data<N, C>() {
@Override
@@ -197,17 +167,12 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
@Override
public N load() throws IOException {
- return OSGiFXMLLoader.load(bundle, bundleRelativeFxmlPath,
- this.resourceBundle, this.builderFactory,
- new ControllerFactory(context));
+ return OSGiFXMLLoader.load(bundle, bundleRelativeFxmlPath, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
}
@Override
public <C> Data<N, C> loadWithController() throws IOException {
- final FXMLData<N, C> d = OSGiFXMLLoader.loadWithController(
- bundle, bundleRelativeFxmlPath,
- this.resourceBundle, this.builderFactory,
- new ControllerFactory(context));
+ final FXMLData<N, C> d = OSGiFXMLLoader.loadWithController(bundle, bundleRelativeFxmlPath, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
return new Data<N, C>() {
@Override
public C getController() {
@@ -236,24 +201,17 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
* @return a loader instance
*/
@NonNull
- public static <N> InjectingFXMLLoader<N> create(
- @NonNull final IEclipseContext context,
- @NonNull final ClassLoader classloader,
- @NonNull final URL url) {
+ public static <N> InjectingFXMLLoader<N> create(@NonNull final IEclipseContext context, @NonNull final ClassLoader classloader, @NonNull final URL url) {
return new InjectingFXMLLoader<N>() {
@Override
public N load() throws IOException {
- return OSGiFXMLLoader.load(classloader, url,
- this.resourceBundle, this.builderFactory,
- new ControllerFactory(context));
+ return OSGiFXMLLoader.load(classloader, url, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
}
@Override
public <C> Data<N, C> loadWithController() throws IOException {
- final FXMLData<N, C> d = OSGiFXMLLoader.loadWithController(
- classloader, url, this.resourceBundle,
- this.builderFactory, new ControllerFactory(context));
+ final FXMLData<N, C> d = OSGiFXMLLoader.loadWithController(classloader, url, this.resourceBundle, this.builderFactory, new ControllerFactory(context));
return new Data<N, C>() {
@Override
public C getController() {
@@ -294,8 +252,7 @@ public abstract class InjectingFXMLLoader<N> implements FXMLBuilder<N> {
@Override
public Object call(Class<?> param) {
Object o;
- if (param.isInterface()
- || (param.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT) {
+ if (param.isInterface() || (param.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT) {
o = this.context.get(param.getName());
} else {
o = ContextInjectionFactory.make(param, this.context);
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/FXMLLoaderSupplier.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/FXMLLoaderSupplier.java
index 4ebe54213..da3c9270c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/FXMLLoaderSupplier.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/FXMLLoaderSupplier.java
@@ -11,6 +11,7 @@
package org.eclipse.fx.ui.di.internal;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.IInjector;
import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier;
import org.eclipse.e4.core.di.suppliers.IObjectDescriptor;
import org.eclipse.e4.core.di.suppliers.IRequestor;
@@ -30,30 +31,27 @@ import org.osgi.framework.FrameworkUtil;
public class FXMLLoaderSupplier extends ExtendedObjectSupplier {
@Override
- public Object get(IObjectDescriptor descriptor, IRequestor requestor,
- boolean track, boolean group) {
- Requestor req = (Requestor) requestor;
- ContextObjectSupplier sub = (ContextObjectSupplier) req
- .getPrimarySupplier();
+ public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
+ Requestor<?> req = (Requestor<?>) requestor;
+ ContextObjectSupplier sub = (ContextObjectSupplier) req.getPrimarySupplier();
final IEclipseContext context = sub.getContext();
- final Class<?> requestingClass = requestor.getRequestingObject()
- .getClass();
- final boolean extended = descriptor.getQualifier(FXMLLoader.class)
- .useExtendedLoader();
+ final Class<?> requestingClass = requestor.getRequestingObject().getClass();
+ if( context == null || requestingClass == null ) {
+ return IInjector.NOT_A_VALUE;
+ }
+ final boolean extended = descriptor.getQualifier(FXMLLoader.class).useExtendedLoader();
return new FXMLLoaderFactory() {
@Override
public <N> FXMLBuilder<N> loadRequestorRelative(@NonNull String relativePath) {
- return InjectingFXMLLoader.create(context, requestingClass,
- relativePath, extended);
+ return InjectingFXMLLoader.create(context, requestingClass, relativePath, extended);
}
+ @SuppressWarnings("null")
@Override
public <N> FXMLBuilder<N> loadBundleRelative(@NonNull String relativePath) {
- return InjectingFXMLLoader.create(context,
- FrameworkUtil.getBundle(requestingClass), relativePath,
- extended);
+ return InjectingFXMLLoader.create(context, FrameworkUtil.getBundle(requestingClass), relativePath, extended);
}
};
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/LoggerSupplier.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/LoggerSupplier.java
index 6c1d7dfe5..47b6b2734 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/LoggerSupplier.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/LoggerSupplier.java
@@ -27,7 +27,7 @@ public class LoggerSupplier extends ExtendedObjectSupplier {
@Override
public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
- Requestor req = (Requestor) requestor;
+ Requestor<?> req = (Requestor<?>) requestor;
ContextObjectSupplier sub = (ContextObjectSupplier) req
.getPrimarySupplier();
final IEclipseContext context = sub.getContext();
@@ -38,6 +38,10 @@ public class LoggerSupplier extends ExtendedObjectSupplier {
loggerName = requestor.getRequestingObjectClass().getName();
}
+ if( loggerName == null ) {
+ loggerName = "AnonymousLogger"; //$NON-NLS-1$
+ }
+
return context.get(LoggerFactory.class).createLogger(loggerName);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/ResourceServiceImpl.java b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/ResourceServiceImpl.java
index a888adece..546d8195c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/ResourceServiceImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.di/src/org/eclipse/fx/ui/di/internal/ResourceServiceImpl.java
@@ -168,6 +168,7 @@ public class ResourceServiceImpl implements ResourceService {
throw new IOException("No provider known for '" + key + "'."); //$NON-NLS-1$ //$NON-NLS-2$
}
+ @SuppressWarnings("null")
private ResourceProviderService lookupOSGI(String key) {
try {
Collection<ServiceReference<ResourceProviderService>> refs = this.context
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingProcessingAddon.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingProcessingAddon.java
index c8efd6f0b..b03ff797e 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingProcessingAddon.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingProcessingAddon.java
@@ -45,6 +45,7 @@ import org.eclipse.fx.ui.keybindings.Binding;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
import org.eclipse.fx.ui.keybindings.e4.internal.BindingTable;
import org.eclipse.fx.ui.keybindings.e4.internal.BindingTableManager;
+import org.eclipse.jdt.annotation.NonNull;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
@@ -71,7 +72,7 @@ public class BindingProcessingAddon {
@Inject
private EBindingService bindingService;
-
+
@Inject
@Log
private Logger logger;
@@ -81,9 +82,9 @@ public class BindingProcessingAddon {
private EventHandler contextHandler;
@PostConstruct
- public void init() {
+ void init() {
defineBindingTables();
- activateContexts(application);
+ activateContexts(this.application);
registerModelListeners();
}
@@ -91,8 +92,7 @@ public class BindingProcessingAddon {
if (me instanceof MBindings) {
MContext contextModel = (MContext) me;
MBindings container = (MBindings) me;
- List<MBindingContext> bindingContexts = container
- .getBindingContexts();
+ List<MBindingContext> bindingContexts = container.getBindingContexts();
IEclipseContext context = contextModel.getContext();
if (context != null && !bindingContexts.isEmpty()) {
EContextService cs = context.get(EContextService.class);
@@ -102,7 +102,8 @@ public class BindingProcessingAddon {
}
}
if (me instanceof MElementContainer) {
- List<MUIElement> children = ((MElementContainer) me).getChildren();
+ @SuppressWarnings("unchecked")
+ List<MUIElement> children = ((MElementContainer<MUIElement>) me).getChildren();
Iterator<MUIElement> i = children.iterator();
while (i.hasNext()) {
MUIElement e = i.next();
@@ -112,7 +113,7 @@ public class BindingProcessingAddon {
}
private void defineBindingTables() {
- for (MBindingTable bindingTable : application.getBindingTables()) {
+ for (MBindingTable bindingTable : this.application.getBindingTables()) {
defineBindingTable(bindingTable);
}
}
@@ -121,49 +122,38 @@ public class BindingProcessingAddon {
* @param bindingTable
*/
private void defineBindingTable(MBindingTable bindingTable) {
- final Context bindingContext = contextManager.getContext(bindingTable
- .getBindingContext().getElementId());
- BindingTable table = bindingTables.getTable(bindingTable
- .getBindingContext().getElementId());
- if (table == null) {
+ final Context bindingContext = this.contextManager.getContext(bindingTable.getBindingContext().getElementId());
+ BindingTable table = this.bindingTables.getTable(bindingTable.getBindingContext().getElementId());
+ if (table == null && bindingContext != null) {
table = new BindingTable(bindingContext);
- bindingTables.addTable(table);
+ this.bindingTables.addTable(table);
}
for (MKeyBinding binding : bindingTable.getBindings()) {
defineBinding(table, bindingContext, binding);
}
}
- /**
- * @param bindingTable
- * @param binding
- */
- private void defineBinding(BindingTable bindingTable,
- Context bindingContext, MKeyBinding binding) {
- Binding keyBinding = createBinding(bindingContext,
- binding.getCommand(), binding.getParameters(),
- binding.getKeySequence(), binding);
- if (keyBinding != null
- && !binding.getTags().contains(
- EBindingService.DELETED_BINDING_TAG)) {
- bindingTable.addBinding(keyBinding);
+ private void defineBinding(BindingTable bindingTable, Context bindingContext, MKeyBinding binding) {
+ String keySequence = binding.getKeySequence();
+ if( keySequence != null ) {
+ Binding keyBinding = createBinding(bindingContext, binding.getCommand(), binding.getParameters(), keySequence, binding);
+ if (keyBinding != null && !binding.getTags().contains(EBindingService.DELETED_BINDING_TAG)) {
+ bindingTable.addBinding(keyBinding);
+ }
}
}
- private Binding createBinding(Context bindingContext, MCommand cmdModel,
- List<MParameter> modelParms, String keySequence, MKeyBinding binding) {
+ @SuppressWarnings("null")
+ private Binding createBinding(Context bindingContext, MCommand cmdModel, List<MParameter> modelParms, @NonNull String keySequence, MKeyBinding binding) {
Binding keyBinding = null;
- if (binding.getTransientData()
- .get(EBindingService.MODEL_TO_BINDING_KEY) != null) {
+ if (binding.getTransientData().get(EBindingService.MODEL_TO_BINDING_KEY) != null) {
try {
- keyBinding = (Binding) binding.getTransientData().get(
- EBindingService.MODEL_TO_BINDING_KEY);
+ keyBinding = (Binding) binding.getTransientData().get(EBindingService.MODEL_TO_BINDING_KEY);
return keyBinding;
} catch (ClassCastException cce) {
- System.err
- .println("Invalid type stored in transient data with the key "
- + EBindingService.MODEL_TO_BINDING_KEY);
+ System.err.println("Invalid type stored in transient data with the key " //$NON-NLS-1$
+ + EBindingService.MODEL_TO_BINDING_KEY);
return null;
}
}
@@ -178,44 +168,50 @@ public class BindingProcessingAddon {
parameters.put(mParm.getName(), mParm.getValue());
}
}
- ParameterizedCommand cmd = commandService.createCommand(
- cmdModel.getElementId(), parameters);
+ ParameterizedCommand cmd = this.commandService.createCommand(cmdModel.getElementId(), parameters);
TriggerSequence sequence = null;
- sequence = bindingService.createSequence(keySequence);
+ sequence = this.bindingService.createSequence(keySequence);
if (cmd == null) {
- logger.error("Failed to find command for binding: " + binding); //$NON-NLS-1$
+ this.logger.error("Failed to find command for binding: " + binding); //$NON-NLS-1$
} else if (sequence == null) {
- logger.error("Failed to map binding: " + binding); //$NON-NLS-1$
+ this.logger.error("Failed to map binding: " + binding); //$NON-NLS-1$
} else {
try {
String schemeId = null;
String locale = null;
String platform = null;
- Map<String, String> attrs = new HashMap<String, String>();
+ Map<@NonNull String, @NonNull String> attrs = new HashMap<>();
List<String> tags = binding.getTags();
for (String tag : tags) {
// remember to skip the ':' in each tag!
if (tag.startsWith(EBindingService.SCHEME_ID_ATTR_TAG)) {
schemeId = tag.substring(9);
- attrs.put(EBindingService.SCHEME_ID_ATTR_TAG, schemeId);
+ if( schemeId != null ) {
+ attrs.put(EBindingService.SCHEME_ID_ATTR_TAG, schemeId);
+ }
} else if (tag.startsWith(EBindingService.LOCALE_ATTR_TAG)) {
locale = tag.substring(7);
- attrs.put(EBindingService.LOCALE_ATTR_TAG, locale);
- } else if (tag
- .startsWith(EBindingService.PLATFORM_ATTR_TAG)) {
+ if( locale != null ) {
+ attrs.put(EBindingService.LOCALE_ATTR_TAG, locale);
+ }
+ } else if (tag.startsWith(EBindingService.PLATFORM_ATTR_TAG)) {
platform = tag.substring(9);
- attrs.put(EBindingService.PLATFORM_ATTR_TAG, platform);
+ if( platform != null ) {
+ attrs.put(EBindingService.PLATFORM_ATTR_TAG, platform);
+ }
} else if (tag.startsWith(EBindingService.TYPE_ATTR_TAG)) {
// system bindings won't pass this attr
- attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
+ attrs.put(EBindingService.TYPE_ATTR_TAG, "user"); //$NON-NLS-1$
}
}
- keyBinding = bindingService.createBinding(sequence, cmd,
- bindingContext.getId(), attrs);
+ String id = bindingContext.getId();
+ if( id != null ) {
+ keyBinding = this.bindingService.createBinding(sequence, cmd, id, attrs);
+ }
} catch (IllegalArgumentException e) {
- logger.error("failed to create: " + binding, e); //$NON-NLS-1$
+ this.logger.error("failed to create: " + binding, e); //$NON-NLS-1$
return null;
}
@@ -237,178 +233,146 @@ public class BindingProcessingAddon {
}
MBindingTable bt = (MBindingTable) parentObj;
- final Context bindingContext = contextManager.getContext(bt
- .getBindingContext().getElementId());
- BindingTable table = bindingTables.getTable(bindingContext.getId());
+ final Context bindingContext = this.contextManager.getContext(bt.getBindingContext().getElementId());
+ BindingTable table = this.bindingTables.getTable(bindingContext.getId());
if (table == null) {
- logger.error("Trying to create \'" + binding //$NON-NLS-1$
+ this.logger.error("Trying to create \'" + binding //$NON-NLS-1$
+ "\' without binding table " + bindingContext.getId());//$NON-NLS-1$
return;
}
- Binding keyBinding = createBinding(bindingContext,
- binding.getCommand(), binding.getParameters(),
- binding.getKeySequence(), binding);
- if (keyBinding != null) {
- if (add) {
- table.addBinding(keyBinding);
- } else {
- table.removeBinding(keyBinding);
- }
+ String keySequence = binding.getKeySequence();
+ if( keySequence != null ) {
+ Binding keyBinding = createBinding(bindingContext, binding.getCommand(), binding.getParameters(), keySequence, binding);
+ if (keyBinding != null) {
+ if (add) {
+ table.addBinding(keyBinding);
+ } else {
+ table.removeBinding(keyBinding);
+ }
+ }
}
}
@PreDestroy
- public void dispose() {
+ void dispose() {
unregsiterModelListeners();
}
- private void registerModelListeners() {
- additionHandler = new EventHandler() {
- public void handleEvent(Event event) {
- Object elementObj = event
- .getProperty(UIEvents.EventTags.ELEMENT);
- if (elementObj instanceof MApplication) {
- Object newObj = event
- .getProperty(UIEvents.EventTags.NEW_VALUE);
- if (UIEvents.EventTypes.ADD.equals(event
- .getProperty(UIEvents.EventTags.TYPE))
- && newObj instanceof MBindingTable) {
- MBindingTable bt = (MBindingTable) newObj;
- final Context bindingContext = contextManager
- .getContext(bt.getBindingContext()
- .getElementId());
- final BindingTable table = new BindingTable(
- bindingContext);
- bindingTables.addTable(table);
- List<MKeyBinding> bindings = bt.getBindings();
- for (MKeyBinding binding : bindings) {
- Binding keyBinding = createBinding(bindingContext,
- binding.getCommand(),
- binding.getParameters(),
- binding.getKeySequence(), binding);
+ private void additionHandler(Event event) {
+ Object elementObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (elementObj instanceof MApplication) {
+ Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (UIEvents.EventTypes.ADD.equals(event.getProperty(UIEvents.EventTags.TYPE)) && newObj instanceof MBindingTable) {
+ MBindingTable bt = (MBindingTable) newObj;
+ final Context bindingContext = this.contextManager.getContext(bt.getBindingContext().getElementId());
+ if (bindingContext != null) {
+ final BindingTable table = new BindingTable(bindingContext);
+ this.bindingTables.addTable(table);
+ List<MKeyBinding> bindings = bt.getBindings();
+ for (MKeyBinding binding : bindings) {
+ String keySequence = binding.getKeySequence();
+ if( keySequence != null ) {
+ Binding keyBinding = createBinding(bindingContext, binding.getCommand(), binding.getParameters(), keySequence, binding);
if (keyBinding != null) {
table.addBinding(keyBinding);
- }
+ }
}
}
- } else if (elementObj instanceof MBindingTable) {
- Object newObj = event
- .getProperty(UIEvents.EventTags.NEW_VALUE);
- Object oldObj = event
- .getProperty(UIEvents.EventTags.OLD_VALUE);
-
- // adding a binding
- if (UIEvents.EventTypes.ADD.equals(event
- .getProperty(UIEvents.EventTags.TYPE))
- && newObj instanceof MKeyBinding) {
-
- MKeyBinding binding = (MKeyBinding) newObj;
- updateBinding(binding, true, elementObj);
- }
- // removing a binding
- else if (UIEvents.EventTypes.REMOVE.equals(event
- .getProperty(UIEvents.EventTags.TYPE))
- && oldObj instanceof MKeyBinding) {
+ }
+ }
+ } else if (elementObj instanceof MBindingTable) {
+ Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ Object oldObj = event.getProperty(UIEvents.EventTags.OLD_VALUE);
- MKeyBinding binding = (MKeyBinding) oldObj;
- updateBinding(binding, false, elementObj);
- }
- } else if (elementObj instanceof MKeyBinding) {
- MKeyBinding binding = (MKeyBinding) elementObj;
-
- String attrName = (String) event
- .getProperty(UIEvents.EventTags.ATTNAME);
-
- if (UIEvents.EventTypes.SET.equals(event
- .getProperty(UIEvents.EventTags.TYPE))) {
- Object oldObj = event
- .getProperty(UIEvents.EventTags.OLD_VALUE);
- if (UIEvents.KeyBinding.COMMAND.equals(attrName)) {
- MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
- .copy((EObject) binding);
- oldBinding.setCommand((MCommand) oldObj);
- updateBinding(oldBinding, false,
- ((EObject) binding).eContainer());
- updateBinding(binding, true, null);
- } else if (UIEvents.KeySequence.KEYSEQUENCE
- .equals(attrName)) {
- MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
- .copy((EObject) binding);
- oldBinding.setKeySequence((String) oldObj);
- updateBinding(oldBinding, false,
- ((EObject) binding).eContainer());
- updateBinding(binding, true, null);
- }
- } else if (UIEvents.KeyBinding.PARAMETERS.equals(attrName)) {
- if (UIEvents.EventTypes.ADD.equals(event
- .getProperty(UIEvents.EventTags.TYPE))) {
- Object newObj = event
- .getProperty(UIEvents.EventTags.NEW_VALUE);
- MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
- .copy((EObject) binding);
- oldBinding.getParameters().remove(newObj);
- updateBinding(oldBinding, false,
- ((EObject) binding).eContainer());
- updateBinding(binding, true, null);
- } else if (UIEvents.EventTypes.REMOVE.equals(event
- .getProperty(UIEvents.EventTags.TYPE))) {
- Object oldObj = event
- .getProperty(UIEvents.EventTags.OLD_VALUE);
- MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
- .copy((EObject) binding);
- oldBinding.getParameters().add((MParameter) oldObj);
- updateBinding(oldBinding, false,
- ((EObject) binding).eContainer());
- updateBinding(binding, true, null);
- }
- }
- // if we've updated the tags for an MKeyBinding
- else if (UIEvents.ApplicationElement.TAGS.equals(attrName)) {
- List<String> tags = binding.getTags();
- // if we added a deleted tag to the MKeyBinding, then
- // remove it from the runtime binding tables
- if (tags.contains(EBindingService.DELETED_BINDING_TAG)) {
- updateBinding(binding, false, elementObj);
- }
- // else we're adding the binding to the runtime tables
- else {
- updateBinding(binding, true, elementObj);
- }
- }
+ // adding a binding
+ if (UIEvents.EventTypes.ADD.equals(event.getProperty(UIEvents.EventTags.TYPE)) && newObj instanceof MKeyBinding) {
+
+ MKeyBinding binding = (MKeyBinding) newObj;
+ updateBinding(binding, true, elementObj);
+ }
+ // removing a binding
+ else if (UIEvents.EventTypes.REMOVE.equals(event.getProperty(UIEvents.EventTags.TYPE)) && oldObj instanceof MKeyBinding) {
+
+ MKeyBinding binding = (MKeyBinding) oldObj;
+ updateBinding(binding, false, elementObj);
+ }
+ } else if (elementObj instanceof MKeyBinding) {
+ MKeyBinding binding = (MKeyBinding) elementObj;
+
+ String attrName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
+
+ if (UIEvents.EventTypes.SET.equals(event.getProperty(UIEvents.EventTags.TYPE))) {
+ Object oldObj = event.getProperty(UIEvents.EventTags.OLD_VALUE);
+ if (UIEvents.KeyBinding.COMMAND.equals(attrName)) {
+ MKeyBinding oldBinding = (MKeyBinding) EcoreUtil.copy((EObject) binding);
+ oldBinding.setCommand((MCommand) oldObj);
+ updateBinding(oldBinding, false, ((EObject) binding).eContainer());
+ updateBinding(binding, true, null);
+ } else if (UIEvents.KeySequence.KEYSEQUENCE.equals(attrName)) {
+ MKeyBinding oldBinding = (MKeyBinding) EcoreUtil.copy((EObject) binding);
+ oldBinding.setKeySequence((String) oldObj);
+ updateBinding(oldBinding, false, ((EObject) binding).eContainer());
+ updateBinding(binding, true, null);
+ }
+ } else if (UIEvents.KeyBinding.PARAMETERS.equals(attrName)) {
+ if (UIEvents.EventTypes.ADD.equals(event.getProperty(UIEvents.EventTags.TYPE))) {
+ Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ MKeyBinding oldBinding = (MKeyBinding) EcoreUtil.copy((EObject) binding);
+ oldBinding.getParameters().remove(newObj);
+ updateBinding(oldBinding, false, ((EObject) binding).eContainer());
+ updateBinding(binding, true, null);
+ } else if (UIEvents.EventTypes.REMOVE.equals(event.getProperty(UIEvents.EventTags.TYPE))) {
+ Object oldObj = event.getProperty(UIEvents.EventTags.OLD_VALUE);
+ MKeyBinding oldBinding = (MKeyBinding) EcoreUtil.copy((EObject) binding);
+ oldBinding.getParameters().add((MParameter) oldObj);
+ updateBinding(oldBinding, false, ((EObject) binding).eContainer());
+ updateBinding(binding, true, null);
}
}
- };
- broker.subscribe(UIEvents.BindingTableContainer.TOPIC_BINDINGTABLES,
- additionHandler);
- broker.subscribe(UIEvents.BindingTable.TOPIC_BINDINGS, additionHandler);
- broker.subscribe(UIEvents.KeyBinding.TOPIC_COMMAND, additionHandler);
- broker.subscribe(UIEvents.KeyBinding.TOPIC_PARAMETERS, additionHandler);
- broker.subscribe(UIEvents.KeySequence.TOPIC_KEYSEQUENCE,
- additionHandler);
- broker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS,
- additionHandler);
-
- contextHandler = new EventHandler() {
- public void handleEvent(Event event) {
- Object elementObj = event
- .getProperty(UIEvents.EventTags.ELEMENT);
- Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
- if (UIEvents.EventTypes.SET.equals(event
- .getProperty(UIEvents.EventTags.TYPE))
- && newObj instanceof IEclipseContext) {
- activateContexts(elementObj);
+ // if we've updated the tags for an MKeyBinding
+ else if (UIEvents.ApplicationElement.TAGS.equals(attrName)) {
+ List<String> tags = binding.getTags();
+ // if we added a deleted tag to the MKeyBinding, then
+ // remove it from the runtime binding tables
+ if (tags.contains(EBindingService.DELETED_BINDING_TAG)) {
+ updateBinding(binding, false, elementObj);
+ }
+ // else we're adding the binding to the runtime tables
+ else {
+ updateBinding(binding, true, elementObj);
}
}
- };
- broker.subscribe(UIEvents.Context.TOPIC_CONTEXT, contextHandler);
+ }
+ }
+
+ private void contextHandler(Event event) {
+ Object elementObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (UIEvents.EventTypes.SET.equals(event.getProperty(UIEvents.EventTags.TYPE)) && newObj instanceof IEclipseContext) {
+ activateContexts(elementObj);
+ }
+ }
+
+ private void registerModelListeners() {
+ this.additionHandler = this::additionHandler;
+
+ this.broker.subscribe(UIEvents.BindingTableContainer.TOPIC_BINDINGTABLES, this.additionHandler);
+ this.broker.subscribe(UIEvents.BindingTable.TOPIC_BINDINGS, this.additionHandler);
+ this.broker.subscribe(UIEvents.KeyBinding.TOPIC_COMMAND, this.additionHandler);
+ this.broker.subscribe(UIEvents.KeyBinding.TOPIC_PARAMETERS, this.additionHandler);
+ this.broker.subscribe(UIEvents.KeySequence.TOPIC_KEYSEQUENCE, this.additionHandler);
+ this.broker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS, this.additionHandler);
+
+ this.contextHandler = this::contextHandler;
+ this.broker.subscribe(UIEvents.Context.TOPIC_CONTEXT, this.contextHandler);
}
private void unregsiterModelListeners() {
- broker.unsubscribe(additionHandler);
- broker.unsubscribe(additionHandler);
- broker.unsubscribe(additionHandler);
- broker.unsubscribe(additionHandler);
- broker.unsubscribe(additionHandler);
- broker.unsubscribe(contextHandler);
+ this.broker.unsubscribe(this.additionHandler);
+ this.broker.unsubscribe(this.additionHandler);
+ this.broker.unsubscribe(this.additionHandler);
+ this.broker.unsubscribe(this.additionHandler);
+ this.broker.unsubscribe(this.additionHandler);
+ this.broker.unsubscribe(this.contextHandler);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingServiceAddon.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingServiceAddon.java
index 0822ed20f..0bdab7b61 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingServiceAddon.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/BindingServiceAddon.java
@@ -12,6 +12,7 @@
package org.eclipse.fx.ui.keybindings.e4;
import javax.annotation.PostConstruct;
+
import org.eclipse.core.commands.contexts.ContextManager;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
@@ -19,21 +20,18 @@ import org.eclipse.fx.ui.keybindings.e4.internal.BindingServiceCreationFunction;
import org.eclipse.fx.ui.keybindings.e4.internal.BindingTableManager;
import org.eclipse.fx.ui.keybindings.e4.internal.ContextSet;
-
-
/**
- * Provide the binding and context id services as an add-on. Must be instantiated against the
- * application level context.
+ * Provide the binding and context id services as an add-on. Must be
+ * instantiated against the application level context.
*/
-@SuppressWarnings("restriction")
public class BindingServiceAddon {
+ @SuppressWarnings("static-method")
@PostConstruct
- public void init(IEclipseContext context) {
+ void init(IEclipseContext context) {
ContextManager contextManager = context.get(ContextManager.class);
ContextSet.setComparator(new ContextSet.CComp(contextManager));
- context.set(BindingTableManager.class,
- ContextInjectionFactory.make(BindingTableManager.class, context));
+ context.set(BindingTableManager.class, ContextInjectionFactory.make(BindingTableManager.class, context));
context.set(EBindingService.class.getName(), new BindingServiceCreationFunction());
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/EBindingService.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/EBindingService.java
index 380ce3f57..363155313 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/EBindingService.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/EBindingService.java
@@ -16,45 +16,179 @@ import java.util.Map;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.fx.ui.keybindings.Binding;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+/**
+ * Service to interact with key bindings
+ */
public interface EBindingService {
+ /**
+ * The id used in the context
+ */
public static final String DIALOG_CONTEXT_ID = "org.eclipse.ui.contexts.dialog"; //$NON-NLS-1$
+ /**
+ * Name of the default scheme
+ */
public static final String DEFAULT_SCHEME_ID = "org.eclipse.ui.defaultAcceleratorConfiguration"; //$NON-NLS-1$
+ /**
+ * Key used to store the binding in the transient map
+ */
public static final String MODEL_TO_BINDING_KEY = "binding"; //$NON-NLS-1$
+ /**
+ * Tag used for the active scheme
+ */
public static final String ACTIVE_SCHEME_TAG = "activeSchemeId"; //$NON-NLS-1$
+ /**
+ * Tag prefix for the scheme
+ */
public static final String SCHEME_ID_ATTR_TAG = "schemeId"; //$NON-NLS-1$
+ /**
+ * Tag prefix for the locale
+ */
public static final String LOCALE_ATTR_TAG = "locale"; //$NON-NLS-1$
+ /**
+ * Tag prefix for the platform
+ */
public static final String PLATFORM_ATTR_TAG = "platform"; //$NON-NLS-1$
+ /**
+ * Tag prefix for the type
+ */
public static final String TYPE_ATTR_TAG = "type"; //$NON-NLS-1$
+ /**
+ * Tag prefix for the deleted
+ */
public static final String DELETED_BINDING_TAG = "deleted"; //$NON-NLS-1$
- Binding createBinding(TriggerSequence sequence, ParameterizedCommand command, String contextId,
- Map<String, String> attributes);
-
- void activateBinding(Binding binding);
-
- void deactivateBinding(Binding binding);
-
- TriggerSequence createSequence(String sequence);
-
- Collection<Binding> getConflictsFor(TriggerSequence sequence);
-
- Collection<Binding> getAllConflicts();
-
- Binding getPerfectMatch(TriggerSequence trigger);
-
- boolean isPartialMatch(TriggerSequence keySequence);
-
- boolean isPerfectMatch(TriggerSequence sequence);
-
- TriggerSequence getBestSequenceFor(ParameterizedCommand command);
-
- Collection<TriggerSequence> getSequencesFor(ParameterizedCommand command);
-
- Collection<Binding> getPartialMatches(TriggerSequence sequence);
-
- Collection<Binding> getActiveBindings();
-
- Collection<Binding> getBindingsFor(ParameterizedCommand cmd);
+ /**
+ * Create a binding between a sequence and a command
+ *
+ * @param sequence
+ * the sequence
+ * @param command
+ * the command
+ * @param contextId
+ * the context id
+ * @param attributes
+ * the attributes
+ * @return the binding
+ */
+ Binding createBinding(@NonNull TriggerSequence sequence, @NonNull ParameterizedCommand command, @NonNull String contextId, @NonNull Map<@NonNull String, @NonNull String> attributes);
+
+ /**
+ * Activate the binding
+ *
+ * @param binding
+ * the binding to activate
+ */
+ void activateBinding(@NonNull Binding binding);
+
+ /**
+ * Deactivate the binding
+ *
+ * @param binding
+ * the binding to deactivate
+ */
+ void deactivateBinding(@NonNull Binding binding);
+
+ /**
+ * Create a trigger sequence from a string definition
+ *
+ * @param sequence
+ * a string definition
+ * @return a trigger sequence
+ */
+ @Nullable
+ TriggerSequence createSequence(@NonNull String sequence);
+
+ /**
+ * Get the conflicts for a sequence
+ *
+ * @param sequence
+ * the sequence
+ * @return the bindings
+ */
+ @Nullable
+ Collection<@NonNull Binding> getConflictsFor(@NonNull TriggerSequence sequence);
+
+ /**
+ * @return all conflicts
+ */
+ @NonNull
+ Collection<@NonNull Binding> getAllConflicts();
+
+ /**
+ * Get the perfect match for the trigger
+ *
+ * @param trigger
+ * the trigger
+ * @return the binding
+ */
+ @Nullable
+ Binding getPerfectMatch(@NonNull TriggerSequence trigger);
+
+ /**
+ * Check if the sequence is partially matched
+ *
+ * @param keySequence
+ * the sequence
+ * @return <code>true</code> if a partial match
+ */
+ boolean isPartialMatch(@NonNull TriggerSequence keySequence);
+
+ /**
+ * Check if there is a perfect match
+ *
+ * @param sequence
+ * the sequence
+ * @return <code>true</code> if a perfect match
+ */
+ boolean isPerfectMatch(@NonNull TriggerSequence sequence);
+
+ /**
+ * Find the best sequence for the command
+ *
+ * @param command
+ * the command
+ * @return the sequence
+ */
+ @Nullable
+ TriggerSequence getBestSequenceFor(@NonNull ParameterizedCommand command);
+
+ /**
+ * Find all sequences for the give command
+ *
+ * @param command
+ * the command
+ * @return all sequences
+ */
+ @NonNull
+ Collection<@NonNull TriggerSequence> getSequencesFor(@NonNull ParameterizedCommand command);
+
+ /**
+ * Find all partial matches
+ *
+ * @param sequence
+ * the sequence
+ * @return the matches
+ */
+ @NonNull
+ Collection<@NonNull Binding> getPartialMatches(@NonNull TriggerSequence sequence);
+
+ /**
+ * @return all active bindings
+ */
+ @NonNull
+ Collection<@NonNull Binding> getActiveBindings();
+
+ /**
+ * Find all bindings for the command
+ *
+ * @param cmd
+ * the command
+ * @return the bindings
+ */
+ @NonNull
+ Collection<@NonNull Binding> getBindingsFor(@NonNull ParameterizedCommand cmd);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceCreationFunction.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceCreationFunction.java
index 4eec74f6b..23f6c7c8c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceCreationFunction.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceCreationFunction.java
@@ -18,16 +18,8 @@ import org.eclipse.e4.core.contexts.IEclipseContext;
/**
*
*/
-@SuppressWarnings("restriction")
public class BindingServiceCreationFunction extends ContextFunction {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.e4.core.services.context.spi.ContextFunction#compute(org.eclipse.e4.core.services
- * .context.IEclipseContext, java.lang.Object[])
- */
@Override
public Object compute(IEclipseContext context) {
return ContextInjectionFactory.make(BindingServiceImpl.class, context);
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceImpl.java
index 7fa82f525..613273d9b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingServiceImpl.java
@@ -25,17 +25,19 @@ import org.eclipse.core.commands.contexts.Context;
import org.eclipse.core.commands.contexts.ContextManager;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.fx.core.log.Log;
+import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.ui.keybindings.Binding;
import org.eclipse.fx.ui.keybindings.KeyLookup;
import org.eclipse.fx.ui.keybindings.ParseException;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
import org.eclipse.fx.ui.keybindings.e4.EBindingService;
import org.eclipse.fx.ui.keybindings.service.BindingFactory;
+import org.eclipse.jdt.annotation.NonNull;
/**
*
*/
-@SuppressWarnings("restriction")
public class BindingServiceImpl implements EBindingService {
final static String ACTIVE_CONTEXTS = "activeContexts"; //$NON-NLS-1$
@@ -56,39 +58,36 @@ public class BindingServiceImpl implements EBindingService {
@Inject
private BindingFactory factory;
+ @NonNull
private ContextSet contextSet = ContextSet.EMPTY;
+
+ @Inject
+ @Log
+ Logger logger;
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.e4.ui.bindings.EBindingService#createBinding(org.eclipse.
- * jface.bindings. TriggerSequence,
- * org.eclipse.core.commands.ParameterizedCommand, java.lang.String,
- * java.lang.String, java.util.Map)
- */
+ @Override
public Binding createBinding(TriggerSequence sequence,
ParameterizedCommand command, String contextId,
Map<String, String> attributes) {
-
String schemeId = DEFAULT_SCHEME_ID;
// String locale = null;
// String platform = null;
// int bindingType = Binding.SYSTEM;
- if (sequence != null && !sequence.isEmpty() && contextId != null) {
- if (attributes != null) {
- String tmp = attributes.get(SCHEME_ID_ATTR_TAG);
- if (tmp != null && tmp.length() > 0) {
- schemeId = tmp;
- }
- // locale = attributes.get(LOCALE_ATTR_TAG);
- // platform = attributes.get(PLATFORM_ATTR_TAG);
- // if (USER_TYPE.equals(attributes.get(TYPE_ATTR_TAG))) {
- // bindingType = Binding.USER;
- // }
+ if (!sequence.isEmpty()) {
+ String tmp = attributes.get(SCHEME_ID_ATTR_TAG);
+ if (tmp != null && tmp.length() > 0) {
+ schemeId = tmp;
+ }
+ // locale = attributes.get(LOCALE_ATTR_TAG);
+ // platform = attributes.get(PLATFORM_ATTR_TAG);
+ // if (USER_TYPE.equals(attributes.get(TYPE_ATTR_TAG))) {
+ // bindingType = Binding.USER;
+ // }
+ if( schemeId == null ) {
+ return null;
}
- return factory.createKeyBinding(sequence, command, schemeId,
+ return this.factory.createKeyBinding(sequence, command, schemeId,
contextId);
// return factory.createKeyBinding((EKeySequence) sequence, command,
// schemeId, contextId, locale,
@@ -97,108 +96,69 @@ public class BindingServiceImpl implements EBindingService {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.e4.ui.bindings.EBindingService#activateBinding(org.eclipse
- * .jface.bindings.Binding )
- */
+ @Override
public void activateBinding(Binding binding) {
String contextId = binding.getContextId();
- BindingTable table = manager.getTable(contextId);
+ BindingTable table = this.manager.getTable(contextId);
if (table == null) {
return;
}
table.addBinding(binding);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.e4.ui.bindings.EBindingService#deactivateBinding(org.eclipse
- * .jface.bindings.Binding )
- */
+ @Override
public void deactivateBinding(Binding binding) {
String contextId = binding.getContextId();
- BindingTable table = manager.getTable(contextId);
+ BindingTable table = this.manager.getTable(contextId);
if (table == null) {
return;
}
table.removeBinding(binding);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.e4.ui.bindings.EBindingService#createSequence(java.lang.String
- * )
- */
+ @Override
public TriggerSequence createSequence(String sequence) {
try {
- return factory.getKeySequenceInstance(keylookup, sequence);
+ KeyLookup keylookup = this.keylookup;
+ if( keylookup != null ) {
+ return this.factory.getKeySequenceInstance(keylookup, sequence);
+ }
} catch (ParseException e) {
- // should probably log
+ this.logger.error("Unable to parse key sequence '"+sequence+"'", e); //$NON-NLS-1$//$NON-NLS-2$
}
return null;
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#getConflictsFor(org.eclipse
- * .e4.ui.bindings. TriggerSequence)
- */
+ @Override
public Collection<Binding> getConflictsFor(TriggerSequence sequence) {
- return manager.getConflictsFor(contextSet, sequence);
+ return this.manager.getConflictsFor(this.contextSet, sequence);
}
+ @Override
public Collection<Binding> getAllConflicts() {
- return manager.getAllConflicts();
+ return this.manager.getAllConflicts();
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#getPerfectMatch(org.eclipse
- * .e4.ui.bindings. TriggerSequence)
- */
+ @Override
public Binding getPerfectMatch(TriggerSequence trigger) {
- return manager.getPerfectMatch(contextSet, trigger);
+ return this.manager.getPerfectMatch(this.contextSet, trigger);
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#isPartialMatch(org.eclipse.
- * e4.ui.bindings. TriggerSequence)
- */
+ @Override
public boolean isPartialMatch(TriggerSequence keySequence) {
- return manager.isPartialMatch(contextSet, keySequence);
+ return this.manager.isPartialMatch(this.contextSet, keySequence);
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#getBestSequenceFor(org.eclipse
- * .core.commands. ParameterizedCommand)
- */
+ @Override
public TriggerSequence getBestSequenceFor(ParameterizedCommand command) {
- Binding binding = manager.getBestSequenceFor(contextSet, command);
+ Binding binding = this.manager.getBestSequenceFor(this.contextSet, command);
return binding == null ? null : binding.getTriggerSequence();
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#getSequencesFor(org.eclipse
- * .core.commands. ParameterizedCommand)
- */
+ @Override
public Collection<TriggerSequence> getSequencesFor(
ParameterizedCommand command) {
- Collection<Binding> bindings = manager.getSequencesFor(contextSet,
+ Collection<Binding> bindings = this.manager.getSequencesFor(this.contextSet,
command);
ArrayList<TriggerSequence> sequences = new ArrayList<TriggerSequence>(
bindings.size());
@@ -208,56 +168,51 @@ public class BindingServiceImpl implements EBindingService {
return sequences;
}
+ @Override
public Collection<Binding> getBindingsFor(ParameterizedCommand command) {
- return manager.getBindingsFor(contextSet, command);
+ return this.manager.getBindingsFor(this.contextSet, command);
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#isPerfectMatch(org.eclipse.
- * e4.ui.bindings. TriggerSequence)
- */
+ @Override
public boolean isPerfectMatch(TriggerSequence sequence) {
return getPerfectMatch(sequence) != null;
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.e4.ui.bindings.EBindingService#getPartialMatches(org.eclipse
- * .e4.ui.bindings. TriggerSequence)
- */
+ @Override
public Collection<Binding> getPartialMatches(TriggerSequence sequence) {
- return manager.getPartialMatches(contextSet, sequence);
+ return this.manager.getPartialMatches(this.contextSet, sequence);
}
/**
* @return the context for this service.
*/
public IEclipseContext getContext() {
- return context;
+ return this.context;
}
@Inject
- public void setContextIds(@Named(ACTIVE_CONTEXTS) @Optional Set<String> set) {
- if (set == null || set.isEmpty() || contextManager == null) {
- contextSet = ContextSet.EMPTY;
- if (contextManager != null) {
- contextManager.setActiveContextIds(Collections.EMPTY_SET);
+ void setContextIds(@Named(ACTIVE_CONTEXTS) @Optional Set<String> set) {
+ if (set == null || set.isEmpty() || this.contextManager == null) {
+ this.contextSet = ContextSet.EMPTY;
+ if (this.contextManager != null) {
+ this.contextManager.setActiveContextIds(Collections.EMPTY_SET);
}
return;
}
- ArrayList<Context> contexts = new ArrayList<Context>();
+ ArrayList<@NonNull Context> contexts = new ArrayList<>();
for (String id : set) {
- contexts.add(contextManager.getContext(id));
+ Context ctx = this.contextManager.getContext(id);
+ if( ctx != null ) {
+ contexts.add(ctx);
+ }
}
- contextSet = manager.createContextSet(contexts);
- contextManager.setActiveContextIds(set);
+ this.contextSet = BindingTableManager.createContextSet(contexts);
+ this.contextManager.setActiveContextIds(set);
}
+ @Override
public Collection<Binding> getActiveBindings() {
- return manager.getActiveBindings();
+ return this.manager.getActiveBindings();
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTable.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTable.java
index 35081483b..21489b842 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTable.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTable.java
@@ -24,6 +24,8 @@ import org.eclipse.fx.ui.keybindings.Binding;
import org.eclipse.fx.ui.keybindings.KeyStroke;
import org.eclipse.fx.ui.keybindings.Trigger;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* manage tables of bindings that can be used to look up commands from keys.
@@ -33,12 +35,12 @@ public class BindingTable {
private String[] activeSchemeIds;
private final int compareSchemes(final String schemeId1, final String schemeId2) {
- if (activeSchemeIds == null || activeSchemeIds.length == 0) {
+ if (this.activeSchemeIds == null || this.activeSchemeIds.length == 0) {
return 0;
}
if (!schemeId2.equals(schemeId1)) {
- for (int i = 0; i < activeSchemeIds.length; i++) {
- final String schemePointer = activeSchemeIds[i];
+ for (int i = 0; i < this.activeSchemeIds.length; i++) {
+ final String schemePointer = this.activeSchemeIds[i];
if (schemeId2.equals(schemePointer)) {
return 1;
} else if (schemeId1.equals(schemePointer)) {
@@ -53,6 +55,7 @@ public class BindingTable {
this.activeSchemeIds = activeSchemeIds;
}
+ @Override
public int compare(Binding o1, Binding o2) {
int rc = compareSchemes(o1.getSchemeId(), o2.getSchemeId());
if (rc != 0) {
@@ -60,7 +63,8 @@ public class BindingTable {
}
/*
- * Check to see which has the least number of triggers in the trigger sequence.
+ * Check to see which has the least number of triggers in the
+ * trigger sequence.
*/
final Trigger[] bestTriggers = o1.getTriggerSequence().getTriggers();
final Trigger[] currentTriggers = o2.getTriggerSequence().getTriggers();
@@ -70,8 +74,9 @@ public class BindingTable {
}
/*
- * Compare the number of keys pressed in each trigger sequence. Some types of keys count
- * less than others (i.e., some types of modifiers keys are less likely to be chosen).
+ * Compare the number of keys pressed in each trigger sequence. Some
+ * types of keys count less than others (i.e., some types of
+ * modifiers keys are less likely to be chosen).
*/
compareTo = countStrokes(bestTriggers) - countStrokes(currentTriggers);
if (compareTo != 0) {
@@ -79,44 +84,42 @@ public class BindingTable {
}
// If this is still a tie, then just chose the shortest text.
- return o1.getTriggerSequence().format().length()
- - o2.getTriggerSequence().format().length();
+ return o1.getTriggerSequence().format().length() - o2.getTriggerSequence().format().length();
}
- private final int countStrokes(final Trigger[] triggers) {
+ private final static int countStrokes(final Trigger[] triggers) {
int strokeCount = triggers.length;
for (int i = 0; i < triggers.length; i++) {
final Trigger trigger = triggers[i];
if (trigger instanceof KeyStroke) {
final KeyStroke keyStroke = (KeyStroke) trigger;
- if( keyStroke.hasAltModifier() ) {
+ if (keyStroke.hasAltModifier()) {
strokeCount += 8;
}
- if( keyStroke.hasCtrlModifier() ) {
+ if (keyStroke.hasCtrlModifier()) {
strokeCount += 2;
}
- if( keyStroke.hasShiftModifier() ) {
+ if (keyStroke.hasShiftModifier()) {
strokeCount += 4;
}
- if( keyStroke.hasCommandModifier() ) {
+ if (keyStroke.hasCommandModifier()) {
strokeCount += 2;
}
-
-
-// final int modifierKeys = keyStroke.getModifierKeys();
-// final IKeyLookup lookup = KeyLookupFactory.getDefault();
-// if ((modifierKeys & lookup.getAlt()) != 0) {
-// strokeCount += 8;
-// }
-// if ((modifierKeys & lookup.getCtrl()) != 0) {
-// strokeCount += 2;
-// }
-// if ((modifierKeys & lookup.getShift()) != 0) {
-// strokeCount += 4;
-// }
-// if ((modifierKeys & lookup.getCommand()) != 0) {
-// strokeCount += 2;
-// }
+
+ // final int modifierKeys = keyStroke.getModifierKeys();
+ // final IKeyLookup lookup = KeyLookupFactory.getDefault();
+ // if ((modifierKeys & lookup.getAlt()) != 0) {
+ // strokeCount += 8;
+ // }
+ // if ((modifierKeys & lookup.getCtrl()) != 0) {
+ // strokeCount += 2;
+ // }
+ // if ((modifierKeys & lookup.getShift()) != 0) {
+ // strokeCount += 4;
+ // }
+ // if ((modifierKeys & lookup.getCommand()) != 0) {
+ // strokeCount += 2;
+ // }
} else {
strokeCount += 99;
}
@@ -126,72 +129,104 @@ public class BindingTable {
}
}
- public static final BindingComparator BEST_SEQUENCE = new BindingComparator();
-
- private Context tableId;
- private ArrayList<Binding> bindings = new ArrayList<Binding>();
- private Map<TriggerSequence, Binding> bindingsByTrigger = new HashMap<TriggerSequence, Binding>();
- private Map<ParameterizedCommand, ArrayList<Binding>> bindingsByCommand = new HashMap<ParameterizedCommand, ArrayList<Binding>>();
- private Map<TriggerSequence, ArrayList<Binding>> bindingsByPrefix = new HashMap<TriggerSequence, ArrayList<Binding>>();
- private Map<TriggerSequence, ArrayList<Binding>> conflicts = new HashMap<TriggerSequence, ArrayList<Binding>>();
+ static final BindingComparator BEST_SEQUENCE = new BindingComparator();
+
+ @NonNull
+ private final Context tableId;
+ @NonNull
+ private final ArrayList<@NonNull Binding> bindings = new ArrayList<>();
+ @NonNull
+ private final Map<@NonNull TriggerSequence, @NonNull Binding> bindingsByTrigger = new HashMap<>();
+ @NonNull
+ private final Map<@NonNull ParameterizedCommand, @NonNull ArrayList<@NonNull Binding>> bindingsByCommand = new HashMap<>();
+ @NonNull
+ private final Map<@NonNull TriggerSequence, @NonNull ArrayList<@NonNull Binding>> bindingsByPrefix = new HashMap<>();
+ @NonNull
+ private final Map<@NonNull TriggerSequence, @NonNull ArrayList<@NonNull Binding>> conflicts = new HashMap<>();
/**
+ * Create a table
+ *
* @param context
*/
- public BindingTable(Context context) {
- tableId = context;
+ public BindingTable(@NonNull Context context) {
+ this.tableId = context;
}
- public Context getTableId() {
- return tableId;
+ /**
+ * @return the context
+ */
+ public @NonNull Context getTableId() {
+ return this.tableId;
}
- public String getId() {
- return tableId.getId();
+ /**
+ * @return the context id
+ */
+ @SuppressWarnings("null")
+ public @NonNull String getId() {
+ return this.tableId.getId();
}
- public Collection<Binding> getConflicts() {
- Collection<Binding> conflictsList = new ArrayList<Binding>();
- for (TriggerSequence key : conflicts.keySet()) {
- ArrayList<Binding> conflictsForTrigger = conflicts.get(key);
- if (conflictsForTrigger != null) {
- conflictsList.addAll(conflictsForTrigger);
- }
+ /**
+ * @return get all conflicts
+ */
+ public @NonNull Collection<@NonNull Binding> getConflicts() {
+ Collection<@NonNull Binding> conflictsList = new ArrayList<>();
+ for (TriggerSequence key : this.conflicts.keySet()) {
+ ArrayList<@NonNull Binding> conflictsForTrigger = this.conflicts.get(key);
+ conflictsList.addAll(conflictsForTrigger);
}
return conflictsList;
}
// checks both the active bindings and conflicts list
- public Collection<Binding> getConflictsFor(TriggerSequence triggerSequence) {
- return conflicts.get(triggerSequence);
+ /**
+ * Get all conflicts for the sequence
+ *
+ * @param triggerSequence
+ * the sequence
+ * @return the conflicts
+ */
+ public @Nullable Collection<@NonNull Binding> getConflictsFor(TriggerSequence triggerSequence) {
+ return this.conflicts.get(triggerSequence);
}
- public void addBinding(Binding binding) {
+ /**
+ *
+ * @param binding
+ */
+ @SuppressWarnings({ "unused", "null" })
+ public void addBinding(@NonNull Binding binding) {
if (!getId().equals(binding.getContextId())) {
throw new IllegalArgumentException("Binding context " + binding.getContextId() //$NON-NLS-1$
+ " does not match " + getId()); //$NON-NLS-1$
}
Binding conflict;
- ArrayList<Binding> conflictsList;
+ ArrayList<@NonNull Binding> conflictsList;
boolean isConflict = false;
+ TriggerSequence triggerSequence = binding.getTriggerSequence();
+ if (triggerSequence == null) {
+ return;
+ }
+
// if this binding conflicts with one other active binding
- if (bindingsByTrigger.containsKey(binding.getTriggerSequence())) {
+ if (this.bindingsByTrigger.containsKey(triggerSequence)) {
// remove the active binding and put it in the conflicts map
- conflict = bindingsByTrigger.get(binding.getTriggerSequence());
+ conflict = this.bindingsByTrigger.get(triggerSequence);
removeBinding(conflict);
- conflictsList = new ArrayList<Binding>();
+ conflictsList = new ArrayList<>();
conflictsList.add(conflict);
- conflicts.put(binding.getTriggerSequence(), conflictsList);
+ this.conflicts.put(triggerSequence, conflictsList);
isConflict = true;
}
// if this trigger is already in the conflicts map
- if (conflicts.containsKey(binding.getTriggerSequence())
- && conflicts.get(binding.getTriggerSequence()).size() > 0) {
+ if (this.conflicts.containsKey(triggerSequence) && this.conflicts.get(triggerSequence).size() > 0) {
// add this binding to the conflicts map
- conflictsList = conflicts.get(binding.getTriggerSequence());
+ conflictsList = this.conflicts.get(triggerSequence);
if (!conflictsList.contains(binding)) {
conflictsList.add(binding);
}
@@ -200,43 +235,50 @@ public class BindingTable {
// if there are no conflicts, then add to the table
if (!isConflict) {
- bindings.add(binding);
- bindingsByTrigger.put(binding.getTriggerSequence(), binding);
+ this.bindings.add(binding);
+ this.bindingsByTrigger.put(triggerSequence, binding);
- ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
+ ArrayList<@NonNull Binding> sequences = this.bindingsByCommand.get(binding.getParameterizedCommand());
if (sequences == null) {
- sequences = new ArrayList<Binding>();
- bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
+ sequences = new ArrayList<>();
+ this.bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
}
sequences.add(binding);
Collections.sort(sequences, BEST_SEQUENCE);
- TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
+ TriggerSequence[] prefs = triggerSequence.getPrefixes();
for (int i = 1; i < prefs.length; i++) {
- ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
+ ArrayList<Binding> bindings = this.bindingsByPrefix.get(prefs[i]);
if (bindings == null) {
- bindings = new ArrayList<Binding>();
- bindingsByPrefix.put(prefs[i], bindings);
+ bindings = new ArrayList<>();
+ this.bindingsByPrefix.put(prefs[i], bindings);
}
bindings.add(binding);
}
}
}
- public void removeBinding(Binding binding) {
+ /**
+ * Remove a binding
+ *
+ * @param binding
+ * the binding
+ */
+ @SuppressWarnings("null")
+ public void removeBinding(@NonNull Binding binding) {
if (!getId().equals(binding.getContextId())) {
throw new IllegalArgumentException("Binding context " + binding.getContextId() //$NON-NLS-1$
+ " does not match " + getId()); //$NON-NLS-1$
}
- ArrayList<Binding> conflictBindings = conflicts.get(binding.getTriggerSequence());
+ ArrayList<@NonNull Binding> conflictBindings = this.conflicts.get(binding.getTriggerSequence());
// if this binding is in the conflicts map, then remove it
- if (!bindingsByTrigger.containsKey(binding.getTriggerSequence())
- && conflictBindings != null) {
+ if (!this.bindingsByTrigger.containsKey(binding.getTriggerSequence()) && conflictBindings != null) {
conflictBindings.remove(binding);
- // if there is only one binding left in the list, then it's not really a conflict
+ // if there is only one binding left in the list, then it's not
+ // really a conflict
// binding anymore and can be re-added to the binding table
if (conflictBindings.size() == 1) {
Binding bindingToReAdd = conflictBindings.remove(0);
@@ -244,48 +286,90 @@ public class BindingTable {
}
} else {
- bindings.remove(binding);
- bindingsByTrigger.remove(binding.getTriggerSequence());
- ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
+ this.bindings.remove(binding);
+ this.bindingsByTrigger.remove(binding.getTriggerSequence());
+ ArrayList<Binding> sequences = this.bindingsByCommand.get(binding.getParameterizedCommand());
if (sequences != null) {
sequences.remove(binding);
}
TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
for (int i = 1; i < prefs.length; i++) {
- ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
+ ArrayList<Binding> bindings = this.bindingsByPrefix.get(prefs[i]);
bindings.remove(binding);
}
}
}
- public Binding getPerfectMatch(TriggerSequence trigger) {
- return bindingsByTrigger.get(trigger);
+ /**
+ * The perfect match for a trigger
+ *
+ * @param trigger
+ * the trigger
+ * @return the match
+ */
+ public @Nullable Binding getPerfectMatch(@NonNull TriggerSequence trigger) {
+ return this.bindingsByTrigger.get(trigger);
}
- public Binding getBestSequenceFor(ParameterizedCommand command) {
- ArrayList<Binding> sequences = bindingsByCommand.get(command);
+ /**
+ * The best sequence for the command
+ *
+ * @param command
+ * the command
+ * @return the binding
+ */
+ @SuppressWarnings("null")
+ public @Nullable Binding getBestSequenceFor(@NonNull ParameterizedCommand command) {
+ ArrayList<Binding> sequences = this.bindingsByCommand.get(command);
if (sequences != null && sequences.size() > 0) {
return sequences.get(0);
}
return null;
}
- public Collection<Binding> getSequencesFor(ParameterizedCommand command) {
- ArrayList<Binding> triggers = bindingsByCommand.get(command);
- return (Collection<Binding>) (triggers == null ? Collections.EMPTY_LIST : triggers.clone());
+ /**
+ * Get all sequences for the command
+ *
+ * @param command
+ * the command
+ * @return all bindings
+ */
+ @SuppressWarnings("null")
+ public @NonNull Collection<@NonNull Binding> getSequencesFor(@NonNull ParameterizedCommand command) {
+ ArrayList<Binding> triggers = this.bindingsByCommand.get(command);
+ return (Collection<@NonNull Binding>) (triggers == null ? Collections.<@NonNull Binding> emptyList() : new ArrayList<>(triggers));
}
- public Collection<Binding> getPartialMatches(TriggerSequence sequence) {
- return bindingsByPrefix.get(sequence);
+ /**
+ * Get partial matches
+ *
+ * @param sequence
+ * the sequence
+ * @return the bindings
+ */
+ public @Nullable Collection<@NonNull Binding> getPartialMatches(@NonNull TriggerSequence sequence) {
+ return this.bindingsByPrefix.get(sequence);
}
- public boolean isPartialMatch(TriggerSequence seq) {
- return bindingsByPrefix.get(seq) != null;
+ /**
+ * Check if the sequence is partially matched
+ *
+ * @param seq
+ * the sequence
+ * @return <code>true</code> if there's a partial match
+ */
+ @SuppressWarnings("null")
+ public boolean isPartialMatch(@NonNull TriggerSequence seq) {
+ return this.bindingsByPrefix.get(seq) != null;
}
- public Collection<Binding> getBindings() {
- return Collections.unmodifiableCollection(bindings);
+ /**
+ * @return all bindings
+ */
+ @SuppressWarnings("null")
+ public @NonNull Collection<@NonNull Binding> getBindings() {
+ return Collections.unmodifiableCollection(this.bindings);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTableManager.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTableManager.java
index 809ee61f3..51fa39724 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTableManager.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/BindingTableManager.java
@@ -24,12 +24,12 @@ import org.eclipse.core.commands.contexts.Context;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.fx.ui.keybindings.Binding;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
-
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* manage tables of bindings that can be used to look up commands from keys.
*/
-@SuppressWarnings("restriction")
public class BindingTableManager {
private static final String BINDING_TABLE_PREFIX = "bindingTable:"; //$NON-NLS-1$
@@ -40,48 +40,72 @@ public class BindingTableManager {
private String[] activeSchemeIds;
- public void addTable(BindingTable table) {
+ /**
+ * Add a binding table
+ *
+ * @param table
+ * the table
+ */
+ public void addTable(@NonNull BindingTable table) {
String contextId = getTableId(table.getId());
- if (eclipseContext.containsKey(contextId)) {
+ if (this.eclipseContext.containsKey(contextId)) {
return; // it's already there
// throw new IllegalArgumentException("Already contains table " + contextId); //$NON-NLS-1$
}
- eclipseContext.set(contextId, table);
- final List<Context> contexts = definedTables.getContexts();
+ this.eclipseContext.set(contextId, table);
+ final List<@NonNull Context> contexts = this.definedTables.getContexts();
if (!contexts.contains(table.getTableId())) {
- // this is only valid because I'm throwing away the old definedTables contextSet
+ // this is only valid because I'm throwing away the old
+ // definedTables contextSet
contexts.add(table.getTableId());
- definedTables = createContextSet(contexts);
+ this.definedTables = createContextSet(contexts);
}
}
- private String getTableId(String id) {
+ private static String getTableId(String id) {
return BINDING_TABLE_PREFIX + id;
}
- public void removeTable(BindingTable table) {
+ /**
+ * remove a table
+ *
+ * @param table
+ * the table
+ */
+ public void removeTable(@NonNull BindingTable table) {
String contextId = getTableId(table.getId());
- if (!eclipseContext.containsKey(contextId)) {
+ if (!this.eclipseContext.containsKey(contextId)) {
throw new IllegalArgumentException("Does not contains table " + contextId); //$NON-NLS-1$
}
- eclipseContext.remove(contextId);
- final List<Context> contexts = definedTables.getContexts();
+ this.eclipseContext.remove(contextId);
+ final List<@NonNull Context> contexts = this.definedTables.getContexts();
if (contexts.contains(table.getTableId())) {
- // this is only valid because I'm throwing away the old definedTables contextSet
+ // this is only valid because I'm throwing away the old
+ // definedTables contextSet
contexts.remove(table.getTableId());
- definedTables = createContextSet(contexts);
+ this.definedTables = createContextSet(contexts);
}
}
- public BindingTable getTable(String id) {
- return (BindingTable) eclipseContext.get(getTableId(id));
+ /**
+ * Get the table for the give id
+ *
+ * @param id
+ * the id
+ * @return the table
+ */
+ public @Nullable BindingTable getTable(String id) {
+ return (BindingTable) this.eclipseContext.get(getTableId(id));
}
- // we're just going through each binding table, and returning a
- // flat list of bindings here
- public Collection<Binding> getActiveBindings() {
- ArrayList<Binding> bindings = new ArrayList<Binding>();
- for (Context ctx : definedTables.getContexts()) {
+ /**
+ * @return the current bindings
+ */
+ public @NonNull Collection<@NonNull Binding> getActiveBindings() {
+ // we're just going through each binding table, and returning a
+ // flat list of bindings here
+ ArrayList<@NonNull Binding> bindings = new ArrayList<>();
+ for (Context ctx : this.definedTables.getContexts()) {
BindingTable table = getTable(ctx.getId());
if (table != null) {
bindings.addAll(table.getBindings());
@@ -90,17 +114,17 @@ public class BindingTableManager {
return bindings;
}
- public ContextSet createContextSet(Collection<Context> contexts) {
+ static @NonNull ContextSet createContextSet(@NonNull Collection<@NonNull Context> contexts) {
return new ContextSet(contexts);
}
- public Collection<Binding> getConflictsFor(ContextSet contextSet,
- TriggerSequence triggerSequence) {
- Collection<Binding> matches = new ArrayList<Binding>();
+ @Nullable
+ Collection<@NonNull Binding> getConflictsFor(@NonNull ContextSet contextSet, @NonNull TriggerSequence triggerSequence) {
+ Collection<@NonNull Binding> matches = new ArrayList<>();
for (Context ctx : contextSet.getContexts()) {
BindingTable table = getTable(ctx.getId());
if (table != null) {
- final Collection<Binding> matchesFor = table.getConflictsFor(triggerSequence);
+ final Collection<@NonNull Binding> matchesFor = table.getConflictsFor(triggerSequence);
if (matchesFor != null) {
matches.addAll(matchesFor);
}
@@ -109,21 +133,21 @@ public class BindingTableManager {
return matches.size() == 0 ? null : matches;
}
- public Collection<Binding> getAllConflicts() {
- Collection<Binding> conflictsList = new ArrayList<Binding>();
- for (Context ctx : definedTables.getContexts()) {
+ @NonNull
+ Collection<@NonNull Binding> getAllConflicts() {
+ Collection<@NonNull Binding> conflictsList = new ArrayList<>();
+ for (Context ctx : this.definedTables.getContexts()) {
BindingTable table = getTable(ctx.getId());
if (table != null) {
- Collection<Binding> conflictsInTable = table.getConflicts();
- if (conflictsInTable != null) {
- conflictsList.addAll(conflictsInTable);
- }
+ Collection<@NonNull Binding> conflictsInTable = table.getConflicts();
+ conflictsList.addAll(conflictsInTable);
}
}
return conflictsList;
}
- public Binding getPerfectMatch(ContextSet contextSet, TriggerSequence triggerSequence) {
+ @Nullable
+ Binding getPerfectMatch(@NonNull ContextSet contextSet, @NonNull TriggerSequence triggerSequence) {
Binding result = null;
Binding currentResult = null;
List<Context> contexts = contextSet.getContexts();
@@ -151,62 +175,51 @@ public class BindingTableManager {
return result;
}
- /**
- * @param currentResult
- * @return
- */
private boolean isMostActiveScheme(Binding currentResult) {
- if (activeSchemeIds == null || activeSchemeIds.length < 2) {
+ if (this.activeSchemeIds == null || this.activeSchemeIds.length < 2) {
return true;
}
- final String mostActive = activeSchemeIds[0];
+ final String mostActive = this.activeSchemeIds[0];
return mostActive == null ? false : mostActive.equals(currentResult.getSchemeId());
}
- public Binding getBestSequenceFor(ContextSet contextSet,
- ParameterizedCommand parameterizedCommand) {
- ArrayList<Binding> bindings = (ArrayList<Binding>) getSequencesFor(contextSet,
- parameterizedCommand);
+ @Nullable Binding getBestSequenceFor(@NonNull ContextSet contextSet, @NonNull ParameterizedCommand parameterizedCommand) {
+ List<@NonNull Binding> bindings = getSequencesFor(contextSet, parameterizedCommand);
if (bindings.size() == 0) {
return null;
}
return bindings.get(0);
}
- public Collection<Binding> getSequencesFor(ContextSet contextSet,
- ParameterizedCommand parameterizedCommand) {
- ArrayList<Binding> bindings = new ArrayList<Binding>();
+ @NonNull List<@NonNull Binding> getSequencesFor(@NonNull ContextSet contextSet, @NonNull ParameterizedCommand parameterizedCommand) {
+ ArrayList<@NonNull Binding> bindings = new ArrayList<>();
List<Context> contexts = contextSet.getContexts();
ListIterator<Context> it = contexts.listIterator(contexts.size());
while (it.hasPrevious()) {
Context c = it.previous();
BindingTable table = getTable(c.getId());
if (table != null) {
- Collection<Binding> sequences = table.getSequencesFor(parameterizedCommand);
- if (sequences != null) {
- bindings.addAll(sequences);
- }
+ Collection<@NonNull Binding> sequences = table.getSequencesFor(parameterizedCommand);
+ bindings.addAll(sequences);
}
}
Collections.sort(bindings, BindingTable.BEST_SEQUENCE);
return bindings;
}
- public Collection<Binding> getBindingsFor(ContextSet contextSet, ParameterizedCommand cmd) {
- Collection<Binding> bindings = new ArrayList<Binding>();
+ @NonNull Collection<@NonNull Binding> getBindingsFor(@NonNull ContextSet contextSet, @NonNull ParameterizedCommand cmd) {
+ Collection<@NonNull Binding> bindings = new ArrayList<>();
for (Context ctx : contextSet.getContexts()) {
BindingTable table = getTable(ctx.getId());
if (table != null) {
- Collection<Binding> matches = table.getSequencesFor(cmd);
- if (matches != null) {
- bindings.addAll(matches);
- }
+ Collection<@NonNull Binding> matches = table.getSequencesFor(cmd);
+ bindings.addAll(matches);
}
}
return bindings;
}
- public boolean isPartialMatch(ContextSet contextSet, TriggerSequence sequence) {
+ boolean isPartialMatch(@NonNull ContextSet contextSet, @NonNull TriggerSequence sequence) {
List<Context> contexts = contextSet.getContexts();
ListIterator<Context> it = contexts.listIterator(contexts.size());
while (it.hasPrevious()) {
@@ -221,15 +234,15 @@ public class BindingTableManager {
return false;
}
- public Collection<Binding> getPartialMatches(ContextSet contextSet, TriggerSequence sequence) {
- ArrayList<Binding> bindings = new ArrayList<Binding>();
+ @NonNull Collection<@NonNull Binding> getPartialMatches(@NonNull ContextSet contextSet, @NonNull TriggerSequence sequence) {
+ ArrayList<@NonNull Binding> bindings = new ArrayList<>();
List<Context> contexts = contextSet.getContexts();
ListIterator<Context> it = contexts.listIterator(contexts.size());
while (it.hasPrevious()) {
Context c = it.previous();
BindingTable table = getTable(c.getId());
if (table != null) {
- Collection<Binding> partialMatches = table.getPartialMatches(sequence);
+ Collection<@NonNull Binding> partialMatches = table.getPartialMatches(sequence);
if (partialMatches != null) {
bindings.addAll(partialMatches);
}
@@ -247,17 +260,18 @@ public class BindingTableManager {
}
/*
- * Copied from org.eclipse.jface.bindings.BindingManager.compareSchemes(String, String)
+ * Copied from
+ * org.eclipse.jface.bindings.BindingManager.compareSchemes(String, String)
*
* Returns an in based on scheme 1 < scheme 2
*/
private final int compareSchemes(final String schemeId1, final String schemeId2) {
- if (activeSchemeIds == null) {
+ if (this.activeSchemeIds == null) {
return 0;
}
if (!schemeId2.equals(schemeId1)) {
- for (int i = 0; i < activeSchemeIds.length; i++) {
- final String schemePointer = activeSchemeIds[i];
+ for (int i = 0; i < this.activeSchemeIds.length; i++) {
+ final String schemePointer = this.activeSchemeIds[i];
if (schemeId2.equals(schemePointer)) {
return 1;
} else if (schemeId1.equals(schemePointer)) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/ContextSet.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/ContextSet.java
index 63c2ce316..80adda596 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/ContextSet.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.e4/src/org/eclipse/fx/ui/keybindings/e4/internal/ContextSet.java
@@ -16,20 +16,40 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.contexts.Context;
import org.eclipse.core.commands.contexts.ContextManager;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A collection of contexts
+ */
public class ContextSet {
- public static ContextSet EMPTY = new ContextSet(Collections.EMPTY_LIST);
+ /**
+ * An empty set
+ */
+ @SuppressWarnings("null")
+ @NonNull
+ public static ContextSet EMPTY = new ContextSet(Collections.emptyList());
+ /**
+ * A context comparator
+ */
public static class CComp implements Comparator<Context> {
private ContextManager manager;
+ /**
+ * Create a comparator
+ *
+ * @param manager
+ * the context manager to use
+ */
public CComp(ContextManager manager) {
this.manager = manager;
}
+ @Override
public int compare(Context o1, Context o2) {
if (o1.equals(o2)) {
return 0;
@@ -48,7 +68,7 @@ public class ContextSet {
String parentId = c.getParentId();
while (parentId != null) {
l++;
- Context context = manager.getContext(parentId);
+ Context context = this.manager.getContext(parentId);
parentId = context.getParentId();
}
} catch (NotDefinedException e) {
@@ -61,30 +81,44 @@ public class ContextSet {
private static Comparator<Context> CONTEXT_COMP = null;
+ /**
+ * Set a default comparator
+ *
+ * @param comp
+ * the compartor
+ */
public static void setComparator(Comparator<Context> comp) {
CONTEXT_COMP = comp;
}
+ /**
+ * @return the current comparator
+ */
public static Comparator<Context> getComparator() {
return CONTEXT_COMP;
}
- private List<Context> contexts;
+ @NonNull
+ private List<@NonNull Context> contexts;
- public ContextSet(Collection<Context> c) {
- contexts = new ArrayList<Context>(c);
- Collections.sort(contexts, CONTEXT_COMP);
+ /**
+ * Create a new context set
+ *
+ * @param c
+ * the context set
+ */
+ public ContextSet(@NonNull Collection<@NonNull Context> c) {
+ this.contexts = new ArrayList<>(c);
+ Collections.sort(this.contexts, CONTEXT_COMP);
}
-
- public List<Context> getContexts() {
- return contexts;
+
+ /**
+ * @return the contexts
+ */
+ public List<@NonNull Context> getContexts() {
+ return this.contexts;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object o) {
if (o == this) {
@@ -93,16 +127,11 @@ public class ContextSet {
if (!(o instanceof ContextSet)) {
return false;
}
- return contexts.equals(((ContextSet) o).contexts);
+ return this.contexts.equals(((ContextSet) o).contexts);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
- return contexts.hashCode();
+ return this.contexts.hashCode();
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingFactoryImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingFactoryImpl.java
index 1637d14a1..e18173b2c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingFactoryImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingFactoryImpl.java
@@ -19,11 +19,15 @@ import org.eclipse.fx.ui.keybindings.KeyStroke;
import org.eclipse.fx.ui.keybindings.ParseException;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
import org.eclipse.fx.ui.keybindings.service.BindingFactory;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * Factory to crate bindings
+ */
public class BindingFactoryImpl implements BindingFactory {
@Override
- public KeySequence getKeySequenceInstance(KeyLookup keylookup, String sequence) throws ParseException {
+ public @NonNull KeySequence getKeySequenceInstance(@NonNull KeyLookup keylookup, @NonNull String sequence) throws ParseException {
return KeySequenceImpl.getInstance(keylookup, sequence);
}
@@ -33,17 +37,17 @@ public class BindingFactoryImpl implements BindingFactory {
}
@Override
- public KeySequence getKeySequenceInstance(KeySequence keySequence, KeyStroke stroke) {
+ public @NonNull KeySequence getKeySequenceInstance(@NonNull KeySequence keySequence, @NonNull KeyStroke stroke) {
return KeySequenceImpl.getInstance(keySequence, stroke);
}
@Override
- public KeySequence getKeySequenceInstance() {
+ public @NonNull KeySequence getKeySequenceInstance() {
return KeySequenceImpl.getInstance();
}
@Override
- public KeyStroke getKeyStrokeInstance(KeyLookup lookup, int modifierKeys, int naturalKey) {
+ public @NonNull KeyStroke getKeyStrokeInstance(@NonNull KeyLookup lookup, int modifierKeys, int naturalKey) {
return KeyStrokeImpl.getInstance(lookup, modifierKeys, naturalKey);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingImpl.java
index ffc3f17ff..3cbddff8e 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/BindingImpl.java
@@ -12,13 +12,18 @@ package org.eclipse.fx.ui.keybindings.generic;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.fx.ui.keybindings.Binding;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A binding implementation
+ */
public abstract class BindingImpl implements Binding {
/**
* The parameterized command to which this binding applies. This value may
* be <code>null</code> if this binding is meant to "unbind" an existing
* binding.
*/
+ @NonNull
private final ParameterizedCommand command;
/**
@@ -26,32 +31,44 @@ public abstract class BindingImpl implements Binding {
* be active before this key binding becomes active. This value will never
* be <code>null</code>.
*/
+ @NonNull
private final String contextId;
-
+
/**
* The identifier of the scheme in which this binding applies. This value
* will never be <code>null</code>.
*/
+ @NonNull
private final String schemeId;
-
- public BindingImpl(ParameterizedCommand command, String schemeId, String contextId) {
+
+ /**
+ * Create a binding impl
+ *
+ * @param command
+ * the command
+ * @param schemeId
+ * the scheme
+ * @param contextId
+ * the context id
+ */
+ public BindingImpl(@NonNull ParameterizedCommand command, @NonNull String schemeId, @NonNull String contextId) {
this.command = command;
this.schemeId = schemeId;
this.contextId = contextId;
}
-
+
@Override
public String getContextId() {
- return contextId;
+ return this.contextId;
}
-
+
@Override
public ParameterizedCommand getParameterizedCommand() {
- return command;
+ return this.command;
}
-
+
@Override
public String getSchemeId() {
- return schemeId;
+ return this.schemeId;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyBindingImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyBindingImpl.java
index 17385c64d..31bb4f7fb 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyBindingImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyBindingImpl.java
@@ -13,18 +13,31 @@ package org.eclipse.fx.ui.keybindings.generic;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.fx.ui.keybindings.KeySequence;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A keybinding implementation
+ */
public class KeyBindingImpl extends BindingImpl {
+ @NonNull
private final KeySequence keySequence;
-
- public KeyBindingImpl(final KeySequence keySequence, ParameterizedCommand command, String schemeId, String contextId) {
+
+ /**
+ * Create a binding
+ *
+ * @param keySequence
+ * @param command
+ * @param schemeId
+ * @param contextId
+ */
+ public KeyBindingImpl(@NonNull final KeySequence keySequence, @NonNull ParameterizedCommand command, @NonNull String schemeId, @NonNull String contextId) {
super(command, schemeId, contextId);
this.keySequence = keySequence;
}
@Override
public TriggerSequence getTriggerSequence() {
- return keySequence;
+ return this.keySequence;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeySequenceImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeySequenceImpl.java
index 10dba08d2..c67925098 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeySequenceImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeySequenceImpl.java
@@ -19,7 +19,11 @@ import org.eclipse.fx.ui.keybindings.KeySequence;
import org.eclipse.fx.ui.keybindings.KeyStroke;
import org.eclipse.fx.ui.keybindings.ParseException;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A keysequence implementation
+ */
public class KeySequenceImpl extends TriggerSequenceImpl implements KeySequence {
@Override
@@ -27,19 +31,19 @@ public class KeySequenceImpl extends TriggerSequenceImpl implements KeySequence
return Util.compare(getTriggers(), o.getTriggers());
}
- private final static KeySequenceImpl EMPTY_KEY_SEQUENCE = new KeySequenceImpl(
- new KeyStroke[0]);
-
- public final static String KEY_STROKE_DELIMITER = "\u0020"; //$NON-NLS-1$
- public final static String KEY_STROKE_DELIMITERS = KEY_STROKE_DELIMITER
- + "\b\r\u007F\u001B\f\n\0\t\u000B"; //$NON-NLS-1$
-
- public KeySequenceImpl(KeyStroke[] triggers) {
+ @NonNull
+ private final static KeySequenceImpl EMPTY_KEY_SEQUENCE = new KeySequenceImpl(new KeyStroke[0]);
+
+ private final static String KEY_STROKE_DELIMITER = "\u0020"; //$NON-NLS-1$
+ private final static String KEY_STROKE_DELIMITERS = KEY_STROKE_DELIMITER + "\b\r\u007F\u001B\f\n\0\t\u000B"; //$NON-NLS-1$
+
+ KeySequenceImpl(KeyStroke[] triggers) {
super(triggers);
}
+ @SuppressWarnings("null")
@Override
- public final TriggerSequence[] getPrefixes() {
+ public final @NonNull TriggerSequence[] getPrefixes() {
final int numberOfPrefixes = getTriggers().length;
final TriggerSequence[] prefixes = new TriggerSequence[numberOfPrefixes];
prefixes[0] = KeySequenceImpl.getInstance();
@@ -52,69 +56,52 @@ public class KeySequenceImpl extends TriggerSequenceImpl implements KeySequence
return prefixes;
}
-
@Override
public String format() {
// TODO Auto-generated method stub
return null;
}
-
- public static final KeySequence getInstance() {
+
+ static final @NonNull KeySequence getInstance() {
return EMPTY_KEY_SEQUENCE;
}
-
- public static final KeySequence getInstance(final KeyStroke[] keyStrokes) {
+
+ static final @NonNull KeySequence getInstance(final @NonNull KeyStroke[] keyStrokes) {
return new KeySequenceImpl(keyStrokes);
}
-
- public static final KeySequence getInstance(final KeySequence keySequence,
- final KeyStroke keyStroke) {
- if (keySequence == null || keyStroke == null) {
- throw new NullPointerException();
- }
+ static final @NonNull KeySequence getInstance(final @NonNull KeySequence keySequence, final @NonNull KeyStroke keyStroke) {
final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes();
final int oldKeyStrokeLength = oldKeyStrokes.length;
final KeyStroke[] newKeyStrokes = new KeyStroke[oldKeyStrokeLength + 1];
- System
- .arraycopy(oldKeyStrokes, 0, newKeyStrokes, 0,
- oldKeyStrokeLength);
+ System.arraycopy(oldKeyStrokes, 0, newKeyStrokes, 0, oldKeyStrokeLength);
newKeyStrokes[oldKeyStrokeLength] = keyStroke;
return new KeySequenceImpl(newKeyStrokes);
}
- public static final KeySequence getInstance(KeyLookup lookup, final String string)
- throws ParseException {
- if (string == null) {
- throw new NullPointerException();
- }
-
+ static final @NonNull KeySequence getInstance(@NonNull KeyLookup lookup, @NonNull final String string) throws ParseException {
final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>();
- final StringTokenizer stringTokenizer = new StringTokenizer(string,
- KEY_STROKE_DELIMITERS);
+ final StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_STROKE_DELIMITERS);
try {
while (stringTokenizer.hasMoreTokens()) {
- keyStrokes.add(KeyStrokeImpl.getInstance(lookup, stringTokenizer
- .nextToken()));
+ keyStrokes.add(KeyStrokeImpl.getInstance(lookup, stringTokenizer.nextToken()));
}
- final KeyStroke[] keyStrokeArray = (KeyStroke[]) keyStrokes
- .toArray(new KeyStroke[keyStrokes.size()]);
+ final KeyStroke[] keyStrokeArray = (KeyStroke[]) keyStrokes.toArray(new KeyStroke[keyStrokes.size()]);
return new KeySequenceImpl(keyStrokeArray);
} catch (final IllegalArgumentException e) {
- throw new ParseException(
- "Could not construct key sequence with these key strokes: " //$NON-NLS-1$
- + keyStrokes);
+ throw new ParseException("Could not construct key sequence with these key strokes: " //$NON-NLS-1$
+ + keyStrokes);
} catch (final NullPointerException e) {
- throw new ParseException(
- "Could not construct key sequence with these key strokes: " //$NON-NLS-1$
- + keyStrokes);
+ throw new ParseException("Could not construct key sequence with these key strokes: " //$NON-NLS-1$
+ + keyStrokes);
}
}
+ @SuppressWarnings("null")
@Override
- public final KeyStroke[] getKeyStrokes() {
+ public final @NonNull KeyStroke[] getKeyStrokes() {
final int triggerLength = getTriggers().length;
final KeyStroke[] keyStrokes = new KeyStroke[triggerLength];
System.arraycopy(getTriggers(), 0, keyStrokes, 0, triggerLength);
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyStrokeImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyStrokeImpl.java
index 7908687f2..a58bf8ffc 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyStrokeImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/KeyStrokeImpl.java
@@ -16,7 +16,11 @@ import org.eclipse.fx.ui.keybindings.KeyLookup;
import org.eclipse.fx.ui.keybindings.KeyStroke;
import org.eclipse.fx.ui.keybindings.ParseException;
import org.eclipse.fx.ui.keybindings.Trigger;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * Keystore implementation
+ */
public class KeyStrokeImpl extends TriggerImpl implements KeyStroke {
/**
* The delimiter between multiple keys in a single key strokes -- expressed
@@ -26,8 +30,8 @@ public class KeyStrokeImpl extends TriggerImpl implements KeyStroke {
public static final String KEY_DELIMITER = "\u002B"; //$NON-NLS-1$
/**
- * The set of delimiters for <code>Key</code> objects allowed during
- * parsing of the formal string representation.
+ * The set of delimiters for <code>Key</code> objects allowed during parsing
+ * of the formal string representation.
*/
public static final String KEY_DELIMITERS = KEY_DELIMITER;
@@ -35,70 +39,70 @@ public class KeyStrokeImpl extends TriggerImpl implements KeyStroke {
* The representation for no key.
*/
public static final int NO_KEY = 0;
-
- public static final KeyStroke getInstance(KeyLookup lookup, final String string)
- throws ParseException {
+
+ static final KeyStroke getInstance(KeyLookup lookup, final String string) throws ParseException {
if (string == null) {
throw new NullPointerException("Cannot parse a null string"); //$NON-NLS-1$
}
int modifierKeys = NO_KEY;
int naturalKey = NO_KEY;
- final StringTokenizer stringTokenizer = new StringTokenizer(string,
- KEY_DELIMITERS, true);
+ final StringTokenizer stringTokenizer = new StringTokenizer(string, KEY_DELIMITERS, true);
int i = 0;
while (stringTokenizer.hasMoreTokens()) {
String token = stringTokenizer.nextToken();
-
- if (i % 2 == 0) {
- if (stringTokenizer.hasMoreTokens()) {
- token = token.toUpperCase();
- final int modifierKey = lookup.formalModifierLookup(token);
- if (modifierKey == NO_KEY) {
- throw new ParseException(
- "Cannot create key stroke with duplicate or non-existent modifier key: " //$NON-NLS-1$
+ if (token != null) {
+ if (i % 2 == 0) {
+ if (stringTokenizer.hasMoreTokens()) {
+ token = token.toUpperCase();
+ if (token != null) {
+ final int modifierKey = lookup.formalModifierLookup(token);
+ if (modifierKey == NO_KEY) {
+ throw new ParseException("Cannot create key stroke with duplicate or non-existent modifier key: " //$NON-NLS-1$
+ token);
+ }
+
+ modifierKeys |= modifierKey;
+ }
+ } else if (token.length() == 1) {
+ naturalKey = token.charAt(0);
+ } else {
+ token = token.toUpperCase();
+ if (token != null) {
+ naturalKey = lookup.formalKeyLookup(token);
+ }
}
-
- modifierKeys |= modifierKey;
-
- } else if (token.length() == 1) {
- naturalKey = token.charAt(0);
-
- } else {
- token = token.toUpperCase();
- naturalKey = lookup.formalKeyLookup(token);
}
- }
- i++;
+ i++;
+ }
}
return new KeyStrokeImpl(lookup, modifierKeys, naturalKey);
}
-
- public static KeyStrokeImpl getInstance(KeyLookup lookup, int modifierKeys, int naturalKey) {
- return new KeyStrokeImpl(lookup,modifierKeys,naturalKey);
+
+ static @NonNull KeyStrokeImpl getInstance(KeyLookup lookup, int modifierKeys, int naturalKey) {
+ return new KeyStrokeImpl(lookup, modifierKeys, naturalKey);
}
-
+
/**
- * An integer representation of the modifier keys; <code>NO_KEY</code>
- * means that there is no modifier key.
+ * An integer representation of the modifier keys; <code>NO_KEY</code> means
+ * that there is no modifier key.
*/
private final int modifierKeys;
/**
- * The natural key for this key stroke. This value is <code>NO_KEY</code>
- * if the key stroke is incomplete (i.e., has no natural key).
+ * The natural key for this key stroke. This value is <code>NO_KEY</code> if
+ * the key stroke is incomplete (i.e., has no natural key).
*/
private final int naturalKey;
private final KeyLookup lookup;
-
+
/**
- * Constructs an instance of <code>KeyStroke</code> given a set of
- * modifier keys and a natural key.
+ * Constructs an instance of <code>KeyStroke</code> given a set of modifier
+ * keys and a natural key.
*
* @param modifierKeys
* the modifier keys. The format of this integer is defined by
@@ -116,72 +120,67 @@ public class KeyStrokeImpl extends TriggerImpl implements KeyStroke {
this.lookup = lookup;
}
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
+ /**
+ * Compare to another trigger
*/
+ @Override
public final int compareTo(final Trigger object) {
final KeyStrokeImpl keyStroke = (KeyStrokeImpl) object;
- int compareTo = Util.compare(modifierKeys, keyStroke.modifierKeys);
+ int compareTo = Util.compare(this.modifierKeys, keyStroke.modifierKeys);
if (compareTo == 0) {
- compareTo = Util.compare(naturalKey, keyStroke.naturalKey);
+ compareTo = Util.compare(this.naturalKey, keyStroke.naturalKey);
}
return compareTo;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
+ @Override
public final boolean equals(final Object object) {
if (!(object instanceof KeyStrokeImpl)) {
return false;
}
final KeyStrokeImpl keyStroke = (KeyStrokeImpl) object;
- if (modifierKeys != keyStroke.modifierKeys) {
+ if (this.modifierKeys != keyStroke.modifierKeys) {
return false;
}
- return (naturalKey == keyStroke.naturalKey);
+ return (this.naturalKey == keyStroke.naturalKey);
}
@Override
public boolean hasAltModifier() {
- return (modifierKeys & lookup.getAlt()) != 0;
+ return (this.modifierKeys & this.lookup.getAlt()) != 0;
}
@Override
public boolean hasCtrlModifier() {
- return (modifierKeys & lookup.getCtrl()) != 0;
+ return (this.modifierKeys & this.lookup.getCtrl()) != 0;
}
@Override
public boolean hasShiftModifier() {
- return (modifierKeys & lookup.getShift()) != 0;
+ return (this.modifierKeys & this.lookup.getShift()) != 0;
}
@Override
public boolean hasCommandModifier() {
- return (modifierKeys & lookup.getCommand()) != 0;
+ return (this.modifierKeys & this.lookup.getCommand()) != 0;
}
+ @Override
public final int hashCode() {
- return modifierKeys << 4 + naturalKey;
+ return this.modifierKeys << 4 + this.naturalKey;
}
-
+
@Override
public int getKeyCode() {
- return naturalKey;
+ return this.naturalKey;
}
-
+
@Override
public String toString() {
- return "Modifiers: " + modifierKeys + "; NatKey: " + naturalKey;
+ return "Modifiers: " + this.modifierKeys + "; NatKey: " + this.naturalKey; //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerImpl.java
index 9b5df90e7..aeac2a8cc 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerImpl.java
@@ -12,6 +12,9 @@ package org.eclipse.fx.ui.keybindings.generic;
import org.eclipse.fx.ui.keybindings.Trigger;
+/**
+ * A trigger implementation
+ */
public abstract class TriggerImpl implements Trigger {
/**
* Tests whether this object is equal to another object. A handle object is
@@ -22,13 +25,15 @@ public abstract class TriggerImpl implements Trigger {
* @return <code>true</code> if the objects are equal; <code>false</code>
* otherwise.
*/
- public abstract boolean equals(final Object object);
+ @Override
+ public abstract boolean equals(final Object object);
/**
* Computes the hash code for this object.
*
* @return The hash code for this object.
*/
- public abstract int hashCode();
+ @Override
+ public abstract int hashCode();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerSequenceImpl.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerSequenceImpl.java
index 7b2d2df4a..e56622443 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerSequenceImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/TriggerSequenceImpl.java
@@ -15,10 +15,14 @@ import java.util.List;
import org.eclipse.fx.ui.keybindings.Trigger;
import org.eclipse.fx.ui.keybindings.TriggerSequence;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * trigger sequence implementation
+ */
public abstract class TriggerSequenceImpl implements TriggerSequence {
private final List<Trigger> triggers;
-
+
/**
* The value to see that hash code to if the hash code is not yet computed.
*/
@@ -32,17 +36,22 @@ public abstract class TriggerSequenceImpl implements TriggerSequence {
/**
* An internal constant used only in this object's hash code algorithm.
*/
- private static final int HASH_INITIAL = TriggerSequence.class.getName()
- .hashCode();
+ private static final int HASH_INITIAL = TriggerSequence.class.getName().hashCode();
/**
* The hash code for this object. This value is computed lazily, and marked
- * as invalid when one of the values on which it is based changes. This
+ * as invalid when one of the values on which it is based changes. This
* values is <code>HASH_CODE_NOT_COMPUTED</code> iff the hash code has not
* yet been computed.
*/
protected transient int hashCode = HASH_CODE_NOT_COMPUTED;
-
+
+ /**
+ * Create a trigger sequence
+ *
+ * @param triggers
+ * the triggers
+ */
public TriggerSequenceImpl(final Trigger[] triggers) {
if (triggers == null) {
throw new NullPointerException("The triggers cannot be null"); //$NON-NLS-1$
@@ -50,35 +59,38 @@ public abstract class TriggerSequenceImpl implements TriggerSequence {
for (int i = 0; i < triggers.length; i++) {
if (triggers[i] == null) {
- throw new IllegalArgumentException(
- "All triggers in a trigger sequence must be an instance of Trigger"); //$NON-NLS-1$
+ throw new IllegalArgumentException("All triggers in a trigger sequence must be an instance of Trigger"); //$NON-NLS-1$
}
}
this.triggers = Arrays.asList(triggers);
}
-
+
+ @SuppressWarnings("null")
@Override
- public Trigger[] getTriggers() {
- return triggers.toArray(new Trigger[0]);
+ public @NonNull Trigger[] getTriggers() {
+ return this.triggers.toArray(new Trigger[0]);
}
-
+
+ @Override
public final boolean isEmpty() {
- return triggers.isEmpty();
+ return this.triggers.isEmpty();
}
-
+
+ @Override
public final int hashCode() {
- if (hashCode == HASH_CODE_NOT_COMPUTED) {
- hashCode = HASH_INITIAL;
- hashCode = hashCode * HASH_FACTOR + Util.hashCode(triggers.toArray());
- if (hashCode == HASH_CODE_NOT_COMPUTED) {
- hashCode++;
+ if (this.hashCode == HASH_CODE_NOT_COMPUTED) {
+ this.hashCode = HASH_INITIAL;
+ this.hashCode = this.hashCode * HASH_FACTOR + Util.hashCode(this.triggers.toArray());
+ if (this.hashCode == HASH_CODE_NOT_COMPUTED) {
+ this.hashCode++;
}
}
- return hashCode;
+ return this.hashCode;
}
-
+
+ @Override
public final boolean equals(final Object object) {
// Check if they're the same.
if (object == this) {
@@ -91,6 +103,6 @@ public abstract class TriggerSequenceImpl implements TriggerSequence {
}
final TriggerSequence triggerSequence = (TriggerSequence) object;
- return Util.equals(triggers.toArray(), triggerSequence.getTriggers());
+ return Util.equals(this.triggers.toArray(), triggerSequence.getTriggers());
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/Util.java b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/Util.java
index b759331a5..be2e706fc 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/Util.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings.generic/src/org/eclipse/fx/ui/keybindings/generic/Util.java
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings.generic;
-import java.util.Collections;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* <p>
@@ -27,16 +26,17 @@ import java.util.TreeSet;
*/
public final class Util {
- /**
- * An unmodifiable, empty, sorted set. This value is guaranteed to never change and never be
- * <code>null</code>.
- */
- public static final SortedSet EMPTY_SORTED_SET = Collections
- .unmodifiableSortedSet(new TreeSet());
+ // /**
+ // * An unmodifiable, empty, sorted set. This value is guaranteed to never
+ // change and never be
+ // * <code>null</code>.
+ // */
+ // public static final SortedSet EMPTY_SORTED_SET = Collections
+ // .unmodifiableSortedSet(new TreeSet());
/**
- * A common zero-length string. It avoids needing write <code>NON-NLS</code> next to code
- * fragments. It's also a bit clearer to read.
+ * A common zero-length string. It avoids needing write <code>NON-NLS</code>
+ * next to code fragments. It's also a bit clearer to read.
*/
public static final String ZERO_LENGTH_STRING = ""; //$NON-NLS-1$
@@ -46,30 +46,32 @@ public final class Util {
* @param object
* The object to check; may be <code>null</code>.
* @param c
- * The class which the object should be; must not be <code>null</code>.
+ * The class which the object should be; must not be
+ * <code>null</code>.
*/
- public static final void assertInstance(final Object object, final Class c) {
+ public static final void assertInstance(@Nullable final Object object, @NonNull final Class<?> c) {
assertInstance(object, c, false);
}
/**
- * Verifies the given object is an instance of the given class. It is possible to specify
- * whether the object is permitted to be <code>null</code>.
+ * Verifies the given object is an instance of the given class. It is
+ * possible to specify whether the object is permitted to be
+ * <code>null</code>.
*
* @param object
* The object to check; may be <code>null</code>.
* @param c
- * The class which the object should be; must not be <code>null</code>.
+ * The class which the object should be; must not be
+ * <code>null</code>.
* @param allowNull
* Whether the object is allowed to be <code>null</code>.
*/
- private static final void assertInstance(final Object object, final Class c,
- final boolean allowNull) {
+ private static final void assertInstance(@Nullable final Object object, @NonNull final Class<?> c, final boolean allowNull) {
if (object == null && allowNull) {
return;
}
- if (object == null || c == null) {
+ if (object == null) {
throw new NullPointerException();
} else if (!c.isInstance(object)) {
throw new IllegalArgumentException();
@@ -77,16 +79,16 @@ public final class Util {
}
/**
- * Compares two boolean values. <code>false</code> is considered to be "less than"
- * <code>true</code>.
+ * Compares two boolean values. <code>false</code> is considered to be
+ * "less than" <code>true</code>.
*
* @param left
* The left value to compare
* @param right
* The right value to compare
- * @return <code>-1</code> if the left is <code>false</code> and the right is <code>true</code>.
- * <code>1</code> if the opposite is true. If they are equal, then it returns
- * <code>0</code>.
+ * @return <code>-1</code> if the left is <code>false</code> and the right
+ * is <code>true</code>. <code>1</code> if the opposite is true. If
+ * they are equal, then it returns <code>0</code>.
*/
public static final int compare(final boolean left, final boolean right) {
return left == false ? (right == true ? -1 : 0) : 1;
@@ -105,9 +107,17 @@ public final class Util {
return left - right;
}
-
- public static final <T extends Comparable<T>> int compare(final T[] left,
- final T[] right) {
+ /**
+ * Compare two arrays
+ *
+ * @param left
+ * the first array
+ * @param right
+ * the 2nd array
+ * @return <code>-1</code> if left is smaller, <code>0</code> if equal and
+ * <code>1</code> if left is bigger
+ */
+ public static final <T extends Comparable<T>> int compare(final T[] left, final T[] right) {
if (left == null && right == null) {
return 0;
} else if (left == null) {
@@ -141,11 +151,10 @@ public final class Util {
* The left object to compare; may be <code>null</code>.
* @param right
* The right object to compare; may be <code>null</code>.
- * @return The result of the comparison. <code>null</code> is considered
- * to be the least possible value.
+ * @return The result of the comparison. <code>null</code> is considered to
+ * be the least possible value.
*/
- public static final <T extends Comparable<T>> int compare(final T left,
- final T right) {
+ public static final <T extends Comparable<T>> int compare(@Nullable final T left, @Nullable final T right) {
if (left == null && right == null) {
return 0;
} else if (left == null) {
@@ -156,21 +165,22 @@ public final class Util {
return left.compareTo(right);
}
}
-
+
/**
- * Compares two lists -- account for <code>null</code>. The lists must contain comparable
- * objects.
+ * Compares two lists -- account for <code>null</code>. The lists must
+ * contain comparable objects.
*
* @param left
- * The left list to compare; may be <code>null</code>. This list must only contain
- * instances of <code>Comparable</code>.
+ * The left list to compare; may be <code>null</code>. This list
+ * must only contain instances of <code>Comparable</code>.
* @param right
- * The right list to compare; may be <code>null</code>. This list must only contain
- * instances of <code>Comparable</code>.
- * @return The result of the comparison. <code>null</code> is considered to be the least
- * possible value. A shorter list is considered less than a longer list.
+ * The right list to compare; may be <code>null</code>. This list
+ * must only contain instances of <code>Comparable</code>.
+ * @return The result of the comparison. <code>null</code> is considered to
+ * be the least possible value. A shorter list is considered less
+ * than a longer list.
*/
- public static final int compare(final List left, final List right) {
+ public static final <T extends Comparable<T>> int compare(@Nullable final List<T> left, @Nullable final List<T> right) {
if (left == null && right == null) {
return 0;
} else if (left == null) {
@@ -186,7 +196,7 @@ public final class Util {
}
for (int i = 0; i < l; i++) {
- int compareTo = compare((Comparable) left.get(i), (Comparable) right.get(i));
+ int compareTo = compare(left.get(i), right.get(i));
if (compareTo != 0) {
return compareTo;
@@ -203,14 +213,14 @@ public final class Util {
* @param left
* The array to check (larger); may be <code>null</code>.
* @param right
- * The array that should be a subsequence (smaller); may be <code>null</code>.
+ * The array that should be a subsequence (smaller); may be
+ * <code>null</code>.
* @param equals
* Whether the two array are allowed to be equal.
- * @return <code>true</code> if the second array is a subsequence of the array list, and they
- * share end elements.
+ * @return <code>true</code> if the second array is a subsequence of the
+ * array list, and they share end elements.
*/
- public static final boolean endsWith(final Object[] left, final Object[] right,
- final boolean equals) {
+ public static final boolean endsWith(final Object[] left, final Object[] right, final boolean equals) {
if (left == null || right == null) {
return false;
}
@@ -232,30 +242,33 @@ public final class Util {
}
/**
- * Checks whether the two objects are <code>null</code> -- allowing for <code>null</code>.
+ * Checks whether the two objects are <code>null</code> -- allowing for
+ * <code>null</code>.
*
* @param left
* The left object to compare; may be <code>null</code>.
* @param right
* The right object to compare; may be <code>null</code>.
- * @return <code>true</code> if the two objects are equivalent; <code>false</code> otherwise.
+ * @return <code>true</code> if the two objects are equivalent;
+ * <code>false</code> otherwise.
*/
- public static final boolean equals(final Object left, final Object right) {
+ public static final boolean equals(@Nullable final Object left, @Nullable final Object right) {
return left == null ? right == null : ((right != null) && left.equals(right));
}
/**
- * Tests whether two arrays of objects are equal to each other. The arrays must not be
- * <code>null</code>, but their elements may be <code>null</code>.
+ * Tests whether two arrays of objects are equal to each other. The arrays
+ * must not be <code>null</code>, but their elements may be
+ * <code>null</code>.
*
* @param leftArray
- * The left array to compare; may be <code>null</code>, and may be empty and may
- * contain <code>null</code> elements.
+ * The left array to compare; may be <code>null</code>, and may
+ * be empty and may contain <code>null</code> elements.
* @param rightArray
- * The right array to compare; may be <code>null</code>, and may be empty and may
- * contain <code>null</code> elements.
- * @return <code>true</code> if the arrays are equal length and the elements at the same
- * position are equal; <code>false</code> otherwise.
+ * The right array to compare; may be <code>null</code>, and may
+ * be empty and may contain <code>null</code> elements.
+ * @return <code>true</code> if the arrays are equal length and the elements
+ * at the same position are equal; <code>false</code> otherwise.
*/
public static final boolean equals(final Object[] leftArray, final Object[] rightArray) {
if (leftArray == rightArray) {
@@ -296,24 +309,27 @@ public final class Util {
}
/**
- * Provides a hash code for the object -- defending against <code>null</code>.
+ * Provides a hash code for the object -- defending against
+ * <code>null</code>.
*
* @param object
* The object for which a hash code is required.
- * @return <code>object.hashCode</code> or <code>0</code> if <code>object</code> if
- * <code>null</code>.
+ * @return <code>object.hashCode</code> or <code>0</code> if
+ * <code>object</code> if <code>null</code>.
*/
- public static final int hashCode(final Object object) {
+ public static final int hashCode(@Nullable final Object object) {
return object != null ? object.hashCode() : 0;
}
/**
- * Computes the hash code for an array of objects, but with defense against <code>null</code>.
+ * Computes the hash code for an array of objects, but with defense against
+ * <code>null</code>.
*
* @param objects
- * The array of objects for which a hash code is needed; may be <code>null</code>.
- * @return The hash code for <code>objects</code>; or <code>0</code> if <code>objects</code> is
- * <code>null</code>.
+ * The array of objects for which a hash code is needed; may be
+ * <code>null</code>.
+ * @return The hash code for <code>objects</code>; or <code>0</code> if
+ * <code>objects</code> is <code>null</code>.
*/
public static final int hashCode(final Object[] objects) {
if (objects == null) {
@@ -332,8 +348,8 @@ public final class Util {
}
/**
- * Checks whether the second array is a subsequence of the first array, and that they share
- * common starting elements.
+ * Checks whether the second array is a subsequence of the first array, and
+ * that they share common starting elements.
*
* @param left
* The first array to compare (large); may be <code>null</code>.
@@ -341,11 +357,10 @@ public final class Util {
* The second array to compare (small); may be <code>null</code>.
* @param equals
* Whether it is allowed for the two arrays to be equivalent.
- * @return <code>true</code> if the first arrays starts with the second list; <code>false</code>
- * otherwise.
+ * @return <code>true</code> if the first arrays starts with the second
+ * list; <code>false</code> otherwise.
*/
- public static final boolean startsWith(final Object[] left, final Object[] right,
- final boolean equals) {
+ public static final boolean startsWith(final Object[] left, final Object[] right, final boolean equals) {
if (left == null || right == null) {
return false;
}
@@ -367,7 +382,8 @@ public final class Util {
}
/**
- * Converts an array into a string representation that is suitable for debugging.
+ * Converts an array into a string representation that is suitable for
+ * debugging.
*
* @param array
* The array to convert; may be <code>null</code>.
@@ -399,16 +415,19 @@ public final class Util {
* Provides a translation of a particular key from the resource bundle.
*
* @param resourceBundle
- * The key to look up in the resource bundle; should not be <code>null</code>.
+ * The key to look up in the resource bundle; should not be
+ * <code>null</code>.
* @param key
- * The key to look up in the resource bundle; should not be <code>null</code>.
+ * The key to look up in the resource bundle; should not be
+ * <code>null</code>.
* @param defaultString
- * The value to return if the resource cannot be found; may be <code>null</code>.
- * @return The value of the translated resource at <code>key</code>. If the key cannot be found,
- * then it is simply the <code>defaultString</code>.
+ * The value to return if the resource cannot be found; may be
+ * <code>null</code>.
+ * @return The value of the translated resource at <code>key</code>. If the
+ * key cannot be found, then it is simply the
+ * <code>defaultString</code>.
*/
- public static final String translateString(final ResourceBundle resourceBundle,
- final String key, final String defaultString) {
+ public static final @Nullable String translateString(@Nullable final ResourceBundle resourceBundle, @Nullable final String key, @Nullable final String defaultString) {
if (resourceBundle != null && key != null) {
try {
final String translatedString = resourceBundle.getString(key);
@@ -436,7 +455,7 @@ public final class Util {
* @return The new string.
* @since 3.4
*/
- public static final String replaceAll(String src, String find, String replacement) {
+ public static final String replaceAll(@NonNull String src, @NonNull String find, @NonNull String replacement) {
final int len = src.length();
final int findLen = find.length();
@@ -473,6 +492,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_WIN32 = "win32";//$NON-NLS-1$
/**
@@ -480,6 +500,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_MOTIF = "motif";//$NON-NLS-1$
/**
@@ -487,6 +508,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_GTK = "gtk";//$NON-NLS-1$
/**
@@ -494,6 +516,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_PHOTON = "photon";//$NON-NLS-1$
/**
@@ -501,6 +524,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_CARBON = "carbon";//$NON-NLS-1$
/**
@@ -508,6 +532,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_COCOA = "cocoa";//$NON-NLS-1$
/**
@@ -515,6 +540,7 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_WPF = "wpf";//$NON-NLS-1$
/**
@@ -522,126 +548,127 @@ public final class Util {
*
* @since 3.5
*/
+ @NonNull
public static final String WS_UNKNOWN = "unknown";//$NON-NLS-1$
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for windows platforms
-// * @since 3.5
-// */
-// public static final boolean isWindows() {
-// final String ws = SWT.getPlatform();
-// return WS_WIN32.equals(ws) || WS_WPF.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for mac platforms
-// * @since 3.5
-// */
-// public static final boolean isMac() {
-// final String ws = SWT.getPlatform();
-// return WS_CARBON.equals(ws) || WS_COCOA.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for linux platform
-// * @since 3.5
-// */
-// public static final boolean isLinux() {
-// final String ws = SWT.getPlatform();
-// return WS_GTK.equals(ws) || WS_MOTIF.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for gtk platforms
-// * @since 3.5
-// */
-// public static final boolean isGtk() {
-// final String ws = SWT.getPlatform();
-// return WS_GTK.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for motif platforms
-// * @since 3.5
-// */
-// public static final boolean isMotif() {
-// final String ws = SWT.getPlatform();
-// return WS_MOTIF.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for photon platforms
-// * @since 3.5
-// */
-// public static final boolean isPhoton() {
-// final String ws = SWT.getPlatform();
-// return WS_PHOTON.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for carbon platforms
-// * @since 3.5
-// */
-// public static final boolean isCarbon() {
-// final String ws = SWT.getPlatform();
-// return WS_CARBON.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for the cocoa platform.
-// * @since 3.5
-// */
-// public static final boolean isCocoa() {
-// final String ws = SWT.getPlatform();
-// return WS_COCOA.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for WPF
-// * @since 3.5
-// */
-// public static final boolean isWpf() {
-// final String ws = SWT.getPlatform();
-// return WS_WPF.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return <code>true</code> for win32
-// * @since 3.5
-// */
-// public static final boolean isWin32() {
-// final String ws = SWT.getPlatform();
-// return WS_WIN32.equals(ws);
-// }
-//
-// /**
-// * Common WS query helper method.
-// *
-// * @return the SWT windowing platform string.
-// * @see SWT#getPlatform()
-// * @since 3.5
-// */
-// public static final String getWS() {
-// return SWT.getPlatform();
-// }
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for windows platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isWindows() {
+ // final String ws = SWT.getPlatform();
+ // return WS_WIN32.equals(ws) || WS_WPF.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for mac platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isMac() {
+ // final String ws = SWT.getPlatform();
+ // return WS_CARBON.equals(ws) || WS_COCOA.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for linux platform
+ // * @since 3.5
+ // */
+ // public static final boolean isLinux() {
+ // final String ws = SWT.getPlatform();
+ // return WS_GTK.equals(ws) || WS_MOTIF.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for gtk platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isGtk() {
+ // final String ws = SWT.getPlatform();
+ // return WS_GTK.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for motif platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isMotif() {
+ // final String ws = SWT.getPlatform();
+ // return WS_MOTIF.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for photon platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isPhoton() {
+ // final String ws = SWT.getPlatform();
+ // return WS_PHOTON.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for carbon platforms
+ // * @since 3.5
+ // */
+ // public static final boolean isCarbon() {
+ // final String ws = SWT.getPlatform();
+ // return WS_CARBON.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for the cocoa platform.
+ // * @since 3.5
+ // */
+ // public static final boolean isCocoa() {
+ // final String ws = SWT.getPlatform();
+ // return WS_COCOA.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for WPF
+ // * @since 3.5
+ // */
+ // public static final boolean isWpf() {
+ // final String ws = SWT.getPlatform();
+ // return WS_WPF.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return <code>true</code> for win32
+ // * @since 3.5
+ // */
+ // public static final boolean isWin32() {
+ // final String ws = SWT.getPlatform();
+ // return WS_WIN32.equals(ws);
+ // }
+ //
+ // /**
+ // * Common WS query helper method.
+ // *
+ // * @return the SWT windowing platform string.
+ // * @see SWT#getPlatform()
+ // * @since 3.5
+ // */
+ // public static final String getWS() {
+ // return SWT.getPlatform();
+ // }
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Binding.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Binding.java
index d7ec07bb9..1a5a04dcc 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Binding.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Binding.java
@@ -11,17 +11,38 @@
package org.eclipse.fx.ui.keybindings;
import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A binding between a trigger sequence and a command
+ */
public interface Binding {
-
+ /**
+ * System binding
+ */
int SYSTEM = 0;
+ /**
+ * User binding
+ */
int USER = 1;
-
- String getSchemeId();
-
- TriggerSequence getTriggerSequence();
-
- ParameterizedCommand getParameterizedCommand();
-
- String getContextId();
+
+ /**
+ * @return the scheme id the binding is part of
+ */
+ @NonNull String getSchemeId();
+
+ /**
+ * @return the sequence
+ */
+ @NonNull TriggerSequence getTriggerSequence();
+
+ /**
+ * @return the command
+ */
+ @NonNull ParameterizedCommand getParameterizedCommand();
+
+ /**
+ * @return the context
+ */
+ @NonNull String getContextId();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyBinding.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyBinding.java
index 675903b0d..517ce202e 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyBinding.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyBinding.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
+/**
+ * a keybinding
+ */
public interface KeyBinding extends Binding {
-
+ // nothing todo
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeySequence.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeySequence.java
index dea50c050..0bcd69f0b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeySequence.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeySequence.java
@@ -10,8 +10,16 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
-public interface KeySequence extends TriggerSequence, Comparable<KeySequence> {
+import org.eclipse.jdt.annotation.NonNull;
- KeyStroke[] getKeyStrokes();
+/**
+ * A key sequence consists of a number of keystrokes
+ */
+public interface KeySequence extends TriggerSequence, Comparable<KeySequence> {
+
+ /**
+ * @return the strokes
+ */
+ @NonNull KeyStroke[] getKeyStrokes();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyStroke.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyStroke.java
index c58d221c0..b5e4a5dff 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyStroke.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/KeyStroke.java
@@ -10,16 +10,33 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
+/**
+ * A key stroke
+ */
public interface KeyStroke extends Trigger {
-
+ /**
+ * @return has an alt key modifier
+ */
boolean hasAltModifier();
+ /**
+ * @return has a control key modifier
+ */
boolean hasCtrlModifier();
+ /**
+ * @return has a shift modifier
+ */
boolean hasShiftModifier();
-
- boolean hasCommandModifier();
+ /**
+ * @return has a command modifier
+ */
+ boolean hasCommandModifier();
+
+ /**
+ * @return the key code
+ */
int getKeyCode();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/ParseException.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/ParseException.java
index 8e11b94b7..f25bc16a3 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/ParseException.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/ParseException.java
@@ -10,14 +10,22 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Exception thrown when parsing of a sequence failed
+ */
public class ParseException extends Exception {
+ private static final long serialVersionUID = 1L;
+
/**
+ * Create a new exception
*
+ * @param string
+ * the error information
*/
- private static final long serialVersionUID = 1L;
-
- public ParseException(String string) {
+ public ParseException(@NonNull String string) {
super(string);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Trigger.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Trigger.java
index 43f480d53..09b5c7ad7 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Trigger.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/Trigger.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
+/**
+ * A trigger
+ */
public interface Trigger extends Comparable<Trigger> {
-
+ // nothing todo
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/TriggerSequence.java b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/TriggerSequence.java
index 1c3714b2d..d9cb425ff 100755
--- a/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/TriggerSequence.java
+++ b/bundles/runtime/org.eclipse.fx.ui.keybindings/src/org/eclipse/fx/ui/keybindings/TriggerSequence.java
@@ -10,15 +10,33 @@
*******************************************************************************/
package org.eclipse.fx.ui.keybindings;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * A trigger sequence
+ */
public interface TriggerSequence {
+ /**
+ * @return the triggers
+ */
+ @NonNull
Trigger[] getTriggers();
+ /**
+ * @return prefix sequence
+ */
+ @NonNull
TriggerSequence[] getPrefixes();
+ /**
+ * @return formated value
+ */
String format();
+ /**
+ * @return check if empty
+ */
boolean isEmpty();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore
deleted file mode 100644
index 934e0e06f..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/bin
-/target
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs b/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index e8ff8be0b..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-pluginProject.equinox=false
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF
deleted file mode 100644
index d8d28a513..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,19 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Lifecycle
-Bundle-SymbolicName: org.eclipse.fx.ui.lifecycle
-Bundle-Version: 1.0.0.qualifier
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.e4.ui.model.workbench,
- org.eclipse.e4.core.di,
- org.eclipse.e4.core.contexts,
- org.eclipse.e4.core.services,
- org.eclipse.e4.ui.workbench,
- org.eclipse.emf.ecore;bundle-version="2.9.0",
- org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional
-Export-Package: org.eclipse.fx.ui.lifecycle,
- org.eclipse.fx.ui.lifecycle.annotations
-Import-Package: javax.annotation;version="1.1.0",
- javax.inject;version="1.0.0"
-Service-Component: OSGI-INF/component.xml
-Bundle-ActivationPolicy: lazy
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java
deleted file mode 100644
index 46ecfcd88..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleServiceImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 BestSolution.at 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:
- * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.fx.ui.internal.lifecycle;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.eclipse.e4.core.contexts.ContextInjectionFactory;
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.services.contributions.IContributionFactory;
-import org.eclipse.e4.ui.model.application.MApplication;
-import org.eclipse.e4.ui.model.application.ui.MContext;
-import org.eclipse.e4.ui.model.application.ui.MUIElement;
-import org.eclipse.e4.ui.workbench.modeling.EModelService;
-import org.eclipse.fx.ui.lifecycle.ELifecycleService;
-import org.eclipse.fx.ui.lifecycle.LifecycleAddon;
-
-public class LifecycleServiceImpl implements ELifecycleService{
-
- @Inject
- private EModelService modelService;
-
- @Inject
- private MApplication app;
-
- @Inject
- private IContributionFactory factory;
-
- public void registerLifecycleURI(MUIElement element, String lifecycleURI) {
- Set<Object> contributions = (Set<Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
- if (contributions == null) {
- contributions = new HashSet<Object>();
- element.getTransientData().put(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY, contributions);
- }
-
- Object object = factory.create(lifecycleURI, app.getContext());
- contributions.add(object);
-
- }
-
- public boolean validateAnnotation(Class annotationClass, MUIElement element, IEclipseContext context) {
- return validateLifecycleAnnotation(annotationClass, getContextForParent(element), context, element);
- }
-
- private boolean validateLifecycleAnnotation(Class clazz, IEclipseContext parentContext,
- IEclipseContext partContext, MUIElement part) {
- Set<Object> set = (Set<Object>) part.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
- if (set!=null){
- for (Object object : set) {
- Object invokeResult = ContextInjectionFactory.invoke(object, clazz, parentContext, partContext,true);
- if (invokeResult!=null){//supports void methods
- boolean res = (boolean)invokeResult;
- if (!res) return false;
- }
- }
- }
- return true;
- }
- private IEclipseContext getContextForParent(MUIElement element) {
- return modelService.getContainingContext(element);
- }
-
- @Override
- public void unregisterLifecycleContribution(MUIElement element,
- Object contribution) {
- Set<Object> objects = (Set<Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
- if (objects!=null) objects.remove(contribution);
- }
-
-} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java b/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java
deleted file mode 100644
index 67f4cbf79..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/ELifecycleService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 BestSolution.at 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:
- * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.fx.ui.lifecycle;
-
-import java.lang.annotation.Annotation;
-
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.ui.model.application.ui.MUIElement;
-
-public interface ELifecycleService {
-
- public void registerLifecycleURI(MUIElement element, String lifecycleURI);
-
- public void unregisterLifecycleContribution(MUIElement element, Object contribution);
-
- public boolean validateAnnotation(Class<? extends Annotation> annotationClass, MUIElement element, IEclipseContext context);
-
-} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Card.java b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Card.java
index df6742360..ad023306f 100644
--- a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Card.java
+++ b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Card.java
@@ -10,22 +10,41 @@
*******************************************************************************/
package org.eclipse.fx.ui.mobile;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.layout.BorderPane;
+/**
+ * A main UI area
+ */
public class Card extends BorderPane {
- private StringProperty name = new SimpleStringProperty(this, "name");
-
- public void setName(String name) {
+ @NonNull
+ private final StringProperty name = new SimpleStringProperty(this, "name"); //$NON-NLS-1$
+
+ /**
+ * set the name of the card
+ *
+ * @param name
+ * the name
+ */
+ public void setName(@NonNull String name) {
this.name.set(name);
}
-
- public String getName() {
+
+ /**
+ * @return the name of the card
+ */
+ public @Nullable String getName() {
return this.name.get();
}
-
- public StringProperty nameProperty() {
- return name;
+
+ /**
+ * @return the string property
+ */
+ public @NonNull StringProperty nameProperty() {
+ return this.name;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Deck.java b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Deck.java
index 709660a65..22230a960 100644
--- a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Deck.java
+++ b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/Deck.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.fx.ui.mobile;
-
-
import org.eclipse.fx.ui.mobile.animations.TransitionDelegate;
+import org.eclipse.jdt.annotation.NonNull;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
@@ -22,53 +21,80 @@ import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Region;
import javafx.scene.shape.Rectangle;
+/**
+ * A stack of cards allowing switch from card to card
+ */
public class Deck extends Region {
- private ObservableList<Card> cards = FXCollections.observableArrayList();
-
- private BorderPane contenArea;
-
+ @SuppressWarnings("null")
+ @NonNull
+ final ObservableList<@NonNull Card> cards = FXCollections.observableArrayList();
+
+ BorderPane contenArea;
+
+ /**
+ * Create a new instance
+ */
public Deck() {
- contenArea = new BorderPane();
- getChildren().add(contenArea);
- cards.addListener(new InvalidationListener() {
-
+ this.contenArea = new BorderPane();
+ getChildren().add(this.contenArea);
+ this.cards.addListener(new InvalidationListener() {
+
@Override
public void invalidated(Observable observable) {
- contenArea.setCenter(cards.get(0));
- cards.removeListener(this);
+ Deck.this.contenArea.setCenter(Deck.this.cards.get(0));
+ Deck.this.cards.removeListener(this);
}
});
}
-
+
@Override
protected void layoutChildren() {
super.layoutChildren();
- contenArea.resizeRelocate(getInsets().getLeft(), getInsets().getTop(),getWidth()-getInsets().getLeft(), getHeight()-getInsets().getTop());
- contenArea.setClip(new Rectangle(getWidth()-getInsets().getLeft(), getHeight()-getInsets().getTop()));
+ this.contenArea.resizeRelocate(getInsets().getLeft(), getInsets().getTop(), getWidth() - getInsets().getLeft(), getHeight() - getInsets().getTop());
+ this.contenArea.setClip(new Rectangle(getWidth() - getInsets().getLeft(), getHeight() - getInsets().getTop()));
}
-
- public ObservableList<Card> getCards() {
- return cards;
+
+ /**
+ * @return the cards
+ */
+ public @NonNull ObservableList<@NonNull Card> getCards() {
+ return this.cards;
}
-
- public void moveTo(String name, TransitionType animation) {
+
+ /**
+ * Switch to another card
+ *
+ * @param name
+ * the name of the card
+ * @param animation
+ * the predefined animation
+ */
+ public void moveTo(@NonNull String name, @NonNull TransitionType animation) {
moveTo(name, animation.getDelegate());
}
-
+
+ /**
+ * Switch to another card
+ *
+ * @param name
+ * the name of the card
+ * @param delegate
+ * the delegate to do the switch
+ */
public void moveTo(String name, TransitionDelegate delegate) {
- for( Card c : cards ) {
- if( name.equals(c.getName()) ) {
- if( contenArea.getCenter() != c ) {
- if( delegate != null ) {
- delegate.transitionTo(contenArea, (Card) contenArea.getCenter(), c);
+ for (Card c : this.cards) {
+ if (name.equals(c.getName())) {
+ if (this.contenArea.getCenter() != c) {
+ if (delegate != null) {
+ delegate.transitionTo(this.contenArea, (Card) this.contenArea.getCenter(), c);
} else {
- contenArea.setCenter(c);
- }
+ this.contenArea.setCenter(c);
+ }
}
-
+
break;
}
}
}
-
+
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/MobileApp.java b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/MobileApp.java
index 5c404f565..6dab4b6a2 100644
--- a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/MobileApp.java
+++ b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/MobileApp.java
@@ -13,12 +13,26 @@ package org.eclipse.fx.ui.mobile;
import java.util.Collections;
import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+
import javafx.scene.layout.Region;
+/**
+ * Basic entry point for applications
+ */
public abstract class MobileApp {
- public List<String> getInitialStylesheets() {
+ /**
+ * @return the initial stylesheets
+ */
+ @SuppressWarnings({ "null", "static-method" })
+ public @NonNull List<@NonNull String> getInitialStylesheets() {
return Collections.emptyList();
}
-
+
+ /**
+ * Create the main UI
+ *
+ * @return the root region
+ */
public abstract Region createUI();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/TransitionType.java b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/TransitionType.java
index 584f56782..5359a06d1 100644
--- a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/TransitionType.java
+++ b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/TransitionType.java
@@ -11,21 +11,44 @@
package org.eclipse.fx.ui.mobile;
import org.eclipse.fx.ui.mobile.animations.TransitionDelegate;
+import org.eclipse.jdt.annotation.Nullable;
+/**
+ * Transition type
+ */
public enum TransitionType {
+ /**
+ * No transition
+ */
NONE(null),
+ /**
+ * slide to the left
+ */
SLIDE_LEFT(TransitionDelegate.slideLeft()),
+ /**
+ * slide to the right
+ */
SLIDE_RIGHT(TransitionDelegate.slideRight()),
+ /**
+ * fade
+ */
FADE(TransitionDelegate.fade()),
+ /**
+ * zoom slide
+ */
ZOOM_SLIDE(TransitionDelegate.zoomSlide());
+ @Nullable
private final TransitionDelegate delegate;
- private TransitionType(TransitionDelegate delegate) {
+ private TransitionType(@Nullable TransitionDelegate delegate) {
this.delegate = delegate;
}
- public TransitionDelegate getDelegate() {
- return delegate;
+ /**
+ * @return the delegate
+ */
+ public @Nullable TransitionDelegate getDelegate() {
+ return this.delegate;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/animations/TransitionDelegate.java b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/animations/TransitionDelegate.java
index e045e8bb0..da9878bf6 100644
--- a/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/animations/TransitionDelegate.java
+++ b/bundles/runtime/org.eclipse.fx.ui.mobile/src/org/eclipse/fx/ui/mobile/animations/TransitionDelegate.java
@@ -4,13 +4,9 @@ import javafx.animation.Animation;
import javafx.animation.FadeTransition;
import javafx.animation.Interpolator;
import javafx.animation.ParallelTransition;
-import javafx.animation.ParallelTransitionBuilder;
import javafx.animation.ScaleTransition;
-import javafx.animation.ScaleTransitionBuilder;
import javafx.animation.SequentialTransition;
-import javafx.animation.SequentialTransitionBuilder;
import javafx.animation.TranslateTransition;
-import javafx.animation.TranslateTransitionBuilder;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
@@ -20,54 +16,71 @@ import javafx.util.Duration;
import org.eclipse.fx.ui.mobile.Card;
+/**
+ * Transition between 2 cards
+ */
public abstract class TransitionDelegate {
+ /**
+ * Transition between the card
+ *
+ * @param parent
+ * the owner
+ * @param from
+ * the from card
+ * @param to
+ * the to card
+ */
public void transitionTo(final BorderPane parent, final Card from, final Card to) {
parent.setCenter(null);
-
+
Bounds b = from.getBoundsInParent();
to.resizeRelocate(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight());
- parent.getChildren().add(0,to);
- parent.getChildren().add(1,from);
-
+ parent.getChildren().add(0, to);
+ parent.getChildren().add(1, from);
+
Animation animation = createAndPrepareAnimation(from, to);
-
+
animation.onFinishedProperty().set(new EventHandler<ActionEvent>() {
-
+
@Override
public void handle(ActionEvent event) {
parent.getChildren().remove(from);
parent.getChildren().remove(to);
parent.setCenter(to);
- resetProperties(from, to);
+ resetProperties(from, to);
}
});
-
+
animation.play();
}
-
+
protected abstract Animation createAndPrepareAnimation(Card from, Card to);
+
protected abstract void resetProperties(Card from, Card to);
-
+
+ /**
+ * @return transition by sliding to the left
+ */
public static TransitionDelegate slideLeft() {
return new TransitionDelegate() {
-
+
@Override
protected void resetProperties(Card from, Card to) {
to.setTranslateX(0);
from.setTranslateX(0);
}
-
+
@Override
protected Animation createAndPrepareAnimation(Card from, Card to) {
from.setOpacity(1);
-
+
double deltaX = -from.getBoundsInLocal().getWidth();
to.setTranslateX(-deltaX);
-
+
return new ParallelTransition(createTransition(deltaX, from), createTransition(deltaX, to));
}
-
+
private TranslateTransition createTransition(double deltaX, Card node) {
TranslateTransition t = new TranslateTransition(new Duration(1000));
t.setInterpolator(Interpolator.EASE_BOTH);
@@ -77,26 +90,29 @@ public abstract class TransitionDelegate {
}
};
}
-
+
+ /**
+ * @return transition by sliding to the right
+ */
public static TransitionDelegate slideRight() {
return new TransitionDelegate() {
-
+
@Override
protected void resetProperties(Card from, Card to) {
to.setTranslateX(0);
from.setTranslateX(0);
}
-
+
@Override
protected Animation createAndPrepareAnimation(Card from, Card to) {
from.setOpacity(1);
-
+
double deltaX = from.getBoundsInLocal().getWidth();
to.setTranslateX(-deltaX);
-
+
return new ParallelTransition(createTransition(deltaX, from), createTransition(deltaX, to));
}
-
+
private TranslateTransition createTransition(double deltaX, Card node) {
TranslateTransition t = new TranslateTransition(new Duration(1000));
t.setInterpolator(Interpolator.EASE_BOTH);
@@ -106,16 +122,19 @@ public abstract class TransitionDelegate {
}
};
}
-
+
+ /**
+ * @return fade between the two cards
+ */
public static TransitionDelegate fade() {
return new TransitionDelegate() {
-
+
@Override
protected void resetProperties(Card from, Card to) {
from.setOpacity(1);
to.setOpacity(1);
}
-
+
@Override
protected Animation createAndPrepareAnimation(Card from, Card to) {
FadeTransition t = new FadeTransition(Duration.seconds(1));
@@ -127,48 +146,47 @@ public abstract class TransitionDelegate {
}
};
}
-
+
+ /**
+ * @return zoom slide animation
+ */
public static TransitionDelegate zoomSlide() {
return new TransitionDelegate() {
-
+
@Override
protected void resetProperties(Card from, Card to) {
to.setTranslateX(0);
to.setScaleX(1);
to.setScaleY(1);
-
+
from.setTranslateX(0);
from.setScaleX(1);
from.setScaleY(1);
-
+
to.setEffect(null);
from.setEffect(null);
}
-
+
@Override
protected Animation createAndPrepareAnimation(Card from, Card to) {
double deltaX = -from.getBoundsInLocal().getWidth();
to.setTranslateX(-deltaX);
-
-// curNode.setEffect(new DropShadow(2, 2, 2, Color.RED));
-// newNode.setEffect(new DropShadow(2, 2, 2, Color.RED));
-
- TranslateTransition slideFrom = translateTransition(from,deltaX);
- TranslateTransition slideTo = translateTransition(to,deltaX);
-
+
+ // curNode.setEffect(new DropShadow(2, 2, 2, Color.RED));
+ // newNode.setEffect(new DropShadow(2, 2, 2, Color.RED));
+
+ TranslateTransition slideFrom = translateTransition(from, deltaX);
+ TranslateTransition slideTo = translateTransition(to, deltaX);
+
ScaleTransition zoomOutFrom = scaleTransition(from, 0.7);
ScaleTransition zoomOutTo = scaleTransition(from, 0.7);
-
+
ScaleTransition zoomInFrom = scaleTransition(from, 1);
ScaleTransition zoomInTo = scaleTransition(from, 1);
-
- return new SequentialTransition(
- new ParallelTransition(zoomOutFrom, zoomOutTo),
- new ParallelTransition(slideFrom, slideTo),
- new ParallelTransition(zoomInFrom, zoomInTo)
- );
+
+ return new SequentialTransition(new ParallelTransition(zoomOutFrom, zoomOutTo), new ParallelTransition(slideFrom, slideTo), new ParallelTransition(zoomInFrom, zoomInTo));
}
-
+
private TranslateTransition translateTransition(Node node, double deltaX) {
TranslateTransition t = new TranslateTransition(Duration.millis(300));
t.setNode(node);
@@ -176,7 +194,7 @@ public abstract class TransitionDelegate {
t.setByX(deltaX);
return t;
}
-
+
private ScaleTransition scaleTransition(Node node, double to) {
ScaleTransition t = new ScaleTransition(Duration.millis(300));
t.setNode(node);
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/.classpath b/bundles/runtime/org.eclipse.fx.ui.panes/.classpath
index ff5b69385..b862a296d 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/.classpath
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/.classpath
@@ -3,6 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="test-src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.ui.panes/.settings/org.eclipse.jdt.core.prefs
index 5671530f4..8d88004d6 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/.settings/org.eclipse.jdt.core.prefs
@@ -50,7 +50,7 @@ org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/AbstractLayoutPane.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/AbstractLayoutPane.java
index 17ab9a09e..fa6523c94 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/AbstractLayoutPane.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/AbstractLayoutPane.java
@@ -10,69 +10,102 @@
*******************************************************************************/
package org.eclipse.fx.ui.panes;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
import javafx.scene.Node;
import javafx.scene.layout.Pane;
+/**
+ * Abstract layout pane
+ *
+ * @param <D>
+ * the constraint
+ */
public abstract class AbstractLayoutPane<D> extends Pane {
+ /**
+ * default
+ */
public static final int FX_DEFAULT = -1;
- public static final int FX_BEGINNING = 1;
- public static final int FX_FILL = 4;
- public static final int FX_LEFT = 16384;
- public static final int FX_END = 16777224;
- public static final int FX_RIGHT = 131072;
- public static final int FX_CENTER = 16777216;
- public static final int FX_BOTTOM = 1024;
- public static final int FX_TOP = 128;
- public static final int FX_HORIZONTAL = 256;
-
+
static class Size {
public final double width;
public final double height;
-
+
public Size(double width, double height) {
this.width = width;
this.height = height;
}
}
-
- protected abstract Size computeSize(double width, double height, boolean flushCache);
-
- protected static void setConstraint(Node node, Object key, Object value) {
- if (value == null) {
- node.getProperties().remove(key);
- } else {
- node.getProperties().put(key, value);
- }
- if (node.getParent() != null) {
- node.getParent().requestLayout();
- }
- }
- protected static Object getConstraint(Node node, Object key) {
- if (node.hasProperties()) {
- Object value = node.getProperties().get(key);
- if (value != null) {
- return value;
- }
- }
- return null;
- }
-
+ /**
+ * Compute the size
+ *
+ * @param width
+ * the available width
+ * @param height
+ * the available height
+ * @param flushCache
+ * flush cached informations
+ * @return the size
+ */
+ protected abstract @NonNull Size computeSize(double width, double height, boolean flushCache);
+
+ /**
+ * Remember a layout constraint
+ *
+ * @param node
+ * the node
+ * @param key
+ * the constraint key
+ * @param value
+ * the value
+ */
+ protected static void setConstraint(@NonNull Node node, @NonNull Object key, @Nullable Object value) {
+ if (value == null) {
+ node.getProperties().remove(key);
+ } else {
+ node.getProperties().put(key, value);
+ }
+ if (node.getParent() != null) {
+ node.getParent().requestLayout();
+ }
+ }
+
+ /**
+ * Access the current constraint value
+ *
+ * @param node
+ * the node
+ * @param key
+ * the key
+ * @return the value if associated
+ */
+ protected static @Nullable Object getConstraint(@NonNull Node node, @NonNull Object key) {
+ if (node.hasProperties()) {
+ Object value = node.getProperties().get(key);
+ if (value != null) {
+ return value;
+ }
+ }
+ return null;
+ }
+
@Override
protected double computeMinHeight(double width) {
return 0;
}
-
+
@Override
protected double computeMinWidth(double height) {
return 0;
}
-
+
@Override
protected double computePrefHeight(double width) {
return computeSize(FX_DEFAULT, FX_DEFAULT, true).height;
}
-
+
@Override
protected double computePrefWidth(double height) {
return computeSize(FX_DEFAULT, FX_DEFAULT, true).width;
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/FillLayoutPane.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/FillLayoutPane.java
index d5afd1508..db8f95298 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/FillLayoutPane.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/FillLayoutPane.java
@@ -14,7 +14,6 @@ package org.eclipse.fx.ui.panes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.WeakHashMap;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
@@ -160,8 +159,9 @@ public class FillLayoutPane extends AbstractLayoutPane<FillLayoutPane.FillData>
}
}
- private final static WeakHashMap<Node, FillData> CONSTRAINTS = new WeakHashMap<Node, FillData>();
-
+ @NonNull
+ private static final String LAYOUT_KEY = "fillData"; //$NON-NLS-1$
+
/**
* Set a constraint object for the node
*
@@ -171,7 +171,7 @@ public class FillLayoutPane extends AbstractLayoutPane<FillLayoutPane.FillData>
* the fill data
*/
public final static void setConstraint(@NonNull Node n, @NonNull FillData data) {
- CONSTRAINTS.put(n, data);
+ setConstraint(n, LAYOUT_KEY, data);
}
/**
@@ -182,7 +182,7 @@ public class FillLayoutPane extends AbstractLayoutPane<FillLayoutPane.FillData>
* @return the constraint or <code>null</code>
*/
public final static @Nullable FillData getConstraint(@NonNull Node n) {
- return CONSTRAINTS.get(n);
+ return (FillData) getConstraint(n, LAYOUT_KEY);
}
/**
@@ -378,7 +378,8 @@ public class FillLayoutPane extends AbstractLayoutPane<FillLayoutPane.FillData>
if (i == count - 1)
childWidth += (extra + 1) / 2;
}
- child.resizeRelocate(x, y, childWidth, height);
+ childWidth = Math.max(childWidth, child.minWidth(height));
+ child.resizeRelocate(x, y, childWidth, Math.max(height,child.minHeight(childWidth)));
x += childWidth + this.spacing.get();
}
} else {
@@ -394,7 +395,8 @@ public class FillLayoutPane extends AbstractLayoutPane<FillLayoutPane.FillData>
if (i == count - 1)
childHeight += (extra + 1) / 2;
}
- child.resizeRelocate(x, y, width, childHeight);
+ childHeight = Math.max(childHeight, child.minHeight(width));
+ child.resizeRelocate(x, y, Math.max(width,child.minWidth(childHeight)), childHeight);
y += childHeight + this.spacing.get();
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridData.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridData.java
index 033cb62a4..c91154bd0 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridData.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridData.java
@@ -23,7 +23,7 @@ import javafx.scene.Node;
* Constraints for grid elements
*/
public class GridData {
-
+
/**
* The alignment of the item in the cell
*/
@@ -45,7 +45,7 @@ public class GridData {
*/
FILL
}
-
+
private ObjectProperty<Alignment> verticalAlignment = new SimpleObjectProperty<Alignment>(this, "verticalAlignment", Alignment.CENTER); //$NON-NLS-1$
private ObjectProperty<Alignment> horizontalAlignment = new SimpleObjectProperty<Alignment>(this, "horizontalAlignment", Alignment.BEGINNING); //$NON-NLS-1$
@@ -189,23 +189,23 @@ public class GridData {
public GridData(int style) {
super();
if ((style & VERTICAL_ALIGN_BEGINNING) != 0)
- this.verticalAlignment.set(Alignment.BEGINNING);
+ setVerticalAlignment(Alignment.BEGINNING);
if ((style & VERTICAL_ALIGN_CENTER) != 0)
- this.verticalAlignment.set(Alignment.CENTER);
+ setVerticalAlignment(Alignment.CENTER);
if ((style & VERTICAL_ALIGN_FILL) != 0)
- this.verticalAlignment.set(Alignment.FILL);
+ setVerticalAlignment(Alignment.FILL);
if ((style & VERTICAL_ALIGN_END) != 0)
- this.verticalAlignment.set(Alignment.END);
+ setVerticalAlignment(Alignment.END);
if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0)
- this.horizontalAlignment.set(Alignment.BEGINNING);
+ setHorizontalAlignment(Alignment.BEGINNING);
if ((style & HORIZONTAL_ALIGN_CENTER) != 0)
- this.horizontalAlignment.set(Alignment.CENTER);
+ setHorizontalAlignment(Alignment.CENTER);
if ((style & HORIZONTAL_ALIGN_FILL) != 0)
- this.horizontalAlignment.set(Alignment.FILL);
+ setHorizontalAlignment(Alignment.FILL);
if ((style & HORIZONTAL_ALIGN_END) != 0)
- this.horizontalAlignment.set(Alignment.END);
- this.grabExcessHorizontalSpace.set((style & GRAB_HORIZONTAL) != 0);
- this.grabExcessVerticalSpace.set((style & GRAB_VERTICAL) != 0);
+ setHorizontalAlignment(Alignment.END);
+ setGrabExcessHorizontalSpace((style & GRAB_HORIZONTAL) != 0);
+ setGrabExcessVerticalSpace((style & GRAB_VERTICAL) != 0);
}
/**
@@ -258,12 +258,12 @@ public class GridData {
*/
public GridData(Alignment horizontalAlignment, Alignment verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) {
super();
- this.horizontalAlignment.set(horizontalAlignment);
- this.verticalAlignment.set(verticalAlignment);
- this.grabExcessHorizontalSpace.set(grabExcessHorizontalSpace);
- this.grabExcessVerticalSpace.set(grabExcessVerticalSpace);
- this.horizontalSpan.set(horizontalSpan);
- this.verticalSpan.set(verticalSpan);
+ setHorizontalAlignment(horizontalAlignment);
+ setVerticalAlignment(verticalAlignment);
+ setGrabExcessHorizontalSpace(grabExcessHorizontalSpace);
+ setGrabExcessVerticalSpace(grabExcessVerticalSpace);
+ setHorizontalSpan(horizontalSpan);
+ setVerticalSpan(verticalSpan);
}
/**
@@ -280,15 +280,15 @@ public class GridData {
*/
public GridData(int width, int height) {
super();
- this.widthHint.set(width);
- this.heightHint.set(height);
+ setWidthHint(width);
+ setHeightHint(height);
}
void computeSize(Node control, int wHint, int hHint, boolean flushCache) {
if (this.cacheWidth != -1 && this.cacheHeight != -1)
return;
-
- if (wHint == this.widthHint.get() && hHint == this.heightHint.get()) {
+
+ if (wHint == getWidthHint() && hHint == getHeightHint()) {
if (this.defaultWidth == -1 || this.defaultHeight == -1 || wHint != this.defaultWhint || hHint != this.defaultHhint) {
// Point size = control.computeSize (wHint, hHint, flushCache);
this.defaultWhint = wHint;
@@ -325,173 +325,319 @@ public class GridData {
return string.substring(index + 1, string.length());
}
- // ----
+ /**
+ * Exclude the node when layouting
+ *
+ * @param value
+ * the new value
+ */
public void setExclude(boolean value) {
- exclude.set(value);
+ excludeProperty().set(value);
}
+ /**
+ * @return Exclude the node when layouting
+ */
public boolean isExclude() {
- return exclude.get();
+ return excludeProperty().get();
}
+ /**
+ * @return Exclude the node when layouting
+ */
public BooleanProperty excludeProperty() {
- return exclude;
+ return this.exclude;
}
- // ----
+ /**
+ * Grab all available horizontal space
+ *
+ * @param value
+ * <code>true</code> to grab space
+ */
public void setGrabExcessHorizontalSpace(boolean value) {
- grabExcessHorizontalSpace.set(value);
+ grabExcessHorizontalSpaceProperty().set(value);
}
+ /**
+ * @return <code>true</code> if space is grabbed
+ */
public boolean isGrabExcessHorizontalSpace() {
- return grabExcessHorizontalSpace.get();
+ return grabExcessHorizontalSpaceProperty().get();
}
+ /**
+ * @return Grab all available horizontal space
+ */
public BooleanProperty grabExcessHorizontalSpaceProperty() {
- return grabExcessHorizontalSpace;
+ return this.grabExcessHorizontalSpace;
}
- // ----
- public void setGrabVerticalSpace(boolean value) {
- grabExcessVerticalSpace.set(value);
+ /**
+ * Grab vertical space if available
+ *
+ * @param value
+ * <code>true</code> to grab space
+ */
+ public void setGrabExcessVerticalSpace(boolean value) {
+ grabExcessVerticalSpaceProperty().set(value);
}
- public boolean isGrabVerticalSapce() {
- return grabExcessVerticalSpace.get();
+ /**
+ * @return <code>true</code> is space is grabbed
+ */
+ public boolean isGrabExcessVerticalSpace() {
+ return grabExcessVerticalSpaceProperty().get();
}
+ /**
+ * @return <code>true</code> is space is grabbed
+ */
public BooleanProperty grabExcessVerticalSpaceProperty() {
- return grabExcessVerticalSpace;
+ return this.grabExcessVerticalSpace;
}
- // ----
+ /**
+ * Set a height hint
+ *
+ * @param value
+ * the hint of or {@link AbstractLayoutPane#FX_DEFAULT} to set
+ * back
+ */
public void setHeightHint(int value) {
- heightHint.set(value);
+ heightHintProperty().set(value);
}
+ /**
+ * @return the current height hint
+ */
public int getHeightHint() {
- return heightHint.get();
+ return heightHintProperty().get();
}
+ /**
+ * @return the height property
+ */
public IntegerProperty heightHintProperty() {
- return heightHint;
+ return this.heightHint;
}
- // ----
+ /**
+ * Set a horizontal alignment
+ *
+ * @param value
+ * the alignment
+ */
public void setHorizontalAlignment(Alignment value) {
- horizontalAlignment.set(value);
+ horizontalAlignmentProperty().set(value);
}
+ /**
+ * @return the current horizontal alignment
+ */
public Alignment getHorizontalAlignment() {
- return horizontalAlignment.get();
+ return horizontalAlignmentProperty().get();
}
+ /**
+ * @return the horizontal alignment property
+ */
public ObjectProperty<Alignment> horizontalAlignmentProperty() {
- return horizontalAlignment;
+ return this.horizontalAlignment;
}
- // ----
+ /**
+ * Set the horizontal indent
+ *
+ * @param value
+ * the indent
+ */
public void setHorizontalIndent(int value) {
- horizontalIndent.set(value);
+ horizontalIndentProperty().set(value);
}
- public int getHorizontalnIdent() {
- return horizontalIndent.get();
+ /**
+ * @return the horizontal indent
+ */
+ public int getHorizontalIndent() {
+ return horizontalIndentProperty().get();
}
+ /**
+ * @return the horizontal indent property
+ */
public IntegerProperty horizontalIndentProperty() {
- return horizontalIndent;
+ return this.horizontalIndent;
}
- // ----
+ /**
+ * Set a horizontal span
+ *
+ * @param value
+ * the horizontal span
+ */
public void setHorizontalSpan(int value) {
- horizontalSpan.set(value);
+ horizontalSpanProperty().set(value);
}
+ /**
+ * @return the current horizontal span
+ */
public int getHorizontalSpan() {
- return horizontalSpan.get();
+ return horizontalSpanProperty().get();
}
+ /**
+ * @return the horizontal span property
+ */
public IntegerProperty horizontalSpanProperty() {
- return horizontalSpan;
+ return this.horizontalSpan;
}
- // ----
+ /**
+ * Set a minimum height
+ *
+ * @param value
+ * the value or {@link AbstractLayoutPane#FX_DEFAULT} for the
+ * default
+ */
public void setMinimumHeight(int value) {
- minimumHeight.set(value);
+ minimumHeightProperty().set(value);
}
+ /**
+ * @return the current minimum height
+ */
public int getMinimumHeight() {
- return minimumHeight.get();
+ return minimumHeightProperty().get();
}
+ /**
+ * @return the current minimum height property
+ */
public IntegerProperty minimumHeightProperty() {
- return minimumHeight;
+ return this.minimumHeight;
}
- // ----
+ /**
+ * Set a minimum width
+ *
+ * @param value
+ * the new minimum width or {@link AbstractLayoutPane#FX_DEFAULT}
+ * for the default
+ */
public void setMinimumWidth(int value) {
- minimumWidth.set(value);
+ minimumWidthProperty().set(value);
}
+ /**
+ * @return the current minimum width
+ */
public int getMinimumWidth() {
- return minimumWidth.get();
+ return minimumWidthProperty().get();
}
+ /**
+ * @return the current minimum width property
+ */
public IntegerProperty minimumWidthProperty() {
- return minimumWidth;
+ return this.minimumWidth;
}
- // ----
+ /**
+ * Set a vertical alignment
+ *
+ * @param value
+ * the new alignment
+ */
public void setVerticalAlignment(Alignment value) {
- verticalAlignment.set(value);
+ verticalAlignmentProperty().set(value);
}
+ /**
+ * @return the current vertical alignment
+ */
public Alignment getVerticalAlignment() {
- return verticalAlignment.get();
+ return verticalAlignmentProperty().get();
}
+ /**
+ * @return the vertical alignment property
+ */
public ObjectProperty<Alignment> verticalAlignmentProperty() {
- return verticalAlignment;
+ return this.verticalAlignment;
}
-
- // ----
+
+ /**
+ * Set a vertical indent
+ *
+ * @param value
+ * the indent
+ */
public void setVerticalIndent(int value) {
- verticalIndent.set(value);
+ verticalIndentProperty().set(value);
}
+ /**
+ * @return The current vertical indent
+ */
public int getVerticalIndent() {
- return verticalIndent.get();
+ return verticalIndentProperty().get();
}
+ /**
+ * @return the vertical indent property
+ */
public IntegerProperty verticalIndentProperty() {
- return verticalIndent;
+ return this.verticalIndent;
}
- // ----
+ /**
+ * Set the vertical span
+ *
+ * @param value
+ * the new vertical span
+ */
public void setVerticalSpan(int value) {
- verticalSpan.set(value);
+ verticalSpanProperty().set(value);
}
+ /**
+ * @return the current vertical span
+ */
public int getVerticalSpan() {
- return verticalSpan.get();
+ return verticalSpanProperty().get();
}
+ /**
+ * @return the vertical span property
+ */
public IntegerProperty verticalSpanProperty() {
- return verticalSpan;
+ return this.verticalSpan;
}
- // ----
+ /**
+ * Set the width hint
+ *
+ * @param value
+ * the width hint or {@link AbstractLayoutPane#FX_DEFAULT}
+ */
public void setWidthHint(int value) {
- widthHint.set(value);
+ widthHintProperty().set(value);
}
+ /**
+ * @return the current width hint
+ */
public int getWidthHint() {
- return widthHint.get();
+ return widthHintProperty().get();
}
+ /**
+ * @return the width hint property
+ */
public IntegerProperty widthHintProperty() {
- return widthHint;
+ return this.widthHint;
}
/**
@@ -500,75 +646,74 @@ public class GridData {
*
* @return a string representation of the GridData object
*/
+ @Override
public String toString() {
- String hAlign = "";
- switch (horizontalAlignment.get()) {
+ String hAlign = ""; //$NON-NLS-1$
+ switch (this.getHorizontalAlignment()) {
case FILL:
- hAlign = "SWT.FILL";
+ hAlign = "SWT.FILL"; //$NON-NLS-1$
break;
case BEGINNING:
- hAlign = "SWT.BEGINNING";
+ hAlign = "SWT.BEGINNING"; //$NON-NLS-1$
break;
case END:
- hAlign = "GridData.END";
+ hAlign = "GridData.END"; //$NON-NLS-1$
break;
case CENTER:
- hAlign = "GridData.CENTER";
+ hAlign = "GridData.CENTER"; //$NON-NLS-1$
break;
default:
- hAlign = "Undefined " + horizontalAlignment;
+ hAlign = "Undefined " + getHorizontalAlignment(); //$NON-NLS-1$
break;
}
-
- String vAlign = "";
- switch (verticalAlignment.get()) {
+
+ String vAlign = ""; //$NON-NLS-1$
+ switch (this.getVerticalAlignment()) {
case FILL:
- vAlign = "SWT.FILL";
+ vAlign = "SWT.FILL"; //$NON-NLS-1$
break;
case BEGINNING:
- vAlign = "SWT.BEGINNING";
+ vAlign = "SWT.BEGINNING"; //$NON-NLS-1$
break;
case END:
- vAlign = "SWT.END";
+ vAlign = "SWT.END"; //$NON-NLS-1$
break;
case CENTER:
- vAlign = "SWT.CENTER";
+ vAlign = "SWT.CENTER"; //$NON-NLS-1$
break;
default:
- vAlign = "Undefined " + verticalAlignment;
+ vAlign = "Undefined " + getVerticalAlignment(); //$NON-NLS-1$
break;
}
-
- String string = getName() + " {";
- string += "horizontalAlignment=" + hAlign + " ";
- if (horizontalIndent.get() != 0)
- string += "horizontalIndent=" + horizontalIndent.get() + " ";
- if (horizontalSpan.get() != 1)
- string += "horizontalSpan=" + horizontalSpan.get() + " ";
- if (grabExcessHorizontalSpace.get())
- string += "grabExcessHorizontalSpace=" + grabExcessHorizontalSpace.get() + " ";
- if (widthHint.get() != FX_DEFAULT)
- string += "widthHint=" + widthHint.get() + " ";
- if (minimumWidth.get() != 0)
- string += "minimumWidth=" + minimumWidth.get() + " ";
- string += "verticalAlignment=" + vAlign + " ";
- if (verticalIndent.get() != 0)
- string += "verticalIndent=" + verticalIndent .get()+ " ";
- if (verticalSpan.get() != 1)
- string += "verticalSpan=" + verticalSpan.get() + " ";
- if (grabExcessVerticalSpace.get())
- string += "grabExcessVerticalSpace=" + grabExcessVerticalSpace.get() + " ";
- if (heightHint.get() != FX_DEFAULT)
- string += "heightHint=" + heightHint.get() + " ";
- if (minimumHeight.get() != 0)
- string += "minimumHeight=" + minimumHeight.get() + " ";
- if (exclude.get())
- string += "exclude=" + exclude.get() + " ";
+
+ String string = getName() + " {"; //$NON-NLS-1$
+ string += "horizontalAlignment=" + hAlign + " "; //$NON-NLS-1$//$NON-NLS-2$
+ if (getHorizontalIndent() != 0)
+ string += "horizontalIndent=" + getHorizontalIndent() + " "; //$NON-NLS-1$//$NON-NLS-2$
+ if (getHorizontalSpan() != 1)
+ string += "horizontalSpan=" + getHorizontalSpan() + " "; //$NON-NLS-1$//$NON-NLS-2$
+ if (isGrabExcessHorizontalSpace())
+ string += "grabExcessHorizontalSpace=" + isGrabExcessHorizontalSpace() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getWidthHint() != FX_DEFAULT)
+ string += "widthHint=" + getWidthHint() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getMinimumWidth() != 0)
+ string += "minimumWidth=" + getMinimumWidth() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ string += "verticalAlignment=" + vAlign + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getVerticalIndent() != 0)
+ string += "verticalIndent=" + getVerticalIndent() + " "; //$NON-NLS-1$//$NON-NLS-2$
+ if (getVerticalSpan() != 1)
+ string += "verticalSpan=" + getVerticalSpan() + " "; //$NON-NLS-1$//$NON-NLS-2$
+ if (isGrabExcessVerticalSpace())
+ string += "grabExcessVerticalSpace=" + isGrabExcessVerticalSpace() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getHeightHint() != FX_DEFAULT)
+ string += "heightHint=" + getHeightHint() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getMinimumHeight() != 0)
+ string += "minimumHeight=" + getMinimumHeight() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (isExclude())
+ string += "exclude=" + isExclude() + " "; //$NON-NLS-1$ //$NON-NLS-2$
string = string.trim();
- string += "}";
+ string += "}"; //$NON-NLS-1$
return string;
}
-
-
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridLayoutPane.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridLayoutPane.java
index e35a49d06..924d59981 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridLayoutPane.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/GridLayoutPane.java
@@ -11,11 +11,16 @@
*******************************************************************************/
package org.eclipse.fx.ui.panes;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.css.CssMetaData;
import javafx.css.SimpleStyleableBooleanProperty;
import javafx.css.SimpleStyleableIntegerProperty;
+import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.scene.Node;
@@ -35,7 +40,9 @@ import com.sun.javafx.css.converters.SizeConverter;
*/
@SuppressWarnings("restriction")
public class GridLayoutPane extends AbstractLayoutPane<GridData> {
- private static final String LAYOUT_KEY = "gd"; //$NON-NLS-1$
+ @NonNull
+ private static final String LAYOUT_KEY = "gridData"; //$NON-NLS-1$
+
private static final CssMetaData<GridLayoutPane, Number> NUM_COLUMNS = new CssMetaData<GridLayoutPane, Number>("-fx-columns", SizeConverter.getInstance(), Integer.valueOf(1)) { //$NON-NLS-1$
@Override
@@ -175,6 +182,33 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
return (StyleableProperty<Number>) node.verticalSpacingProperty();
}
};
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+
+ static {
+
+ @SuppressWarnings("static-access")
+ final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(AbstractLayoutPane.getClassCssMetaData());
+ styleables.add(HORIZONTAL_SPACING);
+ styleables.add(MAKE_COLS_EQUAL_WIDTH);
+ styleables.add(MARGIN_BOTTOM);
+ styleables.add(MARGIN_HEIGHT);
+ styleables.add(MARGIN_LEFT);
+ styleables.add(MARGIN_RIGHT);
+ styleables.add(MARGIN_TOP);
+ styleables.add(MARGIN_WIDTH);
+ styleables.add(VERTICAL_SPACING);
+ STYLEABLES = Collections.unmodifiableList(styleables);
+ }
+
+ public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
+ return STYLEABLES;
+ }
+
+ @Override
+ public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
+ return getClassCssMetaData();
+ }
@NonNull
private final IntegerProperty numColumns = new SimpleStyleableIntegerProperty(NUM_COLUMNS, this, "columns", Integer.valueOf(1)); //$NON-NLS-1$
@@ -235,8 +269,9 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
calculateLayout(true, getLayoutBounds().getMinX(), getLayoutBounds().getMinY(), getLayoutBounds().getWidth(), getLayoutBounds().getHeight(), true);
}
+ @NonNull
private Size calculateLayout(boolean move, double x, double y, double width, double height, boolean flushCache) {
- if (this.numColumns.get() < 1) {
+ if (getNumColumns() < 1) {
return new Size(getInnerMarginLeft() + getInnerMarginRight(), getInnerMarginTop() + getInnerMarginBottom());
}
@@ -248,7 +283,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < children.length; i++) {
Node control = children[i];
GridData data = getConstraint(control);
- if (data == null || !data.excludeProperty().get()) {
+ if (data == null || !data.isExclude()) {
children[count++] = children[i];
}
}
@@ -267,10 +302,10 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
if (flushCache)
data.flushCache();
- data.computeSize(child, data.widthHintProperty().get(), data.heightHintProperty().get(), flushCache);
+ data.computeSize(child, data.getWidthHint(), data.getHeightHint(), flushCache);
- if (data.grabExcessHorizontalSpaceProperty().get() && data.minimumWidthProperty().get() > 0) {
- if (data.cacheWidth < data.minimumWidthProperty().get()) {
+ if (data.isGrabExcessHorizontalSpace() && data.getMinimumWidth() > 0) {
+ if (data.cacheWidth < data.getMinimumWidth()) {
int trim = 0;
// TEMPORARY CODE
// FIXME
@@ -282,16 +317,16 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
// trim = child.getBorderWidth () * 2;
// }
data.cacheWidth = data.cacheHeight = FX_DEFAULT;
- data.computeSize(child, Math.max(0, data.minimumWidthProperty().get() - trim), data.heightHintProperty().get(), false);
+ data.computeSize(child, Math.max(0, data.getMinimumWidth() - trim), data.getHeightHint(), false);
}
}
- if (data.grabExcessVerticalSpaceProperty().get() && data.minimumHeightProperty().get() > 0) {
- data.cacheHeight = Math.max(data.cacheHeight, data.minimumHeightProperty().get());
+ if (data.isGrabExcessVerticalSpace() && data.getMinimumHeight() > 0) {
+ data.cacheHeight = Math.max(data.cacheHeight, data.getMinimumHeight());
}
}
/* Build the grid */
- int row = 0, column = 0, rowCount = 0, columnCount = this.numColumns.get();
+ int row = 0, column = 0, rowCount = 0, columnCount = getNumColumns();
Node[][] grid = new Node[4][columnCount];
for (int i = 0; i < count; i++) {
Node child = children[i];
@@ -299,8 +334,8 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
if (data == null) {
data = new GridData();
}
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
- int vSpan = Math.max(1, data.verticalSpanProperty().get());
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
+ int vSpan = Math.max(1, data.getVerticalSpan());
while (true) {
int lastRow = row + vSpan;
if (lastRow >= grid.length) {
@@ -342,7 +377,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
}
/* Column widths */
- double availableWidth = width - this.horizontalSpacing.get() * (columnCount - 1) - (getInnerMarginLeft() + getInnerMarginRight());
+ double availableWidth = width - getHorizontalSpacing() * (columnCount - 1) - (getInnerMarginLeft() + getInnerMarginRight());
int expandCount = 0;
double[] widths = new double[columnCount];
double[] minWidths = new double[columnCount];
@@ -351,18 +386,18 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < rowCount; i++) {
GridData data = getData(grid, i, j, rowCount, columnCount, true);
if (data != null) {
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
if (hSpan == 1) {
- double w = data.cacheWidth + data.horizontalIndentProperty().get();
+ double w = data.cacheWidth + data.getHorizontalIndent();
widths[j] = Math.max(widths[j], w);
- if (data.grabExcessHorizontalSpaceProperty().get()) {
+ if (data.isGrabExcessHorizontalSpace()) {
if (!expandColumn[j])
expandCount++;
expandColumn[j] = true;
}
- if (!data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() != 0) {
- w = !data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() == FX_DEFAULT ? data.cacheWidth : data.minimumWidthProperty().get();
- w += data.horizontalIndentProperty().get();
+ if (!data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() != 0) {
+ w = !data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() == FX_DEFAULT ? data.cacheWidth : data.getMinimumWidth();
+ w += data.getHorizontalIndent();
minWidths[j] = Math.max(minWidths[j], w);
}
}
@@ -371,7 +406,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < rowCount; i++) {
GridData data = getData(grid, i, j, rowCount, columnCount, false);
if (data != null) {
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
if (hSpan > 1) {
int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0;
for (int k = 0; k < hSpan; k++) {
@@ -380,13 +415,13 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
if (expandColumn[j - k])
spanExpandCount++;
}
- if (data.grabExcessHorizontalSpaceProperty().get() && spanExpandCount == 0) {
+ if (data.isGrabExcessHorizontalSpace() && spanExpandCount == 0) {
expandCount++;
expandColumn[j] = true;
}
- double w = data.cacheWidth + data.horizontalIndentProperty().get() - spanWidth - (hSpan - 1) * this.horizontalSpacing.get();
+ double w = data.cacheWidth + data.getHorizontalIndent() - spanWidth - (hSpan - 1) * getHorizontalSpacing();
if (w > 0) {
- if (this.makeColumnsEqualWidth.get()) {
+ if (isMakeColumnsEqualWidth()) {
double equalWidth = (w + spanWidth) / hSpan;
double remainder = (w + spanWidth) % hSpan;
int last = -1;
@@ -412,9 +447,9 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
}
}
}
- if (!data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() != 0) {
- w = !data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() == FX_DEFAULT ? data.cacheWidth : data.minimumWidthProperty().get();
- w += data.horizontalIndentProperty().get() - spanMinWidth - (hSpan - 1) * this.horizontalSpacingProperty().get();
+ if (!data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() != 0) {
+ w = !data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() == FX_DEFAULT ? data.cacheWidth : data.getMinimumWidth();
+ w += data.getHorizontalIndent() - spanMinWidth - (hSpan - 1) * getHorizontalSpacing();
if (w > 0) {
if (spanExpandCount == 0) {
minWidths[j] += w;
@@ -436,7 +471,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
}
}
}
- if (this.makeColumnsEqualWidth.get()) {
+ if (isMakeColumnsEqualWidth()) {
double minColumnWidth = 0;
double columnWidth = 0;
for (int i = 0; i < columnCount; i++) {
@@ -477,17 +512,17 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < rowCount; i++) {
GridData data = getData(grid, i, j, rowCount, columnCount, false);
if (data != null) {
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
if (hSpan > 1) {
- if (!data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() != 0) {
+ if (!data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() != 0) {
int spanWidth = 0, spanExpandCount = 0;
for (int k = 0; k < hSpan; k++) {
spanWidth += widths[j - k];
if (expandColumn[j - k])
spanExpandCount++;
}
- double w = !data.grabExcessHorizontalSpaceProperty().get() || data.minimumWidthProperty().get() == FX_DEFAULT ? data.cacheWidth : data.minimumWidthProperty().get();
- w += data.horizontalIndentProperty().get() - spanWidth - (hSpan - 1) * this.horizontalSpacing.get();
+ double w = !data.isGrabExcessHorizontalSpace() || data.getMinimumWidth() == FX_DEFAULT ? data.cacheWidth : data.getMinimumWidth();
+ w += data.getHorizontalIndent() - spanWidth - (hSpan - 1) * getHorizontalSpacing();
if (w > 0) {
if (spanExpandCount == 0) {
widths[j] += w;
@@ -530,16 +565,16 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < rowCount; i++) {
GridData data = getData(grid, i, j, rowCount, columnCount, false);
if (data != null) {
- if (data.heightHintProperty().get() == FX_DEFAULT) {
+ if (data.getHeightHint() == FX_DEFAULT) {
Node child = grid[i][j];
// TEMPORARY CODE
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
int currentWidth = 0;
for (int k = 0; k < hSpan; k++) {
currentWidth += widths[j - k];
}
- currentWidth += (hSpan - 1) * this.horizontalSpacing.get() - data.horizontalIndentProperty().get();
- if ((currentWidth != data.cacheWidth && data.horizontalAlignmentProperty().get() == Alignment.FILL) || (data.cacheWidth > currentWidth)) {
+ currentWidth += (hSpan - 1) * getHorizontalSpacing() - data.getHorizontalIndent();
+ if ((currentWidth != data.cacheWidth && data.getHorizontalAlignment() == Alignment.FILL) || (data.cacheWidth > currentWidth)) {
int trim = 0;
// FIXME
// if (child instanceof Scrollable) {
@@ -550,9 +585,9 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
// trim = child.getBorderWidth () * 2;
// }
data.cacheWidth = data.cacheHeight = FX_DEFAULT;
- data.computeSize(child, Math.max(0, currentWidth - trim), data.heightHintProperty().get(), false);
- if (data.grabExcessVerticalSpaceProperty().get() && data.minimumHeightProperty().get() > 0) {
- data.cacheHeight = Math.max(data.cacheHeight, data.minimumHeightProperty().get());
+ data.computeSize(child, Math.max(0, currentWidth - trim), data.getHeightHint(), false);
+ if (data.isGrabExcessVerticalSpace() && data.getMinimumHeight() > 0) {
+ data.cacheHeight = Math.max(data.cacheHeight, data.getMinimumHeight());
}
if (flush == null)
flush = new GridData[count];
@@ -565,7 +600,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
}
/* Row heights */
- double availableHeight = height - this.verticalSpacing.get() * (rowCount - 1) - (getInnerMarginTop() + getInnerMarginBottom());
+ double availableHeight = height - getVerticalSpacing() * (rowCount - 1) - (getInnerMarginTop() + getInnerMarginBottom());
expandCount = 0;
double[] heights = new double[rowCount];
double[] minHeights = new double[rowCount];
@@ -574,18 +609,18 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int j = 0; j < columnCount; j++) {
GridData data = getData(grid, i, j, rowCount, columnCount, true);
if (data != null) {
- int vSpan = Math.max(1, Math.min(data.verticalSpanProperty().get(), rowCount));
+ int vSpan = Math.max(1, Math.min(data.getVerticalSpan(), rowCount));
if (vSpan == 1) {
- double h = data.cacheHeight + data.verticalIndentProperty().get();
+ double h = data.cacheHeight + data.getVerticalIndent();
heights[i] = Math.max(heights[i], h);
- if (data.grabExcessVerticalSpaceProperty().get()) {
+ if (data.isGrabExcessVerticalSpace()) {
if (!expandRow[i])
expandCount++;
expandRow[i] = true;
}
- if (!data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() != 0) {
- h = !data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() == FX_DEFAULT ? data.cacheHeight : data.minimumHeightProperty().get();
- h += data.verticalIndentProperty().get();
+ if (!data.isGrabExcessVerticalSpace() || data.getMinimumHeight() != 0) {
+ h = !data.isGrabExcessVerticalSpace() || data.getMinimumHeight() == FX_DEFAULT ? data.cacheHeight : data.getMinimumHeight();
+ h += data.getVerticalIndent();
minHeights[i] = Math.max(minHeights[i], h);
}
}
@@ -594,7 +629,7 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int j = 0; j < columnCount; j++) {
GridData data = getData(grid, i, j, rowCount, columnCount, false);
if (data != null) {
- int vSpan = Math.max(1, Math.min(data.verticalSpanProperty().get(), rowCount));
+ int vSpan = Math.max(1, Math.min(data.getVerticalSpan(), rowCount));
if (vSpan > 1) {
int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0;
for (int k = 0; k < vSpan; k++) {
@@ -603,11 +638,11 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
if (expandRow[i - k])
spanExpandCount++;
}
- if (data.grabExcessVerticalSpaceProperty().get() && spanExpandCount == 0) {
+ if (data.isGrabExcessVerticalSpace() && spanExpandCount == 0) {
expandCount++;
expandRow[i] = true;
}
- double h = data.cacheHeight + data.verticalIndentProperty().get() - spanHeight - (vSpan - 1) * this.verticalSpacing.get();
+ double h = data.cacheHeight + data.getVerticalIndent() - spanHeight - (vSpan - 1) * getVerticalSpacing();
if (h > 0) {
if (spanExpandCount == 0) {
heights[i] += h;
@@ -624,9 +659,9 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
heights[last] += remainder;
}
}
- if (!data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() != 0) {
- h = !data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() == FX_DEFAULT ? data.cacheHeight : data.minimumHeightProperty().get();
- h += data.verticalIndentProperty().get() - spanMinHeight - (vSpan - 1) * this.verticalSpacing.get();
+ if (!data.isGrabExcessVerticalSpace() || data.getMinimumHeight() != 0) {
+ h = !data.isGrabExcessVerticalSpace() || data.getMinimumHeight() == FX_DEFAULT ? data.cacheHeight : data.getMinimumHeight();
+ h += data.getVerticalIndent() - spanMinHeight - (vSpan - 1) * getVerticalSpacing();
if (h > 0) {
if (spanExpandCount == 0) {
minHeights[i] += h;
@@ -676,17 +711,17 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int j = 0; j < columnCount; j++) {
GridData data = getData(grid, i, j, rowCount, columnCount, false);
if (data != null) {
- int vSpan = Math.max(1, Math.min(data.verticalSpanProperty().get(), rowCount));
+ int vSpan = Math.max(1, Math.min(data.getVerticalSpan(), rowCount));
if (vSpan > 1) {
- if (!data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() != 0) {
+ if (!data.isGrabExcessVerticalSpace() || data.getMinimumHeight() != 0) {
int spanHeight = 0, spanExpandCount = 0;
for (int k = 0; k < vSpan; k++) {
spanHeight += heights[i - k];
if (expandRow[i - k])
spanExpandCount++;
}
- double h = !data.grabExcessVerticalSpaceProperty().get() || data.minimumHeightProperty().get() == FX_DEFAULT ? data.cacheHeight : data.minimumHeightProperty().get();
- h += data.verticalIndentProperty().get() - spanHeight - (vSpan - 1) * this.verticalSpacing.get();
+ double h = !data.isGrabExcessVerticalSpace() || data.getMinimumHeight() == FX_DEFAULT ? data.cacheHeight : data.getMinimumHeight();
+ h += data.getVerticalIndent() - spanHeight - (vSpan - 1) * getVerticalSpacing();
if (h > 0) {
if (spanExpandCount == 0) {
heights[i] += h;
@@ -728,8 +763,8 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int j = 0; j < columnCount; j++) {
GridData data = getData(grid, i, j, rowCount, columnCount, true);
if (data != null) {
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
- int vSpan = Math.max(1, data.verticalSpanProperty().get());
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
+ int vSpan = Math.max(1, data.getVerticalSpan());
int cellWidth = 0, cellHeight = 0;
for (int k = 0; k < hSpan; k++) {
cellWidth += widths[j + k];
@@ -737,35 +772,35 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int k = 0; k < vSpan; k++) {
cellHeight += heights[i + k];
}
- cellWidth += this.horizontalSpacing.get() * (hSpan - 1);
- double childX = gridX + data.horizontalIndentProperty().get();
+ cellWidth += getHorizontalSpacing() * (hSpan - 1);
+ double childX = gridX + data.getHorizontalIndent();
double childWidth = Math.min(data.cacheWidth, cellWidth);
- switch (data.horizontalAlignmentProperty().get()) {
+ switch (data.getHorizontalAlignment()) {
case CENTER:
- childX += Math.max(0, (cellWidth - data.horizontalIndentProperty().get() - childWidth) / 2);
+ childX += Math.max(0, (cellWidth - data.getHorizontalIndent() - childWidth) / 2);
break;
case END:
- childX += Math.max(0, cellWidth - data.horizontalIndentProperty().get() - childWidth);
+ childX += Math.max(0, cellWidth - data.getHorizontalIndent() - childWidth);
break;
case FILL:
- childWidth = cellWidth - data.horizontalIndentProperty().get();
+ childWidth = cellWidth - data.getHorizontalIndent();
break;
case BEGINNING:
// Nothing todo
break;
}
- cellHeight += this.verticalSpacing.get() * (vSpan - 1);
- double childY = gridY + data.verticalIndentProperty().get();
+ cellHeight += getVerticalSpacing() * (vSpan - 1);
+ double childY = gridY + data.getVerticalIndent();
double childHeight = Math.min(data.cacheHeight, cellHeight);
- switch (data.verticalAlignmentProperty().get()) {
+ switch (data.getVerticalAlignment()) {
case CENTER:
- childY += Math.max(0, (cellHeight - data.verticalIndentProperty().get() - childHeight) / 2);
+ childY += Math.max(0, (cellHeight - data.getVerticalIndent() - childHeight) / 2);
break;
case END:
- childY += Math.max(0, cellHeight - data.verticalIndentProperty().get() - childHeight);
+ childY += Math.max(0, cellHeight - data.getVerticalIndent() - childHeight);
break;
case FILL:
- childHeight = cellHeight - data.verticalIndentProperty().get();
+ childHeight = cellHeight - data.getVerticalIndent();
break;
case BEGINNING:
// Nothing todo
@@ -776,9 +811,9 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
child.resizeRelocate(childX, childY, childWidth, childHeight);
}
}
- gridX += widths[j] + this.horizontalSpacing.get();
+ gridX += widths[j] + getHorizontalSpacing();
}
- gridY += heights[i] + this.verticalSpacing.get();
+ gridY += heights[i] + getVerticalSpacing();
}
}
@@ -797,25 +832,25 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
for (int i = 0; i < rowCount; i++) {
totalDefaultHeight += heights[i];
}
- totalDefaultWidth += this.horizontalSpacing.get() * (columnCount - 1) + getInnerMarginLeft() + getInnerMarginRight();
- totalDefaultHeight += this.verticalSpacing.get() * (rowCount - 1) + getInnerMarginTop() + getInnerMarginBottom();
+ totalDefaultWidth += getHorizontalSpacing() * (columnCount - 1) + getInnerMarginLeft() + getInnerMarginRight();
+ totalDefaultHeight += getVerticalSpacing() * (rowCount - 1) + getInnerMarginTop() + getInnerMarginBottom();
return new Size(totalDefaultWidth, totalDefaultHeight);
}
private int getInnerMarginLeft() {
- return (int) Math.ceil(this.marginWidth.get() + this.marginLeft.get() + getPadding().getLeft());
+ return (int) Math.ceil(getMarginWidth() + getMarginLeft() + getPadding().getLeft());
}
private int getInnerMarginRight() {
- return (int) Math.ceil(this.marginWidth.get() + this.marginRight.get() + getPadding().getRight());
+ return (int) Math.ceil(getMarginWidth() + getMarginRight() + getPadding().getRight());
}
private int getInnerMarginTop() {
- return (int) Math.ceil(this.marginHeight.get() + this.marginTop.get() + getPadding().getTop());
+ return (int) Math.ceil(getMarginHeight() + getMarginTop() + getPadding().getTop());
}
private int getInnerMarginBottom() {
- return (int) Math.ceil(this.marginHeight.get() + this.marginBottom.get() + getPadding().getBottom());
+ return (int) Math.ceil(getMarginHeight() + getMarginBottom() + getPadding().getBottom());
}
static GridData getData(Node[][] grid, int row, int column, int rowCount, int columnCount, boolean first) {
@@ -825,8 +860,8 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
if (data == null) {
data = new GridData();
}
- int hSpan = Math.max(1, Math.min(data.horizontalSpanProperty().get(), columnCount));
- int vSpan = Math.max(1, data.verticalSpanProperty().get());
+ int hSpan = Math.max(1, Math.min(data.getHorizontalSpan(), columnCount));
+ int vSpan = Math.max(1, data.getVerticalSpan());
int i = first ? row + vSpan - 1 : row - vSpan + 1;
int j = first ? column + hSpan - 1 : column - hSpan + 1;
if (0 <= i && i < rowCount) {
@@ -846,14 +881,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the columns
*/
public final void setNumColumns(int numColumns) {
- this.numColumns.set(numColumns);
+ numColumnsProperty().set(numColumns);
}
/**
* @return The number of columns
*/
public final int getNumColumns() {
- return this.numColumns.get();
+ return numColumnsProperty().get();
}
/**
@@ -870,14 +905,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* make all columns equal
*/
public final void setMakeColumnsEqualWidth(boolean makeColumnsEqualWidth) {
- this.makeColumnsEqualWidth.set(makeColumnsEqualWidth);
+ makeColumnsEqualWidthProperty().set(makeColumnsEqualWidth);
}
/**
* @return If <code>true</code> all columns have the same width
*/
public final boolean isMakeColumnsEqualWidth() {
- return this.makeColumnsEqualWidth.get();
+ return makeColumnsEqualWidthProperty().get();
}
/**
@@ -894,14 +929,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the spacing
*/
public final void setHorizontalSpacing(int value) {
- this.horizontalSpacing.set(value);
+ horizontalSpacingProperty().set(value);
}
/**
* @return Horizontal spacing between columns
*/
public final int getHorizontalSpacing() {
- return this.horizontalSpacing.get();
+ return horizontalSpacingProperty().get();
}
/**
@@ -918,14 +953,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the margin
*/
public final void setMarginWidth(int value) {
- this.marginWidth.set(value);
+ marginWidthProperty().set(value);
}
/**
* @return Margin on the left and right
*/
public final int getMarginWidth() {
- return this.marginWidth.get();
+ return marginWidthProperty().get();
}
/**
@@ -942,14 +977,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the margin
*/
public final void setMarginHeight(int value) {
- this.marginHeight.set(value);
+ marginHeightProperty().set(value);
}
/**
* @return Margin on the top and bottom
*/
public final int getMarginHeight() {
- return this.marginHeight.get();
+ return marginHeightProperty().get();
}
/**
@@ -966,14 +1001,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the left margin
*/
public final void setMarginLeft(int value) {
- this.marginLeft.set(value);
+ marginLeftProperty().set(value);
}
/**
* @return The margin on the left
*/
public final int getMarginLeft() {
- return this.marginLeft.get();
+ return marginLeftProperty().get();
}
/**
@@ -990,14 +1025,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the new margin
*/
public final void setMarginTop(int value) {
- this.marginTop.set(value);
+ marginTopProperty().set(value);
}
/**
* @return The margin on the top
*/
public final int getMarginTop() {
- return this.marginTop.get();
+ return marginTopProperty().get();
}
/**
@@ -1014,14 +1049,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the new margin
*/
public final void setMarginRight(int value) {
- this.marginRight.set(value);
+ marginRightProperty().set(value);
}
/**
* @return The margin on the right
*/
public final int getMarginRight() {
- return this.marginRight.get();
+ return marginRightProperty().get();
}
/**
@@ -1038,14 +1073,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the new margin
*/
public final void setMarginBottom(int value) {
- this.marginBottom.set(value);
+ marginBottomProperty().set(value);
}
/**
* @return The margin on the bottom
*/
public final int getMarginBottom() {
- return this.marginBottom.get();
+ return marginBottomProperty().get();
}
/**
@@ -1062,14 +1097,14 @@ public class GridLayoutPane extends AbstractLayoutPane<GridData> {
* the spacing
*/
public final void setVerticalSpacing(int value) {
- this.verticalSpacing.set(value);
+ verticalSpacingProperty().set(value);
}
/**
* @return The vertical spacing between rows
*/
public final int getVerticalSpacing() {
- return this.verticalSpacing.get();
+ return verticalSpacingProperty().get();
}
/**
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowData.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowData.java
index 6b7c52935..7e09991a3 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowData.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowData.java
@@ -16,40 +16,13 @@ import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import static org.eclipse.fx.ui.panes.AbstractLayoutPane.*;
+/**
+ * Row data constraint
+ */
public class RowData {
- /**
- * width specifies the desired width in pixels. This value is the wHint
- * passed into Control.computeSize(int, int, boolean) to determine the
- * preferred size of the control.
- *
- * The default value is SWT.DEFAULT.
- *
- * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
- */
- public IntegerProperty width = new SimpleIntegerProperty(this, "width", FX_DEFAULT);
- /**
- * height specifies the preferred height in pixels. This value is the hHint
- * passed into Control.computeSize(int, int, boolean) to determine the
- * preferred size of the control.
- *
- * The default value is SWT.DEFAULT.
- *
- * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
- */
- public IntegerProperty height = new SimpleIntegerProperty(this, "height", FX_DEFAULT);
-
- /**
- * exclude informs the layout to ignore this control when sizing and
- * positioning controls. If this value is <code>true</code>, the size and
- * position of the control will not be managed by the layout. If this value
- * is <code>false</code>, the size and position of the control will be
- * computed and assigned.
- *
- * The default value is <code>false</code>.
- *
- * @since 3.1
- */
- public BooleanProperty exclude = new SimpleBooleanProperty(this, "exclude", false);
+ private IntegerProperty width = new SimpleIntegerProperty(this, "width", FX_DEFAULT); //$NON-NLS-1$
+ private IntegerProperty height = new SimpleIntegerProperty(this, "height", FX_DEFAULT); //$NON-NLS-1$
+ private BooleanProperty exclude = new SimpleBooleanProperty(this, "exclude", false); //$NON-NLS-1$
/**
* Constructs a new instance of RowData using default values.
@@ -59,8 +32,8 @@ public class RowData {
/**
* Constructs a new instance of RowData according to the parameters. A value
- * of SWT.DEFAULT indicates that no minimum width or no minimum height is
- * specified.
+ * of {@link AbstractLayoutPane#FX_DEFAULT} indicates that no minimum width
+ * or no minimum height is specified.
*
* @param width
* a minimum width for the control
@@ -80,43 +53,77 @@ public class RowData {
return string.substring(index + 1, string.length());
}
- // ----
+ /**
+ * Exclude the element from layouting
+ *
+ * @param value
+ * <code>true</code> to exclude
+ */
public void setExclude(boolean value) {
- exclude.set(value);
+ excludeProperty().set(value);
}
+ /**
+ * @return <code>true</code> when excluded
+ */
public boolean isExclude() {
- return exclude.get();
+ return excludeProperty().get();
}
+ /**
+ * @return the exclude property
+ */
public BooleanProperty excludeProperty() {
- return exclude;
+ return this.exclude;
}
- // ----
+ /**
+ * Set the height to use
+ *
+ * @param value
+ * the new height or {@link AbstractLayoutPane#FX_DEFAULT} for
+ * the default
+ */
public void setHeight(int value) {
- height.set(value);
+ heightProperty().set(value);
}
+ /**
+ * @return the current height
+ */
public int getHeight() {
- return height.get();
+ return heightProperty().get();
}
+ /**
+ * @return the height property
+ */
public IntegerProperty heightProperty() {
- return height;
+ return this.height;
}
- // ----
+ /**
+ * Set a new width
+ *
+ * @param value
+ * the new width or {@link AbstractLayoutPane#FX_DEFAULT}
+ */
public void setWidth(int value) {
- width.set(value);
+ widthProperty().set(value);
}
+ /**
+ * @return the current width
+ */
public int getWidth() {
- return width.get();
+ return widthProperty().get();
}
+ /**
+ * @return the width property
+ */
public IntegerProperty widthProperty() {
- return width;
+ return this.width;
}
/**
@@ -125,16 +132,17 @@ public class RowData {
*
* @return a string representation of the RowData object
*/
+ @Override
public String toString() {
- String string = getName() + " {";
- if (width.get() != FX_DEFAULT)
- string += "width=" + width + " ";
- if (height.get() != FX_DEFAULT)
- string += "height=" + height + " ";
- if (exclude.get())
- string += "exclude=" + exclude + " ";
+ String string = getName() + " {"; //$NON-NLS-1$
+ if (getWidth() != FX_DEFAULT)
+ string += "width=" + getWidth() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (getHeight() != FX_DEFAULT)
+ string += "height=" + getHeight() + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ if (isExclude())
+ string += "exclude=" + isExclude() + " "; //$NON-NLS-1$ //$NON-NLS-2$
string = string.trim();
- string += "}";
+ string += "}"; //$NON-NLS-1$
return string;
}
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowLayoutPane.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowLayoutPane.java
index 8a7b14f32..46c31e2a1 100755
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowLayoutPane.java
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/RowLayoutPane.java
@@ -10,164 +10,313 @@
*******************************************************************************/
package org.eclipse.fx.ui.panes;
-import java.util.WeakHashMap;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleIntegerProperty;
-import javafx.beans.property.SimpleObjectProperty;
+import javafx.css.CssMetaData;
+import javafx.css.SimpleStyleableBooleanProperty;
+import javafx.css.SimpleStyleableIntegerProperty;
+import javafx.css.Styleable;
+import javafx.css.StyleableProperty;
import javafx.geometry.BoundingBox;
import javafx.geometry.Bounds;
import javafx.scene.Node;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+import com.sun.javafx.css.converters.BooleanConverter;
+import com.sun.javafx.css.converters.SizeConverter;
+
+/**
+ * Layout items from top to bottom or left to right
+ */
+@SuppressWarnings("restriction")
public class RowLayoutPane extends AbstractLayoutPane<RowData> {
- public enum Type {
- VERTICAL,
- HORIZONTAL
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_WIDTH = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-width", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginWidthProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginWidthProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_HEIGHT = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-height", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginHeightProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginHeightProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_LEFT = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-left", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginLeftProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginLeftProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_TOP = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-top", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginTopProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginTopProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_RIGHT = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-right", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginRightProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginRightProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> MARGIN_BOTTOM = new CssMetaData<RowLayoutPane, Number>("-fx-inner-margin-bottom", SizeConverter.getInstance(), Integer.valueOf(0)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.marginBottomProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.marginBottomProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Number> SPACING = new CssMetaData<RowLayoutPane, Number>("-fx-spacing", SizeConverter.getInstance(), Integer.valueOf(3)) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.spacingProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Number> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Number>) node.spacingProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> WRAP = new CssMetaData<RowLayoutPane, Boolean>("-fx-wrap", BooleanConverter.getInstance(), Boolean.TRUE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.wrapProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.wrapProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> PACK = new CssMetaData<RowLayoutPane, Boolean>("-fx-pack", BooleanConverter.getInstance(), Boolean.TRUE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.packProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.packProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> FILL = new CssMetaData<RowLayoutPane, Boolean>("-fx-fill", BooleanConverter.getInstance(), Boolean.FALSE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.fillProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.fillProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> CENTER = new CssMetaData<RowLayoutPane, Boolean>("-fx-center", BooleanConverter.getInstance(), Boolean.FALSE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.centerProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.centerProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> JUSTIFY = new CssMetaData<RowLayoutPane, Boolean>("-fx-justify", BooleanConverter.getInstance(), Boolean.FALSE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.justifyProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.justifyProperty();
+ }
+ };
+
+ private static final CssMetaData<RowLayoutPane, Boolean> HORIZONTAL = new CssMetaData<RowLayoutPane, Boolean>("-fx-horizontal", BooleanConverter.getInstance(), Boolean.FALSE) { //$NON-NLS-1$
+
+ @Override
+ public boolean isSettable(RowLayoutPane node) {
+ return !node.horizontalProperty().isBound();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public StyleableProperty<Boolean> getStyleableProperty(RowLayoutPane node) {
+ return (StyleableProperty<Boolean>) node.horizontalProperty();
+ }
+ };
+
+ private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
+
+ static {
+ @SuppressWarnings("static-access")
+ final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<CssMetaData<? extends Styleable, ?>>(AbstractLayoutPane.getClassCssMetaData());
+ styleables.add(CENTER);
+ styleables.add(FILL);
+ styleables.add(HORIZONTAL);
+ styleables.add(JUSTIFY);
+ styleables.add(MARGIN_BOTTOM);
+ styleables.add(MARGIN_HEIGHT);
+ styleables.add(MARGIN_LEFT);
+ styleables.add(MARGIN_RIGHT);
+ styleables.add(MARGIN_TOP);
+ styleables.add(PACK);
+ styleables.add(SPACING);
+ styleables.add(WRAP);
+
+ STYLEABLES = Collections.unmodifiableList(styleables);
+ }
+
+ public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
+ return STYLEABLES;
}
- /**
- * type specifies whether the layout places controls in rows or columns.
- *
- * The default value is HORIZONTAL.
- *
- * Possible values are:
- * <ul>
- * <li>HORIZONTAL: Position the controls horizontally from left to right</li>
- * <li>VERTICAL: Position the controls vertically from top to bottom</li>
- * </ul>
- *
- * @since 2.0
- */
- public ObjectProperty<Type> type = new SimpleObjectProperty<Type>(this, "type", Type.HORIZONTAL);
+ @Override
+ public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
+ return getClassCssMetaData();
+ }
- /**
- * marginWidth specifies the number of pixels of horizontal margin that will
- * be placed along the left and right edges of the layout.
- *
- * The default value is 0.
- *
- * @since 3.0
- */
- public IntegerProperty marginWidth = new SimpleIntegerProperty(this, "marginWidth", 0);
+ @NonNull
+ private final IntegerProperty marginWidth = new SimpleStyleableIntegerProperty(MARGIN_WIDTH, this, "marginWidth", Integer.valueOf(0)); //$NON-NLS-1$
+ @NonNull
+ private final IntegerProperty marginHeight = new SimpleStyleableIntegerProperty(MARGIN_HEIGHT, this, "marginHeight", Integer.valueOf(0)); //$NON-NLS-1$
- /**
- * marginHeight specifies the number of pixels of vertical margin that will
- * be placed along the top and bottom edges of the layout.
- *
- * The default value is 0.
- *
- * @since 3.0
- */
- public IntegerProperty marginHeight = new SimpleIntegerProperty(this, "marginHeight", 0);
+ @NonNull
+ private final IntegerProperty marginLeft = new SimpleStyleableIntegerProperty(MARGIN_LEFT, this, "marginLeft", Integer.valueOf(0)); //$NON-NLS-1$
+ @NonNull
+ private final IntegerProperty marginTop = new SimpleStyleableIntegerProperty(MARGIN_TOP, this, "marginTop", Integer.valueOf(0)); //$NON-NLS-1$
+ @NonNull
+ private final IntegerProperty marginRight = new SimpleStyleableIntegerProperty(MARGIN_RIGHT, this, "marginRight", Integer.valueOf(0)); //$NON-NLS-1$
+ @NonNull
+ private final IntegerProperty marginBottom = new SimpleStyleableIntegerProperty(MARGIN_BOTTOM, this, "marginBottom", Integer.valueOf(0)); //$NON-NLS-1$
- /**
- * spacing specifies the number of pixels between the edge of one cell and
- * the edge of its neighbouring cell.
- *
- * The default value is 3.
- */
- public IntegerProperty spacing = new SimpleIntegerProperty(this, "spacing", 3);
+ @NonNull
+ private IntegerProperty spacing = new SimpleStyleableIntegerProperty(SPACING, this, "spacing", Integer.valueOf(3)); //$NON-NLS-1$
- /**
- * wrap specifies whether a control will be wrapped to the next row if there
- * is insufficient space on the current row.
- *
- * The default value is true.
- */
- public BooleanProperty wrap = new SimpleBooleanProperty(this, "wrap", true);
+ @NonNull
+ private BooleanProperty wrap = new SimpleStyleableBooleanProperty(WRAP, this, "wrap", true); //$NON-NLS-1$
- /**
- * pack specifies whether all controls in the layout take their preferred
- * size. If pack is false, all controls will have the same size which is the
- * size required to accommodate the largest preferred height and the largest
- * preferred width of all the controls in the layout.
- *
- * The default value is true.
- */
- public BooleanProperty pack = new SimpleBooleanProperty(this, "pack", true);
+ @NonNull
+ private BooleanProperty pack = new SimpleStyleableBooleanProperty(PACK, this, "pack", true); //$NON-NLS-1$
- /**
- * fill specifies whether the controls in a row should be all the same
- * height for horizontal layouts, or the same width for vertical layouts.
- *
- * The default value is false.
- *
- * @since 3.0
- */
- public BooleanProperty fill = new SimpleBooleanProperty(this, "fill", false);
+ @NonNull
+ private BooleanProperty fill = new SimpleStyleableBooleanProperty(FILL, this, "fill", false); //$NON-NLS-1$
- /**
- * center specifies whether the controls in a row should be centered
- * vertically in each cell for horizontal layouts, or centered horizontally
- * in each cell for vertical layouts.
- *
- * The default value is false.
- *
- * @since 3.4
- */
- public BooleanProperty center = new SimpleBooleanProperty(this, "center", false);
+ @NonNull
+ private BooleanProperty center = new SimpleStyleableBooleanProperty(CENTER, this, "center", false); //$NON-NLS-1$
- /**
- * justify specifies whether the controls in a row should be fully
- * justified, with any extra space placed between the controls.
- *
- * The default value is false.
- */
- public BooleanProperty justify = new SimpleBooleanProperty(this, "justify", false);
+ @NonNull
+ private BooleanProperty justify = new SimpleStyleableBooleanProperty(JUSTIFY, this, "justify", false); //$NON-NLS-1$
- /**
- * marginLeft specifies the number of pixels of horizontal margin that will
- * be placed along the left edge of the layout.
- *
- * The default value is 3.
- */
- public IntegerProperty marginLeft = new SimpleIntegerProperty(this, "marginLeft", 3);
+ @NonNull
+ private BooleanProperty horizontal = new SimpleStyleableBooleanProperty(HORIZONTAL, this, "horizontal", true); //$NON-NLS-1$
- /**
- * marginTop specifies the number of pixels of vertical margin that will be
- * placed along the top edge of the layout.
- *
- * The default value is 3.
- */
- public IntegerProperty marginTop = new SimpleIntegerProperty(this, "marginTop", 3);
+ @NonNull
+ private static final String LAYOUT_KEY = "rowData"; //$NON-NLS-1$
/**
- * marginRight specifies the number of pixels of horizontal margin that will
- * be placed along the right edge of the layout.
+ * Associate a layout constraint with the node
*
- * The default value is 3.
+ * @param n
+ * the node
+ * @param griddata
+ * the constraint
*/
- public IntegerProperty marginRight = new SimpleIntegerProperty(this, "marginRight", 3);
+ public final static void setConstraint(@NonNull Node n, @NonNull RowData griddata) {
+ setConstraint(n, LAYOUT_KEY, griddata);
+ }
/**
- * marginBottom specifies the number of pixels of vertical margin that will
- * be placed along the bottom edge of the layout.
+ * Get the layout constraint for the node
*
- * The default value is 3.
+ * @param n
+ * the node
+ * @return the layout constraint or <code>null</code>
*/
- public IntegerProperty marginBottom = new SimpleIntegerProperty(this, "marginBottom", 3);
-
- private static WeakHashMap<Node, RowData> CONSTRAINTS = new WeakHashMap<Node, RowData>();
-
- public static void setConstraint(Node n, RowData griddata) {
- CONSTRAINTS.put(n, griddata);
- }
-
- public static RowData getConstraint(Node n) {
- return CONSTRAINTS.get(n);
+ public final static @Nullable RowData getConstraint(@NonNull Node n) {
+ return (RowData) getConstraint(n, LAYOUT_KEY);
}
-
+
@Override
protected org.eclipse.fx.ui.panes.AbstractLayoutPane.Size computeSize(double wHint, double hHint, boolean flushCache) {
Size extent;
- if (type.get() == Type.HORIZONTAL) {
- extent = layoutHorizontal(false, (wHint != FX_DEFAULT) && wrap.get(), wHint, flushCache);
+ if (isHorizontal()) {
+ extent = layoutHorizontal(false, (wHint != FX_DEFAULT) && isWrap(), wHint, flushCache);
} else {
- extent = layoutVertical(false, (hHint != FX_DEFAULT) && wrap.get(), hHint, flushCache);
+ extent = layoutVertical(false, (hHint != FX_DEFAULT) && isWrap(), hHint, flushCache);
}
double width = extent.width;
@@ -181,12 +330,12 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
return new Size(width, height);
}
- Size computeSize(Node control, boolean flushCache) {
+ private static Size computeSize(@NonNull Node control, boolean flushCache) {
int wHint = FX_DEFAULT, hHint = FX_DEFAULT;
- RowData data = (RowData) getConstraint(control);
+ RowData data = getConstraint(control);
if (data != null) {
- wHint = data.width.get();
- hHint = data.height.get();
+ wHint = data.getWidth();
+ hHint = data.getHeight();
}
return new Size(control.prefWidth(wHint), control.prefHeight(hHint));
}
@@ -195,28 +344,46 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
protected void layoutChildren() {
super.layoutChildren();
Bounds clientArea = getLayoutBounds();
- if (type.get() == Type.HORIZONTAL) {
- layoutHorizontal(true, wrap.get(), clientArea.getWidth(), true);
+ if (isHorizontal()) {
+ layoutHorizontal(true, isWrap(), clientArea.getWidth(), true);
} else {
- layoutVertical(true, wrap.get(), clientArea.getHeight(), true);
+ layoutVertical(true, isWrap(), clientArea.getHeight(), true);
}
}
+
+ private int getInnerMarginLeft() {
+ return (int) Math.ceil(getMarginWidth() + getMarginLeft() + getPadding().getLeft());
+ }
+
+ private int getInnerMarginRight() {
+ return (int) Math.ceil(getMarginWidth() + getMarginRight() + getPadding().getRight());
+ }
+
+ private int getInnerMarginTop() {
+ return (int) Math.ceil(getMarginHeight() + getMarginTop() + getPadding().getTop());
+ }
+
+ private int getInnerMarginBottom() {
+ return (int) Math.ceil(getMarginHeight() + getMarginBottom() + getPadding().getBottom());
+ }
Size layoutHorizontal(boolean move, boolean wrap, double width, boolean flushCache) {
+ @SuppressWarnings("null")
+ @NonNull
Node[] children = getChildren().toArray(new Node[0]);
int count = 0;
for (int i = 0; i < children.length; i++) {
Node control = children[i];
- RowData data = (RowData) getConstraint(control);
- if (data == null || !data.exclude.get()) {
+ RowData data = getConstraint(control);
+ if (data == null || !data.isExclude()) {
children[count++] = children[i];
}
}
if (count == 0) {
- return new Size(marginLeft.get() + marginWidth.get() * 2 + marginRight.get(), marginTop.get() + marginHeight.get() * 2 + marginBottom.get());
+ return new Size(getInnerMarginLeft() + getInnerMarginRight(), getInnerMarginTop() + getInnerMarginBottom());
}
double childWidth = 0, childHeight = 0, maxHeight = 0;
- if (!pack.get()) {
+ if (!isPack()) {
for (int i = 0; i < count; i++) {
Node child = children[i];
Size size = computeSize(child, flushCache);
@@ -234,91 +401,91 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
double[] wraps = null;
boolean wrapped = false;
Bounds[] bounds = null;
- if (move && (justify.get() || fill.get() || center.get())) {
+ if (move && (isJustify() || isFill() || isCenter())) {
bounds = new Bounds[count];
wraps = new double[count];
}
- double maxX = 0, x = marginLeft.get() + marginWidth.get(), y = marginTop.get() + marginHeight.get();
+ double maxX = 0, x = getInnerMarginLeft(), y = getInnerMarginTop();
for (int i = 0; i < count; i++) {
Node child = children[i];
- if (pack.get()) {
+ if (isPack()) {
Size size = computeSize(child, flushCache);
childWidth = size.width;
childHeight = size.height;
}
if (wrap && (i != 0) && (x + childWidth > width)) {
wrapped = true;
- if (move && (justify.get() || fill.get() || center.get())) {
- if( wraps != null ) {
- wraps[i - 1] = maxHeight;
+ if (move && (isJustify() || isFill() || isCenter())) {
+ if (wraps != null) {
+ wraps[i - 1] = maxHeight;
}
}
-
- x = marginLeft.get() + marginWidth.get();
- y += spacing.get() + maxHeight;
- if (pack.get())
+
+ x = getInnerMarginLeft();
+ y += getSpacing() + maxHeight;
+ if (isPack())
maxHeight = 0;
}
- if (pack.get() || fill.get() || center.get()) {
+ if (isPack() || isFill() || isCenter()) {
maxHeight = Math.max(maxHeight, childHeight);
}
if (move) {
double childX = x + clientX, childY = y + clientY;
- if (justify.get() || fill.get() || center.get()) {
- if( bounds != null ) {
- bounds[i] = new BoundingBox(childX, childY, childWidth, childHeight);
+ if (isJustify() || isFill() || isCenter()) {
+ if (bounds != null) {
+ bounds[i] = new BoundingBox(childX, childY, childWidth, childHeight);
}
} else {
child.resizeRelocate(childX, childY, childWidth, childHeight);
}
}
- x += spacing.get() + childWidth;
+ x += getSpacing() + childWidth;
maxX = Math.max(maxX, x);
}
- maxX = Math.max(clientX + marginLeft.get() + marginWidth.get(), maxX - spacing.get());
+ maxX = Math.max(clientX + getInnerMarginLeft(), maxX - getSpacing());
if (!wrapped)
- maxX += marginRight.get() + marginWidth.get();
- if (move && (justify.get() || fill.get() || center.get())) {
+ maxX += getInnerMarginRight();
+ if (move && (isJustify() || isFill() || isCenter())) {
double space = 0, margin = 0;
if (!wrapped) {
space = Math.max(0, (width - maxX) / (count + 1));
margin = Math.max(0, ((width - maxX) % (count + 1)) / 2);
} else {
- if (fill.get() || justify.get() || center.get()) {
+ if (isFill() || isJustify() || isCenter()) {
int last = 0;
if (count > 0) {
- if( wraps != null ) {
- wraps[count - 1] = maxHeight;
+ if (wraps != null) {
+ wraps[count - 1] = maxHeight;
}
}
-
+
for (int i = 0; i < count; i++) {
- if ( wraps != null && wraps[i] != 0) {
+ if (wraps != null && wraps[i] != 0) {
int wrapCount = i - last + 1;
- if (justify.get()) {
+ if (isJustify()) {
int wrapX = 0;
for (int j = last; j <= i; j++) {
- if( bounds != null ) {
- wrapX += bounds[j].getWidth() + spacing.get();
+ if (bounds != null) {
+ wrapX += bounds[j].getWidth() + getSpacing();
}
}
space = Math.max(0, (width - wrapX) / (wrapCount + 1));
margin = Math.max(0, ((width - wrapX) % (wrapCount + 1)) / 2);
}
for (int j = last; j <= i; j++) {
- if (justify.get()) {
- if( bounds != null ) {
- bounds[j] = changeX(bounds[j], (space * (j - last + 1)) + margin);
+ if (isJustify()) {
+ if (bounds != null) {
+ bounds[j] = changeX(bounds[j], (space * (j - last + 1)) + margin);
}
}
- if (fill.get()) {
- if( bounds != null ) {
- bounds[j] = changeHeight(bounds[j], wraps[i]);
+ if (isFill()) {
+ if (bounds != null) {
+ bounds[j] = changeHeight(bounds[j], wraps[i]);
}
} else {
- if (center.get()) {
- if( bounds != null ) {
- bounds[j] = changeY(bounds[j], Math.max(0, (wraps[i] - bounds[j].getHeight()) / 2));
+ if (isCenter()) {
+ if (bounds != null) {
+ bounds[j] = changeY(bounds[j], Math.max(0, (wraps[i] - bounds[j].getHeight()) / 2));
}
}
}
@@ -330,46 +497,48 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
}
for (int i = 0; i < count; i++) {
if (!wrapped) {
- if (justify.get()) {
- if( bounds != null ) {
- bounds[i] = changeX(bounds[i], (space * (i + 1)) + margin);
+ if (isJustify()) {
+ if (bounds != null) {
+ bounds[i] = changeX(bounds[i], (space * (i + 1)) + margin);
}
}
- if (fill.get()) {
- if( bounds != null ) {
- bounds[i] = changeHeight(bounds[i], maxHeight);
+ if (isFill()) {
+ if (bounds != null) {
+ bounds[i] = changeHeight(bounds[i], maxHeight);
}
} else {
- if (center.get()) {
- if( bounds != null ) {
- bounds[i] = changeY(bounds[i], Math.max(0, (maxHeight - bounds[i].getHeight()) / 2));
+ if (isCenter()) {
+ if (bounds != null) {
+ bounds[i] = changeY(bounds[i], Math.max(0, (maxHeight - bounds[i].getHeight()) / 2));
}
}
}
}
- if( bounds != null ) {
- children[i].resizeRelocate(bounds[i].getMinX(), bounds[i].getMinY(), bounds[i].getWidth(), bounds[i].getHeight());
+ if (bounds != null) {
+ children[i].resizeRelocate(bounds[i].getMinX(), bounds[i].getMinY(), bounds[i].getWidth(), bounds[i].getHeight());
}
}
}
- return new Size(maxX, y + maxHeight + marginBottom.get() + marginHeight.get());
+ return new Size(maxX, y + maxHeight + getInnerMarginBottom());
}
Size layoutVertical(boolean move, boolean wrap, double height, boolean flushCache) {
+ @SuppressWarnings("null")
+ @NonNull
Node[] children = getChildren().toArray(new Node[0]);
int count = 0;
for (int i = 0; i < children.length; i++) {
Node control = children[i];
- RowData data = (RowData) getConstraint(control);
- if (data == null || !data.exclude.get()) {
+ RowData data = getConstraint(control);
+ if (data == null || !data.isExclude()) {
children[count++] = children[i];
}
}
if (count == 0) {
- return new Size(marginLeft.get() + marginWidth.get() * 2 + marginRight.get(), marginTop.get() + marginHeight.get() * 2 + marginBottom.get());
+ return new Size(getInnerMarginLeft() + getInnerMarginRight(), getInnerMarginTop() + getInnerMarginBottom());
}
double childWidth = 0, childHeight = 0, maxWidth = 0;
- if (!pack.get()) {
+ if (!isPack()) {
for (int i = 0; i < count; i++) {
Node child = children[i];
Size size = computeSize(child, flushCache);
@@ -387,90 +556,90 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
double[] wraps = null;
boolean wrapped = false;
Bounds[] bounds = null;
- if (move && (justify.get() || fill.get() || center.get())) {
+ if (move && (isJustify() || isFill() || isCenter())) {
bounds = new Bounds[count];
wraps = new double[count];
}
- double maxY = 0, x = marginLeft.get() + marginWidth.get(), y = marginTop.get() + marginHeight.get();
+ double maxY = 0, x = getInnerMarginLeft(), y = getInnerMarginBottom();
for (int i = 0; i < count; i++) {
Node child = children[i];
- if (pack.get()) {
+ if (isPack()) {
Size size = computeSize(child, flushCache);
childWidth = size.width;
childHeight = size.height;
}
if (wrap && (i != 0) && (y + childHeight > height)) {
wrapped = true;
- if (move && (justify.get() || fill.get() || center.get())) {
- if( wraps != null ) {
- wraps[i - 1] = maxWidth;
+ if (move && (isJustify() || isFill() || isCenter())) {
+ if (wraps != null) {
+ wraps[i - 1] = maxWidth;
}
}
-
- x += spacing.get() + maxWidth;
- y = marginTop.get() + marginHeight.get();
- if (pack.get())
+
+ x += getSpacing() + maxWidth;
+ y = getInnerMarginTop();
+ if (isPack())
maxWidth = 0;
}
- if (pack.get() || fill.get() || center.get()) {
+ if (isPack() || isFill() || isCenter()) {
maxWidth = Math.max(maxWidth, childWidth);
}
if (move) {
double childX = x + clientX, childY = y + clientY;
- if (justify.get() || fill.get() || center.get()) {
- if( bounds != null ) {
- bounds[i] = new BoundingBox(childX, childY, childWidth, childHeight);
+ if (isJustify() || isFill() || isCenter()) {
+ if (bounds != null) {
+ bounds[i] = new BoundingBox(childX, childY, childWidth, childHeight);
}
} else {
child.resizeRelocate(childX, childY, childWidth, childHeight);
}
}
- y += spacing.get() + childHeight;
+ y += getSpacing() + childHeight;
maxY = Math.max(maxY, y);
}
- maxY = Math.max(clientY + marginTop.get() + marginHeight.get(), maxY - spacing.get());
+ maxY = Math.max(clientY + getInnerMarginTop(), maxY - getSpacing());
if (!wrapped)
- maxY += marginBottom.get() + marginHeight.get();
- if (move && (justify.get() || fill.get() || center.get())) {
+ maxY += getInnerMarginBottom();
+ if (move && (isJustify() || isFill() || isCenter())) {
double space = 0, margin = 0;
if (!wrapped) {
space = Math.max(0, (height - maxY) / (count + 1));
margin = Math.max(0, ((height - maxY) % (count + 1)) / 2);
} else {
- if (fill.get() || justify.get() || center.get()) {
+ if (isFill() || isJustify() || isCenter()) {
int last = 0;
if (count > 0) {
- if( wraps != null ) {
- wraps[count - 1] = maxWidth;
+ if (wraps != null) {
+ wraps[count - 1] = maxWidth;
}
}
for (int i = 0; i < count; i++) {
if (wraps != null && wraps[i] != 0) {
int wrapCount = i - last + 1;
- if (justify.get()) {
+ if (isJustify()) {
int wrapY = 0;
for (int j = last; j <= i; j++) {
- if( bounds != null ) {
- wrapY += bounds[j].getHeight() + spacing.get();
+ if (bounds != null) {
+ wrapY += bounds[j].getHeight() + getSpacing();
}
}
space = Math.max(0, (height - wrapY) / (wrapCount + 1));
margin = Math.max(0, ((height - wrapY) % (wrapCount + 1)) / 2);
}
for (int j = last; j <= i; j++) {
- if (justify.get()) {
- if( bounds != null ) {
- bounds[j] = changeY(bounds[j], (space * (j - last + 1)) + margin);
+ if (isJustify()) {
+ if (bounds != null) {
+ bounds[j] = changeY(bounds[j], (space * (j - last + 1)) + margin);
}
}
- if (fill.get()) {
- if( bounds != null ) {
- bounds[j] = changeWidth(bounds[j], wraps[i]);
+ if (isFill()) {
+ if (bounds != null) {
+ bounds[j] = changeWidth(bounds[j], wraps[i]);
}
} else {
- if (center.get()) {
- if( bounds != null ) {
- bounds[j] = changeX(bounds[j], Math.max(0, (wraps[i] - bounds[j].getWidth()) / 2));
+ if (isCenter()) {
+ if (bounds != null) {
+ bounds[j] = changeX(bounds[j], Math.max(0, (wraps[i] - bounds[j].getWidth()) / 2));
}
}
}
@@ -482,30 +651,30 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
}
for (int i = 0; i < count; i++) {
if (!wrapped) {
- if (justify.get()) {
- if( bounds != null ) {
- bounds[i] = changeY(bounds[i], (space * (i + 1)) + margin);
+ if (isJustify()) {
+ if (bounds != null) {
+ bounds[i] = changeY(bounds[i], (space * (i + 1)) + margin);
}
}
- if (fill.get()) {
- if( bounds != null ) {
- bounds[i] = changeWidth(bounds[i], maxWidth);
+ if (isFill()) {
+ if (bounds != null) {
+ bounds[i] = changeWidth(bounds[i], maxWidth);
}
} else {
- if (center.get()) {
- if( bounds != null ) {
- bounds[i] = changeX(bounds[i], Math.max(0, (maxWidth - bounds[i].getWidth()) / 2));
+ if (isCenter()) {
+ if (bounds != null) {
+ bounds[i] = changeX(bounds[i], Math.max(0, (maxWidth - bounds[i].getWidth()) / 2));
}
}
}
}
- if( bounds != null ) {
- children[i].resizeRelocate(bounds[i].getMinX(), bounds[i].getMinY(), bounds[i].getWidth(), bounds[i].getHeight());
+ if (bounds != null) {
+ children[i].resizeRelocate(bounds[i].getMinX(), bounds[i].getMinY(), bounds[i].getWidth(), bounds[i].getHeight());
}
}
}
- return new Size(x + maxWidth + marginRight.get() + marginWidth.get(), maxY);
+ return new Size(x + maxWidth + getInnerMarginRight(), maxY);
}
private static Bounds changeX(Bounds original, double amount) {
@@ -524,172 +693,540 @@ public class RowLayoutPane extends AbstractLayoutPane<RowData> {
return new BoundingBox(original.getMinX(), original.getMinY(), original.getWidth() + amount, original.getHeight());
}
- // ----
- public void setCenterHint(boolean value) {
- center.set(value);
+ /**
+ * center specifies whether the controls in a row should be centered
+ * vertically in each cell for horizontal layouts, or centered horizontally
+ * in each cell for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
+ public void setCenter(boolean value) {
+ centerProperty().set(value);
}
- public boolean isCenterHint() {
- return center.get();
+ /**
+ * center specifies whether the controls in a row should be centered
+ * vertically in each cell for horizontal layouts, or centered horizontally
+ * in each cell for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the current value
+ */
+ public boolean isCenter() {
+ return centerProperty().get();
}
- public BooleanProperty centerProperty() {
- return center;
+ /**
+ * center specifies whether the controls in a row should be centered
+ * vertically in each cell for horizontal layouts, or centered horizontally
+ * in each cell for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty centerProperty() {
+ return this.center;
}
-
- // ----
+
+ /**
+ * fill specifies whether the controls in a row should be all the same
+ * height for horizontal layouts, or the same width for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setFill(boolean value) {
- fill.set(value);
+ fillProperty().set(value);
}
+ /**
+ * fill specifies whether the controls in a row should be all the same
+ * height for horizontal layouts, or the same width for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the current value
+ */
public boolean isFill() {
- return fill.get();
+ return fillProperty().get();
}
- public BooleanProperty fillProperty() {
- return fill;
+ /**
+ * fill specifies whether the controls in a row should be all the same
+ * height for horizontal layouts, or the same width for vertical layouts.
+ *
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty fillProperty() {
+ return this.fill;
}
-
- // ----
+
+ /**
+ * justify specifies whether the controls in a row should be fully
+ * justified, with any extra space placed between the controls.
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setJustify(boolean value) {
- justify.set(value);
+ justifyProperty().set(value);
}
+ /**
+ * justify specifies whether the controls in a row should be fully
+ * justified, with any extra space placed between the controls.
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the current value
+ */
public boolean isJustify() {
- return justify.get();
+ return justifyProperty().get();
}
- public BooleanProperty justifyProperty() {
- return justify;
+ /**
+ * justify specifies whether the controls in a row should be fully
+ * justified, with any extra space placed between the controls.
+ * <p>
+ * The default is <code>false</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty justifyProperty() {
+ return this.justify;
}
-
- // ----
+
+ /**
+ * marginBottom specifies the number of pixels of vertical margin that will
+ * be placed along the bottom edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ */
public void setMarginBottom(int value) {
- marginBottom.set(value);
+ marginBottomProperty().set(value);
}
+ /**
+ * marginBottom specifies the number of pixels of vertical margin that will
+ * be placed along the bottom edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginBottom() {
- return marginBottom.get();
+ return marginBottomProperty().get();
}
- public IntegerProperty marginBottomProperty() {
- return marginBottom;
+ /**
+ * marginBottom specifies the number of pixels of vertical margin that will
+ * be placed along the bottom edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginBottomProperty() {
+ return this.marginBottom;
}
-
- // ----
+
+ /**
+ * marginHeight specifies the number of pixels of vertical margin that will
+ * be placed along the top and bottom edges of the layout.
+ *
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setMarginHeight(int value) {
- marginHeight.set(value);
+ marginHeightProperty().set(value);
}
+ /**
+ * marginHeight specifies the number of pixels of vertical margin that will
+ * be placed along the top and bottom edges of the layout.
+ *
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginHeight() {
- return marginHeight.get();
+ return marginHeightProperty().get();
}
- public IntegerProperty marginHeightProperty() {
- return marginHeight;
+ /**
+ * marginHeight specifies the number of pixels of vertical margin that will
+ * be placed along the top and bottom edges of the layout.
+ *
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginHeightProperty() {
+ return this.marginHeight;
}
-
- // ----
+
+ /**
+ * marginLeft specifies the number of pixels of horizontal margin that will
+ * be placed along the left edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setMarginLeft(int value) {
- marginLeft.set(value);
+ marginLeftProperty().set(value);
}
+ /**
+ * marginLeft specifies the number of pixels of horizontal margin that will
+ * be placed along the left edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginLeft() {
- return marginLeft.get();
+ return marginLeftProperty().get();
}
- public IntegerProperty marginLeftProperty() {
- return marginLeft;
+ /**
+ * marginLeft specifies the number of pixels of horizontal margin that will
+ * be placed along the left edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginLeftProperty() {
+ return this.marginLeft;
}
-
- // ----
+
+ /**
+ * marginRight specifies the number of pixels of horizontal margin that will
+ * be placed along the right edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setMarginRight(int value) {
- marginRight.set(value);
+ marginRightProperty().set(value);
}
+ /**
+ * marginRight specifies the number of pixels of horizontal margin that will
+ * be placed along the right edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginRight() {
- return marginRight.get();
+ return marginRightProperty().get();
}
- public IntegerProperty marginRightProperty() {
- return marginRight;
+ /**
+ * marginRight specifies the number of pixels of horizontal margin that will
+ * be placed along the right edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginRightProperty() {
+ return this.marginRight;
}
-
- // ----
+
+ /**
+ * marginTop specifies the number of pixels of vertical margin that will be
+ * placed along the top edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setMarginTop(int value) {
- marginTop.set(value);
+ marginTopProperty().set(value);
}
+ /**
+ * marginTop specifies the number of pixels of vertical margin that will be
+ * placed along the top edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginTop() {
- return marginTop.get();
+ return marginTopProperty().get();
}
- public IntegerProperty marginTopProperty() {
- return marginTop;
+ /**
+ * marginTop specifies the number of pixels of vertical margin that will be
+ * placed along the top edge of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginTopProperty() {
+ return this.marginTop;
}
-
- // ----
+
+ /**
+ * marginWidth specifies the number of pixels of horizontal margin that will
+ * be placed along the left and right edges of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setMarginWidth(int value) {
- marginWidth.set(value);
+ this.marginWidth.set(value);
}
+ /**
+ * marginWidth specifies the number of pixels of horizontal margin that will
+ * be placed along the left and right edges of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the current value
+ */
public int getMarginWidth() {
- return marginWidth.get();
+ return marginWidthProperty().get();
}
- public IntegerProperty marginWidthProperty() {
- return marginWidth;
+ /**
+ * marginWidth specifies the number of pixels of horizontal margin that will
+ * be placed along the left and right edges of the layout.
+ * <p>
+ * The default is 0
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty marginWidthProperty() {
+ return this.marginWidth;
}
-
- // ----
+
+ /**
+ * pack specifies whether all controls in the layout take their preferred
+ * size. If pack is false, all controls will have the same size which is the
+ * size required to accommodate the largest preferred height and the largest
+ * preferred width of all the controls in the layout.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setPack(boolean value) {
- pack.set(value);
+ packProperty().set(value);
}
+ /**
+ * pack specifies whether all controls in the layout take their preferred
+ * size. If pack is false, all controls will have the same size which is the
+ * size required to accommodate the largest preferred height and the largest
+ * preferred width of all the controls in the layout.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the current value
+ */
public boolean isPack() {
- return pack.get();
+ return packProperty().get();
}
- public BooleanProperty packProperty() {
- return pack;
+ /**
+ * pack specifies whether all controls in the layout take their preferred
+ * size. If pack is false, all controls will have the same size which is the
+ * size required to accommodate the largest preferred height and the largest
+ * preferred width of all the controls in the layout.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty packProperty() {
+ return this.pack;
}
- // ----
+ /**
+ * spacing specifies the number of pixels between the edge of one cell and
+ * the edge of its neighboring cell.
+ *
+ * <p>
+ * The default is 3
+ * </p>
+ *
+ * @param value
+ * the spacing
+ */
public void setSpacing(int value) {
- spacing.set(value);
+ spacingProperty().set(value);
}
+ /**
+ * spacing specifies the number of pixels between the edge of one cell and
+ * the edge of its neighboring cell.
+ *
+ * <p>
+ * The default is 3
+ * </p>
+ *
+ * @return the current value
+ */
public int getSpacing() {
- return spacing.get();
+ return spacingProperty().get();
}
- public IntegerProperty spacingProperty() {
- return spacing;
+ /**
+ * spacing specifies the number of pixels between the edge of one cell and
+ * the edge of its neighboring cell.
+ *
+ * <p>
+ * The default is 3
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull IntegerProperty spacingProperty() {
+ return this.spacing;
}
- // ----
+ /**
+ * wrap specifies whether a control will be wrapped to the next row if there
+ * is insufficient space on the current row.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
public void setWrap(boolean value) {
- wrap.set(value);
+ wrapProperty().set(value);
}
+ /**
+ * wrap specifies whether a control will be wrapped to the next row if there
+ * is insufficient space on the current row.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the current value
+ */
public boolean isWrap() {
- return wrap.get();
+ return wrapProperty().get();
}
- public BooleanProperty wrapProperty() {
- return wrap;
+ /**
+ * wrap specifies whether a control will be wrapped to the next row if there
+ * is insufficient space on the current row.
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty wrapProperty() {
+ return this.wrap;
}
- // ----
- public void setType(Type value) {
- type.set(value);
+ /**
+ * horizontal specifies if controls are layouted horizontally or vertically
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @param value
+ * the new value
+ */
+ public void setHorizontal(boolean value) {
+ horizontalProperty().set(value);
}
- public Type getType() {
- return type.get();
+ /**
+ * horizontal specifies if controls are layouted horizontally or vertically
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the current value
+ */
+ public boolean isHorizontal() {
+ return horizontalProperty().get();
}
- public ObjectProperty<Type> typeProperty() {
- return type;
+ /**
+ * horizontal specifies if controls are layouted horizontally or vertically
+ * <p>
+ * The default is <code>true</code>
+ * </p>
+ *
+ * @return the property
+ */
+ public @NonNull BooleanProperty horizontalProperty() {
+ return this.horizontal;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/SashLayoutPane.java b/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/SashLayoutPane.java
deleted file mode 100755
index efa260387..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.panes/src/org/eclipse/fx/ui/panes/SashLayoutPane.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * Tom Schindl<tom.schindl@bestsolution.at> - ported to JavaFX
- *******************************************************************************/
-package org.eclipse.fx.ui.panes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javafx.beans.property.SimpleIntegerProperty;
-import javafx.beans.value.WritableIntegerValue;
-import javafx.event.EventHandler;
-import javafx.geometry.BoundingBox;
-import javafx.geometry.Bounds;
-import javafx.scene.Cursor;
-import javafx.scene.Node;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.layout.Pane;
-
-public class SashLayoutPane extends Pane {
- class SashRect {
- Bounds rect;
- MGenericTile container;
- MUIElement left;
- MUIElement right;
-
- public SashRect(Bounds rect, MGenericTile container,
- MUIElement left, MUIElement right) {
- this.container = container;
- this.rect = rect;
- this.left = left;
- this.right = right;
- }
- }
-
- public abstract static class MUIElement {
- Double weight;
- Object widget;
- boolean visible = true;
-
- public boolean isVisible() {
- return visible;
- }
-
- public void setWeight(Double weight) {
- this.weight = weight;
- }
- }
-
- public static class MGenericTile extends MUIElement {
- boolean horizontal;
- List<MUIElement> children = new ArrayList<MUIElement>();
-
- public MGenericTile() {
-
- }
-
- public void setHorizontal(boolean horizontal) {
- this.horizontal = horizontal;
- }
-
- public void add(MUIElement element) {
- children.add(element);
- }
- }
-
- public static class MUIControl extends MUIElement {
- public MUIControl() {
-
- }
- }
-
- private WritableIntegerValue minSashPercent = new SimpleIntegerProperty(this, "minSashPercent", 10);
-
- private WritableIntegerValue marginLeft = new SimpleIntegerProperty(this, "marginLeft", 0);
- private WritableIntegerValue marginRight = new SimpleIntegerProperty(this, "marginRight", 0);
- private WritableIntegerValue marginTop = new SimpleIntegerProperty(this, "marginTop", 0);
- private WritableIntegerValue marginBottom = new SimpleIntegerProperty(this, "marginBottom", 0);
- private WritableIntegerValue sashWidth = new SimpleIntegerProperty(this, "sashWidth", 4);
-
- private MGenericTile root;
- private List<SashRect> sashes = new ArrayList<SashRect>();
- private boolean draggingSashes = false;
- List<SashRect> sashesToDrag;
-
- public SashLayoutPane() {
- this.root = new MGenericTile();
- this.root.widget = this;
-
- onMouseMovedProperty().set(new EventHandler<MouseEvent>() {
-
- @Override
- public void handle(MouseEvent event) {
- if (!draggingSashes) {
- // Set the cursor feedback
- List<SashRect> sashList = getSashRects(event.getX(), event.getY());
- if (sashList.size() == 0) {
- setCursor(Cursor.DEFAULT);
- } else if (sashList.size() == 1) {
- if (sashList.get(0).container.horizontal) {
- setCursor(Cursor.W_RESIZE);
- } else {
- setCursor(Cursor.S_RESIZE);
- }
- } else {
- setCursor(Cursor.CROSSHAIR);
- }
- }
- }
- });
-
- onMouseDraggedProperty().set(new EventHandler<MouseEvent>() {
-
- @Override
- public void handle(MouseEvent event) {
- if (draggingSashes) {
- adjustWeights(sashesToDrag, event.getX(), event.getY());
- requestLayout();
- }
- }
- });
-
- onMouseReleasedProperty().set(new EventHandler<MouseEvent>() {
-
- @Override
- public void handle(MouseEvent event) {
- draggingSashes = false;
- }
- });
-
- onMousePressedProperty().set(new EventHandler<MouseEvent>() {
-
- @Override
- public void handle(MouseEvent event) {
- sashesToDrag = getSashRects(event.getX(), event.getY());
- if (sashesToDrag.size() > 0) {
- draggingSashes = true;
- }
- }
- });
-
-// onMouseMovedProperty().addListener(new ChangeListener<EventHandler<MouseEvent>>() {
-//
-// @Override
-// public void changed(
-// ObservableValue<? extends EventHandler<MouseEvent>> observable,
-// EventHandler<MouseEvent> oldValue,
-// EventHandler<MouseEvent> newValue) {
-// newValue.
-// }
-// });
-
-// host.addMouseListener(new MouseListener() {
-// public void mouseUp(MouseEvent e) {
-// host.setCapture(false);
-// draggingSashes = false;
-// }
-//
-// public void mouseDown(MouseEvent e) {
-// if (e.button != 1)
-// return;
-//
-// sashesToDrag = getSashRects(e.x, e.y);
-// if (sashesToDrag.size() > 0) {
-// draggingSashes = true;
-// host.setCapture(true);
-// }
-// }
-//
-// public void mouseDoubleClick(MouseEvent e) {
-// }
-// });
-
- }
-
- public void setMarginLeft(int marginLeft) {
- this.marginLeft.set(marginLeft);
- }
-
- public int getMarginLeft() {
- return this.marginLeft.get();
- }
-
- public void setMarginRight(int marginRight) {
- this.marginRight.set(marginRight);
- }
-
- public int getMarginRight() {
- return this.marginRight.get();
- }
-
- public void setMarginTop(int marginTop) {
- this.marginTop.set(marginTop);
- }
-
- public int getMarginTop() {
- return this.marginTop.get();
- }
-
- public void setMarginBottom(int marginBottom) {
- this.marginBottom.set(marginBottom);
- }
-
- public int getMarginBottom() {
- return this.marginBottom.get();
- }
-
- public void setSashWidth(int sashWidth) {
- this.sashWidth.set(sashWidth);
- }
-
- public int getSashWidth() {
- return this.sashWidth.get();
- }
-
- protected List<SashRect> getSashRects(double x, double y) {
- List<SashRect> srs = new ArrayList<SashRect>();
- boolean inSash = false;
- for (SashRect sr : sashes) {
- if (sr.rect.contains(x, y))
- inSash = true;
- }
- if (!inSash)
- return srs;
-
- BoundingBox target = new BoundingBox(x - 5, y - 5, 10, 10);
- for (SashRect sr : sashes) {
- if (sr.rect.intersects(target))
- srs.add(sr);
- }
- return srs;
- }
-
- protected void adjustWeights(List<SashRect> sashes, double curX, double curY) {
- for (SashRect sr : sashes) {
- double totalWeight = getWeight(sr.left) + getWeight(sr.right);
- double minSashValue = (((totalWeight / 100.0) * minSashPercent.get()) + 0.5);
-
- Bounds leftRect = getRectangle(sr.left);
- Bounds rightRect = getRectangle(sr.right);
- if (leftRect == null || rightRect == null)
- continue;
-
- double leftWeight;
- double rightWeight;
-
- if (sr.container.horizontal) {
- double left = leftRect.getMinX();
- double right = rightRect.getMinX() + rightRect.getWidth();
- double pct = (curX - left) / (right - left);
- leftWeight = ((totalWeight * pct) + 0.5);
- if (leftWeight < minSashValue)
- leftWeight = minSashValue;
- if (leftWeight > (totalWeight - minSashValue))
- leftWeight = totalWeight - minSashValue;
- rightWeight = totalWeight - leftWeight;
- } else {
- double top = leftRect.getMinY();
- double bottom = rightRect.getMinY() + rightRect.getHeight();
- double pct = (curY - top) / (bottom - top);
- leftWeight = (int)((totalWeight * pct) + 0.5);
-
- if (leftWeight < minSashValue)
- leftWeight = minSashValue;
-
- if (leftWeight > (totalWeight - minSashValue))
- leftWeight = totalWeight - minSashValue;
-
- rightWeight = totalWeight - leftWeight;
- }
-
- setWeight(sr.left, leftWeight);
- setWeight(sr.right, rightWeight);
-
- }
- }
-
- private void setWeight(MUIElement element, double weight) {
- element.weight = weight;
- }
-
- public void setConstraint(Node node, MUIControl data) {
- data.widget = node;
- }
-
- public MGenericTile getRoot() {
- return root;
- }
-
- @Override
- protected void layoutChildren() {
- if (root == null)
- return;
-
- Bounds bounds = getLayoutBounds();
- bounds = new BoundingBox(bounds.getMinX() + marginLeft.get(),
- bounds.getMinY() + marginTop.get(),
- bounds.getWidth() - (marginLeft.get() + marginRight.get()),
- bounds.getHeight() - (marginTop.get() + marginBottom.get()));
-
- sashes.clear();
- tileSubNodes(bounds, root);
- }
-
- private Bounds getRectangle(MUIElement element) {
- if (element instanceof MGenericTile)
- return (Bounds) element.widget;
- else if (element.widget instanceof Node)
- return ((Node) (element.widget)).getBoundsInParent();
- return null;
- }
-
- private void setRectangle(MUIElement node, Bounds bounds) {
- if (node.widget instanceof Node) {
- Node ctrl = (Node) node.widget;
- ctrl.resizeRelocate(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
- } else if (node instanceof MGenericTile) {
- Bounds newRect = new BoundingBox(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(),
- bounds.getHeight());
- node.widget = newRect;
- }
- }
-
- private List<MUIElement> getVisibleChildren(MGenericTile sashContainer) {
- List<MUIElement> visKids = new ArrayList<MUIElement>();
- for (MUIElement child : sashContainer.children) {
- if (child.isVisible())
- visKids.add(child);
- }
- return visKids;
- }
-
- private double totalWeight(MGenericTile node) {
- double total = 0;
- for (MUIElement subNode : node.children) {
- if (subNode.isVisible())
- total += getWeight(subNode);
- }
- return total;
- }
-
- private void tileSubNodes(Bounds bounds, MUIElement node) {
- if (node != root)
- setRectangle(node, bounds);
-
- if (!(node instanceof MGenericTile))
- return;
-
- MGenericTile sashContainer = (MGenericTile) node;
- List<MUIElement> visibleChildren = getVisibleChildren(sashContainer);
- int childCount = visibleChildren.size();
-
- // How many pixels do we have?
- double availableWidth = sashContainer.horizontal ? bounds.getWidth()
- : bounds.getHeight();
-
- // Subtract off the room for the sashes
- availableWidth -= ((childCount - 1) * sashWidth.get());
-
- // Get the total of the weights
- double totalWeight = totalWeight(sashContainer);
- double tilePos = sashContainer.horizontal ? bounds.getMinX() : bounds.getMinY();
-
- MUIElement prev = null;
- for (MUIElement subNode : visibleChildren) {
- // Add a 'sash' between this node and the 'prev'
- if (prev != null) {
- Bounds sashRect = sashContainer.horizontal ? new BoundingBox(
- tilePos, bounds.getMinY(), sashWidth.get(), bounds.getHeight())
- : new BoundingBox(bounds.getMinX(), tilePos, bounds.getWidth(),
- sashWidth.get());
- sashes.add(new SashRect(sashRect, sashContainer, prev, subNode));
- tilePos += sashWidth.get();
- }
-
- // Calc the new size as a %'age of the total
- double ratio = getWeight(subNode) / totalWeight;
- double newSize = availableWidth * ratio;
-
- Bounds subBounds = sashContainer.horizontal ? new BoundingBox(
- tilePos, bounds.getMinY(), newSize, bounds.getHeight()) : new BoundingBox(
- bounds.getMinX(), tilePos, bounds.getWidth(), newSize);
-
-
- tilePos += newSize;
-
- tileSubNodes(subBounds, subNode);
- prev = subNode;
- }
- }
-
- private static double getWeight(MUIElement element) {
- Double info = element.weight;
- if (info == null ) {
- element.weight = Double.valueOf(100);
- info = element.weight;
- }
-
- return info;
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/src/panes.cssext b/bundles/runtime/org.eclipse.fx.ui.panes/src/panes.cssext
new file mode 100644
index 000000000..7b9945f4f
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.panes/src/panes.cssext
@@ -0,0 +1,39 @@
+import javafx.scene.layout.Pane
+package org.eclipse.fx.ui.panes {
+ AbstractLayoutPane extends Pane {
+
+ }
+ FillLayoutPane extends AbstractLayoutPane {
+ -fx-inner-margin-width <javafx.length> default: 0;
+ -fx-inner-margin-height <javafx.length> default: 0;
+ -fx-spacing <javafx.length> default: 0;
+ -fx-horizontal <javafx.boolean> default: true;
+ }
+ GridLayoutPane extends AbstractLayoutPane {
+ -fx-columns @INT default: 1;
+ -fx-columns-equal-width <javafx.boolean> default: false;
+ -fx-inner-margin-width <javafx.length> default: 5;
+ -fx-inner-margin-height <javafx.length> default: 5;
+ -fx-inner-margin-left <javafx.length> default: 0;
+ -fx-inner-margin-top <javafx.length> default: 0;
+ -fx-inner-margin-right <javafx.length> default: 0;
+ -fx-inner-margin-bottom <javafx.length> default: 0;
+ -fx-hspace <javafx.length> default: 5;
+ -fx-vspace <javafx.length> default: 5;
+ }
+ RowLayoutPane extends AbstractLayoutPane {
+ -fx-inner-margin-width <javafx.length> default: 0;
+ -fx-inner-margin-height <javafx.length> default: 0;
+ -fx-inner-margin-left <javafx.length> default: 0;
+ -fx-inner-margin-top <javafx.length> default: 0;
+ -fx-inner-margin-right <javafx.length> default: 0;
+ -fx-inner-margin-bottom <javafx.length> default: 0;
+ -fx-spacing <javafx.length> default: 3;
+ -fx-wrap <javafx.boolean> default: true;
+ -fx-pack <javafx.boolean> default: true;
+ -fx-fill <javafx.boolean> default: false;
+ -fx-center <javafx.boolean> default: false;
+ -fx-justify <javafx.boolean> default: false;
+ -fx-horizontal <javafx.boolean> default: false;
+ }
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/TestFillLayout.java b/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/TestFillLayout.java
deleted file mode 100644
index c99366a63..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/TestFillLayout.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.fx.ui.panes;
-
-import javafx.application.Application;
-import javafx.scene.Scene;
-import javafx.scene.control.TableColumn;
-import javafx.scene.control.TableView;
-import javafx.stage.Stage;
-
-public class TestFillLayout extends Application {
-
- public static void main(String[] args) {
- launch(args);
- }
-
- @Override
- public void start(Stage primaryStage) throws Exception {
- FillLayoutPane p = new FillLayoutPane();
- p.getStyleClass().add("test-css");
-
- {
- TableView<String> v = new TableView<>();
- TableColumn<String, String> c = new TableColumn<>();
- c.setPrefWidth(200);
- c.setText("Sample");
- p.getChildren().add(v);
- }
-
- {
- TableView<String> v = new TableView<>();
- TableColumn<String, String> c = new TableColumn<>();
- c.setPrefWidth(200);
- c.setText("Sample");
- p.getChildren().add(v);
- }
-
- Scene s = new Scene(p,500,500);
- s.getStylesheets().add(getClass().getResource("sample.css").toExternalForm());
- primaryStage.setScene(s);
- primaryStage.show();
- }
-
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/sample.css b/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/sample.css
deleted file mode 100644
index 17053c9e1..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.panes/test-src/org/eclipse/fx/ui/panes/sample.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.test-css {
- /*-fx-inner-margin-width: 20px;
- -fx-inner-margin-height: 20px;
- -fx-spacing: 10px;
- -fx-horizontal: false;*/
- -fx-padding: 30 45 10 20;
-} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java
index 7255d4942..da8c9590d 100644
--- a/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java
+++ b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java
@@ -72,5 +72,10 @@ public final class Constants {
* Event sent when the result of a visible when is modified
*/
@NonNull
- public static final String UPDATE_VISIBLE_WHEN_RESULT = ROOT_TOPIC + "/MUIElement/UpdateVisibleWhenResult"; //$NON-NLS-1$
+ public static final String UPDATE_VISIBLE_WHEN_RESULT = ROOT_TOPIC + "/MUIElement/UpdateVisibleWhenResult"; //$NON-NLS-1$
+ /**
+ * Event sent when the theme is changed
+ */
+ @NonNull
+ public static final String THEME_CHANGED = ROOT_TOPIC + "/Theme/modified"; //$NON-NLS-1$
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/sync/UISynchronize.java b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/sync/UISynchronize.java
index 0f8474e12..747d98d07 100644
--- a/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/sync/UISynchronize.java
+++ b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/sync/UISynchronize.java
@@ -13,6 +13,7 @@ package org.eclipse.fx.ui.services.sync;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import org.eclipse.fx.core.Callback;
@@ -75,39 +76,77 @@ public interface UISynchronize {
<T> @Nullable T block(@NonNull BlockCondition<T> blockCondition);
/**
+ * Schedule the execution of the runnable
+ *
+ * @param delay
+ * the delay
+ * @param runnable
+ * the runnable to execute
+ * @return subscription to cancel the execution
+ */
+ Subscription scheduleExecution(long delay, Runnable runnable);
+
+ /**
+ * Schedule the execution of the callable
+ *
+ * @param delay
+ * the delay
+ * @param runnable
+ * the callable to execute
+ * @return future to get informed about the value
+ */
+ <T> CompletableFuture<T> scheduleExecution(long delay, Callable<T> runnable);
+
+ /**
* A block condition
*
* @param <T>
* the type
*/
public static class BlockCondition<T> {
- private List<Callback<T>> callbacks = new ArrayList<>();
+ List<Callback<T>> callbacks = new ArrayList<>();
private boolean isBlocked = true;
+ /**
+ * Subscribe to unblocking
+ *
+ * @param r
+ * the callback
+ * @return the subscription
+ */
public Subscription subscribeUnblockedCallback(Callback<T> r) {
- if (!isBlocked) {
+ if (!this.isBlocked) {
throw new IllegalStateException();
}
- callbacks.add(r);
+ this.callbacks.add(r);
return new Subscription() {
@Override
public void dispose() {
- callbacks.remove(r);
+ BlockCondition.this.callbacks.remove(r);
}
};
}
+ /**
+ * @return check if still blocked
+ */
public boolean isBlocked() {
- return isBlocked;
+ return this.isBlocked;
}
+ /**
+ * Release the lock and pass value
+ *
+ * @param value
+ * the value to pass
+ */
public void release(T value) {
- for (Callback<T> r : callbacks) {
+ for (Callback<T> r : this.callbacks) {
r.call(value);
}
- callbacks.clear();
- isBlocked = false;
+ this.callbacks.clear();
+ this.isBlocked = false;
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.theme/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.theme/META-INF/MANIFEST.MF
index 7186c2198..41ca73bdc 100755
--- a/bundles/runtime/org.eclipse.fx.ui.theme/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.theme/META-INF/MANIFEST.MF
@@ -12,6 +12,9 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Service-Component: OSGI-INF/thememanager.xml
Import-Package: com.sun.javafx.css,
+ javafx.beans;version="2.2.0",
+ javafx.beans.property;version="2.2.0",
javafx.collections;version="2.0.0",
- javafx.scene;version="2.0.0"
+ javafx.scene;version="2.0.0",
+ org.osgi.service.event;version="1.3.0"
Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/runtime/org.eclipse.fx.ui.theme/src/org/eclipse/fx/ui/theme/internal/DefaultThemeManager.java b/bundles/runtime/org.eclipse.fx.ui.theme/src/org/eclipse/fx/ui/theme/internal/DefaultThemeManager.java
index a4c52632e..ce07e311b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.theme/src/org/eclipse/fx/ui/theme/internal/DefaultThemeManager.java
+++ b/bundles/runtime/org.eclipse.fx.ui.theme/src/org/eclipse/fx/ui/theme/internal/DefaultThemeManager.java
@@ -13,9 +13,11 @@ package org.eclipse.fx.ui.theme.internal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.UUID;
+import javafx.beans.InvalidationListener;
import javafx.scene.Scene;
import org.eclipse.core.runtime.FileLocator;
@@ -25,11 +27,15 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.core.log.LoggerFactory;
+import org.eclipse.fx.ui.services.Constants;
import org.eclipse.fx.ui.services.theme.Theme;
import org.eclipse.fx.ui.services.theme.ThemeManager;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
/**
@@ -174,23 +180,39 @@ public class DefaultThemeManager implements ThemeManager {
public List<@NonNull Theme> getAvailableThemes() {
return this.themes;
}
+
+ @SuppressWarnings("null")
+ private static @NonNull String getCSSClassname(@NonNull String id) {
+ return id.replace('.', '-');
+ }
@Override
public void setCurrentThemeId(String id) {
for (Theme t : this.themes) {
if (t.getId().equals(id)) {
this.currentThemeId = id;
+ EventAdmin eventAdmin = getEventAdmin();
+ if( eventAdmin != null ) {
+ eventAdmin.sendEvent(new Event(Constants.THEME_CHANGED, Collections.singletonMap("org.eclipse.e4.data", id))); //$NON-NLS-1$
+ }
for( Scene scene : this.managedScenes ) {
List<Theme> availableThemes = getAvailableThemes();
for (Theme theme : availableThemes) {
for (URL url : theme.getStylesheetURL()) {
+ if( scene.getRoot() != null ) {
+ scene.getRoot().getStyleClass().remove(getCSSClassname(theme.getId()));
+ }
scene.getStylesheets().remove(url.toExternalForm());
}
}
for (Theme theme : availableThemes) {
for (URL url : theme.getStylesheetURL()) {
if (theme.getId().equals(this.currentThemeId)) {
+ if( scene.getRoot() != null ) {
+ scene.getRoot().getStyleClass().remove(getCSSClassname(theme.getId()));
+ scene.getRoot().getStyleClass().add(getCSSClassname(theme.getId()));
+ }
scene.getStylesheets().add(url.toExternalForm());
}
}
@@ -208,23 +230,57 @@ public class DefaultThemeManager implements ThemeManager {
}
private static Logger LOGGER;
-
+
@SuppressWarnings("null")
+ @NonNull
static Logger getLogger() {
- if( LOGGER == null ) {
+ Logger logger = LOGGER;
+ if( logger == null ) {
ServiceReference<LoggerFactory> ref = Activator.getContext().getServiceReference(LoggerFactory.class);
- LOGGER = Activator.getContext().getService(ref).createLogger(DefaultThemeManager.class.getName());
+ logger = Activator.getContext().getService(ref).createLogger(DefaultThemeManager.class.getName());
+ LOGGER = logger;
}
return LOGGER;
}
+ private EventAdmin eventAdmin;
+
+ @Nullable EventAdmin getEventAdmin() {
+ EventAdmin eventAdmin = this.eventAdmin;
+ if( eventAdmin != null ) {
+ return eventAdmin;
+ }
+
+ ServiceReference<EventAdmin> ref = Activator.getContext().getServiceReference(EventAdmin.class);
+ if( ref != null ) {
+ eventAdmin = Activator.getContext().getService(ref);
+ }
+
+ return eventAdmin;
+ }
+
@Override
public Registration registerScene(final Scene scene) {
this.managedScenes.add(scene);
+ InvalidationListener l = (o) -> {
+ String themeId = this.currentThemeId;
+ if( scene.getRoot() != null && themeId != null ) {
+ scene.getRoot().getStyleClass().remove(getCSSClassname(themeId));
+ scene.getRoot().getStyleClass().add(getCSSClassname(themeId));
+ }
+ };
+ String themeId = this.currentThemeId;
+ if( themeId != null ) {
+ scene.getRoot().getStyleClass().remove(getCSSClassname(themeId));
+ scene.getRoot().getStyleClass().add(getCSSClassname(themeId));
+ }
+
+ scene.rootProperty().addListener(l);
return new Registration() {
@Override
public void dispose() {
+ scene.rootProperty().removeListener(l);
DefaultThemeManager.this.managedScenes.remove(scene);
}
};
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.base/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.workbench.base/META-INF/MANIFEST.MF
index c889a5167..bef176704 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.base/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.base/META-INF/MANIFEST.MF
@@ -21,9 +21,10 @@ Require-Bundle: org.eclipse.e4.core.contexts;bundle-version="1.1.0",
org.eclipse.core.runtime;bundle-version="3.10.0",
org.eclipse.fx.osgi.util;bundle-version="1.0.0",
org.eclipse.e4.core.di.extensions,
- org.eclipse.fx.ui.services;bundle-version="1.0.0"
-Export-Package: org.eclipse.fx.ui.workbench.base,
- org.eclipse.fx.ui.workbench.base.rendering
+ org.eclipse.fx.ui.services;bundle-version="1.0.0",
+ org.eclipse.fx.ui.workbench.services;bundle-version="1.0.0"
+Export-Package: org.eclipse.fx.ui.workbench.base;x-friends:="org.eclipse.fx.ui.workbench.fx,org.eclipse.fx.ui.workbench.renderers.fx",
+ org.eclipse.fx.ui.workbench.base.rendering;x-friends:="org.eclipse.fx.ui.workbench.fx,org.eclipse.fx.ui.workbench.renderers.fx"
Import-Package: javax.annotation;version="1.2.0",
javax.inject;version="1.0.0"
Bundle-Activator: org.eclipse.fx.ui.workbench.base.internal.Activator
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
index 91f849220..50aee0b66 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
@@ -20,6 +20,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.concurrent.Callable;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.runtime.Assert;
@@ -50,6 +52,7 @@ import org.eclipse.e4.ui.internal.workbench.SelectionAggregator;
import org.eclipse.e4.ui.internal.workbench.SelectionServiceImpl;
import org.eclipse.e4.ui.model.application.MAddon;
import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl;
@@ -79,6 +82,7 @@ import org.eclipse.fx.ui.workbench.base.internal.Activator;
import org.eclipse.fx.ui.workbench.base.internal.LoggerProviderImpl;
import org.eclipse.fx.ui.workbench.base.restart.RestartPreferenceUtil;
import org.eclipse.fx.ui.workbench.base.restart.RestartServiceImpl;
+import org.eclipse.fx.ui.workbench.services.EModelStylingService;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.osgi.service.datalocation.Location;
@@ -97,13 +101,14 @@ public abstract class AbstractE4Application implements IApplication {
private static final String METADATA_FOLDER = ".metadata"; //$NON-NLS-1$
private static final String VERSION_FILENAME = "version.ini"; //$NON-NLS-1$
- private Object lcManager;
+ Object lcManager;
private IModelResourceHandler handler;
private static org.eclipse.fx.core.log.Logger LOGGER = LoggerCreator.createLogger(AbstractE4Application.class);
/**
- * Create a synchronizer instance who synchronizes between UI and none-UI threads
+ * Create a synchronizer instance who synchronizes between UI and none-UI
+ * threads
*
* @param context
* the context
@@ -148,7 +153,7 @@ public abstract class AbstractE4Application implements IApplication {
protected static String[] getApplicationArguments(IApplicationContext applicationContext) {
return (String[]) applicationContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
}
-
+
/**
* Create the workbench instance
*
@@ -165,12 +170,40 @@ public abstract class AbstractE4Application implements IApplication {
@NonNull
UISynchronize uiSync = createSynchronizer(appContext);
- appContext.set(org.eclipse.e4.ui.di.UISynchronize.class, (org.eclipse.e4.ui.di.UISynchronize)uiSync);
+ appContext.set(org.eclipse.e4.ui.di.UISynchronize.class, (org.eclipse.e4.ui.di.UISynchronize) uiSync);
appContext.set(UISynchronize.class, uiSync);
appContext.set(Realm.class, createRealm(appContext));
appContext.set(IApplicationContext.class, applicationContext);
+ appContext.set(EModelStylingService.class, new EModelStylingService() {
+ private static final String PREFIX = "efx_styleclass:"; //$NON-NLS-1$
+ @Override
+ public void addStyles(MUIElement element, String... tags) {
+ List<String> toAdd = Stream.of(tags).map(t -> PREFIX + t)
+ .filter(t -> !element.getTags().contains(t))
+ .collect(Collectors.toList());
+ element.getTags().addAll(toAdd);
+ }
+
+ @Override
+ public void removeStyles(MUIElement element, String... tags) {
+ List<String> cssTags = Stream.of(tags).map(t -> PREFIX + t).collect(Collectors.toList());
+ element.getTags().removeAll(cssTags);
+ }
+
+ @Override
+ public List<String> getStyles(MUIElement element) {
+ return getStylesFromTags(element.getTags());
+ }
+
+ @Override
+ public List<String> getStylesFromTags(List<String> tags) {
+ return tags.stream().filter((t) -> t.startsWith(PREFIX))
+ .map(t -> t.substring(PREFIX.length()))
+ .collect(Collectors.toList());
+ }
+ });
appContext.set(IResourceUtilities.class, createResourceUtility(appContext));
-
+
// Check if DS is running
if (!appContext.containsKey("org.eclipse.e4.ui.workbench.modeling.EModelService")) { //$NON-NLS-1$
throw new IllegalStateException("Core services not available. Please make sure that a declarative service implementation (such as the bundle 'org.eclipse.equinox.ds') is available!"); //$NON-NLS-1$
@@ -190,25 +223,25 @@ public abstract class AbstractE4Application implements IApplication {
Boolean rv = uiSync.syncExec(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
- return (Boolean)ContextInjectionFactory.invoke(AbstractE4Application.this.lcManager, PostContextCreate.class, appContext, Boolean.TRUE);
+ return (Boolean) ContextInjectionFactory.invoke(AbstractE4Application.this.lcManager, PostContextCreate.class, appContext, Boolean.TRUE);
}
}, null);
-
+
if (rv != null && !rv.booleanValue()) {
return null;
}
}
}
String toolItemTimer = getArgValue(Constants.TOOLITEM_TIMER, applicationContext, false);
- if( toolItemTimer != null ) {
+ if (toolItemTimer != null) {
try {
- appContext.set(Constants.TOOLITEM_TIMER, Long.valueOf(toolItemTimer));
- } catch(NumberFormatException e) {
- LOGGER.error("Unable to parse '"+Constants.TOOLITEM_TIMER+"' value '"+toolItemTimer+"'", e); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ appContext.set(Constants.TOOLITEM_TIMER, Long.valueOf(toolItemTimer));
+ } catch (NumberFormatException e) {
+ LOGGER.error("Unable to parse '" + Constants.TOOLITEM_TIMER + "' value '" + toolItemTimer + "'", e); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
}
-
+
}
-
+
// Create the app model and its context
MApplication appModel = loadApplicationModel(applicationContext, appContext);
appModel.setContext(appContext);
@@ -249,15 +282,16 @@ public abstract class AbstractE4Application implements IApplication {
preCreateWorkbench(appContext);
- // Instantiate the Workbench (which is responsible for 'running' the UI (if any)...
+ // Instantiate the Workbench (which is responsible for 'running' the UI
+ // (if any)...
E4Workbench workbench = new E4Workbench(appModel, appContext);
-
+
// Workbench dependendent services
appContext.set(RestartService.class, ContextInjectionFactory.make(RestartServiceImpl.class, appContext));
return workbench;
}
-
+
/**
* save the model
*/
@@ -348,7 +382,8 @@ public abstract class AbstractE4Application implements IApplication {
Resource resource = this.handler.loadMostRecentModel();
theApp = (MApplication) resource.getContents().get(0);
- // Reset the restart-flag in the preferences regardless of it being used or not, otherwise it would
+ // Reset the restart-flag in the preferences regardless of it being used
+ // or not, otherwise it would
// hang around if -clearPersistedState was also set
restartUtil.setClearPersistedStateOnRestart(false);
@@ -506,7 +541,23 @@ public abstract class AbstractE4Application implements IApplication {
windowContext.set(SelectionAggregator.class, selectionAggregator);
}
- protected static String getArgValue(String argName, IApplicationContext applicationContext, boolean singledCmdArgValue) {
+ /**
+ * Try to access the argument value from different sources:
+ * <ul>
+ * <li>The application arguments</li>
+ * <li>The product extension point</li>
+ * <li>The System-Properties</li>
+ * </ul>
+ *
+ * @param argName
+ * the argument name
+ * @param applicationContext
+ * the application context
+ * @param singledCmdArgValue
+ * <code>true</code> if the argument is single valued
+ * @return the value or <code>null</code>
+ */
+ protected static @Nullable String getArgValue(String argName, IApplicationContext applicationContext, boolean singledCmdArgValue) {
// Is it in the arg list ?
if (argName == null || argName.length() == 0)
return null;
@@ -538,7 +589,7 @@ public abstract class AbstractE4Application implements IApplication {
* @return <code>true</code> if the location is fine
*/
@SuppressWarnings("static-method")
- protected boolean checkInstanceLocation(@Nullable Location instanceLocation, @NonNull IEclipseContext context) {
+ public boolean checkInstanceLocation(@Nullable Location instanceLocation, @NonNull IEclipseContext context) {
// Eclipse has been run with -data @none or -data @noDefault options so
// we don't need to validate the location
if (instanceLocation == null && Boolean.FALSE.equals(context.get(IWorkbench.PERSIST_STATE))) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/restart/RestartPreferenceUtil.java b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/restart/RestartPreferenceUtil.java
index 410809768..7797793cc 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/restart/RestartPreferenceUtil.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/restart/RestartPreferenceUtil.java
@@ -23,6 +23,7 @@ import org.osgi.service.prefs.BackingStoreException;
/**
* Extended service for internal purposes
*/
+@SuppressWarnings("restriction")
@Creatable
public class RestartPreferenceUtil {
@@ -30,7 +31,7 @@ public class RestartPreferenceUtil {
@Inject
@Preference
- protected IEclipsePreferences node;
+ private IEclipsePreferences node;
@Inject
@Optional
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/META-INF/MANIFEST.MF
index 9bf0a0279..5a1161ca1 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/META-INF/MANIFEST.MF
@@ -25,14 +25,17 @@ Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.emf.ecore;bundle-version="2.9.0",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.core.databinding.observable;bundle-version="1.4.1",
- org.eclipse.fx.core.databinding
+ org.eclipse.fx.core.databinding,
+ org.eclipse.e4.core.di.extensions;bundle-version="0.12.0"
Import-Package: com.sun.javafx.tk;version="2.2.0",
+ javafx.animation;version="2.2.0",
javafx.application;version="2.0.0",
javafx.event;version="2.0.0",
javafx.scene;version="2.0.0",
javafx.scene.image;version="2.0.0",
javafx.scene.input;version="2.0.0",
javafx.stage;version="2.0.0",
+ javafx.util;version="2.2.0",
org.apache.commons.lang.text;version="2.6.0",
org.eclipse.osgi.service.environment;version="1.3.0",
org.osgi.framework;version="1.6.0",
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java
index 17365d966..336ee87a3 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java
@@ -18,6 +18,8 @@ import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.internal.workbench.E4Workbench;
@@ -33,6 +35,8 @@ import org.eclipse.fx.osgi.util.LoggerCreator;
import org.eclipse.fx.ui.services.Constants;
import org.eclipse.fx.ui.services.resources.GraphicsLoader;
import org.eclipse.fx.ui.services.sync.UISynchronize;
+import org.eclipse.fx.ui.services.theme.Theme;
+import org.eclipse.fx.ui.services.theme.ThemeManager;
import org.eclipse.fx.ui.workbench.base.AbstractE4Application;
import org.eclipse.fx.ui.workbench.fx.internal.GraphicsLoaderImpl;
import org.eclipse.fx.ui.workbench.fx.internal.UISynchronizeImpl;
@@ -44,6 +48,7 @@ import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
+import org.osgi.service.prefs.BackingStoreException;
/**
* default e4 application
@@ -53,9 +58,9 @@ public class E4Application extends AbstractE4Application {
static org.eclipse.fx.core.log.Logger LOGGER = LoggerCreator.createLogger(E4Application.class);
- private E4Workbench workbench;
- private Location instanceLocation;
- private IEclipseContext workbenchContext;
+ E4Workbench workbench;
+ Location instanceLocation;
+ IEclipseContext workbenchContext;
private static final String EXIT_CODE = "e4.osgi.exit.code"; //$NON-NLS-1$
private static final String PRIMARY_STAGE_KEY = "primaryStage"; //$NON-NLS-1$
@@ -195,6 +200,18 @@ public class E4Application extends AbstractE4Application {
if (getLifecycleManager() != null) {
ContextInjectionFactory.invoke(getLifecycleManager(), PreSave.class, this.workbenchContext, null);
}
+ ThemeManager manager = this.workbenchContext.get(ThemeManager.class);
+ Theme theme = manager.getCurrentTheme();
+ if( theme != null ) {
+ IEclipsePreferences node = InstanceScope.INSTANCE.getNode("org.eclipse.fx.ui.workbench.fx"); //$NON-NLS-1$
+ node.put(AbstractE4Application.THEME_ID, theme.getId());
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ LOGGER.error("Failed to remember the theme id", e); //$NON-NLS-1$
+ }
+ }
+
saveModel();
this.workbench.close();
}
@@ -295,6 +312,7 @@ public class E4Application extends AbstractE4Application {
sendEvent(Constants.APPLICATION_LAUNCHED, map);
}
+ @SuppressWarnings("null")
@Override
protected UISynchronize createSynchronizer(IEclipseContext appContext) {
return ContextInjectionFactory.make(UISynchronizeImpl.class, appContext);
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
index c7665096f..c27a8f0d2 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
@@ -19,6 +19,7 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.e4.core.services.contributions.IContributionFactory;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
@@ -79,14 +80,16 @@ public class PartRenderingEngine implements IPresentationEngine {
@NonNull
private final IEventBroker eventBroker;
-
+
@Inject
PartRenderingEngine(
@Nullable @Named(E4Workbench.RENDERER_FACTORY_URI) @Optional String _factoryUrl,
@NonNull IEclipseContext context,
@NonNull EModelService modelService,
@NonNull IEventBroker eventBroker,
- @NonNull ThemeManager themeManager) {
+ @NonNull ThemeManager themeManager,
+ @Preference(nodePath="org.eclipse.fx.ui.workbench.fx",value=AbstractE4Application.THEME_ID)
+ String themeId) {
final String factoryUrl;
if (_factoryUrl == null) {
factoryUrl = defaultFactoryUrl;
@@ -109,11 +112,21 @@ public class PartRenderingEngine implements IPresentationEngine {
setupEventListener(eventBroker);
- Object object = context.get(AbstractE4Application.THEME_ID);
- if (object != null && object instanceof String) {
- themeManager.setCurrentThemeId((String) object);
- } else {
- this.logger.info("No current theme is set"); //$NON-NLS-1$
+ if( themeId != null && !themeId.isEmpty()) {
+ try {
+ themeManager.setCurrentThemeId(themeId);
+ } catch(Throwable t) {
+ this.logger.error("Unknown theme '"+themeId+"'", t); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+
+ if( themeManager.getCurrentTheme() == null ) {
+ Object object = context.get(AbstractE4Application.THEME_ID);
+ if (object != null && object instanceof String) {
+ themeManager.setCurrentThemeId((String) object);
+ } else {
+ this.logger.info("No current theme is set"); //$NON-NLS-1$
+ }
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/internal/UISynchronizeImpl.java b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/internal/UISynchronizeImpl.java
index 7ba55ff6f..eb5062b17 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/internal/UISynchronizeImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/internal/UISynchronizeImpl.java
@@ -11,18 +11,24 @@
package org.eclipse.fx.ui.workbench.fx.internal;
import java.util.concurrent.Callable;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
+import javafx.animation.KeyFrame;
+import javafx.animation.Timeline;
+import javafx.util.Duration;
+
import javax.inject.Inject;
import org.eclipse.fx.core.Callback;
+import org.eclipse.fx.core.Subscription;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
-import org.eclipse.fx.core.log.Logger.Level;
import org.eclipse.fx.ui.services.sync.UISynchronize;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -53,7 +59,7 @@ public class UISynchronizeImpl extends org.eclipse.e4.ui.di.UISynchronize implem
try {
return task.get();
} catch (InterruptedException | ExecutionException e) {
- this.logger.log(Level.ERROR, "Unable to wait until the task is completed", e); //$NON-NLS-1$
+ this.logger.error("Unable to wait until the task is completed", e); //$NON-NLS-1$
} finally {
task.cancel(true);
}
@@ -71,7 +77,7 @@ public class UISynchronizeImpl extends org.eclipse.e4.ui.di.UISynchronize implem
try {
task.get(); // wait for task to complete
} catch (InterruptedException | ExecutionException e) {
- this.logger.log(Level.ERROR, "Unable to wait until the task is completed", e); //$NON-NLS-1$
+ this.logger.error("Unable to wait until the task is completed", e); //$NON-NLS-1$
} finally {
task.cancel(true);
}
@@ -91,6 +97,43 @@ public class UISynchronizeImpl extends org.eclipse.e4.ui.di.UISynchronize implem
}
@Override
+ public Subscription scheduleExecution(long delay, Runnable runnable) {
+ final AtomicBoolean b = new AtomicBoolean(true);
+ Timeline t = new Timeline(new KeyFrame(Duration.millis(delay), (a) -> {
+ if( b.get() ) {
+ runnable.run();
+ }
+ } ));
+ t.play();
+ return new Subscription() {
+
+ @Override
+ public void dispose() {
+ b.set(false);
+ t.stop();
+ }
+ };
+ }
+
+ @Override
+ public <T> CompletableFuture<T> scheduleExecution(long delay, Callable<T> runnable) {
+ CompletableFuture<T> future = new CompletableFuture<T>();
+
+ Timeline t = new Timeline(new KeyFrame(Duration.millis(delay), (a) -> {
+ try {
+ if( ! future.isCancelled() ) {
+ future.complete(runnable.call());
+ }
+ } catch (Exception e) {
+ future.completeExceptionally(e);
+ }
+ } ));
+ t.play();
+
+ return future;
+ }
+
+ @Override
public <T> @Nullable T block(@NonNull BlockCondition<T> blockCondition) {
AtomicReference<@Nullable T> rv = new AtomicReference<>();
blockCondition.subscribeUnblockedCallback(new Callback<T>() {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/key/KeyBindingDispatcher.java b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/key/KeyBindingDispatcher.java
index 073f32add..3af78657f 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/key/KeyBindingDispatcher.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/key/KeyBindingDispatcher.java
@@ -325,16 +325,16 @@ public class KeyBindingDispatcher {
return !sequenceBeforeKeyStroke.isEmpty();
}
- private @Nullable ParameterizedCommand getPerfectMatch(KeySequence keySequence) {
+ private @Nullable ParameterizedCommand getPerfectMatch(@NonNull KeySequence keySequence) {
Binding perfectMatch = getBindingService().getPerfectMatch(keySequence);
return perfectMatch == null ? null : perfectMatch.getParameterizedCommand();
}
- private boolean isPartialMatch(KeySequence keySequence) {
+ private boolean isPartialMatch(@NonNull KeySequence keySequence) {
return getBindingService().isPartialMatch(keySequence);
}
- private boolean isPerfectMatch(KeySequence keySequence) {
+ private boolean isPerfectMatch(@NonNull KeySequence keySequence) {
return getBindingService().isPerfectMatch(keySequence);
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/META-INF/MANIFEST.MF
index 08cfcc98d..f8135e87c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/META-INF/MANIFEST.MF
@@ -14,19 +14,19 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="0.10.1",
org.eclipse.e4.ui.di;bundle-version="0.10.1",
org.eclipse.fx.core;bundle-version="0.9.0",
org.eclipse.emf.ecore;bundle-version="2.9.0",
- org.eclipse.fx.ui.lifecycle,
org.eclipse.fx.ui.keybindings.e4;bundle-version="0.9.0",
org.eclipse.fx.ui.keybindings;bundle-version="0.9.0",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.fx.core.di;bundle-version="1.0.0",
org.eclipse.fx.ui.services;bundle-version="1.0.0",
org.eclipse.e4.ui.services;bundle-version="1.1.0",
- org.eclipse.core.expressions;bundle-version="3.4.600"
+ org.eclipse.core.expressions;bundle-version="3.4.600",
+ org.eclipse.fx.ui.workbench.services;bundle-version="1.0.0"
Import-Package: javax.annotation;version="1.0.0",
javax.inject;version="1.0.0",
org.osgi.service.event;version="1.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ui.workbench.renderers.base,
- org.eclipse.fx.ui.workbench.renderers.base.addons,
- org.eclipse.fx.ui.workbench.renderers.base.services,
- org.eclipse.fx.ui.workbench.renderers.base.widget
+Export-Package: org.eclipse.fx.ui.workbench.renderers.base;x-friends:="org.eclipse.fx.ui.workbench.renderers.fx",
+ org.eclipse.fx.ui.workbench.renderers.base.addons;x-friends:="org.eclipse.fx.ui.workbench.renderers.fx",
+ org.eclipse.fx.ui.workbench.renderers.base.services;x-friends:="org.eclipse.fx.ui.workbench.renderers.fx",
+ org.eclipse.fx.ui.workbench.renderers.base.widget;x-friends:="org.eclipse.fx.ui.workbench.renderers.fx"
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseCompositePartRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseCompositePartRenderer.java
index 57a4d76f7..70ffb8df7 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseCompositePartRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseCompositePartRenderer.java
@@ -10,9 +10,28 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.base;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
+import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.fx.ui.workbench.base.rendering.RendererFactory;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WCompositePart;
+import org.eclipse.fx.ui.workbench.renderers.base.widget.WLayoutedWidget;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
/**
* Base renderer for {@link MCompositePart}
@@ -21,23 +40,183 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WCompositePart;
* the native widget
*/
public abstract class BaseCompositePartRenderer<N> extends BaseRenderer<MCompositePart, WCompositePart<N>> {
+ @Inject
+ RendererFactory factory;
+
+ @PostConstruct
+ void init(IEventBroker eventBroker) {
+ eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (changedObj instanceof MCompositePart) {
+ MCompositePart parent = (MCompositePart) changedObj;
+ if (BaseCompositePartRenderer.this == parent.getRenderer()) {
+ if (UIEvents.isADD(event)) {
+ handleChildrenAddition(parent, Util.<MPartSashContainerElement> asCollection(event, UIEvents.EventTags.NEW_VALUE));
+ } else if (UIEvents.isREMOVE(event)) {
+ handleChildrenRemove(parent, Util.<MPartSashContainerElement> asCollection(event, UIEvents.EventTags.OLD_VALUE));
+
+ }
+ }
+ }
+ }
+ });
+ eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (changedObj instanceof MCompositePart) {
+ MCompositePart parent = (MCompositePart) changedObj;
+ if (BaseCompositePartRenderer.this == parent.getRenderer()) {
+ String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
+ if (UIEvents.EventTypes.SET.equals(eventType)) {
+ MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
+ handleSelectedElement(parent, (MPartSashContainerElement) oldValue, (MPartSashContainerElement) newValue);
+ }
+ }
+ }
+ }
+ });
+ eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (changedObj.isToBeRendered()) {
+ MUIElement parent = changedObj.getParent();
+ if (parent != null) {
+ if (BaseCompositePartRenderer.this == parent.getRenderer()) {
+ MCompositePart stack = (MCompositePart) parent;
+ String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
+ if (UIEvents.EventTypes.SET.equals(eventType)) {
+ Boolean newValue = (Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (newValue.booleanValue()) {
+ // TODO Is childRendered not
+ // dangerous to call
+ // here??
+ childRendered(stack, changedObj);
+ } else {
+ hideChild(stack, changedObj);
+ }
+ }
+ }
+ }
+ }
+ }
+ });
+ eventBroker.subscribe(UIEvents.UIElement.TOPIC_CONTAINERDATA, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
+ if( changedObj != null && changedObj.getParent() != null && changedObj.getParent().getRenderer() == BaseCompositePartRenderer.this ) {
+ MElementContainer<MUIElement> parent = changedObj.getParent();
+ if( parent != null && !inUIModification(parent) ) {
+ @Nullable
+ WCompositePart<N> widget = getWidget((MCompositePart)(MUIElement)parent);
+ if( widget != null ) {
+ widget.updateLayout();
+ } else {
+ getLogger().error("Could not find widget for '"+parent+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+ }
+ }
+ });
+ }
@Override
- protected void doProcessContent(MCompositePart element) {
- // TODO Auto-generated method stub
+ public void doProcessContent(MCompositePart element) {
+ WCompositePart<N> sash = getWidget(element);
+ if( sash == null ) {
+ getLogger().error("Could not find widget for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ return;
+ }
+ List<WLayoutedWidget<MPartSashContainerElement>> list = new ArrayList<WLayoutedWidget<MPartSashContainerElement>>();
+
+ for (MPartSashContainerElement e : element.getChildren()) {
+ if (e.isToBeRendered()) {
+ WLayoutedWidget<MPartSashContainerElement> widget = engineCreateWidget(e);
+ if (widget != null && e.isVisible()) {
+ list.add(widget);
+ }
+ }
+ }
+ sash.addItems(list);
}
+ @SuppressWarnings("null")
@Override
public void childRendered(MCompositePart parentElement, MUIElement element) {
- // TODO Auto-generated method stub
+ if (inContentProcessing(parentElement)) {
+ return;
+ }
+ int idx = getRenderedIndex(parentElement, element);
+ WCompositePart<N> sash = getWidget(parentElement);
+ if( sash == null ) {
+ getLogger().error("Could not find widget for '"+parentElement+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ WLayoutedWidget<MPartSashContainerElement> w = (WLayoutedWidget<MPartSashContainerElement>) element.getWidget();
+ if( w != null ) {
+ List<@NonNull WLayoutedWidget<MPartSashContainerElement>> l = Collections.singletonList(w);
+ sash.addItems(idx, l);
+ } else {
+ this.logger.error("The widget for element '"+element+"' should not be null"); //$NON-NLS-1$//$NON-NLS-2$
+ }
}
@Override
public void hideChild(MCompositePart container, MUIElement changedObj) {
- // TODO Auto-generated method stub
+ WCompositePart<N> sash = getWidget(container);
+
+ if (sash == null) {
+ return;
+ }
+ @SuppressWarnings("unchecked")
+ WLayoutedWidget<MPartSashContainerElement> widget = (WLayoutedWidget<MPartSashContainerElement>) changedObj.getWidget();
+ if (widget != null) {
+ sash.removeItem(widget);
+ }
}
+ void handleChildrenAddition(@NonNull MCompositePart parent, Collection<MPartSashContainerElement> elements) {
+ Iterator<MPartSashContainerElement> iterator = elements.iterator();
+ while (iterator.hasNext()) {
+ MCompositePart element = (MCompositePart) iterator.next();
+
+ if (element.isToBeRendered() && element.isVisible()) {
+ if (element.getWidget() == null) {
+ engineCreateWidget(element);
+ } else {
+ childRendered(parent, element);
+ }
+ }
+ }
+
+ }
+
+ void handleChildrenRemove(@NonNull MCompositePart parent, Collection<MPartSashContainerElement> elements) {
+ Iterator<MPartSashContainerElement> iterator = elements.iterator();
+ while (iterator.hasNext()) {
+ MPartSashContainerElement element = (MPartSashContainerElement) iterator.next();
+ if (element.isToBeRendered() && element.isVisible() && element.getWidget() != null) {
+ hideChild(parent, element);
+ }
+ }
+ }
+
+ void handleSelectedElement(MCompositePart parent, MPartSashContainerElement oldElement, MPartSashContainerElement newElement) {
+ // TODO Implement (is this needed the SWT renderes don't care about
+ // this!)
+ }
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemContainerRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemContainerRenderer.java
new file mode 100644
index 000000000..6d271aeab
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemContainerRenderer.java
@@ -0,0 +1,167 @@
+package org.eclipse.fx.ui.workbench.renderers.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.contexts.RunAndTrack;
+import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.Selector;
+import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.fx.core.di.ScopedObjectFactory;
+import org.eclipse.fx.ui.workbench.renderers.base.EventProcessor.ChildrenHandler;
+import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Base renderer handling generic part for item containers
+ *
+ * @param <M>
+ * the element
+ * @param <I>
+ * the child type
+ * @param <W>
+ * the widget
+ */
+public abstract class BaseItemContainerRenderer<M extends MElementContainer<I>, I extends MUIElement, W extends WWidget<M>> extends BaseRenderer<M, W> implements ChildrenHandler<M, I> {
+ private List<I> widgets = new ArrayList<>();
+
+ @Inject
+ IEclipseContext context;
+
+ @PostConstruct
+ void init(IEventBroker eventBroker) {
+ EventProcessor.attachChildProcessor(eventBroker, this);
+ EventProcessor.attachVisibleProcessor(eventBroker, this);
+
+ Selector noop = m -> true;
+ eventBroker.subscribe(ScopedObjectFactory.KEYMODIFED_TOPIC, e -> checkExecute(noop));
+ eventBroker.subscribe(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, e -> {
+ Object d = e.getProperty(IEventBroker.DATA);
+ if (d instanceof Selector) {
+ checkExecute((Selector) d);
+ } else if (UIEvents.ALL_ELEMENT_ID.equals(d)) {
+ checkExecute(noop);
+ } else if (d != null) {
+ checkExecute(m -> d.equals(m.getElementId()));
+ }
+ });
+ eventBroker.subscribe(UIEvents.Dirtyable.TOPIC_DIRTY, e -> checkExecute(noop));
+ this.context.runAndTrack(new RunAndTrack() {
+
+ @Override
+ public boolean changed(IEclipseContext context) {
+ context.get(IServiceConstants.ACTIVE_CONTEXTS);
+ context.get(IServiceConstants.ACTIVE_SELECTION);
+ context.get(IServiceConstants.ACTIVE_PART);
+ checkExecute(noop);
+ return true;
+ }
+ });
+ do_init(eventBroker);
+ }
+
+ /**
+ * @return <code>true</code> if the enablement check is disabled currently
+ */
+ @SuppressWarnings("static-method")
+ protected boolean skipEnablementCheck() {
+ return false;
+ }
+
+ /**
+ * Check if the given item is currently show
+ *
+ * @param item
+ * the item
+ * @return <code>true</code> if the item is currently visible on screen
+ */
+ protected boolean isShowing(I item) {
+ return true;
+ }
+
+ void checkExecute(Selector selector) {
+ if (skipEnablementCheck()) {
+ return;
+ }
+
+ List<I> iterationCopy;
+
+ // not ideal because we'll probably check items are already
+ // removed
+ // from the ui
+ synchronized (BaseItemContainerRenderer.this.widgets) {
+ iterationCopy = new ArrayList<>(BaseItemContainerRenderer.this.widgets);
+ }
+
+ for (I e : iterationCopy) {
+ if (!isShowing(e)) {
+ continue;
+ }
+ if (e instanceof MItem && e.getRenderer() instanceof BaseItemRenderer<?, ?> && selector.select(e)) {
+ final MItem tmp = (MItem) e;
+ @SuppressWarnings("unchecked")
+ final BaseItemRenderer<MItem, ?> r = (BaseItemRenderer<MItem, ?>) tmp.getRenderer();
+ if (tmp.getRenderer() != null) {
+ r.checkEnablement(tmp);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void childRendered(M parentElement, MUIElement element) {
+ if (element instanceof MItem) {
+ synchronized (this.widgets) {
+ this.widgets.add((I) element);
+ }
+ }
+ do_childRendered(parentElement, element);
+ }
+
+ @Override
+ public void hideChild(M container, MUIElement changedObj) {
+ if (changedObj instanceof MItem) {
+ synchronized (this.widgets) {
+ this.widgets.remove(changedObj);
+ }
+ }
+ do_hideChild(container, changedObj);
+ }
+
+ /**
+ * Called to init
+ *
+ * @param broker
+ * the event broker
+ */
+ protected abstract void do_init(@NonNull IEventBroker broker);
+
+ /**
+ * Called to render the child
+ *
+ * @param parentElement
+ * the parent
+ * @param element
+ * the element
+ */
+ protected abstract void do_childRendered(@NonNull M parentElement, @NonNull MUIElement element);
+
+ /**
+ * Called to hide a child
+ *
+ * @param container
+ * the container
+ * @param changedObj
+ * the child hidden
+ */
+ protected abstract void do_hideChild(@NonNull M container, @NonNull MUIElement changedObj);
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemRenderer.java
index fcc30a4a2..a4aeb221a 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseItemRenderer.java
@@ -198,7 +198,7 @@ public abstract class BaseItemRenderer<M extends MUIElement, W extends WWidget<M
Object rv = contribution.getObject();
if (rv == null) {
if (contribution.getContributionURI() == null) {
- getLogger().error("No contribution uri defined"); //$NON-NLS-1$
+ getLogger().error("No contribution uri defined for " + contribution); //$NON-NLS-1$
return null;
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuItemRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuItemRenderer.java
index de3f4bf87..5c949ab05 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuItemRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuItemRenderer.java
@@ -59,16 +59,18 @@ public abstract class BaseMenuItemRenderer<N> extends BaseItemRenderer<MMenuItem
}
EBindingService service = lclContext.get(EBindingService.class);
ParameterizedCommand command = generateParameterizedCommand((MHandledMenuItem) element, lclContext);
- Collection<TriggerSequence> sequences = service.getSequencesFor(command);
- if (!sequences.isEmpty()) {
- Iterator<TriggerSequence> it = sequences.iterator();
- while (it.hasNext()) {
- TriggerSequence s = it.next();
- if (s instanceof KeySequence) {
- widget.setAccelerator((KeySequence) s);
- break;
+ if( command != null ) {
+ Collection<TriggerSequence> sequences = service.getSequencesFor(command);
+ if (!sequences.isEmpty()) {
+ Iterator<TriggerSequence> it = sequences.iterator();
+ while (it.hasNext()) {
+ TriggerSequence s = it.next();
+ if (s instanceof KeySequence) {
+ widget.setAccelerator((KeySequence) s);
+ break;
+ }
}
- }
+ }
}
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuRenderer.java
index 43083fa86..f3d2a6075 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseMenuRenderer.java
@@ -12,10 +12,11 @@ package org.eclipse.fx.ui.workbench.renderers.base;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
@@ -30,12 +31,11 @@ import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
-import org.eclipse.fx.ui.lifecycle.ELifecycleService;
-import org.eclipse.fx.ui.lifecycle.annotations.PreClose;
-import org.eclipse.fx.ui.lifecycle.annotations.PreShow;
-import org.eclipse.fx.ui.workbench.renderers.base.EventProcessor.ChildrenHandler;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WMenu;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WMenuElement;
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
+import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreClose;
+import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreShow;
import org.eclipse.jdt.annotation.NonNull;
/**
@@ -45,7 +45,7 @@ import org.eclipse.jdt.annotation.NonNull;
* the native widget type
*/
@SuppressWarnings("restriction")
-public abstract class BaseMenuRenderer<N> extends BaseRenderer<MMenu, WMenu<N>> implements ChildrenHandler<MMenu, MMenuElement> {
+public abstract class BaseMenuRenderer<N> extends BaseItemContainerRenderer<MMenu,MMenuElement, WMenu<N>> {
@Inject
ELifecycleService lifecycleService;
@@ -59,66 +59,61 @@ public abstract class BaseMenuRenderer<N> extends BaseRenderer<MMenu, WMenu<N>>
private static final String DYNAMIC_MENU_CONTRIBUTION = "DYNAMIC_MENU_CONTRIBUTION"; //$NON-NLS-1$
- @PostConstruct
- void init(IEventBroker eventBroker) {
- EventProcessor.attachChildProcessor(eventBroker, this);
- EventProcessor.attachVisibleProcessor(eventBroker, this);
+ private Set<MMenu> currentVisibleMenus = new HashSet<>();
+
+ @Override
+ protected void do_init(@NonNull IEventBroker broker) {
+ // nothing to do
}
-
+
@Override
protected void initWidget(final MMenu element, WMenu<N> widget) {
super.initWidget(element, widget);
- widget.setShowingCallback(new Runnable() {
-
- @Override
- public void run() {
- handleShowing(element);
- }
- });
- widget.setHidingCallback(new Runnable() {
-
- @SuppressWarnings("null")
- @Override
- public void run() {
- IEclipseContext modelContext = getModelContext(element);
- if( modelContext == null ) {
- getLogger().error("Model context is null"); //$NON-NLS-1$
- return;
- }
- IEclipseContext context = modelContext.createChild("lifecycle"); //$NON-NLS-1$
- context.set(MMenu.class, element);
- BaseMenuRenderer.this.lifecycleService.validateAnnotation(PreClose.class, element, context);
-
- for (MMenuElement e : element.getChildren().toArray(new MMenuElement[0])) {
- if (e instanceof MDynamicMenuContribution) {
- MDynamicMenuContribution dc = (MDynamicMenuContribution) e;
+ widget.setShowingCallback( () -> handleShowing(element));
+ widget.setHidingCallback( () -> handleHiding(element));
+ }
+
+ @SuppressWarnings("null")
+ void handleHiding(@NonNull MMenu element) {
+ this.currentVisibleMenus.remove(element);
+ IEclipseContext modelContext = getModelContext(element);
+ if( modelContext == null ) {
+ getLogger().error("Model context is null"); //$NON-NLS-1$
+ return;
+ }
+ IEclipseContext context = modelContext.createChild("lifecycle"); //$NON-NLS-1$
+ context.set(MMenu.class, element);
+ BaseMenuRenderer.this.lifecycleService.validateAnnotation(PreClose.class, element, context);
- Object contrib = dc.getObject();
- if (contrib != null) {
- @SuppressWarnings("unchecked")
- List<MMenuElement> previous = (List<MMenuElement>) dc.getTransientData().remove(DYNAMIC_MENU_CONTRIBUTION);
- context.set(List.class, previous);
- try {
- ContextInjectionFactory.invoke(contrib, AboutToHide.class, context, null);
+ for (MMenuElement e : element.getChildren().toArray(new MMenuElement[0])) {
+ if (e instanceof MDynamicMenuContribution) {
+ MDynamicMenuContribution dc = (MDynamicMenuContribution) e;
- if (previous != null && !previous.isEmpty()) {
- element.getChildren().removeAll(previous);
- }
- } catch (Throwable t) {
- getLogger().debug("Unable to process the AboutToHide", t); //$NON-NLS-1$
- }
+ Object contrib = dc.getObject();
+ if (contrib != null) {
+ @SuppressWarnings("unchecked")
+ List<MMenuElement> previous = (List<MMenuElement>) dc.getTransientData().remove(DYNAMIC_MENU_CONTRIBUTION);
+ context.set(List.class, previous);
+ try {
+ ContextInjectionFactory.invoke(contrib, AboutToHide.class, context, null);
+ if (previous != null && !previous.isEmpty()) {
+ element.getChildren().removeAll(previous);
}
+ } catch (Throwable t) {
+ getLogger().debug("Unable to process the AboutToHide", t); //$NON-NLS-1$
}
- }
- context.dispose();
+ }
}
- });
+ }
+
+ context.dispose();
}
@SuppressWarnings("null")
void handleShowing(@NonNull MMenu element) {
+ this.currentVisibleMenus.add(element);
IEclipseContext modelContext = getModelContext(element);
if( modelContext == null ) {
getLogger().error("The model context is null"); //$NON-NLS-1$
@@ -172,6 +167,16 @@ public abstract class BaseMenuRenderer<N> extends BaseRenderer<MMenu, WMenu<N>>
}
@Override
+ protected boolean skipEnablementCheck() {
+ return this.currentVisibleMenus.isEmpty();
+ }
+
+ @Override
+ protected boolean isShowing(MMenuElement item) {
+ return this.currentVisibleMenus.contains(item.getParent());
+ }
+
+ @Override
public void doProcessContent(MMenu element) {
// TODO Should we do this creation lazy????
WMenu<N> menu = getWidget(element);
@@ -224,7 +229,7 @@ public abstract class BaseMenuRenderer<N> extends BaseRenderer<MMenu, WMenu<N>>
}
@Override
- public void childRendered(@NonNull MMenu parentElement, @NonNull MUIElement element) {
+ public void do_childRendered(@NonNull MMenu parentElement, @NonNull MUIElement element) {
if (inContentProcessing(parentElement)) {
return;
}
@@ -252,7 +257,7 @@ public abstract class BaseMenuRenderer<N> extends BaseRenderer<MMenu, WMenu<N>>
}
@Override
- public void hideChild(MMenu container, MUIElement changedObj) {
+ public void do_hideChild(MMenu container, MUIElement changedObj) {
WMenu<N> menu = getWidget(container);
if (menu == null) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePartRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePartRenderer.java
index 88e1668de..434836a90 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePartRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePartRenderer.java
@@ -11,6 +11,7 @@
package org.eclipse.fx.ui.workbench.renderers.base;
import java.util.Collection;
+import java.util.Collections;
import javax.annotation.PostConstruct;
@@ -22,6 +23,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WCallback;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WMenu;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WPart;
@@ -69,6 +71,72 @@ public abstract class BasePartRenderer<N, T, M> extends BaseRenderer<MPart, WPar
}
}
});
+
+ eventBroker.subscribe(UIEvents.Part.TOPIC_TOOLBAR, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ MUIElement parent = (MUIElement) changedObj;
+ if (parent.getRenderer() == BasePartRenderer.this) {
+ if (UIEvents.isSET(event)) {
+ Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (newValue != null) {
+ handleToolbarAddition((MPart) parent, (MToolBar) newValue);
+ } else {
+ handleToolbarRemove((MPart) parent, (MToolBar) event.getProperty(UIEvents.EventTags.OLD_VALUE));
+ }
+ }
+ }
+ }
+ });
+
+ eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {
+
+ @Override
+ public void handleEvent(Event event) {
+ MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (changedObj.isToBeRendered()) {
+ MUIElement parent = (MUIElement) ((EObject) changedObj).eContainer();
+ if (parent != null) {
+ if (BasePartRenderer.this == parent.getRenderer()) {
+ MPart part = (MPart) parent;
+ String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
+ if (UIEvents.EventTypes.SET.equals(eventType)) {
+ Boolean newValue = (Boolean) event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (newValue.booleanValue()) {
+ childRendered(part, changedObj);
+ } else {
+ hideChild(part, changedObj);
+ }
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ void handleToolbarRemove(@NonNull MPart parent, @NonNull MToolBar toolbar) {
+ WPart<N, T, M> widget = getWidget(parent);
+ if (widget == null) {
+ return;
+ }
+
+ if (widget.getToolbar() == toolbar.getWidget()) {
+ widget.setToolbar(null);
+ }
+ }
+
+ void handleToolbarAddition(@NonNull MPart parent, @NonNull MToolBar toolbar) {
+ WPart<N, T, M> widget = getWidget(parent);
+ if (widget == null) {
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ WToolBar<T> wtoolbar = (WToolBar<T>) getPresentationEngine().createGui(toolbar);
+ widget.setToolbar(wtoolbar);
}
@Override
@@ -103,11 +171,11 @@ public abstract class BasePartRenderer<N, T, M> extends BaseRenderer<MPart, WPar
@Override
public void doProcessContent(@NonNull MPart element) {
WPart<N, T, M> widget = getWidget(element);
- if( widget == null ) {
- getLogger().error("No widget found for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ if (widget == null) {
+ getLogger().error("No widget found for '" + element + "'"); //$NON-NLS-1$//$NON-NLS-2$
return;
}
-
+
MToolBar mToolBar = element.getToolbar();
if (mToolBar != null) {
WToolBar<T> toolbar = engineCreateWidget(mToolBar);
@@ -169,12 +237,24 @@ public abstract class BasePartRenderer<N, T, M> extends BaseRenderer<MPart, WPar
@Override
public void childRendered(MPart parentElement, MUIElement element) {
- // No children
+ if (inContentProcessing(parentElement) || !element.isVisible()) {
+ return;
+ }
+
+ if (element instanceof MToolBar) {
+ handleToolbarAddition(parentElement, (MToolBar) element);
+ } else if (element instanceof MMenu) {
+ handleMenuAddition(parentElement, Collections.singletonList((MMenu) element));
+ }
}
@Override
public void hideChild(MPart container, MUIElement changedObj) {
- // No children
+ if (changedObj instanceof MToolBar) {
+ handleToolbarRemove(container, (MToolBar) changedObj);
+ } else if (changedObj instanceof MMenu) {
+ handleMenuRemove(container, Collections.singletonList((MMenu) changedObj));
+ }
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePopupMenuRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePopupMenuRenderer.java
index ebc515939..3a623b93d 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePopupMenuRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BasePopupMenuRenderer.java
@@ -10,18 +10,34 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.base;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.services.contributions.IContributionFactory;
import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.di.AboutToHide;
+import org.eclipse.e4.ui.di.AboutToShow;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MDynamicMenuContribution;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu;
+import org.eclipse.fx.core.log.Log;
+import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.ui.workbench.renderers.base.EventProcessor.ChildrenHandler;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WMenuElement;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WPopupMenu;
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
+import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreClose;
+import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreShow;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Base renderer for {@link MPopupMenu}
@@ -29,26 +45,117 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WPopupMenu;
* @param <N>
* the native widget type
*/
-public abstract class BasePopupMenuRenderer<N> extends BaseRenderer<MPopupMenu, WPopupMenu<N>> implements ChildrenHandler<MPopupMenu, MMenuElement> {
- @PostConstruct
- void init(IEventBroker eventBroker) {
- EventProcessor.attachChildProcessor(eventBroker, this);
- EventProcessor.attachVisibleProcessor(eventBroker, this);
- }
+@SuppressWarnings("restriction")
+public abstract class BasePopupMenuRenderer<N> extends BaseItemContainerRenderer<MPopupMenu, MMenuElement, WPopupMenu<N>> implements ChildrenHandler<MPopupMenu, MMenuElement> {
+ //FIXME Can we merge this with the BaseMenuRenderer????
+ @Inject
+ ELifecycleService lifecycleService;
+
+ @Inject
+ private IContributionFactory contributionFactory;
+
+ @Log
+ @Inject
+ private Logger logger;
+
+ private static final String DYNAMIC_MENU_CONTRIBUTION = "DYNAMIC_MENU_CONTRIBUTION"; //$NON-NLS-1$
+ private Set<MPopupMenu> currentVisibleMenus = new HashSet<>();
+
+ @Override
+ protected void do_init(@NonNull IEventBroker broker) {
+ // nothing to do
+ }
+
@Override
protected void initWidget(final MPopupMenu element, WPopupMenu<N> widget) {
super.initWidget(element, widget);
- widget.setShowingCallback(new Runnable() {
+ widget.setShowingCallback( () -> handleShowing(element));
+ widget.setHidingCallback( () -> handleHiding(element));
+ }
+
+ @SuppressWarnings("null")
+ void handleHiding(@NonNull MPopupMenu element) {
+ this.currentVisibleMenus.remove(element);
+ IEclipseContext modelContext = getModelContext(element);
+ if( modelContext == null ) {
+ getLogger().error("Model context is null"); //$NON-NLS-1$
+ return;
+ }
+ IEclipseContext context = modelContext.createChild("lifecycle"); //$NON-NLS-1$
+ context.set(MPopupMenu.class, element);
+ this.lifecycleService.validateAnnotation(PreClose.class, element, context);
+
+ for (MMenuElement e : element.getChildren().toArray(new MMenuElement[0])) {
+ if (e instanceof MDynamicMenuContribution) {
+ MDynamicMenuContribution dc = (MDynamicMenuContribution) e;
+
+ Object contrib = dc.getObject();
+ if (contrib != null) {
+ @SuppressWarnings("unchecked")
+ List<MMenuElement> previous = (List<MMenuElement>) dc.getTransientData().remove(DYNAMIC_MENU_CONTRIBUTION);
+ context.set(List.class, previous);
+ try {
+ ContextInjectionFactory.invoke(contrib, AboutToHide.class, context, null);
- @Override
- public void run() {
- handleShowing(element);
+ if (previous != null && !previous.isEmpty()) {
+ element.getChildren().removeAll(previous);
+ }
+ } catch (Throwable t) {
+ getLogger().debug("Unable to process the AboutToHide", t); //$NON-NLS-1$
+ }
+
+ }
}
- });
+ }
+
+ context.dispose();
}
- static void handleShowing(MPopupMenu element) {
+ @SuppressWarnings("null")
+ void handleShowing(@NonNull MPopupMenu element) {
+ this.currentVisibleMenus.add(element);
+ IEclipseContext modelContext = getModelContext(element);
+ if( modelContext == null ) {
+ getLogger().error("The model context is null"); //$NON-NLS-1$
+ return;
+ }
+ IEclipseContext context = modelContext.createChild("lifecycle"); //$NON-NLS-1$
+ context.set(MPopupMenu.class, element);
+ this.lifecycleService.validateAnnotation(PreShow.class, element, context);
+
+ // we iterate of the copy because it is modified in between
+ for (MMenuElement e : element.getChildren().toArray(new MMenuElement[0])) {
+ if (e instanceof MDynamicMenuContribution) {
+ MDynamicMenuContribution dc = (MDynamicMenuContribution) e;
+ if (dc.getObject() == null && dc.getContributionURI() != null) {
+ try {
+ // TODO On which context should we create the instance,
+ // would
+ dc.setObject(this.contributionFactory.create(dc.getContributionURI(), context));
+ } catch (Throwable t) {
+ getLogger().debug("Unable to create contribution", t); //$NON-NLS-1$
+ }
+ }
+
+ Object contrib = dc.getObject();
+ if (contrib != null) {
+ List<MMenuElement> list = new ArrayList<MMenuElement>();
+ context.set(List.class, list);
+ try {
+ ContextInjectionFactory.invoke(contrib, AboutToShow.class, context, null);
+
+ int idx = element.getChildren().indexOf(e);
+ element.getChildren().addAll(idx, list);
+ dc.getTransientData().put(DYNAMIC_MENU_CONTRIBUTION, list);
+ } catch (Throwable t) {
+ getLogger().debug("Unable to process AboutToShow", t); //$NON-NLS-1$
+ }
+
+ }
+ }
+ }
+
for (MMenuElement e : element.getChildren()) {
if (e.getRenderer() instanceof BaseItemRenderer) {
@SuppressWarnings("unchecked")
@@ -56,6 +163,18 @@ public abstract class BasePopupMenuRenderer<N> extends BaseRenderer<MPopupMenu,
r.checkEnablement(e);
}
}
+
+ context.dispose();
+ }
+
+ @Override
+ protected boolean skipEnablementCheck() {
+ return this.currentVisibleMenus.isEmpty();
+ }
+
+ @Override
+ protected boolean isShowing(MMenuElement item) {
+ return this.currentVisibleMenus.contains(item.getParent());
}
@Override
@@ -63,24 +182,27 @@ public abstract class BasePopupMenuRenderer<N> extends BaseRenderer<MPopupMenu,
// TODO Should we do this creation lazy????
WPopupMenu<N> menu = getWidget(element);
if( menu == null ) {
- getLogger().error("Could not find widget for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ getLogger().error("No widget found for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$
return;
}
+
for (MMenuElement e : element.getChildren()) {
- @SuppressWarnings("null")
- WMenuElement<MMenuElement> widget = engineCreateWidget(e);
- if (widget != null && isChildAndRenderedVisible(e)) {
- menu.addElement(widget);
+ if (e.isToBeRendered()) {
+ WMenuElement<MMenuElement> widget = engineCreateWidget(e);
+ if (widget != null && isChildAndRenderedVisible(e)) {
+ menu.addElement(widget);
+ }
}
}
}
@Override
- public void handleChildrenRemove(MPopupMenu parent, Collection<MMenuElement> elements) {
+ public void handleChildrenRemove(@NonNull MPopupMenu parent, @NonNull Collection<@NonNull MMenuElement> elements) {
Iterator<MMenuElement> iterator = elements.iterator();
while (iterator.hasNext()) {
MMenuElement element = iterator.next();
- if (element.isToBeRendered() && element.isVisible() && element.getWidget() != null) {
+
+ if (isChildAndRenderedVisible(element) && element.getWidget() != null) {
hideChild(parent, element);
}
}
@@ -91,7 +213,13 @@ public abstract class BasePopupMenuRenderer<N> extends BaseRenderer<MPopupMenu,
Iterator<MMenuElement> iterator = elements.iterator();
while (iterator.hasNext()) {
MMenuElement element = iterator.next();
- if (element.isToBeRendered() && element.isVisible()) {
+ // if (element instanceof MDynamicMenuContribution) {
+ // MDynamicMenuContribution c = (MDynamicMenuContribution) element;
+ // lifecycleService.registerLifecycleURI(element,
+ // c.getContributionURI());
+ // continue;
+ // }
+ if (isChildAndRenderedVisible(element)) {
if (element.getWidget() == null) {
engineCreateWidget(element);
} else {
@@ -102,25 +230,35 @@ public abstract class BasePopupMenuRenderer<N> extends BaseRenderer<MPopupMenu,
}
@Override
- public void childRendered(MPopupMenu parentElement, MUIElement element) {
+ public void do_childRendered(@NonNull MPopupMenu parentElement, @NonNull MUIElement element) {
if (inContentProcessing(parentElement)) {
return;
}
+ int idx = getRenderedIndex(parentElement, element);
WPopupMenu<N> menu = getWidget(parentElement);
if( menu == null ) {
- getLogger().error("Could not find widget for '"+parentElement+"'"); //$NON-NLS-1$//$NON-NLS-2$
+ getLogger().error("No widget found for '"+parentElement+"'"); //$NON-NLS-1$//$NON-NLS-2$
return;
}
- int idx = getRenderedIndex(parentElement, element);
@SuppressWarnings("unchecked")
WMenuElement<MMenuElement> menuElement = (WMenuElement<MMenuElement>) element.getWidget();
- menu.addElement(idx, menuElement);
+ if( menuElement != null ) {
+ menu.addElement(idx, menuElement);
+ } else {
+ getLogger().error("The widget of the element '"+element+"' is null"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ }
+
+ @Override
+ protected boolean isChildAndRenderedVisible(MUIElement u) {
+ return super.isChildAndRenderedVisible(u) && !(u instanceof MDynamicMenuContribution);
}
@Override
- public void hideChild(MPopupMenu container, MUIElement changedObj) {
+ public void do_hideChild(MPopupMenu container, MUIElement changedObj) {
WPopupMenu<N> menu = getWidget(container);
if (menu == null) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseRenderer.java
index 7e1d092ef..fe0f57e6c 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseRenderer.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.base;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -48,6 +50,7 @@ import org.eclipse.fx.ui.workbench.base.rendering.ElementRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WPropertyChangeHandler.WPropertyChangeEvent;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget.WidgetState;
+import org.eclipse.fx.ui.workbench.services.EModelStylingService;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.osgi.service.event.Event;
@@ -85,6 +88,9 @@ public abstract class BaseRenderer<M extends MUIElement, W extends WWidget<M>> i
@Inject
EModelService modelService;
+
+ @Inject
+ EModelStylingService modelStylingService;
// boolean inContentProcessing;
//
@@ -364,9 +370,9 @@ public abstract class BaseRenderer<M extends MUIElement, W extends WWidget<M>> i
Object newValue = event.getProperty(UIEvents.EventTags.NEW_VALUE);
String attributeName = event.getProperty(UIEvents.EventTags.ATTNAME).toString();
- // for now only process set events
+ // for now only process set and tag events
// TODO Should we skip none attribute changes???
- if (!UIEvents.isSET(event)) {
+ if (!UIEvents.isSET(event) && !UIEvents.ApplicationElement.TAGS.equals(attributeName)) {
return;
}
@@ -380,15 +386,24 @@ public abstract class BaseRenderer<M extends MUIElement, W extends WWidget<M>> i
BaseRenderer.this.contextModification.put(e, Boolean.TRUE);
if (changedObj instanceof MUIElement) {
- if (event.getProperty(UIEvents.EventTags.ATTNAME).equals(UIEvents.ApplicationElement.TAGS)) {
- MUIElement m = (MUIElement) changedObj;
- if (m.getWidget() != null) {
- ((WWidget<?>) m.getWidget()).removeStyleClasses(m.getTags());
- ((WWidget<?>) m.getWidget()).addStyleClasses(m.getTags());
+ if (e.getRenderer() == BaseRenderer.this) {
+
+ if (attributeName.equals(UIEvents.ApplicationElement.TAGS)) {
+ MUIElement m = (MUIElement) changedObj;
+ if (m.getWidget() != null) {
+ if (UIEvents.isADD(event)) {
+ Collection<String> addedTags = Util.<String>asCollection(event, UIEvents.EventTags.NEW_VALUE);
+ ((WWidget<?>) m.getWidget()).addStyleClasses(
+ this.modelStylingService.getStylesFromTags(new ArrayList<String>(addedTags)));
+ } else if (UIEvents.isREMOVE(event)) {
+ Collection<String> removedTags = Util.<String>asCollection(event, UIEvents.EventTags.OLD_VALUE);
+ ((WWidget<?>) m.getWidget()).removeStyleClasses(
+ this.modelStylingService.getStylesFromTags(new ArrayList<String>(removedTags)));
+ }
+ }
}
- }
- if (e.getRenderer() == BaseRenderer.this) {
+
IEclipseContext ctx = (IEclipseContext) e.getTransientData().get(RENDERING_CONTEXT_KEY);
if (ctx != null) {
if (attributeName.equals(UIEvents.ApplicationElement.PERSISTEDSTATE) && newValue instanceof Entry) {
@@ -467,7 +482,7 @@ public abstract class BaseRenderer<M extends MUIElement, W extends WWidget<M>> i
@Override
public void bindWidget(@NonNull M me, @NonNull W widget) {
widget.setDomElement(me);
- widget.addStyleClasses(me.getTags());
+ widget.addStyleClasses(this.modelStylingService.getStyles(me));
EObject eo = (EObject) me;
widget.addStyleClasses("M" + eo.eClass().getName()); //$NON-NLS-1$
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseStackRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseStackRenderer.java
index 031585869..a3fd4ebad 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseStackRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseStackRenderer.java
@@ -33,8 +33,6 @@ import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
-import org.eclipse.fx.ui.lifecycle.ELifecycleService;
-import org.eclipse.fx.ui.lifecycle.annotations.PreClose;
import org.eclipse.fx.ui.workbench.base.rendering.ElementRenderer;
import org.eclipse.fx.ui.workbench.base.rendering.RendererFactory;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WCallback;
@@ -42,6 +40,8 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WLayoutedWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WPlaceholderWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem;
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
+import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreClose;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.osgi.service.event.Event;
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseToolBarRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseToolBarRenderer.java
index 958b05d6f..2b931d195 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseToolBarRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseToolBarRenderer.java
@@ -10,26 +10,15 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.base;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-
-import org.eclipse.e4.core.contexts.IEclipseContext;
-import org.eclipse.e4.core.contexts.RunAndTrack;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.Selector;
-import org.eclipse.e4.ui.workbench.UIEvents;
-import org.eclipse.fx.core.di.ScopedObjectFactory;
import org.eclipse.fx.ui.services.Constants;
-import org.eclipse.fx.ui.workbench.renderers.base.EventProcessor.ChildrenHandler;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WToolBar;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget;
@@ -39,14 +28,9 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget;
* @param <N>
* the widget node
*/
-public abstract class BaseToolBarRenderer<N> extends BaseRenderer<MToolBar, WToolBar<N>> implements ChildrenHandler<MToolBar, MToolBarElement> {
- List<MToolBarElement> widgets = new ArrayList<MToolBarElement>();
-
- @Inject
- IEclipseContext context;
-
- @PostConstruct
- void init(IEventBroker eventBroker) {
+public abstract class BaseToolBarRenderer<N> extends BaseItemContainerRenderer<MToolBar, MToolBarElement, WToolBar<N>> {
+ @Override
+ protected void do_init(IEventBroker eventBroker) {
Object value = this.context.get(Constants.TOOLITEM_TIMER);
Selector noop = m -> true;
if( value != null && value instanceof Number ) {
@@ -66,57 +50,8 @@ public abstract class BaseToolBarRenderer<N> extends BaseRenderer<MToolBar, WToo
syncThread.setDaemon(true);
syncThread.start();
}
-
- EventProcessor.attachChildProcessor(eventBroker, this);
- EventProcessor.attachVisibleProcessor(eventBroker, this);
- eventBroker.subscribe(ScopedObjectFactory.KEYMODIFED_TOPIC, e -> checkExecute(m -> true));
- eventBroker.subscribe(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, e -> {
- Object d = e.getProperty(IEventBroker.DATA);
- if( d instanceof Selector ) {
- checkExecute((Selector) d);
- } else if( UIEvents.ALL_ELEMENT_ID.equals(d)) {
- checkExecute(m -> true);
- } else if( d != null ) {
- checkExecute(m -> d.equals(m.getElementId()));
- }
- });
- this.context.runAndTrack(new RunAndTrack() {
-
- @Override
- public boolean changed(IEclipseContext context) {
- context.get(IServiceConstants.ACTIVE_CONTEXTS);
- context.get(IServiceConstants.ACTIVE_SELECTION);
- context.get(IServiceConstants.ACTIVE_PART);
- checkExecute(noop);
- return true;
- }
- });
-
}
- void checkExecute(Selector selector) {
- MToolBarElement[] iterationCopy;
-
- // not ideal because we'll probably check items are already
- // removed
- // from the ui
- synchronized (BaseToolBarRenderer.this.widgets) {
- iterationCopy = BaseToolBarRenderer.this.widgets.toArray(new MToolBarElement[0]);
- }
-
- for (int i = 0; i < iterationCopy.length; i++) {
- MToolBarElement e = iterationCopy[i];
- if (e.getRenderer() instanceof BaseItemRenderer<?, ?> && selector.select(e)) {
- final MToolBarElement tmp = e;
- @SuppressWarnings("unchecked")
- final BaseItemRenderer<MToolBarElement, ?> r = (BaseItemRenderer<MToolBarElement, ?>) tmp.getRenderer();
- if (tmp.getRenderer() != null) {
- r.checkEnablement(tmp);
- }
- }
- }
- }
-
@Override
public void doProcessContent(MToolBar element) {
WToolBar<N> toolbar = getWidget(element);
@@ -135,11 +70,7 @@ public abstract class BaseToolBarRenderer<N> extends BaseRenderer<MToolBar, WToo
}
@Override
- public void childRendered(MToolBar parentElement, MUIElement element) {
- synchronized (this.widgets) {
- this.widgets.add((MToolBarElement) element);
- }
-
+ public void do_childRendered(MToolBar parentElement, MUIElement element) {
if (inContentProcessing(parentElement)) {
return;
}
@@ -161,11 +92,7 @@ public abstract class BaseToolBarRenderer<N> extends BaseRenderer<MToolBar, WToo
}
@Override
- public void hideChild(MToolBar container, MUIElement changedObj) {
- synchronized (this.widgets) {
- this.widgets.remove(changedObj);
- }
-
+ public void do_hideChild(MToolBar container, MUIElement changedObj) {
WToolBar<N> toolbar = getWidget(container);
if (toolbar == null) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWindowRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWindowRenderer.java
index 9257603a0..2ea030d69 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWindowRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWindowRenderer.java
@@ -26,9 +26,7 @@ import org.eclipse.e4.ui.di.Persist;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.e4.ui.model.application.ui.MContext;
-import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
-import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
@@ -47,7 +45,6 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WWindow;
import org.eclipse.jdt.annotation.NonNull;
import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
/**
* Base renderer for {@link MWindow}
@@ -161,56 +158,58 @@ public abstract class BaseWindowRenderer<N> extends BaseRenderer<MWindow, WWindo
registerEventListener(eventBroker, UIEvents.UILabel.TOPIC_LABEL);
registerEventListener(eventBroker, UIEvents.UILabel.TOPIC_TOOLTIP);
registerEventListener(eventBroker, UIEvents.UIElement.TOPIC_VISIBLE);
- eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, new EventHandler() {
-
- @Override
- public void handleEvent(Event event) {
- Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
- if (changedObj instanceof MPerspective) {
- MPerspective perspective = (MPerspective) changedObj;
- if (BaseWindowRenderer.this == perspective.getRenderer()) {
- String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
- if (UIEvents.EventTypes.ADD.equals(eventType)) {
- MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
- if (element instanceof MWindow) {
- handleWindowAdd((MWindow) element);
- } else if (element instanceof MWindowElement) {
- handleChildAdd((MWindowElement) element);
- }
- } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
- MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
- if (element instanceof MWindow) {
- handleWindowRemove((MWindow) element);
- } else if (element instanceof MWindowElement) {
- handleChildRemove((MWindowElement) element);
- }
- }
- }
- }
- }
- });
+
+ eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, this::handleChildrenEvent);
+ eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, this::handleChildrenEvent);
}
+ void handleChildrenEvent(Event event) {
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (changedObj instanceof MWindow) {
+ MWindow window = (MWindow) changedObj;
+ if (BaseWindowRenderer.this == window.getRenderer()) {
+ String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
+ if (UIEvents.EventTypes.ADD.equals(eventType)) {
+ MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
+ if (element instanceof MWindow) {
+ handleWindowAdd((MWindow) element);
+ } else if (element instanceof MWindowElement) {
+ handleChildAdd(window, (MWindowElement) element);
+ }
+ } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
+ MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
+ if (element instanceof MWindow) {
+ handleWindowRemove(window, (MWindow) element);
+ } else if (element instanceof MWindowElement) {
+ handleChildRemove(window, (MWindowElement) element);
+ }
+ }
+ }
+ }
+ }
+
void handleWindowAdd(@NonNull MWindow element) {
engineCreateWidget(element);
}
- void handleWindowRemove(@NonNull MWindow element) {
- // Nothing to do here
+ void handleWindowRemove(@NonNull MWindow parent, @NonNull MWindow element) {
+ if (element.isToBeRendered() && element.isVisible() && element.getWidget() != null) {
+ hideChild(parent, element);
+ }
}
- void handleChildAdd(@NonNull MWindowElement element) {
- engineCreateWidget(element);
+ void handleChildAdd(@NonNull MWindow window, @NonNull MWindowElement element) {
+ if(element.getWidget() != null) {
+ // e.g. detaching something into a new window
+ childRendered(window, element);
+ } else {
+ engineCreateWidget(element);
+ }
}
- void handleChildRemove(MWindowElement element) {
+ void handleChildRemove(@NonNull MWindow window, MWindowElement element) {
if (element.isToBeRendered() && element.isVisible() && element.getWidget() != null) {
- MElementContainer<MUIElement> parent = element.getParent();
- if( parent != null ) {
- hideChild((MWindow) (MUIElement) parent, element);
- } else {
- getLogger().error("Unable to find parent for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$
- }
+ hideChild(window, element);
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWorkbenchRendererFactory.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWorkbenchRendererFactory.java
index 517c899f5..84d857283 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWorkbenchRendererFactory.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/BaseWorkbenchRendererFactory.java
@@ -22,6 +22,7 @@ import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
+import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
@@ -98,6 +99,8 @@ public abstract class BaseWorkbenchRendererFactory implements RendererFactory {
private BasePopupMenuRenderer<?> popupMenuRenderer;
@Nullable
private BasePartMenuRenderer<?> partMenuRenderer;
+ @Nullable
+ private BaseCompositePartRenderer<?> compositePartRenderer;
/**
* Create a new instance of the renderer factory
@@ -116,7 +119,12 @@ public abstract class BaseWorkbenchRendererFactory implements RendererFactory {
@SuppressWarnings("unchecked")
@Override
public <R extends ElementRenderer<?, ?>> R getRenderer(MUIElement modelObject) {
- if (modelObject instanceof MPopupMenu) {
+ if(modelObject instanceof MCompositePart) {
+ if (this.compositePartRenderer == null) {
+ this.compositePartRenderer = make(getCompositePartRendererClass());
+ }
+ return (R) this.compositePartRenderer;
+ } else if (modelObject instanceof MPopupMenu) {
if (this.popupMenuRenderer == null) {
this.popupMenuRenderer = make(getPopupMenuRendererClass());
}
@@ -159,7 +167,7 @@ public abstract class BaseWorkbenchRendererFactory implements RendererFactory {
return (R) this.toolItemMenuRenderer;
} else if (((EObject) modelObject).eContainer() instanceof MPart && ((MMenu) modelObject).getTags().contains(BasePartRenderer.VIEW_MENU_TAG)) {
if (this.partMenuRenderer == null) {
- this.partMenuRenderer = make(getPartMenuRenderer());
+ this.partMenuRenderer = make(getPartMenuRendererClass());
}
return (R) this.partMenuRenderer;
} else {
@@ -354,5 +362,10 @@ public abstract class BaseWorkbenchRendererFactory implements RendererFactory {
* @return the part menu renderer class
*/
@NonNull
- protected abstract Class<@NonNull ? extends BasePartMenuRenderer<?>> getPartMenuRenderer();
+ protected abstract Class<@NonNull ? extends BasePartMenuRenderer<?>> getPartMenuRendererClass();
+ /**
+ * @return the composite part renderer class
+ */
+ @NonNull
+ protected abstract Class<@NonNull ? extends BaseCompositePartRenderer<?>> getCompositePartRendererClass();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/CleanUpAddon.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/CleanUpAddon.java
new file mode 100644
index 000000000..87fffad05
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/CleanUpAddon.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.workbench.renderers.base.addons;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.MGenericTile;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
+import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
+import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
+import org.eclipse.e4.ui.workbench.IPresentationEngine;
+import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.fx.ui.services.sync.UISynchronize;
+import org.osgi.service.event.Event;
+
+/**
+ * Addon which cleans up the model from empty containers
+ */
+public class CleanUpAddon {
+
+ @Inject
+ UISynchronize synchronize;
+
+ @PostConstruct
+ void init(IEventBroker broker) {
+ broker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, this::handleChildrenModified);
+ }
+
+ private void handleChildrenModified(Event event) {
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (UIEvents.isREMOVE(event)) {
+ final MElementContainer<?> container = (MElementContainer<?>) changedObj;
+ MUIElement containerParent = container.getParent();
+
+ // Elements who will never be destroyed even when empty
+ if (container instanceof MApplication || container instanceof MPerspectiveStack || container instanceof MMenuElement || container instanceof MTrimBar || container instanceof MToolBar || container instanceof MArea || container.getTags().contains(IPresentationEngine.NO_AUTO_COLLAPSE)) {
+ return;
+ }
+
+ if (container instanceof MWindow && containerParent instanceof MApplication) {
+ return;
+ }
+
+ this.synchronize.scheduleExecution(200, () -> {
+ if (container.getChildren().isEmpty()) {
+ container.setParent(null);
+
+ } else if( container instanceof MGenericTile<?> && container.getChildren().size() == 1 ) {
+ final MGenericTile<MUIElement> tile = (MGenericTile<MUIElement>) container;
+ int idx = container.getParent().getChildren().indexOf(container);
+
+ String containerData = tile.getContainerData();
+ MUIElement child = container.getChildren().remove(0);
+ child.setContainerData(containerData);
+ container.getParent().getChildren().add(idx,child);
+ container.setParent(null);
+ }
+ });
+ }
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/DnDAddon.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/DnDAddon.java
index 37efee700..c519627e0 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/DnDAddon.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/addons/DnDAddon.java
@@ -23,18 +23,23 @@ import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
+import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.UIEvents.EventTags;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.fx.ui.workbench.renderers.base.BaseStackRenderer;
+import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragSourceWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragSourceWidget.DragData;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropData;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType;
-import org.eclipse.fx.ui.workbench.renderers.base.widget.WMinMaxableWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.osgi.service.event.Event;
/**
@@ -42,132 +47,206 @@ import org.osgi.service.event.Event;
*/
public class DnDAddon {
private static String CSS_CLASS_STACK_MOVE = "stack-move"; //$NON-NLS-1$
-
+
@Inject
IEventBroker eventBroker;
-
+
@Inject
EPartService partService;
-
+
@Inject
UISynchronize synchronize;
- //FIXME This is workaround because of TabFolder problems
+ @Inject
+ EModelService modelService;
+
+ // FIXME This is workaround because of TabFolder problems
private Timer timer;
-
+
/**
* Create an instance
*/
public DnDAddon() {
this.timer = new Timer(true);
}
-
+
private WDragTargetWidget getTargetWidget(MUIElement changedElement) {
if (changedElement instanceof MPlaceholder) {
return getTargetWidget(((MPlaceholder) changedElement).getRef());
}
- if (changedElement.getWidget() instanceof WMinMaxableWidget) {
+ if (changedElement.getWidget() instanceof WDragTargetWidget) {
return (WDragTargetWidget) changedElement.getWidget();
}
return null;
}
-
+
private WStack<?, ?, ?> getSourceWidget(MUIElement changedElement) {
if (changedElement instanceof MPlaceholder) {
return getSourceWidget(((MPlaceholder) changedElement).getRef());
}
- if (changedElement.getWidget() instanceof WMinMaxableWidget) {
+ if (changedElement.getWidget() instanceof WDragSourceWidget) {
return (WStack<?, ?, ?>) changedElement.getWidget();
}
return null;
}
-
+
private void handleWidget(Event event) {
final MUIElement changedElement = (MUIElement) event.getProperty(EventTags.ELEMENT);
WDragTargetWidget acceptWidget = getTargetWidget(changedElement);
- if( acceptWidget != null ) {
+ if (acceptWidget != null) {
acceptWidget.setDragDroppedCallback(this::droppedHandler);
}
-
+
if (!(changedElement instanceof MPartStack) && !(changedElement instanceof MArea))
return;
-
- WStack<?, ?, ?> sourceWidget = getSourceWidget(changedElement);
- if( sourceWidget != null ) {
+
+ WDragSourceWidget sourceWidget = getSourceWidget(changedElement);
+ if (sourceWidget != null) {
sourceWidget.setDragStartCallback(this::dragStartHandler);
}
}
-
+
private Void droppedHandler(DropData d) {
- MElementContainer<MUIElement> sourceContainer = d.sourceElement.getParent();
- if( d.reference != null ) {
- MElementContainer<MUIElement> targetContainer = d.reference.getParent();
-
- if( sourceContainer == targetContainer ) {
- try {
- targetContainer.getTags().add(CSS_CLASS_STACK_MOVE);
- d.sourceElement.getTransientData().put(BaseStackRenderer.MAP_MOVE, Boolean.TRUE);
- List<MUIElement> children = targetContainer.getChildren();
- children.remove(d.sourceElement);
-
- int idx = targetContainer.getChildren().indexOf(d.reference);
-
- if( d.dropType == DropType.AFTER ) {
- idx += 1;
- }
-
- if( idx > targetContainer.getChildren().size() ) {
- targetContainer.getChildren().add(d.sourceElement);
- } else {
- targetContainer.getChildren().add(idx, d.sourceElement);
- }
-
- } finally {
- d.sourceElement.getTransientData().put(BaseStackRenderer.MAP_MOVE, Boolean.TRUE);
- targetContainer.getTags().remove(CSS_CLASS_STACK_MOVE);
- }
- } else {
- int idx = targetContainer.getChildren().indexOf(d.reference);
- if( d.dropType == DropType.AFTER ) {
+ @Nullable
+ MUIElement reference = d.reference;
+ @NonNull
+ MUIElement sourceElement = d.sourceElement;
+
+ switch (d.dropType) {
+ case AFTER:
+ case BEFORE:
+ if (reference != null) {
+ handleReorder(reference, sourceElement, d.dropType);
+ }
+ break;
+ case INSERT:
+ if (reference != null) {
+ handleInsert(reference, sourceElement);
+ }
+ break;
+ case SPLIT_VERTICAL:
+ case SPLIT_HORIZONTAL:
+ if (reference != null) {
+ handleSplit(reference, sourceElement, d.dropType);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+ private static void handleInsert(@NonNull MUIElement reference, @NonNull MUIElement sourceElement) {
+ if (reference instanceof MElementContainer<?>) {
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> c = (MElementContainer<MUIElement>) reference;
+ c.getChildren().add(sourceElement);
+ }
+ }
+
+ private void handleSplit(@NonNull MUIElement reference, @NonNull MUIElement sourceElement, @NonNull DropType dropType) {
+ MElementContainer<MUIElement> parent = reference.getParent();
+ if( (MUIElement)parent instanceof MPartStack ) {
+ split(parent, sourceElement, dropType == DropType.SPLIT_HORIZONTAL );
+ }
+ }
+
+ private void split(MUIElement toSplit, MUIElement child, boolean horizontal) {
+ // remove the moved element from its parent
+ child.setParent(null);
+
+ // remember the index to insert
+ MElementContainer<MUIElement> owner = toSplit.getParent();
+ int index = owner.getChildren().indexOf(toSplit);
+
+ // remove the split from the parent
+ owner.getChildren().remove(toSplit);
+
+ MPartSashContainer container = this.modelService.createModelElement(MPartSashContainer.class);
+ container.setContainerData(toSplit.getContainerData());
+
+ MPartStack childContainer = this.modelService.createModelElement(MPartStack.class);
+ childContainer.getChildren().add((MStackElement) child);
+
+ toSplit.setContainerData(null);
+ childContainer.setContainerData(null);
+
+ container.setToBeRendered(true);
+ container.setVisible(true);
+ container.setHorizontal(horizontal);
+ container.getChildren().add((MPartSashContainerElement) toSplit);
+ container.getChildren().add((MPartSashContainerElement) childContainer);
+//
+ owner.getChildren().add(index, container);
+ }
+
+ private void handleReorder(@NonNull MUIElement reference, @NonNull MUIElement sourceElement, @NonNull DropType dropType) {
+ MElementContainer<MUIElement> sourceContainer = sourceElement.getParent();
+ MElementContainer<MUIElement> targetContainer = reference.getParent();
+
+ if (sourceContainer == targetContainer) {
+ try {
+ targetContainer.getTags().add(CSS_CLASS_STACK_MOVE);
+ sourceElement.getTransientData().put(BaseStackRenderer.MAP_MOVE, Boolean.TRUE);
+ List<MUIElement> children = targetContainer.getChildren();
+ children.remove(sourceElement);
+
+ int idx = targetContainer.getChildren().indexOf(reference);
+
+ if (dropType == DropType.AFTER) {
idx += 1;
}
-
- if( idx < targetContainer.getChildren().size() ) {
- targetContainer.getChildren().add(idx, d.sourceElement);
+
+ if (idx > targetContainer.getChildren().size()) {
+ targetContainer.getChildren().add(sourceElement);
} else {
- targetContainer.getChildren().add(d.sourceElement);
+ targetContainer.getChildren().add(idx, sourceElement);
}
+
+ } finally {
+ sourceElement.getTransientData().put(BaseStackRenderer.MAP_MOVE, Boolean.TRUE);
+ targetContainer.getTags().remove(CSS_CLASS_STACK_MOVE);
+ }
+ } else {
+ int idx = targetContainer.getChildren().indexOf(reference);
+ if (dropType == DropType.AFTER) {
+ idx += 1;
+ }
+
+ if (idx < targetContainer.getChildren().size()) {
+ targetContainer.getChildren().add(idx, sourceElement);
+ } else {
+ targetContainer.getChildren().add(sourceElement);
}
-
- TimerTask t = new TimerTask() {
-
- @Override
- public void run() {
- DnDAddon.this.synchronize.asyncExec(new Runnable() {
-
- @Override
- public void run() {
- targetContainer.setSelectedElement(d.sourceElement);
- }
- });
- }
- };
- this.timer.schedule(t, 200);
}
-
- return null;
+
+ TimerTask t = new TimerTask() {
+
+ @Override
+ public void run() {
+ DnDAddon.this.synchronize.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ targetContainer.setSelectedElement(sourceElement);
+ }
+ });
+ }
+ };
+ this.timer.schedule(t, 200);
}
-
+
@SuppressWarnings("null")
@NonNull
private Boolean dragStartHandler(@NonNull DragData d) {
return Boolean.TRUE;
}
-
+
@PostConstruct
void hookListeners() {
this.eventBroker.subscribe(UIEvents.UIElement.TOPIC_WIDGET, this::handleWidget);
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WCompositePart.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WCompositePart.java
index 2416c5b68..4e5b24f4d 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WCompositePart.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WCompositePart.java
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.base.widget;
+import java.util.List;
+
import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Widget abstraction for a composite part widget
@@ -19,5 +23,88 @@ import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
* the native widget
*/
public interface WCompositePart<N> extends WLayoutedWidget<MCompositePart> {
- // no extra methods yet
+ /**
+ * PersistatedState Key to fix the layout.
+ * <p>
+ * Value type is boolean.
+ * </p>
+ */
+ public static final String TAG_FIXED_LAYOUT = "fx_fixedLayout"; //$NON-NLS-1$
+
+ /**
+ * PersistatedState Key to specify the fixed layout width - only has an
+ * effect when used with {@link #TAG_FIXED_LAYOUT}.
+ * <p>
+ * Value type is int.
+ * </p>
+ */
+ public static final String FIXED_LAYOUT_WIDTH = "fx_layout_width"; //$NON-NLS-1$
+ /**
+ * PersistatedState Key to specify the fixed layout height - only has an
+ * effect when used with {@link #TAG_FIXED_LAYOUT}
+ * <p>
+ * Value type is int.
+ * </p>
+ */
+ public static final String FIXED_LAYOUT_HEIGHT = "fx_layout_height"; //$NON-NLS-1$
+ /**
+ * PersistatedState Key to specify that the control should grab the
+ * remaining horizontal space
+ * <p>
+ * Value type is boolean.
+ * </p>
+ */
+ public static final String FIXED_LAYOUT_GRAB_HORIZONTAL = "fx_layout_grab_horizontal"; //$NON-NLS-1$
+ /**
+ * PersistatedState Key to specify that the control should grab the
+ * remaining vertical space
+ * <p>
+ * Value type is boolean.
+ * </p>
+ */
+ public static final String FIXED_LAYOUT_GRAB_VERTICAL = "fx_layout_grab_vertical"; //$NON-NLS-1$
+
+ /**
+ * Append a widget
+ *
+ * @param widget
+ * the widget
+ */
+ public void addItem(@NonNull WLayoutedWidget<MPartSashContainerElement> widget);
+
+ /**
+ * @return amount of children
+ */
+ public int getItemCount();
+
+ /**
+ * Append a list of widgets
+ *
+ * @param list
+ * the list of widgets
+ */
+ public void addItems(@NonNull List<WLayoutedWidget<MPartSashContainerElement>> list);
+
+ /**
+ * Insert items at the given index
+ *
+ * @param index
+ * the index
+ * @param list
+ * the list of items
+ */
+ public void addItems(int index, @NonNull List<WLayoutedWidget<MPartSashContainerElement>> list);
+
+ /**
+ * Remove item
+ *
+ * @param widget
+ * the widget
+ */
+ public void removeItem(@NonNull WLayoutedWidget<MPartSashContainerElement> widget);
+
+ /**
+ * Update the layout
+ */
+ public void updateLayout();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WDragTargetWidget.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WDragTargetWidget.java
index 2515cf0e4..0ea231fce 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WDragTargetWidget.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WDragTargetWidget.java
@@ -39,21 +39,17 @@ public interface WDragTargetWidget {
*/
AFTER,
/**
- * Split on the left
- */
- SPLIT_LEFT,
- /**
- * Split on the right
+ * Insert the element into the reference
*/
- SPLIT_RIGHT,
+ INSERT,
/**
- * Split on the top
+ * Split on the left
*/
- SPLIT_TOP,
+ SPLIT_VERTICAL,
/**
* split on the bottom
*/
- SPLIT_BOTTOM
+ SPLIT_HORIZONTAL
}
/**
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WLayoutedWidget.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WLayoutedWidget.java
index d04cada89..c82588086 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WLayoutedWidget.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WLayoutedWidget.java
@@ -19,7 +19,7 @@ import org.eclipse.jdt.annotation.NonNull;
* @param <M>
* the model type
*/
-public interface WLayoutedWidget<M extends MUIElement> extends WWidget<M> {
+public interface WLayoutedWidget<M extends MUIElement> extends WWidget<M>, WDragTargetWidget {
/**
* @return the static layout node
*/
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPart.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPart.java
index bd1d37769..46e9a7613 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPart.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPart.java
@@ -45,4 +45,10 @@ public interface WPart<N, T, M> extends WLayoutedWidget<MPart> {
*/
@Nullable
public WMenu<M> getMenu();
+
+ /**
+ * @return the current toolbar
+ */
+ @Nullable
+ public WToolBar<T> getToolbar();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPopupMenu.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPopupMenu.java
index 934021b9e..a6a85585b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPopupMenu.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.base/src/org/eclipse/fx/ui/workbench/renderers/base/widget/WPopupMenu.java
@@ -48,6 +48,14 @@ public interface WPopupMenu<N> extends WMenuElement<MPopupMenu> {
void setShowingCallback(Runnable showingCallback);
/**
+ * Callback to invoke when the menu is hidden
+ *
+ * @param hidingCallback
+ * the callback
+ */
+ void setHidingCallback(Runnable hidingCallback);
+
+ /**
* Remove a widget
*
* @param widget
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/META-INF/MANIFEST.MF
index b88e7fc9c..cdd9c3cd8 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/META-INF/MANIFEST.MF
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/META-INF/MANIFEST.MF
@@ -25,13 +25,15 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="0.10.1",
org.eclipse.emf.common;bundle-version="2.9.0",
org.eclipse.emf.ecore;bundle-version="2.9.0",
org.eclipse.fx.osgi.util;bundle-version="0.9.0",
- org.eclipse.fx.ui.lifecycle;bundle-version="0.9.0",
org.eclipse.fx.ui.keybindings;bundle-version="0.9.0",
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
org.eclipse.osgi.services;bundle-version="3.4.0",
org.eclipse.e4.ui.services;bundle-version="1.1.0",
- org.eclipse.fx.ui.controls;bundle-version="1.0.0"
-Import-Package: javafx.application,
+ org.eclipse.fx.ui.controls;bundle-version="1.0.0",
+ org.eclipse.emf.ecore.xmi;bundle-version="2.10.0",
+ org.eclipse.fx.ui.workbench.services;bundle-version="1.0.0"
+Import-Package: com.sun.javafx.scene.control.skin;version="2.2.0",
+ javafx.application,
javafx.beans;version="2.0.0",
javafx.beans.property,
javafx.beans.value,
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefAreaRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefAreaRenderer.java
index 082bbc546..a28be24db 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefAreaRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefAreaRenderer.java
@@ -71,9 +71,11 @@ public class DefAreaRenderer extends BaseAreaRenderer<SplitPane> {
prev = d;
}
- MPartSashContainerElement element = this.items.get(this.items.size() - 1).getDomElement();
- if( element != null ) {
- element.setContainerData((1.0 - prev) * 10 + ""); //$NON-NLS-1$
+ if( this.items.size() - 1 >= 0 ) {
+ MPartSashContainerElement element = this.items.get(this.items.size() - 1).getDomElement();
+ if( element != null ) {
+ element.setContainerData((1.0 - prev) * 10 + ""); //$NON-NLS-1$
+ }
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefCompositePartRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefCompositePartRenderer.java
index 1bc1d9e53..6eaaaf6b8 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefCompositePartRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefCompositePartRenderer.java
@@ -10,33 +10,373 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.fx;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import javafx.application.Platform;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.ListChangeListener;
+import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.SplitPane;
+import javafx.scene.control.SplitPane.Divider;
import org.eclipse.e4.ui.model.application.ui.basic.MCompositePart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainerElement;
+import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.fx.ui.panes.GridData;
+import org.eclipse.fx.ui.panes.GridLayoutPane;
+import org.eclipse.fx.ui.panes.GridData.Alignment;
import org.eclipse.fx.ui.workbench.renderers.base.BaseCompositePartRenderer;
+import org.eclipse.fx.ui.workbench.renderers.base.BaseRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WCompositePart;
+import org.eclipse.fx.ui.workbench.renderers.base.widget.WLayoutedWidget;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.WLayoutedWidgetImpl;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+/**
+ * Renderer for a composite part
+ */
public class DefCompositePartRenderer extends BaseCompositePartRenderer<Node> {
@Override
- protected Class<? extends WCompositePart<Node>> getWidgetClass(MCompositePart element) {
- return CompositePartWidgetImpl.class;
+ protected Class<? extends WCompositePart<Node>> getWidgetClass(MCompositePart container) {
+ if (container.getTags().contains(WCompositePart.TAG_FIXED_LAYOUT)) {
+ return WFixedSashImpl.class;
+ } else {
+ return WResizableSashImpl.class;
+ }
}
- static class CompositePartWidgetImpl extends WLayoutedWidgetImpl<SplitPane, SplitPane, MCompositePart> implements WCompositePart<Node> {
+ static class WFixedSashImpl extends WLayoutedWidgetImpl<GridLayoutPane, Node, MCompositePart> implements WCompositePart<Node> {
+
+ private static @NonNull GridData toGridData(Map<String, String> dataMap) {
+ GridData gd = new GridData();
+ if (dataMap.containsKey(WCompositePart.FIXED_LAYOUT_WIDTH)) {
+ gd.widthHintProperty().set(Integer.parseInt(dataMap.get(WCompositePart.FIXED_LAYOUT_WIDTH)));
+ if (!dataMap.containsKey(WCompositePart.FIXED_LAYOUT_HEIGHT)) {
+ gd.grabExcessVerticalSpaceProperty().set(true);
+ gd.verticalAlignmentProperty().set(Alignment.FILL);
+ }
+ } else {
+ gd.horizontalAlignmentProperty().set(Alignment.FILL);
+ }
+
+ if (dataMap.containsKey(WCompositePart.FIXED_LAYOUT_HEIGHT)) {
+ gd.heightHintProperty().set(Integer.parseInt(dataMap.get(WCompositePart.FIXED_LAYOUT_HEIGHT)));
+ if (!dataMap.containsKey(WCompositePart.FIXED_LAYOUT_WIDTH)) {
+ gd.grabExcessHorizontalSpaceProperty().set(true);
+ gd.horizontalAlignmentProperty().set(Alignment.FILL);
+ }
+ } else {
+ gd.verticalAlignmentProperty().set(Alignment.FILL);
+ }
+
+ if (dataMap.containsKey(WCompositePart.FIXED_LAYOUT_GRAB_HORIZONTAL)) {
+ gd.grabExcessHorizontalSpaceProperty().set(Boolean.parseBoolean(dataMap.get(WCompositePart.FIXED_LAYOUT_GRAB_HORIZONTAL)));
+ gd.horizontalAlignmentProperty().set(Alignment.FILL);
+ }
+
+ if (dataMap.containsKey(WCompositePart.FIXED_LAYOUT_GRAB_VERTICAL)) {
+ gd.grabExcessVerticalSpaceProperty().set(Boolean.parseBoolean(dataMap.get(WCompositePart.FIXED_LAYOUT_GRAB_VERTICAL)));
+ gd.verticalAlignmentProperty().set(Alignment.FILL);
+ }
+
+ return gd;
+ }
@Override
- protected SplitPane getWidgetNode() {
+ public void addItem(WLayoutedWidget<MPartSashContainerElement> widget) {
+ Node n = (Node) widget.getStaticLayoutNode();
+
+ GridLayoutPane p = getWidget();
+ MCompositePart element = getDomElement();
+ if ( element != null && element.isHorizontal()) {
+ p.setNumColumns(p.getNumColumns() + 1);
+ }
+
+ MPartSashContainerElement domElement2 = widget.getDomElement();
+ if( domElement2 != null ) {
+ GridData gd = toGridData(domElement2.getPersistedState());
+ GridLayoutPane.setConstraint(n, gd);
+ }
+ p.getChildren().add(n);
+ }
+
+ @Override
+ public int getItemCount() {
+ return getWidget().getChildren().size();
+ }
+
+ @Override
+ public void addItems(List<WLayoutedWidget<MPartSashContainerElement>> list) {
+ List<Node> nodeList = new ArrayList<Node>();
+ GridLayoutPane p = getWidget();
+
+ for (WLayoutedWidget<MPartSashContainerElement> w : list) {
+ Node n = (Node) w.getStaticLayoutNode();
+
+ MPartSashContainerElement element = w.getDomElement();
+ if( element != null ) {
+ GridData gd = toGridData(element.getPersistedState());
+ GridLayoutPane.setConstraint(n, gd);
+ }
+ nodeList.add(n);
+ }
+
+ MCompositePart element = getDomElement();
+ if (element != null && element.isHorizontal()) {
+ p.setNumColumns(p.getNumColumns() + nodeList.size());
+ }
+
+ p.getChildren().addAll(nodeList);
+ }
+
+ @Override
+ public void addItems(int index, List<WLayoutedWidget<MPartSashContainerElement>> list) {
+ List<Node> nodeList = new ArrayList<Node>();
+ GridLayoutPane p = getWidget();
+
+ for (WLayoutedWidget<MPartSashContainerElement> w : list) {
+ Node n = (Node) w.getStaticLayoutNode();
+
+ MPartSashContainerElement element = w.getDomElement();
+ if( element != null ) {
+ GridData gd = toGridData(element.getPersistedState());
+ GridLayoutPane.setConstraint(n, gd);
+ }
+ nodeList.add(n);
+ }
+
+ MCompositePart element = getDomElement();
+ if (element != null && element.isHorizontal()) {
+ p.setNumColumns(p.getNumColumns() + nodeList.size());
+ }
+
+ p.getChildren().addAll(index, nodeList);
+ }
+
+ @Override
+ public void removeItem(WLayoutedWidget<MPartSashContainerElement> widget) {
+ Node n = (Node) widget.getStaticLayoutNode();
+ GridLayoutPane p = getWidget();
+ p.setNumColumns(p.getNumColumns() - 1);
+ p.getChildren().remove(n);
+ }
+
+ @Override
+ protected GridLayoutPane getWidgetNode() {
+ return getWidget();
+ }
+
+ @Override
+ protected GridLayoutPane createWidget() {
+ GridLayoutPane p = new GridLayoutPane();
+ p.setMarginWidth(0);
+ p.setMarginHeight(0);
+ p.setHorizontalSpacing(0);
+ p.setVerticalSpacing(0);
+ p.setNumColumns(0);
+ return p;
+ }
+
+ @Override
+ public void updateLayout() {
// TODO Auto-generated method stub
- return null;
+
+ }
+ }
+
+ static class WResizableSashImpl extends WLayoutedWidgetImpl<SplitPane, SplitPane, MCompositePart> implements WCompositePart<Node> {
+ private List<WLayoutedWidget<MPartSashContainerElement>> items = new ArrayList<WLayoutedWidget<MPartSashContainerElement>>();
+
+ ChangeListener<Number> listener = new ChangeListener<Number>() {
+ boolean queueing;
+
+ @Override
+ public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
+ if (!this.queueing) {
+ this.queueing = true;
+ Platform.runLater(new Runnable() {
+
+ @SuppressWarnings("unqualified-field-access")
+ @Override
+ public void run() {
+ recalcWeight();
+ queueing = false;
+ }
+ });
+ }
+ }
+ };
+
+ @Override
+ public void updateLayout() {
+ updateDividers();
+ }
+
+ void recalcWeight() {
+ @Nullable
+ MCompositePart domElement = getDomElement();
+ if( domElement != null ) {
+ BaseRenderer<?, ?> r = (BaseRenderer<?, ?>) domElement.getRenderer();
+ r.syncUIModifications(domElement, this::doRecalcWeight);
+ } else {
+ this.logger.error("The domain object should not be null at this point"); //$NON-NLS-1$
+ }
+ }
+
+ void doRecalcWeight() {
+ if (this.state != WidgetState.CREATED) {
+ return;
+ }
+
+ // FIXME We should not do recalcs when we are in teardown of the
+ // widget
+ double prev = 0;
+ int idx = 0;
+ // No items nothing to recalculate
+ if (this.items.isEmpty()) {
+ return;
+ }
+ for (double d : getWidget().getDividerPositions()) {
+ MPartSashContainerElement element = this.items.get(idx++).getDomElement();
+ if( element != null ) {
+ element.setContainerData((d - prev) * 10 + ""); //$NON-NLS-1$
+ }
+ prev = d;
+ }
+ MPartSashContainerElement element = this.items.get(this.items.size() - 1).getDomElement();
+ if( element != null ) {
+ element.setContainerData((1.0 - prev) * 10 + ""); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ protected void bindProperties(final SplitPane widget) {
+ super.bindProperties(widget);
+ widget.getDividers().addListener(new ListChangeListener<Divider>() {
+
+ @Override
+ public void onChanged(javafx.collections.ListChangeListener.Change<? extends Divider> c) {
+ while (c.next()) {
+ for (Divider d : c.getAddedSubList()) {
+ d.positionProperty().addListener(WResizableSashImpl.this.listener);
+ }
+
+ for (Divider d : c.getRemoved()) {
+ d.positionProperty().removeListener(WResizableSashImpl.this.listener);
+ }
+ }
+ }
+ });
+ for (Divider d : widget.getDividers()) {
+ d.positionProperty().addListener(this.listener);
+ }
}
@Override
protected SplitPane createWidget() {
- throw new UnsupportedOperationException();
+ SplitPane p = new SplitPane();
+ return p;
+ }
+
+ @Inject
+ void setOrientation(@Named(UIEvents.GenericTile.HORIZONTAL) boolean horizontal) {
+ getWidget().setOrientation(horizontal ? Orientation.HORIZONTAL : Orientation.VERTICAL);
+ }
+
+ @Override
+ protected SplitPane getWidgetNode() {
+ return getWidget();
+ }
+
+ @Override
+ public void addItem(WLayoutedWidget<MPartSashContainerElement> widget) {
+ SplitPane p = getWidget();
+ p.getItems().add((Node) widget.getStaticLayoutNode());
+ this.items.add(widget);
+ updateDividers();
+ }
+
+ @Override
+ public void addItems(int index, List<WLayoutedWidget<MPartSashContainerElement>> list) {
+ SplitPane p = getWidget();
+ List<Node> l = new ArrayList<Node>();
+ for (WLayoutedWidget<MPartSashContainerElement> i : list) {
+ l.add((Node) i.getStaticLayoutNode());
+ }
+ p.getItems().addAll(index, l);
+ this.items.addAll(index, list);
+ updateDividers();
+ }
+
+ @Override
+ public void addItems(List<WLayoutedWidget<MPartSashContainerElement>> list) {
+ SplitPane p = getWidget();
+ List<Node> l = new ArrayList<Node>();
+ for (WLayoutedWidget<MPartSashContainerElement> i : list) {
+ l.add((Node) i.getStaticLayoutNode());
+ }
+ p.getItems().addAll(l);
+ this.items.addAll(list);
+ updateDividers();
+ }
+
+ @Override
+ public void setWidgetState(WidgetState state) {
+ super.setWidgetState(state);
+ if (state == WidgetState.CREATED) {
+ updateDividers();
+ }
+ }
+
+ @Override
+ public void removeItem(WLayoutedWidget<MPartSashContainerElement> widget) {
+ SplitPane p = getWidget();
+ p.getItems().remove(widget.getStaticLayoutNode());
+ this.items.remove(widget);
+ updateDividers();
+ }
+
+ @Override
+ protected void doCleanup() {
+ super.doCleanup();
+ this.items.clear();
}
+ private void updateDividers() {
+ if (this.items.size() <= 1) {
+ return;
+ }
+
+ if (this.state != WidgetState.CREATED) {
+ return;
+ }
+
+ double total = 0;
+
+ for (WLayoutedWidget<MPartSashContainerElement> w : this.items) {
+ total += w.getWeight();
+ }
+
+ double[] deviders = new double[this.items.size() - 1];
+ for (int i = 0; i < this.items.size() - 1; i++) {
+ deviders[i] = (i == 0 ? 0 : deviders[i - 1]) + (this.items.get(i).getWeight() / total);
+ }
+
+ getWidget().setDividerPositions(deviders);
+ }
+
+ @Override
+ public int getItemCount() {
+ return getWidget().getItems().size();
+ }
}
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java
index 0a845882e..e934b1aec 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java
@@ -13,7 +13,6 @@ package org.eclipse.fx.ui.workbench.renderers.fx;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
-import javafx.scene.Parent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
@@ -36,6 +35,7 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WToolBar;
import org.eclipse.fx.ui.workbench.renderers.fx.internal.CustomContainerSupport;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.WLayoutedWidgetImpl;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* default renderer for {@link MPart}
@@ -80,15 +80,15 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
WPart<BorderPane, Node, Node> part = ((WPart<BorderPane, Node, Node>) element.getWidget());
if (part == null)
return;
- if( ! checkFocusControl((Node) part.getWidget()) ) {
+ if (!checkFocusControl((Node) part.getWidget())) {
Node node = (Node) part.getWidget();
- node.requestFocus();
+ node.requestFocus();
}
}
}
-
- public static boolean checkFocusControl(Node check) {
+
+ static boolean checkFocusControl(Node check) {
if (check.getScene() == null) {
return false;
}
@@ -124,6 +124,7 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
StackPane toolbarGroup;
Group menuGroup;
private WMenu<Node> viewMenuWidget;
+ private WToolBar<Node> viewToolbarWidget;
@Override
protected Pane createWidget() {
@@ -136,7 +137,7 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
public void handle(MouseEvent event) {
event.consume();
MPart domElement = getDomElement();
- if( domElement != null ) {
+ if (domElement != null) {
PartImpl.this.service.activate(domElement, true);
if (!checkFocusControl(getWidget()) && (domElement.getObject() != null)) {
// ContextInjectionFactory.invoke(domElement.getObject(),
@@ -145,7 +146,7 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
// p.requestFocus();
// }
p.requestFocus();
- }
+ }
}
}
});
@@ -259,6 +260,7 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
this.toolbarGroup.getChildren().clear();
this.dataArea.setTop(null);
this.dataArea.setBottom(null);
+ this.toolbarGroup = null;
}
} else {
initToolbarMenu();
@@ -277,6 +279,8 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
n.getStyleClass().add(CSS_CLASS_VIEW_TOOLBAR);
this.toolbarGroup.getChildren().setAll(n);
}
+
+ this.viewToolbarWidget = widget;
}
@Override
@@ -299,6 +303,11 @@ public class DefPartRenderer extends BasePartRenderer<Pane, Node, Node> {
public WMenu<Node> getMenu() {
return this.viewMenuWidget;
}
+
+ @Override
+ public @Nullable WToolBar<Node> getToolbar() {
+ return this.viewToolbarWidget;
+ }
}
static class HandleGroup extends Group {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPopupMenuRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPopupMenuRenderer.java
index d91bc256f..0c7b200a6 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPopupMenuRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefPopupMenuRenderer.java
@@ -24,6 +24,7 @@ import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu;
import org.eclipse.fx.ui.workbench.renderers.base.BasePopupMenuRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WMenuElement;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WPopupMenu;
+import org.eclipse.fx.ui.workbench.renderers.fx.DefMenuRenderer.MenuImpl;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.WWidgetImpl;
/**
@@ -38,6 +39,13 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
static class ContextMenuImpl extends WWidgetImpl<ContextMenu, MPopupMenu> implements WPopupMenu<ContextMenu> {
private ToggleGroup group;
Runnable showingCallback;
+ Runnable hidingCallback;
+ MenuItem item;
+
+ public ContextMenuImpl() {
+ this.item = new MenuItem("<empty>"); //$NON-NLS-1$
+ this.item.setDisable(true);
+ }
@Override
protected ContextMenu createWidget() {
@@ -49,6 +57,23 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
if (ContextMenuImpl.this.showingCallback != null) {
ContextMenuImpl.this.showingCallback.run();
}
+
+ if (getWidget().getItems().size() > 1) {
+ getWidget().getItems().remove(ContextMenuImpl.this.item);
+ }
+ }
+ });
+ m.setOnHiding(new EventHandler<WindowEvent>() {
+
+ @Override
+ public void handle(WindowEvent event) {
+ if (ContextMenuImpl.this.hidingCallback != null) {
+ ContextMenuImpl.this.hidingCallback.run();
+ }
+
+ if (getWidget().getItems().isEmpty()) {
+ getWidget().getItems().add(ContextMenuImpl.this.item);
+ }
}
});
return m;
@@ -58,6 +83,11 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
public void setShowingCallback(Runnable showingCallback) {
this.showingCallback = showingCallback;
}
+
+ @Override
+ public void setHidingCallback(Runnable hidingCallback) {
+ this.hidingCallback = hidingCallback;
+ }
@Override
public void addStyleClasses(List<String> classnames) {
@@ -86,6 +116,10 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
@Override
public void addElement(WMenuElement<MMenuElement> widget) {
+ if (getWidget().getItems().size() == 1) {
+ getWidget().getItems().remove(this.item);
+ }
+
if (widget.getWidget() instanceof Toggle) {
if (this.group == null) {
this.group = new ToggleGroup();
@@ -99,6 +133,10 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
@Override
public void addElement(int idx, WMenuElement<MMenuElement> widget) {
+ if (getWidget().getItems().size() == 1) {
+ getWidget().getItems().remove(this.item);
+ }
+
if (widget.getWidget() instanceof Toggle) {
if (this.group == null) {
this.group = new ToggleGroup();
@@ -116,6 +154,9 @@ public class DefPopupMenuRenderer extends BasePopupMenuRenderer<ContextMenu> {
((Toggle) widget.getWidget()).setToggleGroup(null);
}
getWidget().getItems().remove(widget.getWidget());
+ if (getWidget().getItems().isEmpty()) {
+ getWidget().getItems().add(this.item);
+ }
}
@Override
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefSashRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefSashRenderer.java
index 9e92975b4..b3b9732ae 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefSashRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefSashRenderer.java
@@ -37,6 +37,7 @@ import org.eclipse.fx.ui.workbench.renderers.base.BaseSashRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WLayoutedWidget;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WSash;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.WLayoutedWidgetImpl;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
/**
@@ -55,7 +56,7 @@ public class DefSashRenderer extends BaseSashRenderer<Node> {
static class WFixedSashImpl extends WLayoutedWidgetImpl<GridLayoutPane, Node, MPartSashContainer> implements WSash<Node> {
- private static GridData toGridData(Map<String, String> dataMap) {
+ private static @NonNull GridData toGridData(Map<String, String> dataMap) {
GridData gd = new GridData();
if (dataMap.containsKey(WSash.FIXED_LAYOUT_WIDTH)) {
gd.widthHintProperty().set(Integer.parseInt(dataMap.get(WSash.FIXED_LAYOUT_WIDTH)));
@@ -90,6 +91,14 @@ public class DefSashRenderer extends BaseSashRenderer<Node> {
return gd;
}
+
+ private final @NonNull MPartSashContainer mPartSashContainer;
+
+ @Inject
+ public WFixedSashImpl(@NonNull @Named(BaseRenderer.CONTEXT_DOM_ELEMENT) MPartSashContainer mPartSashContainer) {
+ this.mPartSashContainer = mPartSashContainer;
+ }
+
@Override
public void addItem(WLayoutedWidget<MPartSashContainerElement> widget) {
Node n = (Node) widget.getStaticLayoutNode();
@@ -165,7 +174,11 @@ public class DefSashRenderer extends BaseSashRenderer<Node> {
public void removeItem(WLayoutedWidget<MPartSashContainerElement> widget) {
Node n = (Node) widget.getStaticLayoutNode();
GridLayoutPane p = getWidget();
- p.setNumColumns(p.getNumColumns() - 1);
+ MPartSashContainer domElement = getDomElement();
+
+ if( domElement != null && domElement.isHorizontal() ) {
+ p.setNumColumns(p.getNumColumns() - 1);
+ }
p.getChildren().remove(n);
}
@@ -181,6 +194,7 @@ public class DefSashRenderer extends BaseSashRenderer<Node> {
p.setMarginHeight(0);
p.setHorizontalSpacing(0);
p.setVerticalSpacing(0);
+ p.setNumColumns(this.mPartSashContainer.isHorizontal() ? 0 : 1);
return p;
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefStackRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefStackRenderer.java
index 161eebe51..e46b6aaff 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefStackRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefStackRenderer.java
@@ -38,6 +38,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory;
import org.eclipse.fx.ui.services.resources.GraphicsLoader;
import org.eclipse.fx.ui.workbench.fx.EMFUri;
import org.eclipse.fx.ui.workbench.renderers.base.BaseRenderer;
@@ -47,7 +48,6 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WCallback;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem;
import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDSupport;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.PaginationItem;
import org.eclipse.fx.ui.workbench.renderers.fx.widget.WLayoutedWidgetImpl;
import org.eclipse.jdt.annotation.NonNull;
@@ -73,7 +73,6 @@ public class DefStackRenderer extends BaseStackRenderer<Node, Object, Node> {
WCallback<WStackItem<Object, Node>, Void> mouseSelectedItemCallback;
WCallback<WStackItem<Object, Node>, Void> keySelectedItemCallback;
WCallback<@NonNull DragData, @NonNull Boolean> dragStartCallback;
- WCallback<@NonNull DropData, @Nullable Void> droppedCallback;
// private WCallback<WMinMaxState, Void> minMaxCallback;
// private MinMaxGroup minMaxGroup;
@@ -161,107 +160,18 @@ public class DefStackRenderer extends BaseStackRenderer<Node, Object, Node> {
protected TabPane createWidget() {
DnDSupport dnd = new DnDSupport(
(param) -> StackWidgetImpl.this.dragStartCallback,
- (param) -> StackWidgetImpl.this.droppedCallback,
+ (param) -> StackWidgetImpl.this.getDropCallback(),
StackWidgetImpl.this.dndFeedback,
this.domainElement);
- DnDTabPane p = new DnDTabPane();
- p.addEventHandler(DnDTabPane.DND_TABPANE_DRAG_START, dnd::handleDragStart);
- p.addEventHandler(DnDTabPane.DND_TABPANE_DROPPED, dnd::handleDropped);
- p.addEventHandler(DnDTabPane.DND_TABPANE_DRAG_FEEDBACK, dnd::handleFeedback);
- p.addEventHandler(DnDTabPane.DND_TABPANE_DRAG_FINISHED, dnd::handleFinished);
+ TabPane p = DndTabPaneFactory.createDndTabPane((s) -> {
+ s.setStartFunction(dnd::handleDragStart);
+ s.setDropConsumer(dnd::handleDropped);
+ s.setFeedbackConsumer(dnd::handleFeedback);
+ s.setDragFinishedConsumer(dnd::handleFinished);
+ s.setClipboardDataFunction(dnd::clipboardDataFunction);
+ });
-// TabPane p = new TabPane() {
-// @Override
-// protected Skin<?> createDefaultSkin() {
-// Skin<?> skin = super.createDefaultSkin();
-// DnDSupporter.hookTabPane(skin, getDomElement(), StackWidgetImpl.this.dndFeedback,
-// (param) -> StackWidgetImpl.this.dragStartCallback,
-// (param) -> StackWidgetImpl.this.droppedCallback);
-// return skin;
-// }
-// };
-
- // ContextMenu m = new ContextMenu();
- //
- // {
- // MenuItem item = new MenuItem("Detach");
- // item.setOnAction(new EventHandler<ActionEvent>() {
- //
- // @Override
- // public void handle(ActionEvent event) {
- // DetachView d = new DetachView();
- // d.detach((MPart) getDomElement().getSelectedElement(),
- // modelService);
- // }
- // });
- // m.getItems().add(item);
- // }
- //
- // {
- // MenuItem item = new MenuItem("Move To First");
- // item.setOnAction(new EventHandler<ActionEvent>() {
- //
- // @Override
- // public void handle(ActionEvent event) {
- // MoveToFirst d = new MoveToFirst();
- // d.move((MPart) getDomElement().getSelectedElement());
- // }
- // });
- // m.getItems().add(item);
- // }
- //
- // {
- // MenuItem item = new MenuItem("Move To Last");
- // item.setOnAction(new EventHandler<ActionEvent>() {
- //
- // @Override
- // public void handle(ActionEvent event) {
- // MoveToLast d = new MoveToLast();
- // d.move((MPart) getDomElement().getSelectedElement());
- // }
- // });
- // m.getItems().add(item);
- // }
- //
- // {
- // MenuItem item = new MenuItem("Pin To Bottom");
- // item.setOnAction(new EventHandler<ActionEvent>() {
- //
- // @Override
- // public void handle(ActionEvent event) {
- // PinToBottom d = new PinToBottom();
- // d.pin((MPart) getDomElement().getSelectedElement());
- // }
- // });
- // m.getItems().add(item);
- // }
- //
- // p.setContextMenu(m);
- // (FXTabPane)p.minMaxStateProperty().addListener(new
- // ChangeListener<MinMaxState>() {
- //
- // @Override
- // public void changed(ObservableValue<? extends MinMaxState>
- // observable, MinMaxState oldValue, MinMaxState newValue) {
- // if( minMaxCallback != null ) {
- // switch (newValue) {
- // case RESTORED:
- // minMaxCallback.call(WMinMaxState.RESTORED);
- // break;
- // case MAXIMIZED:
- // minMaxCallback.call(WMinMaxState.MAXIMIZED);
- // break;
- // case MINIMIZED:
- // minMaxCallback.call(WMinMaxState.MINIMIZED);
- // break;
- // case NONE:
- // // Nothing to do
- // break;
- // }
- // }
- // }
- // });
p.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override
@@ -404,13 +314,6 @@ public class DefStackRenderer extends BaseStackRenderer<Node, Object, Node> {
public void setDragStartCallback(@NonNull WCallback<@NonNull DragData, @NonNull Boolean> dragStackCallback) {
this.dragStartCallback = dragStackCallback;
}
-
- @Override
- public void setDragDroppedCallback(@NonNull WCallback<@NonNull DropData, @Nullable Void> droppedCallback) {
- this.droppedCallback = droppedCallback;
- }
-
-
}
static class StackItemImpl implements WStackItem<Object, Node> {
@@ -660,12 +563,6 @@ public class DefStackRenderer extends BaseStackRenderer<Node, Object, Node> {
public void setDragStartCallback(@NonNull WCallback<@NonNull DragData, @NonNull Boolean> dragStackCallback) {
// not implemented yet
}
-
- @Override
- public void setDragDroppedCallback(@NonNull WCallback<@NonNull DropData, @Nullable Void> callback) {
- // not implemented yet
- }
-
}
static class PagninationItemImpl implements WStackItem<Object, Node> {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
index c05eaddd6..682f5455b 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
@@ -185,6 +185,7 @@ public class DefWindowRenderer extends BaseWindowRenderer<Stage> {
private boolean fullscreen;
@Inject
+ @NonNull
IEclipseContext context;
IEclipseContext modelContext;
@@ -524,6 +525,7 @@ public class DefWindowRenderer extends BaseWindowRenderer<Stage> {
sb.append(uri.segment(i));
}
+ @SuppressWarnings("null")
InjectingFXMLLoader<Node> loader = InjectingFXMLLoader.create(this.context, b, sb.toString());
ResourceBundle resourceBundle = this.localizationService.getLocalization(b, Locale.getDefault().toString());
if( resourceBundle != null ) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWorkbenchRendererFactory.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWorkbenchRendererFactory.java
index 9aa689ae8..f4f653b2d 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWorkbenchRendererFactory.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWorkbenchRendererFactory.java
@@ -14,6 +14,7 @@ import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.fx.ui.workbench.renderers.base.BaseAreaRenderer;
+import org.eclipse.fx.ui.workbench.renderers.base.BaseCompositePartRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.BaseMenuBarRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.BaseMenuItemRenderer;
import org.eclipse.fx.ui.workbench.renderers.base.BaseMenuRenderer;
@@ -147,7 +148,12 @@ public class DefWorkbenchRendererFactory extends BaseWorkbenchRendererFactory {
}
@Override
- protected Class<? extends BasePartMenuRenderer<?>> getPartMenuRenderer() {
+ protected Class<? extends BasePartMenuRenderer<?>> getPartMenuRendererClass() {
return DefPartMenuRenderer.class;
}
+
+ @Override
+ protected Class<? extends BaseCompositePartRenderer<?>> getCompositePartRendererClass() {
+ return DefCompositePartRenderer.class;
+ }
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/CustomContainerSupport.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/CustomContainerSupport.java
index 994b8f47a..f2fdb3a1f 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/CustomContainerSupport.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/CustomContainerSupport.java
@@ -27,7 +27,6 @@ import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.ui.panes.FillLayoutPane;
import org.eclipse.fx.ui.panes.GridLayoutPane;
import org.eclipse.fx.ui.panes.RowLayoutPane;
-import org.eclipse.fx.ui.panes.SashLayoutPane;
import org.eclipse.fx.ui.workbench.renderers.base.BaseRenderer;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -47,7 +46,6 @@ public class CustomContainerSupport {
private static final String WIDGET_EFX_FILL_TAG = "Container:FillLayoutPane"; //$NON-NLS-1$
private static final String WIDGET_EFX_GRID_TAG = "Container:GridLayoutPane"; //$NON-NLS-1$
private static final String WIDGET_EFX_ROW_TAG = "Container:RowLayoutPane"; //$NON-NLS-1$
- private static final String WIDGET_EFX_SASH_TAG = "Container:SashLayoutPane"; //$NON-NLS-1$
private static final String WIDGET_URLPANE_TAG = "Container:UrlPane:"; //$NON-NLS-1$
@@ -82,8 +80,6 @@ public class CustomContainerSupport {
tmp = new GridLayoutPane();
} else if (tags.contains(WIDGET_EFX_ROW_TAG)) {
tmp = new RowLayoutPane();
- } else if (tags.contains(WIDGET_EFX_SASH_TAG)) {
- tmp = new SashLayoutPane();
}
if (tmp == null) {
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DefaultDnDFeedback.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DefaultDnDFeedback.java
index b81b5c721..76c085635 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DefaultDnDFeedback.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DefaultDnDFeedback.java
@@ -89,6 +89,7 @@ public class DefaultDnDFeedback implements DnDFeedbackService {
};
}
+ @SuppressWarnings("null")
private static MarkerFeedback handleMove(Pane layoutNode, DnDFeedbackData data) {
TabOutlineMarker marker = null;
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDSupport.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDSupport.java
index c5f144df4..2c2cc130e 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDSupport.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDSupport.java
@@ -10,11 +10,18 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.renderers.fx.internal;
+import javafx.scene.control.Tab;
+
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.osgi.util.LoggerCreator;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.DropType;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.DroppedData;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.FeedbackData;
import org.eclipse.fx.ui.workbench.renderers.base.services.DnDFeedbackService;
import org.eclipse.fx.ui.workbench.renderers.base.services.DnDFeedbackService.DnDFeedbackData;
import org.eclipse.fx.ui.workbench.renderers.base.services.DnDFeedbackService.MarkerFeedback;
@@ -22,11 +29,6 @@ import org.eclipse.fx.ui.workbench.renderers.base.widget.WCallback;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragSourceWidget.DragData;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropData;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane.DropType;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane.TabPaneDragFinishedEvent;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane.TabPaneDragStartEvent;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane.TabPaneDroppedEvent;
-import org.eclipse.fx.ui.workbench.renderers.fx.internal.DnDTabPane.TabPaneFeedbackDragEvent;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
@@ -73,32 +75,55 @@ public class DnDSupport {
}
/**
+ * Function to serialize tab
+ *
+ * @param tab
+ * the tab
+ * @return the tab
+ */
+ @SuppressWarnings({ "static-method" })
+ public @NonNull String clipboardDataFunction(@NonNull Tab tab) {
+ MStackElement domElement = ((WStackItem<?, ?>) tab.getUserData()).getDomElement();
+ String rv = null;
+ if (domElement != null) {
+ EObject eo = (EObject) domElement;
+ rv = ((XMIResource) eo.eResource()).getID(eo);
+ }
+ if( rv != null ) {
+ return rv;
+ }
+ return System.identityHashCode(tab) + ""; //$NON-NLS-1$
+ }
+
+ /**
* Handle the drag start
*
- * @param event
- * the event
+ * @param tab
+ * the tab
+ * @return <code>true</code> if drag can start
+ *
*/
- public void handleDragStart(TabPaneDragStartEvent event) {
+ @SuppressWarnings("null")
+ public @NonNull Boolean handleDragStart(@NonNull Tab tab) {
WCallback<DragData, Boolean> dragStartCallback = this.dragStartCallbackProvider.call(null);
if (dragStartCallback != null) {
- WStackItem<?, ?> item = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) event.tab.getUserData();
+ WStackItem<?, ?> item = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) tab.getUserData();
MStackElement itemElement = item.getDomElement();
if (itemElement == null) {
- return;
+ return Boolean.FALSE;
}
MPartStack itemContainer = (MPartStack) (MUIElement) itemElement.getParent();
if (itemContainer != null) {
DragData dragData = new DragData(itemContainer, itemElement);
if (!dragStartCallback.call(dragData).booleanValue()) {
- event.consume();
+ return Boolean.TRUE;
}
} else {
LOGGER.error("Stack element '" + itemElement + "' has no container"); //$NON-NLS-1$//$NON-NLS-2$
}
- } else {
- event.consume();
}
+ return Boolean.TRUE;
}
/**
@@ -108,14 +133,14 @@ public class DnDSupport {
* the event
*/
@SuppressWarnings("all")
- public void handleDropped(TabPaneDroppedEvent event) {
+ public void handleDropped(DroppedData data) {
WCallback<DropData, Void> call = this.dropCallbackProvider.call(null);
if (call != null) {
- WStackItem<?, ?> referenceItem = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) event.targetTab.getUserData();
- WStackItem<?, ?> sourceItem = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) event.sourceTab.getUserData();
+ WStackItem<?, ?> referenceItem = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) data.targetTab.getUserData();
+ WStackItem<?, ?> sourceItem = (org.eclipse.fx.ui.workbench.renderers.base.widget.WStack.WStackItem<?, ?>) data.draggedTab.getUserData();
MStackElement domElement = sourceItem.getDomElement();
if (domElement != null) {
- call.call(new DropData(referenceItem.getDomElement(), domElement, event.type == DropType.AFTER ? org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.AFTER : org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.BEFORE));
+ call.call(new DropData(referenceItem.getDomElement(), domElement, data.dropType == DropType.AFTER ? org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.AFTER : org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.BEFORE));
} else {
LOGGER.error("Source item '" + sourceItem + "' has no dom element attached"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -125,36 +150,38 @@ public class DnDSupport {
/**
* Handle the feedback event
*
- * @param event
- * the event
+ * @param data
+ * the data
+ *
*/
- public void handleFeedback(TabPaneFeedbackDragEvent event) {
- if (event.dropType == DropType.NONE) {
+ public void handleFeedback(FeedbackData data) {
+ if (data.dropType == DropType.NONE) {
cleanup();
return;
}
- MStackElement reference = ((WStackItem<?, ?>) event.targetTab.getUserData()).getDomElement();
- MStackElement sourceReference = ((WStackItem<?, ?>) event.sourceTab.getUserData()).getDomElement();
+ MStackElement reference = ((WStackItem<?, ?>) data.targetTab.getUserData()).getDomElement();
+ MStackElement sourceReference = ((WStackItem<?, ?>) data.draggedTab.getUserData()).getDomElement();
- DnDFeedbackData data = new DnDFeedbackData(reference, sourceReference, event.dropType == DropType.AFTER ? org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.AFTER : org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.BEFORE, this.stack,
- new DnDFeedbackService.Region(event.bounds.getMinX(), event.bounds.getMinY(), event.bounds.getWidth(), event.bounds.getHeight()));
+ DnDFeedbackData dndData = new DnDFeedbackData(reference, sourceReference, data.dropType == DropType.AFTER ? org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.AFTER : org.eclipse.fx.ui.workbench.renderers.base.widget.WDragTargetWidget.DropType.BEFORE, this.stack,
+ new DnDFeedbackService.Region(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()));
MarkerFeedback f = CURRENT_FEEDBACK;
if (f == null || !f.equals(data)) {
cleanup();
- CURRENT_FEEDBACK = this.feedbackService.showFeedback(data);
+ CURRENT_FEEDBACK = this.feedbackService.showFeedback(dndData);
}
}
/**
* Handle the finish event
*
- * @param event
- * the event
+ * @param tab
+ * the tab
+ *
*/
@SuppressWarnings("static-method")
- public void handleFinished(TabPaneDragFinishedEvent event) {
+ public void handleFinished(Tab tab) {
cleanup();
}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDTabPane.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDTabPane.java
deleted file mode 100644
index c8c1004e3..000000000
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal/DnDTabPane.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 BestSolution.at 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:
- * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
- *******************************************************************************/
-package org.eclipse.fx.ui.workbench.renderers.fx.internal;
-
-import java.lang.reflect.Field;
-
-import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.css.StyleOrigin;
-import javafx.css.StyleableProperty;
-import javafx.event.Event;
-import javafx.event.EventHandler;
-import javafx.event.EventType;
-import javafx.geometry.Bounds;
-import javafx.scene.Node;
-import javafx.scene.SnapshotParameters;
-import javafx.scene.control.Skin;
-import javafx.scene.control.Tab;
-import javafx.scene.control.TabPane;
-import javafx.scene.image.PixelReader;
-import javafx.scene.image.PixelWriter;
-import javafx.scene.image.WritableImage;
-import javafx.scene.input.ClipboardContent;
-import javafx.scene.input.DataFormat;
-import javafx.scene.input.DragEvent;
-import javafx.scene.input.Dragboard;
-import javafx.scene.input.MouseEvent;
-import javafx.scene.input.TransferMode;
-import javafx.scene.layout.Pane;
-import javafx.scene.layout.StackPane;
-import javafx.scene.paint.Color;
-
-@SuppressWarnings("javadoc")
-public class DnDTabPane extends TabPane {
- private static Tab DRAGGED_TAB;
- private static final DataFormat TAB_MOVE = new DataFormat("DnDTabPane:tabMove"); //$NON-NLS-1$
-
-
- public static final EventType<TabPaneDragStartEvent> DND_TABPANE_DRAG_START = new EventType<> (Event.ANY, "DND_TABPANE_DRAG_START"); //$NON-NLS-1$
- public static final EventType<TabPaneDroppedEvent> DND_TABPANE_DROPPED = new EventType<> (Event.ANY, "DND_TABPANE_DROPPED"); //$NON-NLS-1$
- public static final EventType<TabPaneDragFinishedEvent> DND_TABPANE_DRAG_FINISHED = new EventType<> (Event.ANY, "DND_TABPANE_DRAG_FINISHED"); //$NON-NLS-1$
- public static final EventType<TabPaneFeedbackDragEvent> DND_TABPANE_DRAG_FEEDBACK = new EventType<> (Event.ANY, "DND_TABPANE_DRAG_FEEDBACK"); //$NON-NLS-1$
-
- private Object noneEnum;
- private StyleableProperty<Object> openAnimation;
- private StyleableProperty<Object> closeAnimation;
-
- public static class TabPaneDragStartEvent extends Event {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public final Tab tab;
-
- public TabPaneDragStartEvent(TabPane pane, Tab tab) {
- super(pane, pane, DND_TABPANE_DRAG_START);
- this.tab = tab;
- }
- }
-
- public static class TabPaneDragFinishedEvent extends Event {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public final Tab tab;
-
- public TabPaneDragFinishedEvent(TabPane pane, Tab tab) {
- super(pane, pane, DND_TABPANE_DRAG_FINISHED);
- this.tab = tab;
- }
- }
-
- public static class TabPaneDroppedEvent extends Event {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public final Tab sourceTab;
-
- public final Tab targetTab;
-
- public final DropType type;
-
- public TabPaneDroppedEvent(TabPane pane, Tab sourceTab, Tab targetTab, DropType type) {
- super(pane, pane, DND_TABPANE_DROPPED);
- this.sourceTab = sourceTab;
- this.targetTab = targetTab;
- this.type = type;
- }
- }
-
- public static class TabPaneFeedbackDragEvent extends Event {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public final Tab sourceTab;
-
- public final Tab targetTab;
-
- public final DropType dropType;
-
- public final Bounds bounds;
-
- public TabPaneFeedbackDragEvent(TabPane pane, Tab sourceTab, Tab targetTab, Bounds bounds, DropType dropType) {
- super(pane, pane, DND_TABPANE_DRAG_FEEDBACK);
- this.sourceTab = sourceTab;
- this.targetTab = targetTab;
- this.dropType = dropType;
- this.bounds = bounds;
- }
- }
-
- public enum DropType {
- NONE,
- BEFORE,
- AFTER
- }
-
- private BooleanProperty dndEnabled = new SimpleBooleanProperty(this, "dndEnabled", true); //$NON-NLS-1$
-
-
- @Override
- protected Skin<?> createDefaultSkin() {
- Skin<?> skin = super.createDefaultSkin();
- hookTabFolderSkin(skin);
- return skin;
- }
-
- @SuppressWarnings("unchecked")
- private void hookTabFolderSkin(Skin<?> skin) {
- try {
- Field f_tabHeaderArea = skin.getClass().getDeclaredField("tabHeaderArea"); //$NON-NLS-1$
- f_tabHeaderArea.setAccessible(true);
-
- Pane tabHeaderArea = (StackPane) f_tabHeaderArea.get(skin);
-
- Field f_headersRegion = tabHeaderArea.getClass().getDeclaredField("headersRegion"); //$NON-NLS-1$
- f_headersRegion.setAccessible(true);
-
- Pane headersRegion = (StackPane) f_headersRegion.get(tabHeaderArea);
- EventHandler<MouseEvent> handler = this::tabPane_handleDragStart;
- EventHandler<DragEvent> handlerFinished = this::tabPane_handleDragDone;
-
- for( Node tabHeaderSkin : headersRegion.getChildren() ) {
- tabHeaderSkin.addEventHandler(MouseEvent.DRAG_DETECTED, handler);
- tabHeaderSkin.addEventHandler(DragEvent.DRAG_DONE, handlerFinished);
- }
-
- headersRegion.getChildren().addListener((javafx.collections.ListChangeListener.Change<? extends Node> change) -> {
- while (change.next()) {
- if (change.wasRemoved()) {
- change.getRemoved().forEach((e) -> e.removeEventHandler(MouseEvent.DRAG_DETECTED, handler));
- change.getRemoved().forEach((e) -> e.removeEventHandler(DragEvent.DRAG_DONE, handlerFinished));
- }
- if( change.wasAdded() ) {
- change.getAddedSubList().forEach((e) -> e.addEventHandler(MouseEvent.DRAG_DETECTED, handler));
- change.getRemoved().forEach((e) -> e.addEventHandler(DragEvent.DRAG_DONE, handlerFinished));
- }
- }
- });
-
- tabHeaderArea.addEventHandler(DragEvent.DRAG_OVER, (e) -> tabPane_handleDragOver(tabHeaderArea, headersRegion, e));
- tabHeaderArea.addEventHandler(DragEvent.DRAG_DROPPED, (e) -> tabPane_handleDragDropped(tabHeaderArea, headersRegion, e));
- tabHeaderArea.addEventHandler(DragEvent.DRAG_EXITED, this::tabPane_handleDragDone);
-
- Field field = skin.getClass().getDeclaredField("openTabAnimation"); //$NON-NLS-1$
- field.setAccessible(true);
- this.openAnimation = (StyleableProperty<Object>) field.get(skin);
-
- field = skin.getClass().getDeclaredField("closeTabAnimation"); //$NON-NLS-1$
- field.setAccessible(true);
- this.closeAnimation = (StyleableProperty<Object>) field.get(skin);
-
- for( Class<?> cl : skin.getClass().getDeclaredClasses() ) {
- if( "TabAnimation".equals(cl.getSimpleName()) ) {
- for( Enum<?> enumConstant : (Enum<?>[]) cl.getEnumConstants()){
- if( "NONE".equals(enumConstant.name())) {
- this.noneEnum = enumConstant;
- break;
- }
- }
- break;
- }
-
- }
- } catch (Throwable t) {
-// // TODO Auto-generated catch block
- t.printStackTrace();
- }
- }
-
- void tabPane_handleDragStart(MouseEvent event) {
- if( this.dndEnabled.get() ) {
- try {
- Field f_tab = event.getSource().getClass().getDeclaredField("tab"); //$NON-NLS-1$
- f_tab.setAccessible(true);
- Tab t = (Tab) f_tab.get(event.getSource());
-
- TabPaneDragStartEvent dndStartEvent = new TabPaneDragStartEvent(this,t);
- Event.fireEvent(this, dndStartEvent);
-
- if( ! dndStartEvent.isConsumed() ) {
- DRAGGED_TAB = t;
- Node node = (Node)event.getSource();
- Dragboard db = node.startDragAndDrop(TransferMode.MOVE);
-
- WritableImage snapShot = node.snapshot(new SnapshotParameters(), null);
- PixelReader reader = snapShot.getPixelReader();
- int padX = 10;
- int padY = 10;
- int width = (int)snapShot.getWidth();
- int height = (int)snapShot.getHeight();
- WritableImage image = new WritableImage(width+padX,height+padY);
- PixelWriter writer = image.getPixelWriter();
-
- int h = 0;
- int v = 0;
- while( h < width+padX ) {
- v = 0;
- while( v < height+padY ) {
- if( h >= padX && h <= width + padX && v >= padY && v <= height + padY ) {
- writer.setColor(h, v, reader.getColor(h - padX, v - padY));
- } else {
- writer.setColor(h, v, Color.TRANSPARENT);
- }
-
- v++;
- }
- h++;
- }
-
- db.setDragView(image, image.getWidth(), image.getHeight()*-1);
-
- ClipboardContent content = new ClipboardContent();
- content.put(TAB_MOVE, Boolean.TRUE);
- db.setContent(content);
- }
- } catch(Throwable t) {
-// // TODO Auto-generated catch block
- t.printStackTrace();
- }
- }
- }
-
- void tabPane_handleDragOver(Pane tabHeaderArea, Pane headersRegion, DragEvent event) {
- if( DRAGGED_TAB == null ) {
- return;
- }
-
- double x = event.getX() - headersRegion.getBoundsInParent().getMinX();
-
- Node referenceNode = null;
- DropType type = DropType.AFTER;
- for( Node n : headersRegion.getChildren() ) {
- Bounds b = n.getBoundsInParent();
- if( b.getMaxX() > x ) {
- if( b.getMinX() + b.getWidth()/2 > x ) {
- referenceNode = n;
- type = DropType.BEFORE;
- } else {
- referenceNode = n;
- type = DropType.AFTER;
- }
- break;
- }
- }
-
- if( referenceNode == null && headersRegion.getChildren().size() > 0 ) {
- referenceNode = headersRegion.getChildren().get(headersRegion.getChildren().size()-1);
- type = DropType.AFTER;
- }
-
- if( referenceNode != null ) {
- try {
- Field field = referenceNode.getClass().getDeclaredField("tab"); //$NON-NLS-1$
- field.setAccessible(true);
- Tab tab = (Tab) field.get(referenceNode);
-
- boolean noMove = false;
- if( tab == DRAGGED_TAB ) {
- noMove = true;
- } else if( type == DropType.BEFORE ) {
- int idx = getTabs().indexOf(tab);
- if( idx > 0 ) {
- if( getTabs().get(idx-1) == DRAGGED_TAB ) {
- noMove = true;
- }
- }
- } else {
- int idx = getTabs().indexOf(tab);
-
- if( idx + 1 < getTabs().size() ) {
- if( getTabs().get(idx+1) == DRAGGED_TAB ) {
- noMove = true;
- }
- }
- }
-
- if( noMove ) {
- TabPaneFeedbackDragEvent feedbackEvent = new TabPaneFeedbackDragEvent(this, DRAGGED_TAB, null, null, DropType.NONE);
- Event.fireEvent(this, feedbackEvent);
- return;
- }
-
- Bounds b = referenceNode.getBoundsInLocal();
- b = referenceNode.localToScene(b);
- b = this.sceneToLocal(b);
-
- TabPaneFeedbackDragEvent feedbackEvent = new TabPaneFeedbackDragEvent(this, DRAGGED_TAB, tab, b, type);
- Event.fireEvent(this, feedbackEvent);
- } catch (Throwable e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- event.acceptTransferModes(TransferMode.MOVE);
- event.consume();
- } else {
- TabPaneFeedbackDragEvent feedbackEvent = new TabPaneFeedbackDragEvent(this, DRAGGED_TAB, null, null, DropType.NONE);
- Event.fireEvent(this, feedbackEvent);
- }
- }
-
- void tabPane_handleDragDropped(Pane tabHeaderArea, Pane headersRegion, DragEvent event) {
- if( DRAGGED_TAB == null ) {
- return;
- }
-
- double x = event.getX() - headersRegion.getBoundsInParent().getMinX();
-
- Node referenceNode = null;
- DropType type = DropType.AFTER;
- for( Node n : headersRegion.getChildren() ) {
- Bounds b = n.getBoundsInParent();
- if( b.getMaxX() > x ) {
- if( b.getMinX() + b.getWidth()/2 > x ) {
- referenceNode = n;
- type = DropType.BEFORE;
- } else {
- referenceNode = n;
- type = DropType.AFTER;
- }
- break;
- }
- }
-
- if( referenceNode == null && headersRegion.getChildren().size() > 0 ) {
- referenceNode = headersRegion.getChildren().get(headersRegion.getChildren().size()-1);
- type = DropType.AFTER;
- }
-
- if( referenceNode != null ) {
- try {
- Field field = referenceNode.getClass().getDeclaredField("tab"); //$NON-NLS-1$
- field.setAccessible(true);
- Tab tab = (Tab) field.get(referenceNode);
-
- boolean noMove = false;
- if( tab == DRAGGED_TAB ) {
- noMove = true;
- } else if( type == DropType.BEFORE ) {
- int idx = getTabs().indexOf(tab);
- if( idx > 0 ) {
- if( getTabs().get(idx-1) == DRAGGED_TAB ) {
- noMove = true;
- }
- }
- } else {
- int idx = getTabs().indexOf(tab);
-
- if( idx + 1 < getTabs().size() ) {
- if( getTabs().get(idx+1) == DRAGGED_TAB ) {
- noMove = true;
- }
- }
- }
-
-
- if( ! noMove ) {
- StyleOrigin openOrigin = openAnimation.getStyleOrigin();
- StyleOrigin closeOrigin = closeAnimation.getStyleOrigin();
- Object openValue = openAnimation.getValue();
- Object closeValue = closeAnimation.getValue();
- try {
- openAnimation.setValue(noneEnum);
- closeAnimation.setValue(noneEnum);
- TabPaneDroppedEvent dropped = new TabPaneDroppedEvent(this, DRAGGED_TAB, tab, type);
- Event.fireEvent(this, dropped);
- event.setDropCompleted(true);
- } finally {
- openAnimation.applyStyle(openOrigin, openValue);
- closeAnimation.applyStyle(closeOrigin, closeValue);
- }
-
- } else {
- event.setDropCompleted(false);
- }
- } catch (Throwable e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- event.consume();
- }
- }
-
- void tabPane_handleDragDone(DragEvent event) {
- if( DRAGGED_TAB == null ) {
- return;
- }
-
- TabPaneDragFinishedEvent dndStartEvent = new TabPaneDragFinishedEvent(this,DRAGGED_TAB);
- Event.fireEvent(this, dndStartEvent);
- }
-}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/widget/WLayoutedWidgetImpl.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/widget/WLayoutedWidgetImpl.java
index 822ccb809..ef0a024a8 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/widget/WLayoutedWidgetImpl.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/widget/WLayoutedWidgetImpl.java
@@ -12,7 +12,11 @@ package org.eclipse.fx.ui.workbench.renderers.fx.widget;
import java.util.List;
+import javafx.geometry.BoundingBox;
+import javafx.geometry.Bounds;
import javafx.scene.Node;
+import javafx.scene.input.DragEvent;
+import javafx.scene.input.TransferMode;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
@@ -20,12 +24,22 @@ import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.MElementContainer;
+import org.eclipse.e4.ui.model.application.ui.MGenericTile;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.fx.core.log.Log;
import org.eclipse.fx.core.log.Logger;
+import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory;
+import org.eclipse.fx.ui.workbench.renderers.base.services.DnDFeedbackService;
+import org.eclipse.fx.ui.workbench.renderers.base.widget.WCallback;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WLayoutedWidget;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
/**
* Base implementation for all {@link WLayoutedWidget} implementations
@@ -41,7 +55,11 @@ import org.eclipse.jdt.annotation.NonNull;
public abstract class WLayoutedWidgetImpl<N, NN extends Node, M extends MUIElement> extends WWidgetImpl<N, M> implements WLayoutedWidget<M> {
private Node staticLayoutGroup;
private double weight = 10;
+ private WCallback<@NonNull DropData, @Nullable Void> dropCallback;
+ @Inject
+ DnDFeedbackService feedbackService;
+
/**
* @return the widget node
*/
@@ -74,6 +92,8 @@ public abstract class WLayoutedWidgetImpl<N, NN extends Node, M extends MUIEleme
@NonNull
protected Node createStaticLayoutNode() {
Pane staticLayoutGroup = createStaticPane();
+ staticLayoutGroup.addEventHandler(DragEvent.DRAG_OVER, this::handleDragOver);
+ staticLayoutGroup.addEventHandler(DragEvent.DRAG_DROPPED, this::handleDragDropped);
Node n = getWidgetNode();
if (n != null) {
staticLayoutGroup.getChildren().add(n);
@@ -84,6 +104,121 @@ public abstract class WLayoutedWidgetImpl<N, NN extends Node, M extends MUIEleme
}
/**
+ * Handling the drag over
+ *
+ * @param e
+ * the event
+ */
+ protected void handleDragOver(DragEvent e) {
+ if (this.dropCallback != null) {
+ if (! DndTabPaneFactory.hasDnDContent(e)) {
+ return;
+ }
+
+ @Nullable
+ M m = getDomElement();
+
+ if( m instanceof MGenericTile<?> ) {
+ // Tiles are not split
+ e.consume();
+ } else if( m instanceof MPart && isSplit(e) ) {
+ e.consume();
+ if( (MUIElement)m.getParent() instanceof MPartStack ) {
+ e.acceptTransferModes(TransferMode.MOVE);
+ }
+ } else if (m instanceof MElementContainer<?>) {
+ MElementContainer<?> c = (MElementContainer<?>) m;
+ if (c.getChildren().isEmpty()) {
+ e.acceptTransferModes(TransferMode.MOVE);
+ e.consume();
+ }
+ }
+ }
+ }
+
+ private int SPLIT_PADDING = 20;
+
+ private boolean isSplit(DragEvent e) {
+ Bounds boundsInLocal = getStaticLayoutNode().getBoundsInLocal();
+ boundsInLocal = new BoundingBox(
+ boundsInLocal.getMinX()+SPLIT_PADDING,
+ boundsInLocal.getMinY()+SPLIT_PADDING, boundsInLocal.getWidth()-SPLIT_PADDING*2,
+ boundsInLocal.getHeight()-SPLIT_PADDING*2);
+ return boundsInLocal.contains(e.getX(), e.getY());
+ }
+
+ private DropType getSplitType(DragEvent e) {
+ return DropType.SPLIT_VERTICAL;
+ }
+
+ private MUIElement findElement(String objectId) {
+ EObject eo = (EObject) getDomElement();
+ EObject rv = null;
+ if (eo != null) {
+ rv = ((XMIResource) eo.eResource()).getEObject(objectId);
+ }
+ if (rv instanceof MUIElement) {
+ return (MUIElement) rv;
+ }
+ return null;
+ }
+
+ /**
+ * Handle the drag
+ *
+ * @param e
+ * the event
+ */
+ protected void handleDragDropped(DragEvent e) {
+ if (this.dropCallback != null) {
+ if (!DndTabPaneFactory.hasDnDContent(e)) {
+ return;
+ }
+
+ String objectId = DndTabPaneFactory.getDnDContent(e);
+
+ MUIElement draggedElement = findElement(objectId);
+ if (draggedElement == null) {
+ return;
+ }
+
+ @Nullable
+ M m = getDomElement();
+ if( m instanceof MGenericTile<?> ) {
+ // Tiles are not split
+ e.consume();
+ } else if( m instanceof MPart && isSplit(e) ) {
+ e.consume();
+ if( (MUIElement)m.getParent() instanceof MPartStack ) {
+ DropData d = new DropData(getDomElement(), draggedElement, getSplitType(e));
+ this.dropCallback.call(d);
+ }
+ } else if (m instanceof MElementContainer<?>) {
+ MElementContainer<?> c = (MElementContainer<?>) m;
+ if (c.getChildren().isEmpty()) {
+ DropData d = new DropData(getDomElement(), draggedElement, DropType.INSERT);
+ this.dropCallback.call(d);
+ e.consume();
+ e.setDropCompleted(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public final void setDragDroppedCallback(@NonNull WCallback<@NonNull DropData, @Nullable Void> callback) {
+ this.dropCallback = callback;
+ }
+
+ /**
+ * Allow access to the drop callback
+ * @return the callback
+ */
+ protected @Nullable WCallback<@NonNull DropData, @Nullable Void> getDropCallback() {
+ return this.dropCallback;
+ }
+
+ /**
* Create the static layout pane
*
* @return the layout pane
@@ -117,7 +252,7 @@ public abstract class WLayoutedWidgetImpl<N, NN extends Node, M extends MUIEleme
getWidgetNode().getStyleClass().removeAll(classnames);
getWidgetNode().applyCss();
}
-
+
@Override
public void setStyleId(String id) {
getWidgetNode().setId(id);
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/.classpath b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.classpath
new file mode 100644
index 000000000..eca7bdba8
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/.gitignore b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.gitignore
new file mode 100644
index 000000000..ae3c17260
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/.project b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.project
new file mode 100644
index 000000000..bed10a2bf
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.fx.ui.workbench.services</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..106e5b71e
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,398 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=300
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.workbench.services/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..9dca8f36f
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Services
+Bundle-SymbolicName: org.eclipse.fx.ui.workbench.services
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0",
+ org.eclipse.jdt.annotation;bundle-version="2.0.0";resolution:=optional,
+ org.eclipse.e4.ui.workbench;bundle-version="1.1.0",
+ org.eclipse.e4.core.contexts;bundle-version="1.3.100",
+ org.eclipse.e4.core.services;bundle-version="1.2.0",
+ org.eclipse.e4.core.di;bundle-version="1.4.0",
+ org.eclipse.emf.common,
+ org.eclipse.emf.ecore;bundle-version="2.10.0"
+Export-Package: org.eclipse.fx.ui.workbench.services,
+ org.eclipse.fx.ui.workbench.services.lifecycle,
+ org.eclipse.fx.ui.workbench.services.lifecycle.annotation
+Import-Package: javax.annotation;version="1.2.0",
+ javax.inject;version="1.0.0"
+Service-Component: OSGI-INF/lifecyclecomponent.xml
+Bundle-ActivationPolicy: lazy
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml b/bundles/runtime/org.eclipse.fx.ui.workbench.services/OSGI-INF/lifecyclecomponent.xml
index 86219f015..5c643fd91 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/OSGI-INF/component.xml
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/OSGI-INF/lifecyclecomponent.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ui.lifecycle">
- <implementation class="org.eclipse.fx.ui.internal.lifecycle.LifecycleContextFunction"/>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.fx.ui.workbench.services.lifecyclecomponent">
+ <implementation class="org.eclipse.fx.ui.workbench.services.lifecycle.internal.LifecycleContextFunction"/>
<service>
<provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
</service>
- <property name="service.context.key" type="String" value="org.eclipse.fx.ui.lifecycle.ELifecycleService"/>
-</scr:component> \ No newline at end of file
+ <property name="service.context.key" type="String" value="org.eclipse.fx.ui.workbench.services.ELifecycleService"/>
+</scr:component>
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/about.html b/bundles/runtime/org.eclipse.fx.ui.workbench.services/about.html
new file mode 100644
index 000000000..c258ef55d
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties b/bundles/runtime/org.eclipse.fx.ui.workbench.services/build.properties
index 9dd43c6dd..626772844 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/build.properties
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/build.properties
@@ -1,6 +1,6 @@
-source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
about.html
+source.. = src/
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml b/bundles/runtime/org.eclipse.fx.ui.workbench.services/pom.xml
index 6ece0f5c8..ed1257790 100644..100755
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/pom.xml
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/pom.xml
@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>e(fx)clipse - Runtime - e4 - Lifecycle Service API</name>
+ <name>e(fx)clipse - Runtime - e4 workbench services</name>
<groupId>org.eclipse.fx</groupId>
- <artifactId>org.eclipse.fx.ui.lifecycle</artifactId>
+ <artifactId>org.eclipse.fx.ui.workbench.services</artifactId>
<packaging>eclipse-plugin</packaging>
<parent>
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/ELifecycleService.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/ELifecycleService.java
new file mode 100644
index 000000000..97104b695
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/ELifecycleService.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.workbench.services;
+
+import java.lang.annotation.Annotation;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Service to register lifecycle handlers on model elements
+ */
+public interface ELifecycleService {
+ /**
+ * Register a life-cycle handler
+ *
+ * @param element
+ * the model element
+ * @param lifecycleURI
+ * the uri
+ */
+ public void registerLifecycleURI(@NonNull MUIElement element, @NonNull String lifecycleURI);
+
+ /**
+ * Unregister a life-cycle handler
+ *
+ * @param element
+ * the element
+ * @param contribution
+ */
+ public void unregisterLifecycleContribution(@NonNull MUIElement element, @NonNull Object contribution);
+
+ /**
+ * Validate an annotation
+ *
+ * @param annotationClass
+ * the annotation class
+ * @param element
+ * the element
+ * @param context
+ * the context
+ * @return <code>true</code> if validation succeeded
+ */
+ public boolean validateAnnotation(@NonNull Class<? extends Annotation> annotationClass, @NonNull MUIElement element, @NonNull IEclipseContext context);
+
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/EModelStylingService.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/EModelStylingService.java
new file mode 100644
index 000000000..5b09a36dd
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/EModelStylingService.java
@@ -0,0 +1,51 @@
+package org.eclipse.fx.ui.workbench.services;
+
+import java.util.List;
+
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+
+/**
+ * Service to set style classes on model elements.
+ */
+public interface EModelStylingService {
+
+ /**
+ * Add style classes to the given element.
+ *
+ * @param element
+ * the element to add style classes to
+ * @param classes
+ * the style classes to add
+ */
+ public void addStyles(MUIElement element, String... classes);
+
+ /**
+ * Remove style classes from the given element.
+ *
+ * @param element
+ * the element to remove style classes from
+ * @param classes
+ * the style classes to remove
+ */
+ public void removeStyles(MUIElement element, String... classes);
+
+ /**
+ * Returns the style classes currently assigned to an element.
+ *
+ * @param element
+ * the element to get the style classes of
+ * @return
+ * the style classes
+ */
+ public List<String> getStyles(MUIElement element);
+
+ /**
+ * Returns the style classes from a list of element tags.
+ *
+ * @param tags
+ * A list of tags
+ * @return
+ * the list of style classes found in tags
+ */
+ public List<String> getStylesFromTags(List<String> tags);
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/LifecycleAddon.java
index f2c894dbe..4123b9ccd 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/LifecycleAddon.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/LifecycleAddon.java
@@ -8,7 +8,7 @@
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
-package org.eclipse.fx.ui.lifecycle;
+package org.eclipse.fx.ui.workbench.services.lifecycle;
import java.util.List;
@@ -20,38 +20,45 @@ import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
-
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
//when we are ready to ditch the tag-based stuff we simply swap the addon
+/**
+ * Addon to add so that lifecycle stuff is initialized
+ */
public class LifecycleAddon {
-
+
@Inject
MApplication app;
-
-// @Inject
-// EModelService modelService;
-
+
@Inject
ELifecycleService lifecycleService;
- public static final String LIFECYCLE_TRANSIENT_KEY="EFX_LIFECYCLE";
-
- public static final String LIFECYCLE_TAG_PREFIX = "EFX_LC:";
+ /**
+ * Key used to store the lifecycle instances inside the transient map
+ */
+ public static final String LIFECYCLE_TRANSIENT_KEY = "EFX_LIFECYCLE"; //$NON-NLS-1$
+ /**
+ * Tag prefix to use
+ */
+ public static final String LIFECYCLE_TAG_PREFIX = "EFX_LC:"; //$NON-NLS-1$
+
+ @SuppressWarnings("null")
@PostConstruct
- public void postConstruct(){
- TreeIterator<EObject> it = EcoreUtil.getAllContents((EObject)app, true);
- while( it.hasNext() ) {
+ void postConstruct() {
+ TreeIterator<EObject> it = EcoreUtil.getAllContents((EObject) this.app, true);
+ while (it.hasNext()) {
EObject e = it.next();
- if( e instanceof MUIElement ) {
+ if (e instanceof MUIElement) {
MUIElement element = (MUIElement) e;
List<String> tags = element.getTags();
- for (String tag: tags) {
+ for (String tag : tags) {
if (tag.startsWith(LIFECYCLE_TAG_PREFIX)) {
- lifecycleService.registerLifecycleURI(element,tag.substring(LIFECYCLE_TAG_PREFIX.length()));
+ this.lifecycleService.registerLifecycleURI(element, tag.substring(LIFECYCLE_TAG_PREFIX.length()));
}
}
}
- }
+ }
}
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreClose.java
index e148dfae2..f682a304e 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreClose.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreClose.java
@@ -8,7 +8,7 @@
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
-package org.eclipse.fx.ui.lifecycle.annotations;
+package org.eclipse.fx.ui.workbench.services.lifecycle.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -16,9 +16,13 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * Called before something like Part, Perspective, Window, ... is closed
+ * allowing to veto it
+ */
@Documented
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface PreClose {
-
+ // nothing
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreShow.java
index d94d4b250..008abae35 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/lifecycle/annotations/PreShow.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/annotation/PreShow.java
@@ -8,7 +8,7 @@
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
-package org.eclipse.fx.ui.lifecycle.annotations;
+package org.eclipse.fx.ui.workbench.services.lifecycle.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -16,9 +16,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * Called before a Part, Perspective, Window, ... is closed
+ */
@Documented
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface PreShow {
-
+ // nothing
} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleContextFunction.java
index 1cec28662..b076e2f57 100644
--- a/bundles/runtime/org.eclipse.fx.ui.lifecycle/src/org/eclipse/fx/ui/internal/lifecycle/LifecycleContextFunction.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleContextFunction.java
@@ -8,12 +8,16 @@
* Contributors:
* Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
*******************************************************************************/
-package org.eclipse.fx.ui.internal.lifecycle;
+package org.eclipse.fx.ui.workbench.services.lifecycle.internal;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
+/**
+ * Context function creating a {@link ELifecycleService}
+ */
public class LifecycleContextFunction extends ContextFunction {
@Override
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleServiceImpl.java b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleServiceImpl.java
new file mode 100644
index 000000000..c566d6dc1
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.services/src/org/eclipse/fx/ui/workbench/services/lifecycle/internal/LifecycleServiceImpl.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2014 BestSolution.at 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:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.workbench.services.lifecycle.internal;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.services.contributions.IContributionFactory;
+import org.eclipse.e4.ui.model.application.MApplication;
+import org.eclipse.e4.ui.model.application.ui.MUIElement;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.fx.ui.workbench.services.ELifecycleService;
+import org.eclipse.fx.ui.workbench.services.lifecycle.LifecycleAddon;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Implementation of a {@link ELifecycleService}
+ */
+@SuppressWarnings("restriction")
+public class LifecycleServiceImpl implements ELifecycleService {
+
+ @Inject
+ private EModelService modelService;
+
+ @Inject
+ private MApplication app;
+
+ @Inject
+ private IContributionFactory factory;
+
+ @Override
+ public void registerLifecycleURI(MUIElement element, String lifecycleURI) {
+ @SuppressWarnings("unchecked")
+ Set<@NonNull Object> contributions = (Set<@NonNull Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (contributions == null) {
+ contributions = new HashSet<>();
+ element.getTransientData().put(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY, contributions);
+ }
+
+ Object object = this.factory.create(lifecycleURI, this.app.getContext());
+ if (object != null) {
+ contributions.add(object);
+ }
+ }
+
+ @Override
+ public boolean validateAnnotation(Class<? extends Annotation> annotationClass, MUIElement element, IEclipseContext context) {
+ return validateLifecycleAnnotation(annotationClass, getContextForParent(element), context, element);
+ }
+
+ private static boolean validateLifecycleAnnotation(Class<? extends Annotation> clazz, IEclipseContext parentContext, IEclipseContext partContext, MUIElement part) {
+ @SuppressWarnings("unchecked")
+ Set<@NonNull Object> set = (Set<@NonNull Object>) part.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (set != null) {
+ for (Object object : set) {
+ Object invokeResult = ContextInjectionFactory.invoke(object, clazz, parentContext, partContext, Boolean.TRUE);
+ if (invokeResult != null && invokeResult instanceof Boolean) {// supports
+ // void
+ // methods
+ boolean res = ((Boolean) invokeResult).booleanValue();
+ if (!res)
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private IEclipseContext getContextForParent(MUIElement element) {
+ return this.modelService.getContainingContext(element);
+ }
+
+ @Override
+ public void unregisterLifecycleContribution(MUIElement element, Object contribution) {
+ @SuppressWarnings("unchecked")
+ Set<@NonNull Object> objects = (Set<@NonNull Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY);
+ if (objects != null)
+ objects.remove(contribution);
+ }
+
+} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.converter/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.converter/META-INF/MANIFEST.MF
index a85ef2665..4d3fcabbf 100755
--- a/bundles/tooling/org.eclipse.fx.ide.converter/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.converter/META-INF/MANIFEST.MF
@@ -8,4 +8,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources;bundle-version="3.7.0",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.core.expressions;bundle-version="3.4.300",
- org.eclipse.fx.formats.svg;bundle-version="0.9.0"
+ org.eclipse.fx.formats.svg;bundle-version="0.9.0",
+ org.eclipse.fx.osgi.util,
+ org.eclipse.jdt.annotation;bundle-version="2.0.0";resolution:=optional
+Import-Package: org.eclipse.fx.core.log
diff --git a/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/AbstractConverterHandler.java b/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/AbstractConverterHandler.java
index a1af719fe..2d2f636a2 100755
--- a/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/AbstractConverterHandler.java
+++ b/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/AbstractConverterHandler.java
@@ -22,10 +22,14 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
+/**
+ * Basic handler for conversions
+ */
public abstract class AbstractConverterHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -43,6 +47,10 @@ public abstract class AbstractConverterHandler extends AbstractHandler {
f.getName().length() - f.getFileExtension().length()
- 1)
+ getTargetFileExtension()));
+ if( outFile == null ) {
+ throw new ExecutionException("Unable to get file from folder"); //$NON-NLS-1$
+ }
+
String content = convert(outFile, f);
if (!outFile.exists()) {
@@ -70,7 +78,7 @@ public abstract class AbstractConverterHandler extends AbstractHandler {
return null;
}
- protected abstract String convert(IFile outFile, IFile file)
+ protected abstract String convert(@NonNull IFile outFile, @NonNull IFile file)
throws ExecutionException;
protected abstract String getTargetFileExtension();
diff --git a/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/ConvertSVGHandler.java b/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/ConvertSVGHandler.java
index fbe900415..cf752cccb 100755
--- a/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/ConvertSVGHandler.java
+++ b/bundles/tooling/org.eclipse.fx.ide.converter/src/org/eclipse/fx/ide/converter/ConvertSVGHandler.java
@@ -10,27 +10,38 @@
*******************************************************************************/
package org.eclipse.fx.ide.converter;
+import java.io.InputStream;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.fx.formats.svg.converter.FXMLConverter;
import org.eclipse.fx.formats.svg.handler.XMLLoader;
import org.eclipse.fx.formats.svg.svg.SvgSvgElement;
+import org.eclipse.fx.osgi.util.LoggerCreator;
+import org.eclipse.jdt.annotation.NonNull;
+/**
+ * Handler to convert SVG to FXML
+ */
public class ConvertSVGHandler extends AbstractConverterHandler {
+ @SuppressWarnings("null")
@Override
- protected String convert(IFile outFile, IFile file) throws ExecutionException {
- try {
- XMLLoader loader = new XMLLoader();
- SvgSvgElement root = loader.loadDocument(outFile.getFullPath().toOSString(), file.getContents());
+ protected String convert(@NonNull IFile outFile, @NonNull IFile file) throws ExecutionException {
+ try(InputStream contents = file.getContents()) {
+ if( contents == null ) {
+ throw new ExecutionException("Could not retrieve file contents"); //$NON-NLS-1$
+ }
+ SvgSvgElement root = XMLLoader.loadDocument(outFile.getFullPath().toOSString(), contents);
return new FXMLConverter(root).generate().toString();
} catch (Exception e) {
- throw new ExecutionException("Conversion failed", e);
+ LoggerCreator.createLogger(getClass()).error("Conversion failed", e); //$NON-NLS-1$
+ throw new ExecutionException("Conversion failed", e); //$NON-NLS-1$
}
}
@Override
protected String getTargetFileExtension() {
- return ".fxml";
+ return ".fxml"; //$NON-NLS-1$
}
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/META-INF/MANIFEST.MF
index 4199ecec7..f76b9ab46 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/META-INF/MANIFEST.MF
@@ -21,26 +21,26 @@ Require-Bundle: org.eclipse.fx.ide.css.cssext;visibility:=reexport,
org.eclipse.jdt.core;bundle-version="3.7.3"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.css.cssext.ui;
+Export-Package: org.eclipse.fx.ide.css.cssext.ui;x-internal:=true;
uses:="org.eclipse.core.resources,
org.eclipse.ui.plugin,
org.osgi.framework,
org.eclipse.xtext.ui,
org.eclipse.xtext.ui.guice,
com.google.inject",
- org.eclipse.fx.ide.css.cssext.ui.contentassist;
+ org.eclipse.fx.ide.css.cssext.ui.contentassist;x-internal:=true;
uses:="org.eclipse.xtext,
org.eclipse.emf.ecore,
org.eclipse.xtext.common.ui.contentassist,
org.eclipse.xtext.ui.editor.contentassist",
- org.eclipse.fx.ide.css.cssext.ui.contentassist.antlr;
+ org.eclipse.fx.ide.css.cssext.ui.contentassist.antlr;x-internal:=true;
uses:="org.eclipse.xtext,
org.eclipse.fx.ide.css.cssext.services,
org.eclipse.fx.ide.css.cssext.ui.contentassist.antlr.internal,
org.eclipse.xtext.ui.editor.contentassist.antlr.internal,
org.eclipse.xtext.ui.codetemplates.ui.partialEditing,
org.eclipse.xtext.ui.editor.contentassist.antlr",
- org.eclipse.fx.ide.css.cssext.ui.internal;uses:="org.eclipse.ui.plugin,org.osgi.framework,com.google.inject"
+ org.eclipse.fx.ide.css.cssext.ui.internal;x-internal:=true;uses:="org.eclipse.ui.plugin,org.osgi.framework,com.google.inject"
Bundle-Activator: org.eclipse.fx.ide.css.cssext.ui.internal.CssExtDslActivator
Service-Component: OSGI-INF/cssExtProvider.xml,
OSGI-INF/ColorProposalContributor.xml
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssFile.java b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssFile.java
index cba1c98cc..7b098d5a6 100644
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssFile.java
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext.ui/src/org/eclipse/fx/ide/css/cssext/ui/CssFile.java
@@ -12,37 +12,35 @@ package org.eclipse.fx.ide.css.cssext.ui;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.fx.ide.css.cssext.CssExtDslStandaloneSetup;
import org.eclipse.fx.ide.css.cssext.cssExtDsl.CssExtension;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.xtext.linking.lazy.LazyLinkingResource;
/**
* @author ccaks
*
*/
public class CssFile {
-
+ private static Map<URI, CssExtensionNfo> EXTENSION_CACHE = new HashMap<>();
+
public static class CssExtensionNfo {
public final URI uri;
public final CssExtension model;
@@ -200,20 +198,27 @@ public class CssFile {
for (ClassPathSearchUtil.Entry entry : allFiles) {
// load model
final URI uri = entry.toURI();
- try {
- Resource resource = rs.createResource(uri);
- resource.setURI(uri);
- resource.load(Collections.emptyMap());
-
- final CssExtension ex = (CssExtension) resource.getContents().get(0);
- extensions.add(new CssExtensionNfo(uri, ex));
- }
- catch (Exception e) {
- System.err.println("could not load model : " + uri);
- e.printStackTrace();
+ if( EXTENSION_CACHE.containsKey(uri) ) {
+ extensions.add(EXTENSION_CACHE.get(uri));
+ } else {
+ try {
+ Resource resource = rs.createResource(uri);
+ resource.setURI(uri);
+ resource.load(Collections.emptyMap());
+
+ final CssExtension ex = (CssExtension) resource.getContents().get(0);
+ CssExtensionNfo e = new CssExtensionNfo(uri, ex);
+ EXTENSION_CACHE.put(uri, e);
+ extensions.add(e);
+ }
+ catch (Exception e) {
+ System.err.println("could not load model : " + uri);
+ e.printStackTrace();
+ }
}
}
+
return extensions;
}
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.cssext/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.css.cssext/META-INF/MANIFEST.MF
index 51f24d72b..9506bd09f 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.cssext/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.css.cssext/META-INF/MANIFEST.MF
@@ -27,20 +27,20 @@ Import-Package: org.apache.log4j,
org.eclipse.core.runtime;version="3.4.0",
org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.css.cssext,
- org.eclipse.fx.ide.css.cssext.cssExtDsl,
- org.eclipse.fx.ide.css.cssext.cssExtDsl.impl,
- org.eclipse.fx.ide.css.cssext.cssExtDsl.util,
- org.eclipse.fx.ide.css.cssext.formatting,
- org.eclipse.fx.ide.css.cssext.generator,
- org.eclipse.fx.ide.css.cssext.parseTreeConstruction,
- org.eclipse.fx.ide.css.cssext.parser,
- org.eclipse.fx.ide.css.cssext.parser.antlr,
- org.eclipse.fx.ide.css.cssext.parser.antlr.internal,
- org.eclipse.fx.ide.css.cssext.parser.result,
- org.eclipse.fx.ide.css.cssext.proposal,
- org.eclipse.fx.ide.css.cssext.scoping,
- org.eclipse.fx.ide.css.cssext.services,
- org.eclipse.fx.ide.css.cssext.validation
+Export-Package: org.eclipse.fx.ide.css.cssext;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.cssExtDsl;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.cssExtDsl.impl;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.cssExtDsl.util;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.formatting;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.generator;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.parseTreeConstruction;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.parser;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.parser.antlr;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.parser.antlr.internal;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.parser.result;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.proposal;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.scoping;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.services;x-internal:=true,
+ org.eclipse.fx.ide.css.cssext.validation;x-internal:=true
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx8/.project b/bundles/tooling/org.eclipse.fx.ide.css.jfx8/.project
index a3b0f5ce9..c0b4517a0 100644
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx8/.project
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx8/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -24,5 +29,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.jfx8/src/jfx8.cssext b/bundles/tooling/org.eclipse.fx.ide.css.jfx8/src/jfx8.cssext
index 1c9e078fb..9ffa31f27 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.jfx8/src/jfx8.cssext
+++ b/bundles/tooling/org.eclipse.fx.ide.css.jfx8/src/jfx8.cssext
@@ -835,6 +835,7 @@ package javafx {
*/
radial-gradient = radial-gradient([ focus-angle <angle>, ]? [ focus-distance <percentage>, ]? [ center <point>, ]? radius [ <length> | <percentage> ] [ [ repeat | reflect ], ]? <color-stop>[, <color-stop>]+);
+ alignment = [ top-left | top-center | top-right | center-left | center | center-right bottom-left | bottom-center | bottom-right | baseline-left | baseline-center | baseline-right ];
package scene {
blend-mode = [ add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over ];
@@ -955,8 +956,6 @@ package javafx {
dash-style = [ none | solid | dotted | dashed | <segments> ];
segments = segments( @NUM, @NUM [, @NUM]*);
- alignment = [ top-left | top-center | top-right | center-left | center | center-right bottom-left | bottom-center | bottom-right | baseline-left | baseline-center | baseline-right ];
-
//TODO REMOVE if attribute references are available
/**
@@ -1197,7 +1196,30 @@ package javafx {
* -fx-border-image-slice and -fx-border-image-width. There is no shorthand notation for -fx-image-borders at this time.
*/
-fx-image-borders <-fx-border-image-source> [ <-fx-border-image-insets> || <-fx-border-image-repeat> || <-fx-border-image-slice> || <-fx-border-image-width> ] default: null;
-
+ /**
+ * The preferred width of the region
+ */
+ -fx-pref-width <size> default:-1.0;
+ /**
+ * The preferred height of the region
+ */
+ -fx-pref-height <size> default:-1.0;
+ /**
+ * The min width of the region
+ */
+ -fx-min-width <size> default:-1.0;
+ /**
+ * The min height of the region
+ */
+ -fx-min-height <size> default:-1.0;
+ /**
+ * The max width of the region
+ */
+ -fx-max-width <size> default:-1.0;
+ /**
+ * The max height of the region
+ */
+ -fx-max-height <size> default:-1.0;
}
/**
* Base class for layout panes which need to expose the children list as public
@@ -1641,6 +1663,10 @@ package javafx {
* Defines if each line of text should have a line below it.
*/
-fx-underline <boolean> default: false;
+ /**
+ * Defines how the bounds are calculated
+ */
+ -fx-bounds-type [ logical | visual | logical_vertical_center ] default: logical;
}
}
package web {
@@ -2088,7 +2114,9 @@ package javafx {
*/
-fx-use-system-menu-bar <boolean> default: false;
substructure Desktop {
- Menu styleclass menu
+ layout.HBox styleclass container {
+ MenuButton styleclass menu
+ }
}
}
/**
@@ -2111,7 +2139,14 @@ package javafx {
* API.
*/
MenuItem extends Control styleclass menu-item {
- // TODO SUPPORT STYLE_CLASS
+ //TODO on desktops the Item is a Button!!!!
+ -fx-text-fill <paint> default: black;
+ substructure Desktop {
+ Label styleclass label
+ layout.StackPane styleclass right-container {
+ layout.Region styleclass arrow
+ }
+ }
}
/**
* A Pagination control is used for navigation between pages of a single content,
@@ -2138,6 +2173,7 @@ package javafx {
* page alignment
*/
-fx-page-information-alignment [top | bottom | left | right] default: true;
+ -fx-arrow-button-gap <size> default: 4;
substructure Desktop {
layout.StackPane styleclass page
@@ -2175,6 +2211,8 @@ package javafx {
-fx-indeterminate-bar-escape <boolean> default: true;
-fx-indeterminate-bar-flip <boolean> default: true;
-fx-indeterminate-bar-animation-time @NUM default: 2.0;
+ -fx-indeterminate-segment-count @INT default: 8;
+ -fx-spin-enabled <boolean> default: false;
substructure Desktop {
layout.StackPane styleclass track {
layout.Region styleclass bar
@@ -2555,6 +2593,7 @@ package javafx {
* plain text.
*/
TextArea extends TextInputControl styleclass text-area {
+ -fx-pref-column-count @INT default:40;
substructure Desktop {
ScrollPane styleclass scroll-pane {
layout.Region styleclass content
@@ -2593,6 +2632,7 @@ package javafx {
top-left | top-center | top-right | center-left |
center | center-right | bottom-left | bottom-center | bottom-right | baseline-left | baseline-center | baseline-right
] default: center-left;
+ -fx-pref-column-count @INT default: 12;
}
/**
* A TitledPane is a panel with a title that can be opened and closed.
@@ -2643,6 +2683,8 @@ package javafx {
* The orientation
*/
-fx-orientation [ horizontal | vertical ] default: horizontal;
+ -fx-spacing <size> default 0;
+ -fx-alignment <alignment> default: top-left;
/**
* applies if this ToolBar is horizontal
*/
@@ -2697,6 +2739,9 @@ package javafx {
-fx-font-size <font-size> default: null; /* INHERITED */
-fx-font-style <font-style> default: null; /* INHERITED */
-fx-font-weight <font-weight> default: null; /* INHERITED */
+ //TODO At runtime the tip is represented as a label so it inherits ALL attributes
+ // from Label
+ -fx-text-fill <paint> default: null;
substructure Desktop {
Label styleclass label
layout.StackPane styleclass page-corner
diff --git a/bundles/tooling/org.eclipse.fx.ide.css.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.css.ui/META-INF/MANIFEST.MF
index b83b804d2..6b433af11 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.css.ui/META-INF/MANIFEST.MF
@@ -23,11 +23,11 @@ Import-Package: org.apache.commons.logging,
org.apache.log4j,
org.eclipse.fx.osgi.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.css.ui,
- org.eclipse.fx.ide.css.ui.contentassist,
- org.eclipse.fx.ide.css.ui.contentassist.antlr,
- org.eclipse.fx.ide.css.ui.extapi,
- org.eclipse.fx.ide.css.ui.hover,
- org.eclipse.fx.ide.css.ui.internal
+Export-Package: org.eclipse.fx.ide.css.ui;x-internal:=true,
+ org.eclipse.fx.ide.css.ui.contentassist;x-internal:=true,
+ org.eclipse.fx.ide.css.ui.contentassist.antlr;x-internal:=true,
+ org.eclipse.fx.ide.css.ui.extapi;x-internal:=true,
+ org.eclipse.fx.ide.css.ui.hover;x-internal:=true,
+ org.eclipse.fx.ide.css.ui.internal;x-internal:=true
Bundle-Activator: org.eclipse.fx.ide.css.ui.internal.CssDslActivator
Eclipse-BundleShape: dir
diff --git a/bundles/tooling/org.eclipse.fx.ide.css/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.css/META-INF/MANIFEST.MF
index d4a354ff2..ced3673a1 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.css/META-INF/MANIFEST.MF
@@ -25,17 +25,17 @@ Import-Package: org.apache.commons.logging,
org.apache.log4j,
org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.css,
- org.eclipse.fx.ide.css.cssDsl,
- org.eclipse.fx.ide.css.cssDsl.impl,
- org.eclipse.fx.ide.css.cssDsl.util,
- org.eclipse.fx.ide.css.extapi,
- org.eclipse.fx.ide.css.formatting,
- org.eclipse.fx.ide.css.parser.antlr,
- org.eclipse.fx.ide.css.parser.antlr.internal,
- org.eclipse.fx.ide.css.scoping,
- org.eclipse.fx.ide.css.serializer,
- org.eclipse.fx.ide.css.services,
- org.eclipse.fx.ide.css.util,
- org.eclipse.fx.ide.css.validation
+Export-Package: org.eclipse.fx.ide.css;x-internal:=true,
+ org.eclipse.fx.ide.css.cssDsl;x-internal:=true,
+ org.eclipse.fx.ide.css.cssDsl.impl;x-internal:=true,
+ org.eclipse.fx.ide.css.cssDsl.util;x-internal:=true,
+ org.eclipse.fx.ide.css.extapi;x-internal:=true,
+ org.eclipse.fx.ide.css.formatting;x-internal:=true,
+ org.eclipse.fx.ide.css.parser.antlr;x-internal:=true,
+ org.eclipse.fx.ide.css.parser.antlr.internal;x-internal:=true,
+ org.eclipse.fx.ide.css.scoping;x-internal:=true,
+ org.eclipse.fx.ide.css.serializer;x-internal:=true,
+ org.eclipse.fx.ide.css.services;x-internal:=true,
+ org.eclipse.fx.ide.css.util;x-internal:=true,
+ org.eclipse.fx.ide.css.validation;x-internal:=true
diff --git a/bundles/tooling/org.eclipse.fx.ide.css/plugin.xml b/bundles/tooling/org.eclipse.fx.ide.css/plugin.xml
index fe0f35364..6ba2d97bf 100755
--- a/bundles/tooling/org.eclipse.fx.ide.css/plugin.xml
+++ b/bundles/tooling/org.eclipse.fx.ide.css/plugin.xml
@@ -5,9 +5,9 @@
<extension point="org.eclipse.emf.ecore.generated_package">
<package
- uri = "http://www.bestsolution.at/efxclipse/tooling/css/CssDsl"
+ uri = "http://www.eclipse.org/efxclipse/ide/css/CssDsl"
class = "org.eclipse.fx.ide.css.cssDsl.CssDslPackage"
- genModel = "at/bestsolution/efxclipse/tooling/css/CssDsl.genmodel" />
+ genModel = "org/eclipse/fx/ide/css/CssDsl.genmodel" />
</extension>
<extension
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxgraph.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.fxgraph.ui/META-INF/MANIFEST.MF
index 79bcd6f72..afae868a1 100755
--- a/bundles/tooling/org.eclipse.fx.ide.fxgraph.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.fxgraph.ui/META-INF/MANIFEST.MF
@@ -30,9 +30,9 @@ Require-Bundle: org.eclipse.fx.ide.fxgraph;visibility:=reexport,
Import-Package: org.apache.log4j,
org.apache.commons.logging
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.fxgraph.ui.contentassist.antlr,
- org.eclipse.fx.ide.fxgraph.ui.internal,
- org.eclipse.fx.ide.fxgraph.ui.util,
- org.eclipse.fx.ide.fxgraph.ui.contentassist,
- org.eclipse.fx.ide.fxgraph.ui.quickfix
+Export-Package: org.eclipse.fx.ide.fxgraph.ui.contentassist;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.ui.contentassist.antlr;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.ui.internal;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.ui.quickfix;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.ui.util;x-internal:=true
Bundle-Activator: org.eclipse.fx.ide.fxgraph.ui.internal.FXGraphActivator
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxgraph/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.fxgraph/META-INF/MANIFEST.MF
index 3ed0c8f6f..d474181d9 100755
--- a/bundles/tooling/org.eclipse.fx.ide.fxgraph/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.fxgraph/META-INF/MANIFEST.MF
@@ -30,19 +30,19 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.6.0";visibility:=reexport,
Import-Package: org.apache.commons.logging,
org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.fxgraph,
- org.eclipse.fx.ide.fxgraph.compiler,
- org.eclipse.fx.ide.fxgraph.converter,
- org.eclipse.fx.ide.fxgraph.fXGraph,
- org.eclipse.fx.ide.fxgraph.fXGraph.impl,
- org.eclipse.fx.ide.fxgraph.fXGraph.util,
- org.eclipse.fx.ide.fxgraph.formatting,
- org.eclipse.fx.ide.fxgraph.generator,
- org.eclipse.fx.ide.fxgraph.jvmmodel,
- org.eclipse.fx.ide.fxgraph.parseTreeConstruction,
- org.eclipse.fx.ide.fxgraph.parser.antlr,
- org.eclipse.fx.ide.fxgraph.parser.antlr.internal,
- org.eclipse.fx.ide.fxgraph.scoping,
- org.eclipse.fx.ide.fxgraph.services,
- org.eclipse.fx.ide.fxgraph.validation
+Export-Package: org.eclipse.fx.ide.fxgraph;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.compiler;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.converter;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.fXGraph;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.fXGraph.impl;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.fXGraph.util;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.formatting;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.generator;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.jvmmodel;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.parseTreeConstruction;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.parser.antlr;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.parser.antlr.internal;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.scoping;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.services;x-internal:=true,
+ org.eclipse.fx.ide.fxgraph.validation;x-internal:=true
diff --git a/bundles/tooling/org.eclipse.fx.ide.fxml/src/org/eclipse/fx/ide/fxml/editors/FXMLCompletionProposalComputer.java b/bundles/tooling/org.eclipse.fx.ide.fxml/src/org/eclipse/fx/ide/fxml/editors/FXMLCompletionProposalComputer.java
index 7ddce944b..e36bbbfdb 100755
--- a/bundles/tooling/org.eclipse.fx.ide.fxml/src/org/eclipse/fx/ide/fxml/editors/FXMLCompletionProposalComputer.java
+++ b/bundles/tooling/org.eclipse.fx.ide.fxml/src/org/eclipse/fx/ide/fxml/editors/FXMLCompletionProposalComputer.java
@@ -192,6 +192,13 @@ public class FXMLCompletionProposalComputer extends AbstractXMLCompletionProposa
typeName = parent.getAttributes().getNamedItem("type").getNodeValue(); //$NON-NLS-1$
}
+ if( ! existingAttributes.contains("fx:id") ) { //$NON-NLS-1$
+ FXMLCompletionProposal cp = createAttributeProposal(contentAssistRequest, context, "fx:id=\"\"", new StyledString("fx:id").append(" - FXML built-in", StyledString.QUALIFIER_STYLER), IconKeys.getIcon(IconKeys.CLASS_KEY), DEFAULT_PRIORITY+10, MATCHER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if( cp != null ) {
+ contentAssistRequest.addProposal(cp);
+ }
+ }
+
if (typeName != null) {
if (Character.isLowerCase(typeName.charAt(0)) || typeName.contains(".")) { //$NON-NLS-1$
@@ -249,9 +256,11 @@ public class FXMLCompletionProposalComputer extends AbstractXMLCompletionProposa
}
}
} else {
- FXMLCompletionProposal cp = createAttributeProposal(contentAssistRequest, context, "fx:controller=\"\"", new StyledString("fx:controller").append(" - FXML built-in", StyledString.QUALIFIER_STYLER), IconKeys.getIcon(IconKeys.CLASS_KEY), DEFAULT_PRIORITY+10, MATCHER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if( cp != null ) {
- contentAssistRequest.addProposal(cp);
+ if( ! existingAttributes.contains("fx:controller") ) { //$NON-NLS-1$
+ FXMLCompletionProposal cp = createAttributeProposal(contentAssistRequest, context, "fx:controller=\"\"", new StyledString("fx:controller").append(" - FXML built-in", StyledString.QUALIFIER_STYLER), IconKeys.getIcon(IconKeys.CLASS_KEY), DEFAULT_PRIORITY+10, MATCHER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if( cp != null ) {
+ contentAssistRequest.addProposal(cp);
+ }
}
}
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.java6/.settings/org.eclipse.jdt.core.prefs b/bundles/tooling/org.eclipse.fx.ide.java6/.settings/org.eclipse.jdt.core.prefs
index 0448c8920..470001a0d 100644
--- a/bundles/tooling/org.eclipse.fx.ide.java6/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/tooling/org.eclipse.fx.ide.java6/.settings/org.eclipse.jdt.core.prefs
@@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -111,4 +111,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/bundles/tooling/org.eclipse.fx.ide.java6/src/org/eclipse/fx/ide/java6/JavaVersionCheck.java b/bundles/tooling/org.eclipse.fx.ide.java6/src/org/eclipse/fx/ide/java6/JavaVersionCheck.java
index ee5c74c44..8fbb5dded 100755
--- a/bundles/tooling/org.eclipse.fx.ide.java6/src/org/eclipse/fx/ide/java6/JavaVersionCheck.java
+++ b/bundles/tooling/org.eclipse.fx.ide.java6/src/org/eclipse/fx/ide/java6/JavaVersionCheck.java
@@ -5,11 +5,14 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.statushandlers.StatusManager;
+/**
+ * Start up participant who will open an error dialog
+ */
public class JavaVersionCheck implements IStartup {
@Override
public void earlyStartup() {
StatusManager.getManager().handle(
- new Status(IStatus.ERROR, "org.eclipse.fx.ide.java6", "You are not running your eclipse instance with Java8. The JavaFX tooling is disabled because of this.Make Java8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java8 install.\r\n\r\nIn case you want to turn off this check open your preferences and go to General > Startup and Shutdown and uncheck 'JavaFX Tooling Java Check'"),StatusManager.SHOW);
+ new Status(IStatus.ERROR, "org.eclipse.fx.ide.java6", "You are not running your eclipse instance with Java8. The JavaFX tooling is disabled because of this.Make Java8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java8 install.\r\n\r\nIn case you want to turn off this check open your preferences and go to General > Startup and Shutdown and uncheck 'JavaFX Tooling Java Check'"),StatusManager.SHOW); //$NON-NLS-1$ //$NON-NLS-2$
}
} \ No newline at end of file
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.core/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.jdt.core/META-INF/MANIFEST.MF
index 80eb978ff..e1d5ff37b 100755
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.core/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.core/META-INF/MANIFEST.MF
@@ -14,6 +14,6 @@ Require-Bundle: org.eclipse.jdt.core;bundle-version="3.7.0",
org.eclipse.core.resources;bundle-version="3.8.0"
Bundle-Activator: org.eclipse.fx.ide.jdt.core.internal.JavaFXCorePlugin
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.fx.ide.jdt.core,
+Export-Package: org.eclipse.fx.ide.jdt.core;x-internal:=true,
org.eclipse.fx.ide.jdt.core.internal;x-friends:="org.eclipse.fx.ide.jdt.ui"
Bundle-Vendor: %Bundle-Vendor
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
index b3ba6aa91..f0d2eda88 100755
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.core/src/org/eclipse/fx/ide/jdt/core/internal/BuildPathSupport.java
@@ -31,7 +31,7 @@ import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.LibraryLocation;
public class BuildPathSupport {
- public static final String WEB_JAVADOC_LOCATION = "http://docs.oracle.com/javafx/2/api/";
+ public static final String WEB_JAVADOC_LOCATION = "http://docs.oracle.com/javase/8/javafx/api/";
private static final Logger LOGGER = LoggerCreator.createLogger(BuildPathSupport.class);
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.jdt.ui/META-INF/MANIFEST.MF
index 37c787f99..796c8eaf7 100755
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.ui/META-INF/MANIFEST.MF
@@ -55,12 +55,12 @@ Bundle-ClassPath: .
Export-Package: org.eclipse.fx.ide.jdt.ui.internal;x-internal:=true,
org.eclipse.fx.ide.jdt.ui.internal.buildpath;x-internal:=true,
org.eclipse.fx.ide.jdt.ui.internal.editors;x-internal:=true,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.impl,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters.impl,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters.util,
- org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.util,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks;x-internal:=true,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.impl;x-internal:=true,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters;x-internal:=true,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters.impl;x-internal:=true,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.parameters.util;x-internal:=true,
+ org.eclipse.fx.ide.jdt.ui.internal.editors.model.anttasks.util;x-internal:=true,
org.eclipse.fx.ide.jdt.ui.internal.editors.outline;x-internal:=true,
org.eclipse.fx.ide.jdt.ui.internal.handler;x-internal:=true,
org.eclipse.fx.ide.jdt.ui.internal.wizard;x-internal:=true,
diff --git a/bundles/tooling/org.eclipse.fx.ide.jdt.ui/src/org/eclipse/fx/ide/jdt/ui/internal/handler/AddFXBeanGetterSetterHandler.java b/bundles/tooling/org.eclipse.fx.ide.jdt.ui/src/org/eclipse/fx/ide/jdt/ui/internal/handler/AddFXBeanGetterSetterHandler.java
index 66480bda1..c1f6e28d0 100644
--- a/bundles/tooling/org.eclipse.fx.ide.jdt.ui/src/org/eclipse/fx/ide/jdt/ui/internal/handler/AddFXBeanGetterSetterHandler.java
+++ b/bundles/tooling/org.eclipse.fx.ide.jdt.ui/src/org/eclipse/fx/ide/jdt/ui/internal/handler/AddFXBeanGetterSetterHandler.java
@@ -20,35 +20,28 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.ide.jdt.ui.internal.Util;
+import org.eclipse.fx.osgi.util.LoggerCreator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.FieldAccess;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.NodeFinder;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
import org.eclipse.jdt.core.formatter.CodeFormatter;
-import org.eclipse.jdt.internal.core.util.ASTNodeFinder;
import org.eclipse.jdt.internal.corext.ValidateEditException;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2;
@@ -60,17 +53,20 @@ import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jdt.internal.ui.javaeditor.ASTProvider;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
-import org.eclipse.jdt.internal.ui.text.correction.ASTResolving;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
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.Shell;
@@ -106,7 +102,6 @@ public class AddFXBeanGetterSetterHandler extends AbstractHandler {
}
} else if( selection instanceof IStructuredSelection ) {
List list = ((IStructuredSelection) selection).toList();
- System.err.println(list);
}
if( type != null ) {
@@ -117,12 +112,21 @@ public class AddFXBeanGetterSetterHandler extends AbstractHandler {
return null;
}
-
+ static class PropertyItem {
+ final IField field;
+// boolean makeFinal = true;
+
+ public PropertyItem(IField field) {
+ this.field = field;
+ }
+ }
public static class GetterSetterDialog extends TitleAreaDialog {
+ private Logger logger = LoggerCreator.createLogger(getClass());
private final IType type;
private Util util;
private CheckboxTableViewer viewer;
+ private Button makeMethodsFinal;
public GetterSetterDialog(Shell parentShell, IType type) {
super(parentShell);
@@ -140,30 +144,66 @@ public class AddFXBeanGetterSetterHandler extends AbstractHandler {
Composite content = new Composite(container, SWT.NONE);
content.setLayoutData(new GridData(GridData.FILL_BOTH));
- content.setLayout(new GridLayout());
+ content.setLayout(new GridLayout(2,false));
- viewer = new CheckboxTableViewer(new Table(content, SWT.FULL_SELECTION|SWT.CHECK|SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL));
+ this.viewer = new CheckboxTableViewer(new Table(content, SWT.FULL_SELECTION|SWT.CHECK|SWT.BORDER|SWT.V_SCROLL|SWT.H_SCROLL));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint=200;
- viewer.getControl().setLayoutData(gd);
- viewer.setContentProvider(ArrayContentProvider.getInstance());
-// viewer.getTable().setHeaderVisible(true);
-// viewer.getTable().setLinesVisible(true);
- viewer.setLabelProvider(new JavaElementLabelProvider());
+ this.viewer.getControl().setLayoutData(gd);
+ this.viewer.setContentProvider(ArrayContentProvider.getInstance());
+ JavaElementLabelProvider provider = new JavaElementLabelProvider();
+ this.viewer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ return provider.getImage(((PropertyItem)element).field);
+ }
+
+ @Override
+ public String getText(Object element) {
+ PropertyItem i = (PropertyItem) element;
+ return provider.getText(i.field);
+ }
+ });
+
+
try {
- List<IField> candidates = new ArrayList<>();
+ List<PropertyItem> candidates = new ArrayList<>();
for( IField f : this.type.getFields() ) {
if( this.util.isPropertyField(this.type, f)
&& ! this.type.getMethod("get" + Util.toFirstUpper(f.getElementName()), new String[0]).exists() //$NON-NLS-1$
&& ! this.type.getMethod("is" + Util.toFirstUpper(f.getElementName()), new String[0]).exists() //$NON-NLS-1$
&& ! this.type.getMethod(f.getElementName()+"Property", new String[0]).exists()) { //$NON-NLS-1$
- candidates.add(f);
+ candidates.add(new PropertyItem(f));
}
}
- viewer.setInput(candidates);
+ this.viewer.setInput(candidates);
} catch (JavaModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ this.logger.error("Failure while analyzing the class", e); //$NON-NLS-1$
+ }
+
+ Composite buttonContainer = new Composite(content, SWT.NONE);
+ buttonContainer.setLayout(GridLayoutFactory.fillDefaults().create());
+ buttonContainer.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ {
+ Button b = new Button(buttonContainer, SWT.PUSH);
+ b.setText("Select All");
+ b.addListener(SWT.Selection, (e) -> this.viewer.setAllChecked(true));
+ b.setLayoutData(new GridData(SWT.FILL,SWT.DEFAULT,false,false));
+ }
+
+ {
+ Button b = new Button(buttonContainer, SWT.PUSH);
+ b.setText("Deselect All");
+ b.addListener(SWT.Selection, (e) -> this.viewer.setAllChecked(false));
+ b.setLayoutData(new GridData(SWT.FILL,SWT.DEFAULT,false,false));
+ }
+
+ {
+ this.makeMethodsFinal = new Button(buttonContainer, SWT.CHECK);
+ this.makeMethodsFinal.setText("make methods final");
+ this.makeMethodsFinal.addListener(SWT.Selection, (e) -> this.viewer.setAllChecked(false));
+ this.makeMethodsFinal.setSelection(true);
+ this.makeMethodsFinal.setLayoutData(new GridData(SWT.FILL,SWT.DEFAULT,false,false));
}
return container;
@@ -172,47 +212,39 @@ public class AddFXBeanGetterSetterHandler extends AbstractHandler {
@Override
protected void okPressed() {
try {
- CompilationUnit astRoot = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(type.getCompilationUnit(), true);
+ CompilationUnit astRoot = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(this.type.getCompilationUnit(), true);
- final ICompilationUnit unit= type.getCompilationUnit();
+ final ICompilationUnit unit= this.type.getCompilationUnit();
final ASTRewrite astRewrite= ASTRewrite.create(astRoot.getAST());
ListRewrite listRewriter= null;
- if (type.isAnonymous()) {
- final ClassInstanceCreation creation= (ClassInstanceCreation) ASTNodes.getParent(NodeFinder.perform(astRoot, type.getNameRange()), ClassInstanceCreation.class);
+ if (this.type.isAnonymous()) {
+ final ClassInstanceCreation creation= (ClassInstanceCreation) ASTNodes.getParent(NodeFinder.perform(astRoot, this.type.getNameRange()), ClassInstanceCreation.class);
if (creation != null) {
final AnonymousClassDeclaration declaration= creation.getAnonymousClassDeclaration();
if (declaration != null)
listRewriter= astRewrite.getListRewrite(declaration, AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY);
}
} else {
- final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(astRoot, type.getNameRange()), AbstractTypeDeclaration.class);
+ final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(astRoot, this.type.getNameRange()), AbstractTypeDeclaration.class);
if (declaration != null)
listRewriter= astRewrite.getListRewrite(declaration, declaration.getBodyDeclarationsProperty());
}
- IType propertyType = type.getJavaProject().findType("javafx.beans.property.Property");
+ IType propertyType = this.type.getJavaProject().findType("javafx.beans.property.Property"); //$NON-NLS-1$
- for( Object o : viewer.getCheckedElements() ) {
- IField f = (IField) o;
- generateAccessors(astRoot, type, propertyType, listRewriter, f, null);
+ for( Object o : this.viewer.getCheckedElements() ) {
+ PropertyItem i = (PropertyItem) o;
+ generateAccessors(astRoot, this.type, propertyType, listRewriter, i.field, null, this.makeMethodsFinal.getSelection());
}
TextEdit fEdit = astRewrite.rewriteAST();
JavaModelUtil.applyEdit(unit, fEdit, true, new SubProgressMonitor(new NullProgressMonitor(), 1));
- } catch(JavaModelException e) {
- e.printStackTrace();
- }
- // TODO Auto-generated method stub
- catch (ValidateEditException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch(CoreException e) {
+ this.logger.error("Failure while generating accessor code", e); //$NON-NLS-1$
}
-// super.okPressed();
+ super.okPressed();
}
}
@@ -222,130 +254,107 @@ public class AddFXBeanGetterSetterHandler extends AbstractHandler {
return b;
}
}
- if( "java.lang.Object".equals(type.getQualifiedName()) ) {
+ if( "java.lang.Object".equals(type.getQualifiedName()) ) { //$NON-NLS-1$
return null;
}
return findMethodBinding(type.getSuperclass(), name);
}
- static void generateAccessors(CompilationUnit cu, IType ownerType, IType propertyType, ListRewrite rewrite, IField f, IJavaElement sibling) throws JavaModelException {
+ static void generateAccessors(CompilationUnit cu, IType ownerType, IType propertyType, ListRewrite rewrite, IField f, IJavaElement sibling, boolean makeFinal) throws JavaModelException {
ASTNode astNode = ASTNodeSearchUtil.getAstNode(cu, f.getSourceRange().getOffset(), f.getSourceRange().getLength());
FieldDeclaration fDec = (FieldDeclaration) astNode;
ITypeBinding tp = fDec.getType().resolveBinding();
// first search for get which returns the primitive type
- IMethodBinding accessMethod = findMethodBinding(tp, "get");
+ IMethodBinding accessMethod = findMethodBinding(tp, "get"); //$NON-NLS-1$
if( accessMethod == null ) {
- accessMethod = findMethodBinding(tp, "getValue");
+ accessMethod = findMethodBinding(tp, "getValue"); //$NON-NLS-1$
}
if( accessMethod == null ) {
return;
}
- IMethodBinding readonlyMethod = findMethodBinding(tp, "getReadOnlyProperty");
+ IMethodBinding readonlyMethod = findMethodBinding(tp, "getReadOnlyProperty"); //$NON-NLS-1$
- String propertyContent = generatePropertyAccessContent(f, readonlyMethod);
+ String propertyContent = generatePropertyAccessContent(f, makeFinal, readonlyMethod);
ASTNode insertion= StubUtility2.getNodeToInsertBefore(rewrite, sibling);
addNewAccessor(ownerType, f, propertyContent , rewrite, insertion);
- String getterContent = generateGetAccessContent(f, accessMethod);
+ String getterContent = generateGetAccessContent(f, makeFinal, accessMethod);
insertion= StubUtility2.getNodeToInsertBefore(rewrite, sibling);
addNewAccessor(ownerType, f, getterContent , rewrite, insertion);
IType fieldType = Util.toType(ownerType, f.getTypeSignature());
if( readonlyMethod == null && ! isReadonly(fieldType, propertyType) ) {
- String setterContent = generateSetAccessContent(f, accessMethod);
+ String setterContent = generateSetAccessContent(f, makeFinal, accessMethod);
insertion= StubUtility2.getNodeToInsertBefore(rewrite, sibling);
addNewAccessor(ownerType, f, setterContent , rewrite, insertion);
}
}
- static String generateSetAccessContent(IField f, IMethodBinding accessMethod) throws JavaModelException {
- String lineDelim = "\n";
+ static String generateSetAccessContent(IField f, boolean makeFinal, IMethodBinding accessMethod) throws JavaModelException {
+ String lineDelim = "\n"; //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
- buf.append("public void");
+ buf.append("public "+(makeFinal?"final ":"")+" void"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
String sig = accessMethod.getReturnType().getQualifiedName();
- buf.append(" set" + Util.toFirstUpper(f.getElementName()) + "(final "+sig+" "+f.getElementName()+") {");
+ buf.append(" set" + Util.toFirstUpper(f.getElementName()) + "(final "+sig+" "+f.getElementName()+") {"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
buf.append(lineDelim);
- buf.append("this."+f.getElementName()+"Property()."+ accessMethod.getName().replace("get", "set") + "("+f.getElementName()+");");
+ buf.append("this."+f.getElementName()+"Property()."+ accessMethod.getName().replace("get", "set") + "("+f.getElementName()+");"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
buf.append(lineDelim);
- buf.append("}");
+ buf.append("}"); //$NON-NLS-1$
buf.append(lineDelim);
return buf.toString();
}
- static String generateGetAccessContent(IField f, IMethodBinding accessMethod) throws JavaModelException {
- String lineDelim = "\n";
+ static String generateGetAccessContent(IField f, boolean makeFinal, IMethodBinding accessMethod) throws JavaModelException {
+ String lineDelim = "\n"; //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
- buf.append("public ");
+ buf.append("public "+(makeFinal?"final ":"")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
String sig = accessMethod.getReturnType().getQualifiedName();
buf.append(sig);
- if( "boolean".equals(sig) ) {
- buf.append(" is" + Util.toFirstUpper(f.getElementName()) + "() {");
+ if( "boolean".equals(sig) ) { //$NON-NLS-1$
+ buf.append(" is" + Util.toFirstUpper(f.getElementName()) + "() {"); //$NON-NLS-1$//$NON-NLS-2$
} else {
- buf.append(" get" + Util.toFirstUpper(f.getElementName()) + "() {");
+ buf.append(" get" + Util.toFirstUpper(f.getElementName()) + "() {"); //$NON-NLS-1$//$NON-NLS-2$
}
buf.append(lineDelim);
- buf.append("return this."+f.getElementName()+"Property()."+accessMethod.getName() + "();");
+ buf.append("return this."+f.getElementName()+"Property()."+accessMethod.getName() + "();"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
buf.append(lineDelim);
- buf.append("}");
+ buf.append("}"); //$NON-NLS-1$
buf.append(lineDelim);
return buf.toString();
}
-//
-// static String getType(IField f, IMethod method) throws JavaModelException {
-// String returnType = method.getReturnType();
-// String sig = Signature.toString(returnType);
-//
-// String typedParameter = null;
-// ITypeParameter[] typeParameterSignatures = method.getDeclaringType().getTypeParameters();
-// if( typeParameterSignatures.length == 1 ) {
-// typedParameter = typeParameterSignatures[0].getElementName();
-// }
-// if( sig.equals(typedParameter) ) {
-// String[] typeArgs = Signature.getTypeArguments(f.getTypeSignature());
-// if( typeArgs.length > 0 ) {
-// return Signature.toString(typeArgs[0]);
-// } else {
-// //FIXME We need to search now!!!
-// return "String";
-// }
-//
-// } else {
-// return sig;
-// }
-// }
- static String generatePropertyAccessContent(IField f, IMethodBinding readonlyBinding) throws IllegalArgumentException, JavaModelException {
- String lineDelim = "\n";
+ static String generatePropertyAccessContent(IField f, boolean makeFinal, IMethodBinding readonlyBinding) throws IllegalArgumentException, JavaModelException {
+ String lineDelim = "\n"; //$NON-NLS-1$
StringBuffer buf = new StringBuffer();
- buf.append("public ");
+ buf.append("public "+(makeFinal?"final ":"")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
if( readonlyBinding != null ) {
buf.append(readonlyBinding.getReturnType().getQualifiedName());
} else {
buf.append(Signature.toString(f.getTypeSignature()));
}
- buf.append(" " + f.getElementName()+"Property() {");
+ buf.append(" " + f.getElementName()+"Property() {"); //$NON-NLS-1$//$NON-NLS-2$
buf.append(lineDelim);
- buf.append("return this."+f.getElementName() + ( readonlyBinding != null ? ".getReadOnlyProperty()" : "" ) + ";");
+ buf.append("return this."+f.getElementName() + ( readonlyBinding != null ? ".getReadOnlyProperty()" : "" ) + ";"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
buf.append(lineDelim);
- buf.append("}");
+ buf.append("}"); //$NON-NLS-1$
buf.append(lineDelim);
return buf.toString();
}
static boolean isReadonlyWrapper(IType fieldType) throws JavaModelException {
- return fieldType.getMethod("getReadOnlyProperty", new String[0]).exists();
+ return fieldType.getMethod("getReadOnlyProperty", new String[0]).exists(); //$NON-NLS-1$
}
static boolean isReadonly(IType fieldType, IType propertyType) {
diff --git a/bundles/tooling/org.eclipse.fx.ide.model/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.model/META-INF/MANIFEST.MF
index 66e38e5ec..a3ac71d0a 100755
--- a/bundles/tooling/org.eclipse.fx.ide.model/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.model/META-INF/MANIFEST.MF
@@ -9,5 +9,5 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.annotation;bundle-version="2.0.0";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.model,
+Export-Package: org.eclipse.fx.ide.model;x-internal:=true,
org.eclipse.fx.ide.model.internal.utils;x-friends:="org.eclipse.fx.ide.fxgraph.ui"
diff --git a/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/e4App.rtask b/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/e4App.rtask
index c44a30298..12b08826a 100755
--- a/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/e4App.rtask
+++ b/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/e4App.rtask
@@ -212,7 +212,7 @@ RobotTask {
"org.eclipse.fx.ui.workbench.fx",
"org.eclipse.fx.ui.workbench.renderers.base",
"org.eclipse.fx.ui.workbench.renderers.fx",
- "org.eclipse.fx.ui.lifecycle",
+ "org.eclipse.fx.ui.workbench.services",
"com.ibm.icu",
// TODO NEED TO SUPPORT CONDITIONALS HERE "com.ibm.icu.base",
"javax.annotation",
diff --git a/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/mediaSample.rtask b/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/mediaSample.rtask
index 9f334885d..0aa846e4f 100755
--- a/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/mediaSample.rtask
+++ b/bundles/tooling/org.eclipse.fx.ide.pde.ui.e4/generator-tasks/mediaSample.rtask
@@ -250,7 +250,7 @@ RobotTask {
"org.eclipse.fx.ui.workbench.fx",
"org.eclipse.fx.ui.workbench.renderers.base",
"org.eclipse.fx.ui.workbench.renderers.fx",
- "org.eclipse.fx.ui.lifecycle",
+ "org.eclipse.fx.ui.workbench.services",
"com.ibm.icu",
// TODO NEED TO SUPPORT CONDITIONALS HERE "com.ibm.icu.base",
"javax.annotation",
diff --git a/bundles/tooling/org.eclipse.fx.ide.pde.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.pde.ui/META-INF/MANIFEST.MF
index a89187190..04246314b 100755
--- a/bundles/tooling/org.eclipse.fx.ide.pde.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.pde.ui/META-INF/MANIFEST.MF
@@ -31,5 +31,5 @@ Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Export-Package: org.eclipse.fx.ide.pde.ui.templates;x-friends:="org.eclipse.fx.ide.pde.e4",
org.eclipse.fx.ide.pde.ui.templates.tycho;x-friends:="org.eclipse.fx.ide.pde.e4",
- org.eclipse.fx.ide.pde.ui.wizard,
- org.eclipse.fx.ide.pde.ui.wizard.model
+ org.eclipse.fx.ide.pde.ui.wizard;x-internal:=true,
+ org.eclipse.fx.ide.pde.ui.wizard.model;x-internal:=true
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..0c68a61dc
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/build.properties b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/build.properties
index e7597ef93..6d4240460 100755
--- a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/build.properties
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.tests/build.properties
@@ -2,6 +2,5 @@ source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
- plugin.xml,\
about.html
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.ui/META-INF/MANIFEST.MF
index f8e57b6c9..042eef0c3 100755
--- a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl.ui/META-INF/MANIFEST.MF
@@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.fx.ide.rrobot.dsl;visibility:=reexport,
org.eclipse.fx.ide.rrobot;bundle-version="0.9.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.rrobot.dsl.ui.contentassist,
- org.eclipse.fx.ide.rrobot.dsl.ui.contentassist.antlr,
- org.eclipse.fx.ide.rrobot.dsl.ui.quickfix
+Export-Package: org.eclipse.fx.ide.rrobot.dsl.ui.contentassist;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.ui.contentassist.antlr;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.ui.quickfix;x-internal:=true
Bundle-Activator: org.eclipse.fx.ide.rrobot.dsl.ui.internal.RTaskActivator
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl/META-INF/MANIFEST.MF
index d072815f5..ced69ee06 100755
--- a/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot.dsl/META-INF/MANIFEST.MF
@@ -18,11 +18,11 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
org.eclipse.osgi;bundle-version="3.7.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.rrobot.dsl,
- org.eclipse.fx.ide.rrobot.dsl.services,
- org.eclipse.fx.ide.rrobot.dsl.parseTreeConstruction,
- org.eclipse.fx.ide.rrobot.dsl.parser.antlr,
- org.eclipse.fx.ide.rrobot.dsl.parser.antlr.internal,
- org.eclipse.fx.ide.rrobot.dsl.validation,
- org.eclipse.fx.ide.rrobot.dsl.scoping,
- org.eclipse.fx.ide.rrobot.dsl.formatting
+Export-Package: org.eclipse.fx.ide.rrobot.dsl;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.formatting;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.parseTreeConstruction;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.parser.antlr;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.parser.antlr.internal;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.scoping;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.services;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.dsl.validation;x-internal:=true
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot.model/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.rrobot.model/META-INF/MANIFEST.MF
index 834fdc7ae..f91b5695b 100755
--- a/bundles/tooling/org.eclipse.fx.ide.rrobot.model/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot.model/META-INF/MANIFEST.MF
@@ -7,11 +7,11 @@ Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.rrobot.model.bundle,
- org.eclipse.fx.ide.rrobot.model.bundle.util,
- org.eclipse.fx.ide.rrobot.model.task,
- org.eclipse.fx.ide.rrobot.model.task.util,
- org.eclipse.fx.ide.rrobot.model.util
+Export-Package: org.eclipse.fx.ide.rrobot.model.bundle;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.model.bundle.util;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.model.task;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.model.task.util;x-internal:=true,
+ org.eclipse.fx.ide.rrobot.model.util;x-internal:=true
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.jdt.annotation;bundle-version="2.0.0";resolution:=optional
diff --git a/bundles/tooling/org.eclipse.fx.ide.rrobot/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.rrobot/META-INF/MANIFEST.MF
index 74b2440fc..add6e2b40 100755
--- a/bundles/tooling/org.eclipse.fx.ide.rrobot/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.rrobot/META-INF/MANIFEST.MF
@@ -17,6 +17,6 @@ Require-Bundle: org.eclipse.equinox.common;bundle-version="3.6.0",
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/manifestgen.xml,OSGI-INF/pluginxmlgen.xml,OSGI-INF/buildpropgen.xml,OSGI-INF/def_projecthandler.xml,OSGI-INF/bundle_projecthandler.xml,OSGI-INF/rrobot.xml,OSGI-INF/feature_projecthandler.xml,OSGI-INF/featurexmlgen.xml,OSGI-INF/productgen.xml,OSGI-INF/java-exec.xml,
OSGI-INF/js-boolean-exec.xml.xml
-Export-Package: org.eclipse.fx.ide.rrobot
+Export-Package: org.eclipse.fx.ide.rrobot;x-internal:=true
Import-Package: org.apache.commons.lang.text;version="2.6.0"
diff --git a/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
index 8b22c4bcf..d595b585a 100644
--- a/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
@@ -36,9 +36,9 @@ Import-Package: javafx.animation;version="2.2.0",
javafx.stage;version="2.2.0",
javafx.util;version="2.2.0",
javafx.util.converter;version="2.2.0"
-Export-Package: org.eclipse.fx.ide.ui.mobile.sim.device,
- org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyNote2,
- org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyS3,
- org.eclipse.fx.ide.ui.mobile.sim.device.ios.ipad,
- org.eclipse.fx.ide.ui.mobile.sim.device.ios.iphone
+Export-Package: org.eclipse.fx.ide.ui.mobile.sim.device;x-internal:=true,
+ org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyNote2;x-internal:=true,
+ org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyS3;x-internal:=true,
+ org.eclipse.fx.ide.ui.mobile.sim.device.ios.ipad;x-internal:=true,
+ org.eclipse.fx.ide.ui.mobile.sim.device.ios.iphone;x-internal:=true
Require-Bundle: org.eclipse.fx.ui.mobile;bundle-version="0.9.0"
diff --git a/bundles/tooling/org.eclipse.fx.ide.ui.preview/src/org/eclipse/fx/ide/ui/preview/LivePreviewSynchronizer.java b/bundles/tooling/org.eclipse.fx.ide.ui.preview/src/org/eclipse/fx/ide/ui/preview/LivePreviewSynchronizer.java
index e66d73670..75266d20b 100755
--- a/bundles/tooling/org.eclipse.fx.ide.ui.preview/src/org/eclipse/fx/ide/ui/preview/LivePreviewSynchronizer.java
+++ b/bundles/tooling/org.eclipse.fx.ide.ui.preview/src/org/eclipse/fx/ide/ui/preview/LivePreviewSynchronizer.java
@@ -155,12 +155,15 @@ public class LivePreviewSynchronizer implements IPartListener, IPropertyListener
} else if( e.getEntryKind() == IClasspathEntry.CPE_CONTAINER ) {
if( ! e.getPath().toString().startsWith("org.eclipse.jdt.launching.JRE_CONTAINER")
&& ! e.getPath().toString().startsWith("org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER")) {
+// System.err.println("====> A container");
+
IClasspathContainer cp = JavaCore.getClasspathContainer(e.getPath(), project);
for( IClasspathEntry ce : cp.getClasspathEntries() ) {
+// System.err.println(ce.getEntryKind() + "=> " + ce);
if( ce.getEntryKind() == IClasspathEntry.CPE_LIBRARY ) {
listRefLibraries.add(ce.getPath());
} else if( ce.getEntryKind() == IClasspathEntry.CPE_PROJECT ) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(e.getPath().lastSegment());
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(ce.getPath().lastSegment());
if (p.exists()) {
resolveDataProject(JavaCore.create(p), outputPath, listRefLibraries);
}
diff --git a/bundles/tooling/org.eclipse.fx.ide.ui/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.ui/META-INF/MANIFEST.MF
index 70f9d38c5..8a4663310 100755
--- a/bundles/tooling/org.eclipse.fx.ide.ui/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.ui/META-INF/MANIFEST.MF
@@ -18,10 +18,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions;bundle-version="3.4.300"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Export-Package: org.eclipse.fx.ide.ui.editor,
- org.eclipse.fx.ide.ui.util,
- org.eclipse.fx.ide.ui.wizards,
- org.eclipse.fx.ide.ui.wizards.template
+Export-Package: org.eclipse.fx.ide.ui.editor;x-internal:=true,
+ org.eclipse.fx.ide.ui.util;x-internal:=true,
+ org.eclipse.fx.ide.ui.wizards;x-internal:=true,
+ org.eclipse.fx.ide.ui.wizards.template;x-internal:=true
Bundle-Vendor: %Bundle-Vendor
Service-Component: OSGI-INF/colorvaluecontributor.xml,
OSGI-INF/valuecontributorcollector.xml

Back to the top