Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src')
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java69
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/accumulator/CustomRowOverrideLabelAccumulator.java70
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java73
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractComboAction.java84
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ButtonConfiguration.java120
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ComboBoxWithButtonCellEditor.java176
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfiguration.java55
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfigurationFactory.java111
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java124
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisCellEditorConfiguration.java120
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisEStructuralFeatureCellEditorConfiguration.java33
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java74
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/TableCommands.java310
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CornerConfiguration.java77
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CustomizedCellPainter.java163
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java168
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnHeaderStyleConfiguration.java43
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnResizeBindingsConfiguration.java54
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java46
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java55
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java128
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowHeaderStyleConfiguration.java42
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowResizeBindingsConfiguration.java56
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/StyleConfiguration.java40
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java94
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/copy/CopySelectionToClipboardAction.java46
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractDataProvider.java68
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractHeaderDataProvider.java202
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/BodyDataProvider.java54
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/ColumnHeaderDataProvider.java132
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/RowHeaderDataProvider.java141
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/DisplayedAxisSelectorDialog.java127
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/exception/ErrorInPastePreparationException.java34
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/formatter/PapyrusExportFormatter.java45
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeHeaderConfigurationHandler.java90
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeIndexStyleHandler.java72
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeLabelConfigurationValueHandler.java177
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeHeaderConfigurationHandler.java54
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeLabelConfigurationValueHandler.java79
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java77
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeHeaderConfigurationHandler.java57
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeLabelConfigurationValueHandler.java80
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java238
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexColumnStyleHandler.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexRowStyleHandler.java34
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnAutoResizeHandler.java44
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java64
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java63
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayIndexHeaderHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureIsDerivedHandler.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureMultiplicityHandler.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureNameHandler.java37
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureTypeHandler.java37
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelHeaderHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelImageHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelTextHandler.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java57
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnMasterDisconnectRowSlaveHandler.java36
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ExportToXLSHandler.java31
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java41
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PrintTableHandler.java43
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowAutoResizeHandler.java45
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java64
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java63
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayIndexHeaderHandler.java37
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabeTextHandler.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureIsDerivedHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureMultiplicityHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureNameHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureTypeHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelHeaderHandler.java37
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelImageHandler.java38
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java57
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowMasterDisconnectColumnSlaveHandler.java36
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectAllHandler.java35
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java54
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java54
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java60
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java59
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/DestroyTableAdviceHelper.java9
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/TableContentsAdviceHelper.java90
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusGridLayer.java77
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSelectionLayer.java90
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java115
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java44
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderLayerStack.java80
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDropListener.java139
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java567
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java306
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AxisManagerFactory.java84
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java562
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java295
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java52
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java68
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java45
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java126
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java114
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java461
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ILimitedNattableModelManager.java25
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java184
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ITableAxisElementProvider.java29
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java1036
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java192
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties82
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/nattableconfiguration/NattableConfigurationRegistry.java158
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomCheckBoxPainter.java49
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomImagePainter.java51
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractNattableCellLabelProvider.java175
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java78
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/IndexHeaderLabelProvider.java53
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/NattableTopLabelProvider.java255
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java157
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java128
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/CompoundFilteredRestrictedContentProvider.java145
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/FlattenableRestrictedFilteredContentProvider.java192
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IIgnoreStereotypeBasePropertyContentProvider.java41
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IInheritedElementContentProvider.java40
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IRestrictedContentProvider.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomCellDragModeForColumn.java89
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomColumnReorderDragMode.java85
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomDefaultColumnReorderBindings.java58
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/ITableTester.java34
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/TableTesterRegistry.java72
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisComparator.java92
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisUtils.java127
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/Constants.java57
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/HeaderAxisConfigurationManagementUtils.java167
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderCellContextElementWrapper.java30
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderContextElementWrapper.java41
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/IPasteInTableCommandProvider.java72
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelConfigurationManagementUtils.java310
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderCellContextElementWrapper.java221
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderContextElementWrapper.java70
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LocationValue.java229
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigAttributes.java67
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java85
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtil.java35
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java34
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java60
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableEditingDomainuUtils.java75
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableGridRegion.java23
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableHelper.java110
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/widget/NatComboButton.java256
143 files changed, 14677 insertions, 0 deletions
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java
new file mode 100644
index 00000000000..db654b72350
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.nattable"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/accumulator/CustomRowOverrideLabelAccumulator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/accumulator/CustomRowOverrideLabelAccumulator.java
new file mode 100644
index 00000000000..d786f0e84fc
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/accumulator/CustomRowOverrideLabelAccumulator.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.accumulator;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.AbstractOverrider;
+
+/**
+ *
+ * Tghis accumulator is used to register CellEditor on rows
+ *
+ */
+public class CustomRowOverrideLabelAccumulator extends AbstractOverrider {
+
+ private final ILayer layer;
+
+ public CustomRowOverrideLabelAccumulator(ILayer layer) {
+ this.layer = layer;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator#accumulateConfigLabels(org.eclipse.nebula.widgets.nattable.layer.LabelStack,
+ * int, int)
+ *
+ * @param configLabels
+ * @param columnPosition
+ * @param rowPosition
+ */
+ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
+ int rowIndex = layer.getRowIndexByPosition(rowPosition);
+ List<String> overrides = getOverrides(Integer.valueOf(rowIndex));
+ if(overrides != null) {
+ for(String configLabel : overrides) {
+ configLabels.addLabel(configLabel);
+ }
+ }
+ }
+
+ /**
+ * Register labels to be contributed a column. This label will be applied to<br/>
+ * all cells in the column.
+ */
+ public void registerRowOverrides(int rowIndex, String... configLabels) {
+ super.registerOverrides(Integer.valueOf(rowIndex), configLabels);
+ }
+
+ /**
+ * Register labels to be contributed a column. This label will be applied to<br/>
+ * all cells in the column.
+ */
+ public void registerRowOverridesOnTop(int rowIndex, String... configLabels) {
+ super.registerOverridesOnTop(Integer.valueOf(rowIndex), configLabels);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java
new file mode 100644
index 00000000000..59afcd9e25f
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.advice;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+
+/**
+ * Destroy the NatTable
+ *
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class DeleteNatTableContextAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
+ final EObject objectToDestroy = request.getElementToDestroy();
+ if(objectToDestroy == null) {
+ return null;
+ }
+
+ final ECrossReferenceAdapter crossReferencerAdapter = CrossReferenceAdapter.getCrossReferenceAdapter(objectToDestroy);
+ final Collection<Setting> settings = crossReferencerAdapter.getNonNavigableInverseReferences(objectToDestroy);
+ CompositeCommand cmd = new CompositeCommand(Messages.DeleteNatTableContextAdvice_DestroyNattableCommand);
+ for(Setting currentSetting : settings) {
+ final EObject currentEObject = currentSetting.getEObject();
+ final EStructuralFeature currentfeature = currentSetting.getEStructuralFeature();
+ if(currentEObject instanceof Table && currentfeature == NattablePackage.eINSTANCE.getTable_Context()) {
+ final DestroyElementRequest request2 = new DestroyElementRequest(currentEObject, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(currentEObject);
+ cmd.add(provider.getEditCommand(request2));
+ }
+ }
+ if(!cmd.isEmpty()) {
+ return cmd;
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractComboAction.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractComboAction.java
new file mode 100644
index 00000000000..71fd8a77bb3
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractComboAction.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor;
+
+import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
+import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
+
+/**
+ *
+ * This abstract class is used to declare addition action for a button located near a NatCombo
+ *
+ */
+public abstract class AbstractComboAction {
+
+ /**
+ * The NatCombo
+ */
+ protected NatCombo combo;
+
+ /**
+ * the column index of the edited cell
+ */
+ protected int columnIndex;
+
+ /**
+ * the row index of the edited cell
+ */
+ protected int rowIndex;
+
+ /**
+ * The combo box data provider
+ */
+ protected IComboBoxDataProvider dataProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * the data provider used for the combo
+ */
+ public AbstractComboAction(final IComboBoxDataProvider dataProvider) {
+ this.dataProvider = dataProvider;
+ }
+
+ /**
+ *
+ * @param combo
+ * the NatCombo
+ */
+ public void setNatCombo(final NatCombo combo) {
+ this.combo = combo;
+ }
+
+ /**
+ * This method is called when the button is pressed
+ */
+ public abstract void run();
+
+
+ /**
+ * Setter for the edited cell location
+ *
+ * @param columnIndex
+ * the column index of the edited cell
+ * @param rowIndex
+ * the row index of the edited cell
+ */
+ public final void setCellLocation(int columnIndex, int rowIndex) {
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ButtonConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ButtonConfiguration.java
new file mode 100644
index 00000000000..13e2d823895
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ButtonConfiguration.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This class allows to store required information to customize
+ * a Button and define the action done when it is pressed.
+ */
+public class ButtonConfiguration {
+
+ /** The text to use for the button. */
+ private String text;
+
+ /** The tooltip to use for the button. */
+ private String tooltipText;
+
+ /** the action done by the button. */
+ private AbstractComboAction action;
+
+ /** the image to set on the button. */
+ private Image image;
+
+
+ /**
+ * Gets the image.
+ *
+ * @return the image
+ */
+ public Image getImage() {
+ return image;
+ }
+
+
+ /**
+ * Sets the image.
+ *
+ * @param image
+ * the new image
+ */
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+
+ /**
+ * Gets the text.
+ *
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+
+ /**
+ * Sets the text.
+ *
+ * @param text
+ * the new text
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+
+ /**
+ * Gets the tooltip text.
+ *
+ * @return the tooltip text
+ */
+ public String getTooltipText() {
+ return tooltipText;
+ }
+
+
+ /**
+ * Sets the tooltip text.
+ *
+ * @param tooltipText
+ * the new tooltip text
+ */
+ public void setTooltipText(String tooltipText) {
+ this.tooltipText = tooltipText;
+ }
+
+
+ /**
+ * Gets the action.
+ *
+ * @return the action
+ */
+ public AbstractComboAction getAction() {
+ return action;
+ }
+
+
+ /**
+ * Sets the action.
+ *
+ * @param action
+ * the new action
+ */
+ public void setAction(AbstractComboAction action) {
+ this.action = action;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ComboBoxWithButtonCellEditor.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ComboBoxWithButtonCellEditor.java
new file mode 100644
index 00000000000..616d5e8aec2
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/ComboBoxWithButtonCellEditor.java
@@ -0,0 +1,176 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
+import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
+import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
+import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
+import org.eclipse.papyrus.infra.nattable.widget.NatComboButton;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class ComboBoxWithButtonCellEditor extends ComboBoxCellEditor {
+
+ /**
+ * the action done by the button
+ */
+ private ButtonConfiguration buttonConfiguration;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param multiselect
+ * @param buttonConfig
+ * the action done by the button
+ */
+ public ComboBoxWithButtonCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, boolean freeEdit, boolean multiselect, ButtonConfiguration buttonConfig) {
+ this(dataProvider, maxVisibleItems, freeEdit, buttonConfig);
+ setMultiselect(multiselect);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, boolean freeEdit, ButtonConfiguration action) {
+ this(dataProvider, maxVisibleItems, action);
+ setFreeEdit(freeEdit);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param maxVisibleItems
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, ButtonConfiguration action) {
+ super(dataProvider, maxVisibleItems);
+ this.buttonConfiguration = action;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(IComboBoxDataProvider dataProvider, ButtonConfiguration action) {
+ super(dataProvider);
+ this.buttonConfiguration = action;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param canonicalValues
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param multiselect
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(List<?> canonicalValues, int maxVisibleItems, boolean freeEdit, boolean multiselect, ButtonConfiguration action) {
+ this(canonicalValues, maxVisibleItems, freeEdit, action);
+ setMultiselect(multiselect);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param canonicalValues
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(List<?> canonicalValues, int maxVisibleItems, boolean freeEdit, ButtonConfiguration action) {
+ this(canonicalValues, maxVisibleItems, action);
+ setFreeEdit(freeEdit);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param canonicalValues
+ * @param maxVisibleItems
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(List<?> canonicalValues, int maxVisibleItems, ButtonConfiguration action) {
+ super(canonicalValues, maxVisibleItems);
+ this.buttonConfiguration = action;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param canonicalValues
+ * @param action
+ */
+ public ComboBoxWithButtonCellEditor(List<?> canonicalValues, ButtonConfiguration action) {
+ super(canonicalValues);
+ this.buttonConfiguration = action;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor#createEditorControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ public NatCombo createEditorControl(Composite parent) {
+ int style = this.editMode == EditModeEnum.INLINE ? SWT.NONE : SWT.BORDER;
+ final NatCombo combo = this.iconImage == null ? new NatComboButton(parent, this.cellStyle, this.maxVisibleItems, this.freeEdit, this.multiselect, style, buttonConfiguration) : new NatComboButton(parent, this.cellStyle, this.maxVisibleItems, this.freeEdit, this.multiselect, style, this.iconImage, buttonConfiguration);
+
+ combo.setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_IBEAM));
+
+ if(multiselect) {
+ combo.setMultiselectValueSeparator(this.multiselectValueSeparator);
+ combo.setMultiselectTextBracket(this.multiselectTextPrefix, this.multiselectTextSuffix);
+ }
+
+ addNatComboListener(combo);
+ //configure the action done by the button
+ buttonConfiguration.getAction().setCellLocation(layerCell.getColumnIndex(), layerCell.getRowIndex());
+ buttonConfiguration.getAction().setNatCombo(combo);
+ return combo;
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfiguration.java
new file mode 100644
index 00000000000..65fe8cd52e4
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfiguration.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor.config;
+
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+
+
+public abstract class AbstractCellEditorConfiguration implements IAxisCellEditorConfiguration {
+
+ public static final String CELL_LABEL = "cell_label"; //$NON-NLS-1$
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration#getConfigCellId()
+ *
+ * @return
+ */
+ public final String getConfigCellId() {
+ return getEditorId() + CELL_LABEL;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration#getDataValidator(Table, Object)
+ *
+ * @return
+ * <code>null</code>
+ */
+ public IDataValidator getDataValidator(Table table, Object axisElement) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration#getEditorDescription()
+ *
+ * @return
+ */
+ public String getEditorDescription() {
+ return "No Existing Description";
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfigurationFactory.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfigurationFactory.java
new file mode 100644
index 00000000000..903ca5df9ea
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/AbstractCellEditorConfigurationFactory.java
@@ -0,0 +1,111 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor.config;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ *
+ * The abstract class to used for CellEditorFactory
+ *
+ */
+public abstract class AbstractCellEditorConfigurationFactory {
+
+ /**
+ * the id of the factory
+ */
+ private String id;
+
+ /**
+ * the id of the extension point used to register contribution
+ */
+ public static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.celleditor.configuration"; //$NON-NLS-1$
+
+ public static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ public static final String FACTORY_ID_ATTRIBUTE = "factoryId"; //$NON-NLS-1$
+
+ public static final String ORDER_ATTRIBUTE = "order"; //$NON-NLS-1$
+
+ /**
+ *
+ * @param id
+ * the id of the factory
+ */
+ public void initFactory(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ * the id of the factory
+ */
+ public final String getFactoryId() {
+ return this.id;
+ }
+
+ /**
+ *
+ * @return
+ * the registered element for this factory
+ */
+ public Collection<IConfigurationElement> getAllRegisteredCellEditorConfiguration() {
+ Collection<IConfigurationElement> elements = new ArrayList<IConfigurationElement>();
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+ final String current = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
+ if(current.equals(this.id)) {
+ elements.add(iConfigurationElement);
+ }
+ }
+ return elements;
+ }
+
+ /**
+ *
+ * @param editorId
+ * the editor id
+ * @return
+ * the configuration for this editor or <code>null</code> if the editor is not registered in this factory
+ */
+ public abstract IAxisCellEditorConfiguration getCellEditorConfiguration(final String editorId);
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param axisElement
+ * an eobject
+ * @return
+ * <code>true</code> if this factory allows to edit the object for this table
+ */
+ public abstract boolean handles(final Table table, final Object axisElement);
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param axisElement
+ * an eobject
+ * @return
+ * the cell editor configuration for the couple table - axisElement
+ */
+ public abstract IAxisCellEditorConfiguration getCellEditorConfiguration(Table table, final Object axisElement);
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java
new file mode 100644
index 00000000000..e08a2e9e555
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ *
+ * This class allows to load and get all registered CellEditorConfigurationFactory
+ *
+ */
+public class CellEditorConfigurationFactory {
+
+ private Map<Integer, IAxisCellEditorConfiguration> registry;
+
+ public static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.celleditor.configuration"; //$NON-NLS-1$
+
+ // public static final String FACTORY_ID_ATTRIBUTE = "id"; //$NON-NLS-1$
+
+ public static final String CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ public static final String ORDER_ATTRIBUTE = "order"; //$NON-NLS-1$
+
+ public static final CellEditorConfigurationFactory INSTANCE = new CellEditorConfigurationFactory();
+
+ /**
+ *
+ * Constructor.
+ * Initial the registry of the configuration factories
+ */
+ private CellEditorConfigurationFactory() {
+ //to prevent instanciation
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ this.registry = new TreeMap<Integer, IAxisCellEditorConfiguration>();
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+ // final String id = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
+ final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER_ATTRIBUTE));
+ try {
+ final IAxisCellEditorConfiguration factory = (IAxisCellEditorConfiguration)iConfigurationElement.createExecutableExtension(CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE);
+ // factory.initFactory(id);
+
+ if(factory != null) {
+ this.registry.put(order, factory);
+ }
+ } catch (final CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param configurationId
+ * the id of the factory
+ * @return
+ * the cellEditorFactory declared on this id or <code>null</code> if not found
+ */
+ public IAxisCellEditorConfiguration getCellEditorConfigruation(final String configurationId) {
+ assert configurationId != null;
+ for(final Integer order : this.registry.keySet()) {
+ final IAxisCellEditorConfiguration current = this.registry.get(order);
+ if(configurationId.equals(current.getEditorId())) {
+ return current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * the table for which we are looking for a cell editor factory
+ * @param obj
+ * the object for which we are looking for a cell editor factory
+ * @return
+ * the first cell editor configuration factory which is able to manage this object
+ */
+ public IAxisCellEditorConfiguration getFirstCellEditorConfiguration(final Table table, final Object obj) {
+ final List<IAxisCellEditorConfiguration> factories = getCellEditorConfigurationFactories(table, obj);
+ if(!factories.isEmpty()) {
+ return factories.get(0);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * the table for which we are looking for a cell editor factory
+ * @param obj
+ * the object for which we are looking for a cell editor factory
+ * @return
+ * the list of the cell editor configuration which are able to manage this object
+ */
+ public List<IAxisCellEditorConfiguration> getCellEditorConfigurationFactories(final Table table, final Object obj) {
+ final List<IAxisCellEditorConfiguration> factories = new ArrayList<IAxisCellEditorConfiguration>();
+ for(final IAxisCellEditorConfiguration current : this.registry.values()) {
+ if(current.handles(table, obj)) {
+ factories.add(current);
+ }
+ }
+ return factories;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisCellEditorConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisCellEditorConfiguration.java
new file mode 100644
index 00000000000..fb36d642615
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisCellEditorConfiguration.java
@@ -0,0 +1,120 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor.config;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
+import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ *
+ * This interface declares the methods used to get the element for the configuration of celleditors when they are declared by axis
+ *
+ */
+public interface IAxisCellEditorConfiguration {
+
+ /**
+ *
+ * @param axisElement
+ * TODO
+ * @param table
+ * TODO
+ * @param provider
+ * the label provider to use
+ * @return
+ * the display converter
+ */
+ public IDisplayConverter getDisplayConvert(Object axisElement, Table table, final ILabelProvider provider);
+
+ /**
+ *
+ * @param table
+ * TODO
+ * @param axisElement
+ * TODO
+ * @return
+ * the cell painter for the editor
+ */
+ public ICellPainter getCellPainter(Table table, Object axisElement);
+
+ /**
+ *
+ * @param table
+ * TODO
+ * @param axisElement
+ * the edited element axis
+ * @param elementProvider
+ * @return
+ */
+ public ICellEditor getICellEditor(Table table, Object axisElement, ITableAxisElementProvider elementProvider);
+
+
+ /**
+ *
+ * @param table
+ * TODO
+ * @param axisElement
+ * TODO
+ * @return
+ * the display mode to use for the editor
+ */
+ public String getDisplayMode(Table table, Object axisElement);
+
+ /**
+ *
+ * @return
+ * the id of the editor
+ */
+ //FIXME should be renamed into getEditorConfigId
+ public String getEditorId();
+
+ /**
+ *
+ * @return
+ * the id to use to tag the cell
+ */
+ public String getConfigCellId();//FIXME : shoudl be removed!
+
+ /**
+ * the data validator
+ *
+ * @param table
+ * TODO
+ * @param axisElement
+ * TODO
+ */
+ public IDataValidator getDataValidator(Table table, Object axisElement);
+
+ /**
+ *
+ * @return
+ * the description for the editor (should be used by the preferences)
+ */
+ public String getEditorDescription();
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param object
+ * an object
+ * @return
+ * <code>true</code> if the cell editor configuration is able to manage the object
+ */
+ public boolean handles(Table table, Object object);
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisEStructuralFeatureCellEditorConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisEStructuralFeatureCellEditorConfiguration.java
new file mode 100644
index 00000000000..af85027c26a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/IAxisEStructuralFeatureCellEditorConfiguration.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor.config;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ *
+ * A specific interface to declare editor on specific EStructuralFeature
+ *
+ */
+public interface IAxisEStructuralFeatureCellEditorConfiguration extends IAxisCellEditorConfiguration {
+
+ /**
+ *
+ * @return
+ * the edited feature
+ */
+ public Collection<EStructuralFeature> getEditedFeature();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java
new file mode 100644
index 00000000000..6236f06c7ee
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/CommandIds.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.command;
+
+/**
+ * This class references the ids of the commands declared for tables
+ *
+ * @author vl222926
+ *
+ */
+public class CommandIds {
+
+ private CommandIds() {
+ //to prevent instanciation
+ }
+
+ public static final String TOGGLE_STATE = "org.eclipse.ui.commands.toggleState"; //$NON-NLS-1$
+
+ public static final String RADIO_STATE = "org.eclipse.ui.commands.radioState"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_DISPLAY_INDEX_ID = "org.eclipse.papyrus.infra.nattable.column.display.index"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_DISPLAY_LABEL_ID = "org.eclipse.papyrus.infra.nattable.column.display.label"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_DISPLAY_INDEX_STYLE_ID = "org.eclipse.papyrus.infra.nattable.column.index.style"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_DISPLAY_INDEX_ID = "org.eclipse.papyrus.infra.nattable.row.display.index"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_DISPLAY_LABEL_ID = "org.eclipse.papyrus.infra.nattable.row.display.label"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_DISPLAY_INDEX_STYLE_ID = "org.eclipse.papyrus.infra.nattable.row.index.style"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_DISPLAY_ICON = "org.eclipse.papyrus.infra.nattable.column.label.display.icon"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_DISPLAY_ICON = "org.eclipse.papyrus.infra.nattable.row.label.display.icon"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_DISPLAY_LABEL = "org.eclipse.papyrus.infra.nattable.column.label.display.label"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_DISPLAY_LABEL = "org.eclipse.papyrus.infra.nattable.row.label.display.label"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_FEATURE_DISPLAY_IS_DERIVED = "org.eclipse.papyrus.infra.nattable.row.label.feature.display.isderived"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_FEATURE_DISPLAY_MULTIPLICITY = "org.eclipse.papyrus.infra.nattable.row.label.feature.display.multiplicity"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_FEATURE_DISPLAY_TYPE = "org.eclipse.papyrus.infra.nattable.row.label.feature.display.type"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_IS_DERIVED = "org.eclipse.papyrus.infra.nattable.column.label.feature.display.isderived"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_MULTIPLICITY = "org.eclipse.papyrus.infra.nattable.column.label.feature.display.multiplicity"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_TYPE = "org.eclipse.papyrus.infra.nattable.column.label.feature.display.type"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_LABEL_FEATURE_DISPLAY_NAME = "org.eclipse.papyrus.infra.nattable.row.label.feature.display.name"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_NAME = "org.eclipse.papyrus.infra.nattable.column.label.feature.display.name"; //$NON-NLS-1$
+
+ public static final String COMMAND_ROW_DISCONNECT_SLAVE = "org.eclipse.papyrus.infra.nattable.row.disconnect.slave"; //$NON-NLS-1$
+
+ public static final String COMMAND_COLUMN_DISCONNECT_SLAVE = "org.eclipse.papyrus.infra.nattable.column.disconnect.slave"; //$NON-NLS-1$
+
+ public static final String COMMAND_INVERT_AXIS = "org.eclipse.papyrus.infra.nattable.invert.axis"; //$NON-NLS-1$
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/TableCommands.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/TableCommands.java
new file mode 100644
index 00000000000..78ea5676701
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/command/TableCommands.java
@@ -0,0 +1,310 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.LocalTableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainuUtils;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+
+/**
+ * This class provides some useful commands used to edit the table properties
+ *
+ * @author vl222926
+ *
+ */
+public class TableCommands {
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ private TableCommands() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param feature
+ * the edited feature
+ * @param newValue
+ * the new value for this feature
+ * @return
+ * the command to change a value in the row configuration header of a table
+ */
+ //FIXME : the handler must use me
+ public static ICommand getSetRowHeaderConfigurationValueCommand(final Table table, final EStructuralFeature feature, final Object newValue) {
+ final TransactionalEditingDomain domain = TableEditingDomainuUtils.getTableEditingDomain(table);
+ final CompositeCommand compositeCommand = new CompositeCommand("SetRowHeaderConfigurationCommand"); //$NON-NLS-1$
+ EObject elementToEdit = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisUsedInTable(table);
+ if(elementToEdit instanceof TableHeaderAxisConfiguration) {
+ elementToEdit = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration((TableHeaderAxisConfiguration)elementToEdit);
+ SetRequest request = null;
+ if(!table.isInvertAxis()) {
+ request = new SetRequest(domain, table, NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration(), elementToEdit);
+ } else {
+ request = new SetRequest(domain, table, NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration(), elementToEdit);
+ }
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(table);
+ final ICommand cmd = provider.getEditCommand(request);
+ compositeCommand.add(cmd);
+ }
+ final SetRequest request = new SetRequest(domain, elementToEdit, feature, newValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
+ final ICommand cmd = provider.getEditCommand(request);
+ compositeCommand.add(cmd);
+ return compositeCommand;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param feature
+ * the edited feature
+ * @param newValue
+ * the new value for this feature
+ * @return
+ * the command to change a value in the column configuration header of a table
+ */
+ //FIXME : the handler must use me
+ public static ICommand getSetColumnHeaderConfigurationValueCommand(final Table table, final EStructuralFeature feature, final Object newValue) {
+ final TransactionalEditingDomain domain = TableEditingDomainuUtils.getTableEditingDomain(table);
+ final CompositeCommand compositeCommand = new CompositeCommand("SetColumnHeaderConfigurationCommand"); //$NON-NLS-1$
+ EObject elementToEdit = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(table);
+ if(elementToEdit instanceof TableHeaderAxisConfiguration) {
+ elementToEdit = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration((TableHeaderAxisConfiguration)elementToEdit);
+ SetRequest request = null;
+ if(table.isInvertAxis()) {
+ request = new SetRequest(domain, table, NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration(), elementToEdit);
+ } else {
+ request = new SetRequest(domain, table, NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration(), elementToEdit);
+ }
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(table);
+ final ICommand cmd = provider.getEditCommand(request);
+ compositeCommand.add(cmd);
+ }
+ final SetRequest request = new SetRequest(domain, elementToEdit, feature, newValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
+ final ICommand cmd = provider.getEditCommand(request);
+ compositeCommand.add(cmd);
+ return compositeCommand;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param usedLabelConfiguration
+ * the used label configuration
+ * @param editedFeature
+ * the edited feature
+ * @param newValue
+ * the new value for this feature
+ * @return
+ * the command to modify the feature value in the label configuration of the table. This command adds the localLabelConfiguration when it
+ * is required
+ */
+ //FIXME the handler must use me
+ public static final ICommand getSetColumnLabelConfigurationValueCommand(final Table table, final ILabelProviderConfiguration usedLabelConfiguration, final EStructuralFeature editedFeature, final Object newValue) {
+ final CompositeCommand cmd = new CompositeCommand("ChangeColumnLabelConfigurationValueCommand"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = TableEditingDomainuUtils.getTableEditingDomain(table);
+ ILabelProviderConfiguration editedLabelConf;
+ if(usedLabelConfiguration.eContainer() instanceof TableHeaderAxisConfiguration) {
+ editedLabelConf = EcoreUtil.copy(usedLabelConfiguration);
+ cmd.add(getRegisterLocalColumnLabelConfigurationCommand(table, usedLabelConfiguration, editedLabelConf));
+ } else {
+ editedLabelConf = usedLabelConfiguration;
+ }
+ final IEditCommandRequest request = new SetRequest(domain, editedLabelConf, editedFeature, newValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(editedLabelConf);
+ cmd.add(provider.getEditCommand(request));
+ return cmd;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param usedLabelConfiguration
+ * the used label configuration
+ * @param editedFeature
+ * the edited feature
+ * @param newValue
+ * the new value for this feature
+ * @return
+ * the command to modify the feature value in the label configuration of the table. This command adds the localLabelConfiguration when it
+ * is required
+ */
+ //FIXME the handler must use me
+ public static final ICommand getSetRowLabelConfigurationValueCommand(final Table table, final ILabelProviderConfiguration usedLabelConfiguration, final EStructuralFeature editedFeature, final Object newValue) {
+ final CompositeCommand cmd = new CompositeCommand("ChangeRowLabelConfigurationValueCommand"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = TableEditingDomainuUtils.getTableEditingDomain(table);
+ ILabelProviderConfiguration editedLabelConf;
+ if(usedLabelConfiguration.eContainer() instanceof TableHeaderAxisConfiguration) {
+ editedLabelConf = EcoreUtil.copy(usedLabelConfiguration);
+ cmd.add(getRegisterLocalRowLabelConfigurationCommand(table, usedLabelConfiguration, editedLabelConf));
+ } else {
+ editedLabelConf = usedLabelConfiguration;
+ }
+ final IEditCommandRequest request = new SetRequest(domain, editedLabelConf, editedFeature, newValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(editedLabelConf);
+ cmd.add(provider.getEditCommand(request));
+ return cmd;
+ }
+
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param tableLabelConfiguration
+ * the table LabelConfiguration
+ * @param localTableLabelConfiguration
+ * the local table label configuration
+ * @return
+ * the command to register the local column label configuration to the table
+ */
+ private static final ICommand getRegisterLocalColumnLabelConfigurationCommand(final Table table, final ILabelProviderConfiguration tableLabelConfiguration, final ILabelProviderConfiguration localTableLabelConfiguration) {
+ final AbstractHeaderAxisConfiguration abstractHeaderAxisUsedInTable = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(table);
+
+ EStructuralFeature axisConfigurationFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ if(!table.isInvertAxis()) {
+ axisConfigurationFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+
+ final TableHeaderAxisConfiguration headerAxisConfig = (TableHeaderAxisConfiguration)HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisInTableConfiguration(table);
+ return getRegisterLocalLabelConfigurationCommand("ChangeColumnHeaderLabelConfigurationCommand", table, abstractHeaderAxisUsedInTable, headerAxisConfig, axisConfigurationFeature, localTableLabelConfiguration, tableLabelConfiguration); //$NON-NLS-1$
+ }
+
+
+ /**
+ *
+ * @param table
+ * the table
+ * @param tableLabelConfiguration
+ * the table LabelConfiguration
+ * @param localTableLabelConfiguration
+ * the local table label configuration
+ * @return
+ * the command to register the local row label configuration to the table
+ */
+ private static final ICommand getRegisterLocalRowLabelConfigurationCommand(final Table table, final ILabelProviderConfiguration tableLabelConfiguration, final ILabelProviderConfiguration localTableLabelConfiguration) {
+ AbstractHeaderAxisConfiguration abstractHeaderAxisUsedInTable = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisUsedInTable(table);
+
+ EStructuralFeature axisConfigurationFeature = NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ axisConfigurationFeature = NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+
+ final TableHeaderAxisConfiguration headerAxisConfig = (TableHeaderAxisConfiguration)HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(table);
+ return getRegisterLocalLabelConfigurationCommand("ChangeRowHeaderLabelConfigurationCommand", table, abstractHeaderAxisUsedInTable, headerAxisConfig, axisConfigurationFeature, localTableLabelConfiguration, tableLabelConfiguration); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param commandName
+ * the name of the command
+ * @param table
+ * the table to edit
+ * @param headerAxisConfigurationUsedInTable
+ * the headerAxisConfiguration currently used in the table
+ * @param tableHeaderAxisConfiguration
+ * the table header axis configuration defined in the table configuration
+ * @param axisConfigurationFeature
+ * the feature to use to register a local HeaderAxisConfiguration if it is required
+ * @param localTableLabelConfiguration
+ * the local table label configuration to register
+ * @param tableLabelConfiguration
+ * the table label configuration
+ * @return
+ * the command to register the local label configuration
+ */
+ private static final ICommand getRegisterLocalLabelConfigurationCommand(final String commandName, final Table table, final AbstractHeaderAxisConfiguration headerAxisConfigurationUsedInTable, final TableHeaderAxisConfiguration tableHeaderAxisConfiguration, final EStructuralFeature axisConfigurationFeature, final ILabelProviderConfiguration localTableLabelConfiguration, final ILabelProviderConfiguration tableLabelConfiguration) {
+ final TransactionalEditingDomain domain = TableEditingDomainuUtils.getTableEditingDomain(table);
+ final CompositeCommand cmd = new CompositeCommand(commandName);
+
+ //1. we must get or create the required LocalTableHeaderAxisConfiguration
+ LocalTableHeaderAxisConfiguration localConfig = null;
+ if(headerAxisConfigurationUsedInTable instanceof LocalTableHeaderAxisConfiguration) {
+ localConfig = (LocalTableHeaderAxisConfiguration)headerAxisConfigurationUsedInTable;
+ } else if(headerAxisConfigurationUsedInTable instanceof TableHeaderAxisConfiguration) {
+ //we can't edit it, because it's comes from the initial configuration
+ localConfig = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration((TableHeaderAxisConfiguration)headerAxisConfigurationUsedInTable);
+ final IEditCommandRequest request = new SetRequest(domain, table, axisConfigurationFeature, headerAxisConfigurationUsedInTable);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(table);
+ cmd.add(provider.getEditCommand(request));
+ }
+
+ //2. this one must store the new label configuration
+ final IEditCommandRequest request = new SetRequest(domain, headerAxisConfigurationUsedInTable, NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_OwnedLabelConfigurations(), localTableLabelConfiguration);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(headerAxisConfigurationUsedInTable);
+ cmd.add(provider.getEditCommand(request));
+
+ //3. we must get or create the AxisManagerConfiguration(s)
+ final List<AxisManagerConfiguration> axisManagerConfiguration = new ArrayList<AxisManagerConfiguration>();
+ for(final AxisManagerRepresentation current : tableHeaderAxisConfiguration.getAxisManagers()) {
+ //we look for defined axis manager which uses the labelconfiguration defined in the table config
+ if(current.getHeaderLabelConfiguration() == tableLabelConfiguration) {
+ AxisManagerConfiguration currentConf = null;
+ //we look for an axis manager configuration mapped in this axis manager representation
+ for(final AxisManagerConfiguration axisConf : localConfig.getAxisManagerConfigurations()) {
+ if(axisConf.getAxisManager() == current) {
+ currentConf = axisConf;
+ }
+ }
+ if(currentConf == null) {
+ currentConf = NattableaxisconfigurationFactory.eINSTANCE.createAxisManagerConfiguration();
+ currentConf.setAxisManager(current);
+ final IEditCommandRequest request2 = new SetRequest(domain, localConfig, NattableaxisconfigurationPackage.eINSTANCE.getLocalTableHeaderAxisConfiguration_AxisManagerConfigurations(), currentConf);
+ final IElementEditService provider2 = ElementEditServiceUtils.getCommandProvider(localConfig);
+ cmd.add(provider2.getEditCommand(request2));
+ }
+ axisManagerConfiguration.add(currentConf);
+ }
+ }
+
+ //4. these one must reference the LabelConfiguration
+ for(final AxisManagerConfiguration current : axisManagerConfiguration) {
+ final IEditCommandRequest request2 = new SetRequest(domain, current, NattableaxisconfigurationPackage.eINSTANCE.getAxisManagerConfiguration_LocalHeaderLabelConfiguration(), localTableLabelConfiguration);
+ final IElementEditService provider2 = ElementEditServiceUtils.getCommandProvider(current);
+ cmd.add(provider2.getEditCommand(request2));
+ }
+ return cmd;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CornerConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CornerConfiguration.java
new file mode 100644
index 00000000000..29295119699
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CornerConfiguration.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ *
+ * This configuration allows to add action clicking on the top left corner of the table
+ *
+ */
+public class CornerConfiguration extends AbstractRegistryConfiguration {
+
+ /**
+ * the manager of the table
+ */
+ private INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the manager of the table
+ */
+ public CornerConfiguration(final INattableModelManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ super.configureUiBindings(uiBindingRegistry);
+ uiBindingRegistry.registerSingleClickBinding(new MouseEventMatcher(GridRegion.CORNER), new IMouseAction() {
+
+ public void run(final NatTable natTable, final MouseEvent event) {
+ manager.selectAll();
+ }
+ });
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.config.IConfiguration#configureRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param configRegistry
+ */
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ //nothing to do
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CustomizedCellPainter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CustomizedCellPainter.java
new file mode 100644
index 00000000000..64ab0305f7c
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/CustomizedCellPainter.java
@@ -0,0 +1,163 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Override of the paintCell() method
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
+import org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand;
+import org.eclipse.nebula.widgets.nattable.style.CellStyleUtil;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.style.IStyle;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.ICell;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Status;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Custom CellPainter to define the LabelProvider to use
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+//FIXME : we should use the TextPainter itself, now with the GenericDisplayConverter, it should works fine
+public class CustomizedCellPainter extends TextPainter {
+
+ /**
+ *
+ * Constructor. We're overriding it to always set word-wrapping for our cells.
+ *
+ */
+ public CustomizedCellPainter() {
+ super(false, true);//with (true,true), automatic newLine when the text is too long to be displayed.
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.painter.cell.AbstractTextPainter#convertDataType(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ @Override
+ protected String convertDataType(final ILayerCell cell, final IConfigRegistry configRegistry) {
+ final LabelProviderService serv = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ final ILabelProviderContextElementWrapper contextElement = new LabelProviderCellContextElementWrapper(cell, configRegistry);
+ final ILabelProvider provider = serv.getLabelProvider(Constants.TABLE_LABEL_PROVIDER_CONTEXT, contextElement);
+ String str = provider.getText(contextElement);
+ if(str == null) {
+ str = ""; //$NON-NLS-1$
+ }
+ return str;
+ }
+
+ /**
+ * Overridden to show, additionally to the contents of a cell, a vertical arrow pointing down in case there are masked lines
+ *
+ * @see org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter#paintCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.swt.graphics.GC, org.eclipse.swt.graphics.Rectangle, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param cell
+ * @param gc
+ * @param rectangle
+ * @param configRegistry
+ */
+ @Override
+ public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
+ super.paintCell(cell, gc, rectangle, configRegistry);
+ IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
+ int fontHeight = gc.getFontMetrics().getHeight();
+ String text = convertDataType(cell, configRegistry);
+ text = getTextToDisplay(cell, gc, rectangle.width, text);
+
+ int numberOfNewLines = getNumberOfNewLines(text);
+ //we're extending the row height (only if word wrapping is enabled)
+ int contentHeight = (fontHeight * numberOfNewLines) + (spacing * 2);
+ int contentToCellDiff = (cell.getBounds().height - rectangle.height);
+
+ if(performRowResize(contentHeight, rectangle)) {
+ ILayer layer = cell.getLayer();
+ layer.doCommand(new RowResizeCommand(layer, cell.getRowPosition(), contentHeight + contentToCellDiff));
+ }
+ if(numberOfNewLines > 1) {
+
+ int yStartPos = rectangle.y + CellStyleUtil.getVerticalAlignmentPadding(cellStyle, rectangle, contentHeight);
+ String[] lines = text.split("\n"); //$NON-NLS-1$
+ for(String line : lines) {
+ int lineContentWidth = Math.min(getLengthFromCache(gc, line), rectangle.width);
+
+ Image im = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("org.eclipse.papyrus.infra.nattable", "/icons/arrow_down_end.png"); //$NON-NLS-1$ //$NON-NLS-2$
+ gc.drawText(line, rectangle.x + CellStyleUtil.getHorizontalAlignmentPadding(cellStyle, rectangle, lineContentWidth) + spacing, yStartPos + spacing, SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER);
+
+ //We test if, given the current cell size and text position, we should display the down pointing arrow.
+ if(contentHeight > rectangle.height && yStartPos + fontHeight > rectangle.height + rectangle.y) {
+ int yDownRowIcon = rectangle.y + rectangle.height - im.getBounds().height;
+ int xDownRowIcon = rectangle.x + rectangle.width - im.getBounds().width;
+ gc.drawImage(im, xDownRowIcon, yDownRowIcon);
+ }
+
+ //after every line calculate the y start pos new
+ yStartPos += fontHeight;
+ }
+ }
+ }
+
+ //FIXME : essayer d'être plus subtile pour ce genre de chose!
+ @Override
+ protected Color getBackgroundColour(ILayerCell cell, IConfigRegistry configRegistry) {
+ if(cell.getConfigLabels().hasLabel("BODY")) {//FIXME : doesn't work for boolean checkbox!
+ int rowPosition = cell.getRowIndex();
+ int columnPostion = cell.getColumnIndex();
+ NattableModelManager manager = (NattableModelManager)configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ Object rowElement = manager.getRowElement(rowPosition);
+ Object columnElement = manager.getColumnElement(columnPostion);
+ ICell tableCell = null;
+
+ for(final ICell current : manager.getTable().getCells()) {
+ if(manager.getTable().isInvertAxis()) {
+ if(current.getRowElement() == columnElement && current.getColumnElement() == rowElement) {
+ tableCell = current;
+ }
+ } else {
+ if(current.getRowElement() == rowElement && current.getColumnElement() == columnElement) {
+ tableCell = current;
+ }
+ }
+ if(tableCell == null) {
+ break;
+ }
+ if(tableCell.getProblems().size()!=0) {
+ return new Color(Display.getDefault(), new RGB(255, 0, 0));
+ }
+ }
+ }
+ return super.getBackgroundColour(cell, configRegistry);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java
new file mode 100644
index 00000000000..5e3c9aeb0e7
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration;
+import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.accumulator.CustomRowOverrideLabelAccumulator;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.CellEditorConfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration;
+import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.CellEditorDeclaration;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+
+
+/**
+ *
+ * The configuration for the edition of the table
+ *
+ */
+public class EditConfiguration extends DefaultEditConfiguration {
+
+ /**
+ * the list of the message already displayed
+ */
+ private Collection<String> messagesAlreadyDisplayed = new ArrayList<String>();
+
+ @Override
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ super.configureRegistry(configRegistry);
+ //we remove the default cell editor
+ configRegistry.unregisterConfigAttribute(EditConfigAttributes.CELL_EDITOR, DisplayMode.NORMAL, null);
+
+ INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+
+ final BodyLayerStack bodyLayerStack = modelManager.getBodyLayerStack();
+ final Table table = modelManager.getTable();
+ final CellEditorDeclaration editorDeclaration = modelManager.getTable().getTableConfiguration().getCellEditorDeclaration();
+ if(editorDeclaration.equals(CellEditorDeclaration.COLUMN)) {
+ if(table.isInvertAxis()) {
+ //we declared celleditor on row
+ final CustomRowOverrideLabelAccumulator accumulator = new CustomRowOverrideLabelAccumulator(bodyLayerStack);
+ declaredCellEditors(modelManager.getRowElementsList(), configRegistry, null, accumulator);
+ bodyLayerStack.setConfigLabelAccumulator(accumulator);
+ } else {
+ final ColumnOverrideLabelAccumulator accumulator = new ColumnOverrideLabelAccumulator(bodyLayerStack);
+ declaredCellEditors(modelManager.getColumnElementsList(), configRegistry, accumulator, null);
+ bodyLayerStack.setConfigLabelAccumulator(accumulator);
+ }
+ } else if(editorDeclaration.equals(CellEditorDeclaration.ROW)) {
+ if(table.isInvertAxis()) {
+ //we declared celleditor on column
+ final ColumnOverrideLabelAccumulator accumulator = new ColumnOverrideLabelAccumulator(bodyLayerStack);
+ declaredCellEditors(modelManager.getColumnElementsList(), configRegistry, accumulator, null);
+ bodyLayerStack.setConfigLabelAccumulator(accumulator);
+ } else {
+ final CustomRowOverrideLabelAccumulator accumulator = new CustomRowOverrideLabelAccumulator(bodyLayerStack);
+ declaredCellEditors(modelManager.getRowElementsList(), configRegistry, null, accumulator);
+ bodyLayerStack.setConfigLabelAccumulator(accumulator);
+ }
+ } else if(editorDeclaration.equals(CellEditorDeclaration.CELL)) {
+ //not yet supported
+ throw new UnsupportedOperationException(Messages.EditConfiguration_DeclarationNotYetSupported);
+ }
+
+
+ }
+
+ private void declaredCellEditors(final List<Object> elements, final IConfigRegistry configRegistry, final ColumnOverrideLabelAccumulator columnAccumulator, final CustomRowOverrideLabelAccumulator rowAccumulator) {
+ INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ boolean declareOnColumn = columnAccumulator != null;
+ boolean declareOnRow = rowAccumulator != null;
+ assert declareOnColumn != declareOnRow;
+ final CellEditorConfigurationFactory factory = CellEditorConfigurationFactory.INSTANCE;
+ List<String> existingEditorIds = new ArrayList<String>();
+ for(int i = 0; i < elements.size(); i++) {
+ //FIXME : for containement feature : see oep.views.properties.
+ // example : create Usecase in a class from the property view : EcorePropertyEditorFactory create a popup to display available type
+ //then EditionDialog to edit the created object
+ Object current = elements.get(i);
+ if(current instanceof IAxis) {
+ current = ((IAxis)current).getElement();
+ }
+ final Table table = modelManager.getTable();
+ final IAxisCellEditorConfiguration config = factory.getFirstCellEditorConfiguration(table, current);
+ if(config != null) {
+ final ICellEditor editor = config.getICellEditor(table, current, modelManager.getTableAxisElementProvider());
+ if(editor != null) {
+ final String editorId = config.getEditorId() + Integer.toString(i);
+ if(existingEditorIds.contains(editorId)) {
+ org.eclipse.papyrus.infra.nattable.Activator.log.warn("Several editor have the same id");
+ } else {
+ existingEditorIds.add(editorId);
+ }
+
+ final String cellId = editorId + "_cellId"; //$NON-NLS-1$
+
+ final ICellPainter painter = config.getCellPainter(table, current);
+ final String displayMode = config.getDisplayMode(table, current);
+ final IDisplayConverter converter = config.getDisplayConvert(current, table, new EMFLabelProvider());//FIXME : label provider + arg order
+
+ final IDataValidator validator = config.getDataValidator(table, current);
+ assert !cellId.equals(editorId);
+ if(declareOnColumn) {
+ columnAccumulator.registerColumnOverrides(i, editorId, cellId);
+ } else {
+ rowAccumulator.registerRowOverrides(i, editorId, cellId);
+ }
+ if(painter != null) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, displayMode, cellId);
+ }
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, displayMode, editorId);
+
+ if(converter != null) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, converter, displayMode, cellId);
+ }
+
+ if(validator != null) {
+ configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, validator, displayMode, cellId);
+ }
+ } else {
+ final String errorMessage = NLS.bind(Messages.EditConfiguration_FactoryHandlesElementButDoesntProvideEditor, config.getEditorId(), current);
+ if(!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ Activator.log.warn(errorMessage);
+ this.messagesAlreadyDisplayed.add(errorMessage);
+ }
+
+ }
+ } else {
+ final String errorMessage = NLS.bind(Messages.EditConfiguration_ConfigurationNotFound, current);
+ if(!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ Activator.log.warn(errorMessage);
+ this.messagesAlreadyDisplayed.add(errorMessage);
+ }
+ }
+ }
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnHeaderStyleConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnHeaderStyleConfiguration.java
new file mode 100644
index 00000000000..93ed611bb84
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnHeaderStyleConfiguration.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration;
+import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator;
+import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator;
+import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum;
+import org.eclipse.papyrus.infra.nattable.painter.CustomImagePainter;
+
+/**
+ *
+ * The default style for the column. We provide a specific label provider and image painter
+ *
+ */
+public class PapyrusColumnHeaderStyleConfiguration extends DefaultColumnHeaderStyleConfiguration {
+
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration#configureRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param configRegistry
+ */
+ @Override
+ public void configureRegistry(final IConfigRegistry configRegistry) {
+ this.cellPainter = new BeveledBorderDecorator(new CellPainterDecorator(new CustomizedCellPainter(), CellEdgeEnum.LEFT, new CustomImagePainter()));//new CustomizedCellPainter());
+ super.configureRegistry(configRegistry);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnResizeBindingsConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnResizeBindingsConfiguration.java
new file mode 100644
index 00000000000..69369c3a28c
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusColumnResizeBindingsConfiguration.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.resize.action.ColumnResizeCursorAction;
+import org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEventMatcher;
+import org.eclipse.nebula.widgets.nattable.resize.mode.ColumnResizeDragMode;
+import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
+import org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.SWT;
+
+/**
+ * Adapted code from DefaultRowResizeBindings. Allow to resize the columns on all regions of the table (corner, body, row header, column header)
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusColumnResizeBindingsConfiguration extends AbstractUiBindingConfiguration {
+
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ // Mouse move - Show resize cursor
+ uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 0), new ColumnResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 0), new ColumnResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.CORNER, 0), new ColumnResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.BODY, 0), new ColumnResizeCursorAction());
+
+ uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(), new ClearCursorAction());
+
+ // Column resize
+ uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new ColumnResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1), new ColumnResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.CORNER, 1), new ColumnResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.BODY, 1), new ColumnResizeDragMode());
+
+ // uiBindingRegistry.registerDoubleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new AutoResizeColumnAction());
+ uiBindingRegistry.registerSingleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new NoOpMouseAction());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java
new file mode 100644
index 00000000000..b1ca4412e61
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusGridLayerConfiguration.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration;
+import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
+
+/**
+ * We change the edit configuration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class PapyrusGridLayerConfiguration extends DefaultGridLayerConfiguration {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param gridLayer
+ */
+ public PapyrusGridLayerConfiguration(CompositeLayer gridLayer) {
+ super(gridLayer);
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultGridLayerConfiguration#addEditingHandlerConfig()
+ *
+ */
+ @Override
+ protected void addEditingHandlerConfig() {
+ addConfiguration(new EditConfiguration());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
new file mode 100644
index 00000000000..ec447728d31
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusHeaderMenuConfiguration.java
@@ -0,0 +1,55 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.SWT;
+
+/**
+ * The configuration for the popup to use in the header of the table
+ *
+ * Adapted code from AbstractHeaderMenuConfiguration
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusHeaderMenuConfiguration extends AbstractUiBindingConfiguration {
+
+ /**
+ * the category used for the column command
+ */
+ public static final String COLUMN_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.columns.command.category"; //$NON-NLS-1$
+
+ /**
+ * the category used for the row command
+ */
+ public static final String ROW_COMMANDS_CATEGORY_ID = "org.eclipse.papyrus.infra.nattable.rows.command.category"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.config.IConfiguration#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusPopupMenuAction(COLUMN_COMMANDS_CATEGORY_ID));
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusPopupMenuAction(ROW_COMMANDS_CATEGORY_ID));
+
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
new file mode 100644
index 00000000000..d377ea0c755
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.tools.util.EclipseCommandUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+/**
+ * PopupAction for Papyrus -> The contents of the popup is builded for each right click and not builded only one time as in NatTable
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusPopupMenuAction extends PopupMenuAction {
+
+ /** the category of the commands to add to this menu */
+ private final String category;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param categoryId
+ * the category of the commands to add to this menu
+ */
+ public PapyrusPopupMenuAction(final String categoryId) {
+ super(null);//because we create the menu for each run
+ this.category = categoryId;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction#run(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void run(NatTable natTable, MouseEvent event) {
+ //we need to recreate the menu each time (we need to verify for each action if it is enabled or not
+ Menu menu = new Menu(natTable.getShell());
+ buildMenu(menu, event.data);
+ menu.setData(event.data);
+ menu.setVisible(true);
+ }
+
+ /**
+ *
+ * @param popupMenu
+ * @param eventData
+ */
+ private void buildMenu(final Menu popupMenu, final Object eventData) {
+ final Collection<Command> commands = EclipseCommandUtils.getAllExistingCommandsInCategory(category);
+
+ //FIXME : we should use the EclipseContext to transfert the eventData from here to the handler, but currently we can't have dependency on e4 plugins
+ // final IEclipseContext eclipseContext = (IEclipseContext)PlatformUI.getWorkbench().getService(IEclipseContext.class);
+ // eclipseContext.set(AbstractTableHandler.NAT_EVENT_DATA_PARAMETER_ID, eventData);
+
+ for(final Command command : commands) {
+ final IHandler handler = command.getHandler();
+ if(handler == null || !(handler instanceof AbstractHandler)) {
+ continue;
+ }
+ //FIXME : we should use the EclipseContext to transfert the eventData from here to the handler, but currently we can't have dependency on e4 plugins
+ // ((AbstractHandler)handler).setEnabled(eclipseContext);
+ ((AbstractHandler)handler).setEnabled(null);
+ boolean isEnabled = handler.isEnabled();
+
+ if(isEnabled) {
+ MenuItem item = new MenuItem(popupMenu, SWT.PUSH);
+ item.setEnabled(true);
+ item.setImage(EclipseCommandUtils.getCommandIcon(command).createImage());
+ try {
+ item.setText(command.getName());
+ } catch (NotDefinedException e) {
+ Activator.log.error(e);
+ }
+ item.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ //FIXME : we must be able to give the SelectionEvent to the handler using EclispeContext
+ Map<Object, Object> parameters = Collections.emptyMap();
+ handler.execute(new ExecutionEvent(command, parameters, null, null));
+ } catch (ExecutionException e1) {
+ Activator.log.error(e1);
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //nothing do to
+ }
+ });
+ }
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowHeaderStyleConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowHeaderStyleConfiguration.java
new file mode 100644
index 00000000000..14f1daa1b59
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowHeaderStyleConfiguration.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderStyleConfiguration;
+import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.BeveledBorderDecorator;
+import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator;
+import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum;
+import org.eclipse.papyrus.infra.nattable.painter.CustomImagePainter;
+
+/**
+ *
+ * The default style for the row header. We provide a specific label provider and image painter
+ *
+ */
+public class PapyrusRowHeaderStyleConfiguration extends DefaultRowHeaderStyleConfiguration {
+
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderStyleConfiguration#configureRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param configRegistry
+ */
+ @Override
+ public void configureRegistry(final IConfigRegistry configRegistry) {
+ this.cellPainter = new BeveledBorderDecorator(new CellPainterDecorator(new CustomizedCellPainter(), CellEdgeEnum.LEFT, new CustomImagePainter()));
+ super.configureRegistry(configRegistry);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowResizeBindingsConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowResizeBindingsConfiguration.java
new file mode 100644
index 00000000000..68fd98da512
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusRowResizeBindingsConfiguration.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.resize.action.RowResizeCursorAction;
+import org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEventMatcher;
+import org.eclipse.nebula.widgets.nattable.resize.mode.RowResizeDragMode;
+import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
+import org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.SWT;
+
+/**
+ * Adapted code from DefaultRowResizeBindings. Allow to resize the rows on all regions of the table (corner, body, row header, column header)
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusRowResizeBindingsConfiguration extends AbstractUiBindingConfiguration {
+
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ // Mouse move - Show resize cursor
+ uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 0), new RowResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 0), new RowResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.CORNER, 0), new RowResizeCursorAction());
+ uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.BODY, 0), new RowResizeCursorAction());
+
+ uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(), new ClearCursorAction());
+
+ // Row resize
+ uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new RowResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1), new RowResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, GridRegion.CORNER, 1), new RowResizeDragMode());
+ uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, GridRegion.BODY, 1), new RowResizeDragMode());
+
+ // uiBindingRegistry.registerDoubleClickBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1), new AutoResizeRowAction());
+ uiBindingRegistry.registerSingleClickBinding(new RowResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1), new NoOpMouseAction());
+
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/StyleConfiguration.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/StyleConfiguration.java
new file mode 100644
index 00000000000..347dc352c80
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/StyleConfiguration.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.configuration;
+
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.papyrus.infra.nattable.converter.GenericDisplayConverter;
+import org.eclipse.papyrus.infra.nattable.formatter.PapyrusExportFormatter;
+
+/**
+ * Register a specific Cellpainter
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class StyleConfiguration extends DefaultNatTableStyleConfiguration {
+
+ @Override
+ public void configureRegistry(final IConfigRegistry configRegistry) {
+ super.configureRegistry(configRegistry);
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CustomizedCellPainter());
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter());
+ configRegistry.registerConfigAttribute(CellConfigAttributes.EXPORT_FORMATTER, new PapyrusExportFormatter());
+
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java
new file mode 100644
index 00000000000..a0945f736fd
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.converter;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+
+/**
+ * This converter uses the label provider service to display the correct text
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class GenericDisplayConverter implements IDisplayConverter {
+
+ /**
+ * throw new UnsupportedOperationException();
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter#canonicalToDisplayValue(java.lang.Object)
+ *
+ * @param canonicalValue
+ * @return
+ */
+ public Object canonicalToDisplayValue(Object canonicalValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * throw new UnsupportedOperationException();
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter#displayToCanonicalValue(java.lang.Object)
+ *
+ * @param displayValue
+ * @return
+ */
+ public Object displayToCanonicalValue(Object displayValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter#canonicalToDisplayValue(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
+ *
+ * @param cell
+ * @param configRegistry
+ * @param canonicalValue
+ * @return
+ */
+ public Object canonicalToDisplayValue(final ILayerCell cell, final IConfigRegistry configRegistry, final Object canonicalValue) {
+ final LabelProviderService service = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ final ILabelProvider labelProvider = service.getLabelProvider(Constants.TABLE_LABEL_PROVIDER_CONTEXT);
+ final ILabelProviderContextElementWrapper contextElement = new LabelProviderCellContextElementWrapper(cell, canonicalValue, configRegistry);
+ assert labelProvider != null;
+ return labelProvider.getText(contextElement);
+ }
+
+ /**
+ * throw new UnsupportedOperationException();
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter#displayToCanonicalValue(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
+ *
+ * @param cell
+ * @param configRegistry
+ * @param displayValue
+ * @return
+ */
+ public Object displayToCanonicalValue(ILayerCell cell, IConfigRegistry configRegistry, Object displayValue) {
+ // throw new UnsupportedOperationException();
+ return displayValue;
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/copy/CopySelectionToClipboardAction.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/copy/CopySelectionToClipboardAction.java
new file mode 100644
index 00000000000..fa98199ba7b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/copy/CopySelectionToClipboardAction.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.copy;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+
+/**
+ * The handler for the copy selection to clipboard action
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class CopySelectionToClipboardAction extends AbstractTableHandler {
+
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ INattableModelManager manager = getCurrentNattableModelManager();
+ ((AbstractNattableWidgetManager)manager).copyToClipboard();
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractDataProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractDataProvider.java
new file mode 100644
index 00000000000..01396dcd661
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractDataProvider.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.ui.services.IDisposable;
+
+
+public abstract class AbstractDataProvider implements IDataProvider, IDisposable {
+
+ /**
+ * the manager used to manage the table
+ */
+ protected INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableModelManager
+ * the manager of the table
+ */
+ public AbstractDataProvider(final INattableModelManager tableModelManager) {
+ this.manager = tableModelManager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getColumnCount()
+ *
+ * @return
+ */
+ public int getColumnCount() {
+ return this.manager.getColumnCount();
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getRowCount()
+ *
+ * @return
+ */
+ public int getRowCount() {
+ return this.manager.getRowCount();
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ *
+ */
+ public void dispose() {
+ this.manager = null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractHeaderDataProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractHeaderDataProvider.java
new file mode 100644
index 00000000000..0ded58331ae
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractHeaderDataProvider.java
@@ -0,0 +1,202 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisIndexStyle;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.tools.util.IntegerAndSpreadsheetNumberConverter;
+
+/**
+ * Abstract class for the header data provider
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractHeaderDataProvider extends AbstractDataProvider {
+
+ /** fields used to know what display in the headers */
+ protected boolean displayIndex;
+
+ protected boolean displayLabel;
+
+ protected boolean displayFilter;
+
+ protected AxisIndexStyle style;
+
+ /** listener on {@link Table#isInvertAxis()} feature */
+ private Adapter invertedListener;
+
+ /**
+ * listener on the axis configuration
+ */
+ private Adapter axisListener;
+
+ /**
+ * listener on the table
+ */
+ private Adapter localHeaderConfigListener;
+
+ /**
+ * the listen axis configuration
+ */
+ private AbstractHeaderAxisConfiguration listenAxisConfiguration;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableModelManager
+ */
+ public AbstractHeaderDataProvider(INattableModelManager tableModelManager) {//FIXME : we don't manage the remove of the axis configuration (possible when we return to the initial configuration
+ super(tableModelManager);
+ this.listenAxisConfiguration = getAxisConfiguration();
+ initListeners();
+ this.manager.getTable().eAdapters().add(this.invertedListener);
+ this.manager.getTable().eAdapters().add(this.localHeaderConfigListener);
+ initFields();
+ }
+
+ /**
+ * Create the listeners, but doesn't assign them to an object
+ */
+ protected void initListeners() {
+ this.axisListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ final Object feature = msg.getFeature();
+ if(feature != null) {
+ if(feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayFilter())) {
+ AbstractHeaderDataProvider.this.displayFilter = msg.getNewBooleanValue();
+ updateAxisCount();
+ } else if(feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex())) {
+ AbstractHeaderDataProvider.this.displayIndex = msg.getNewBooleanValue();
+ updateAxisCount();
+ } else if(feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel())) {
+ AbstractHeaderDataProvider.this.displayLabel = msg.getNewBooleanValue();
+ updateAxisCount();
+ } else if(feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_IndexStyle())) {
+ AbstractHeaderDataProvider.this.style = AxisIndexStyle.get(msg.getNewStringValue());
+ updateAxisCount();
+ }
+ }
+ }
+ };
+ this.invertedListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if(msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) {
+ final Object oldValue = msg.getOldValue();
+ final Object newValue = msg.getNewValue();
+ if(oldValue != null && newValue != null) {
+ initFields();
+ }
+ }
+ }
+ };
+
+ this.localHeaderConfigListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if(msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration() || msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration()) {
+ initFields();
+ }
+ }
+ };
+ }
+
+ /**
+ * init the field value, and update the listen axis if required
+ */
+ private void initFields() {
+ if(this.listenAxisConfiguration != getAxisConfiguration() && this.listenAxisConfiguration != null) {
+ this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
+ }
+ this.listenAxisConfiguration = getAxisConfiguration();
+ if(this.listenAxisConfiguration != null) {
+ this.listenAxisConfiguration.eAdapters().add(this.axisListener);
+ if(this.listenAxisConfiguration instanceof AbstractHeaderAxisConfiguration) {
+ AbstractHeaderAxisConfiguration config = this.listenAxisConfiguration;
+ this.style = config.getIndexStyle();
+ this.displayFilter = config.isDisplayFilter();
+ this.displayLabel = config.isDisplayLabel();
+ this.displayIndex = config.isDisplayIndex();
+ }
+ }
+ updateAxisCount();
+ }
+
+ /**
+ * this method is used to update the values in the inherited classes
+ */
+ protected abstract void updateAxisCount();
+
+ /**
+ *
+ * @return
+ * the axis configuration to listen
+ */
+ protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration();
+
+ /**
+ *
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ removeListeners();
+ this.listenAxisConfiguration = null;
+ super.dispose();
+ }
+
+ /**
+ * remove the listener
+ */
+ protected void removeListeners() {
+ if(this.listenAxisConfiguration != null) {
+ this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
+ }
+ this.manager.getTable().eAdapters().remove(this.invertedListener);
+ this.manager.getTable().eAdapters().remove(this.localHeaderConfigListener);
+ }
+
+ /**
+ *
+ * @param axisIndex
+ * the index of the axis
+ * @return
+ * the index to display according to the index style
+ */
+ protected Object getAxisIndex(int axisIndex) {
+ switch(this.style) {
+ case ALPHABETIC:
+ return IntegerAndSpreadsheetNumberConverter.toString(axisIndex + 1);
+ case NUMERIC:
+ return axisIndex;
+ }
+ return null;
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/BodyDataProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/BodyDataProvider.java
new file mode 100644
index 00000000000..d3c87aec785
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/BodyDataProvider.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class BodyDataProvider extends AbstractDataProvider {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableModelManager
+ * the table manager
+ */
+ public BodyDataProvider(final INattableModelManager tableModelManager) {
+ super(tableModelManager);
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getDataValue(int, int)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @return
+ */
+ public Object getDataValue(int columnIndex, int rowIndex) {
+ IDataProvider provider = this.manager.getBodyDataProvider();
+ return provider.getDataValue(columnIndex, rowIndex);
+ }
+
+ public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
+ this.manager.setDataValue(columnIndex, rowIndex, newValue);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/ColumnHeaderDataProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/ColumnHeaderDataProvider.java
new file mode 100644
index 00000000000..c7ace9a9810
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/ColumnHeaderDataProvider.java
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+/**
+ *
+ * This manager is used to manage the column header.
+ *
+ *
+ */
+public class ColumnHeaderDataProvider extends AbstractHeaderDataProvider {
+
+ private int rowCount;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the manager used to manage the table
+ */
+ public ColumnHeaderDataProvider(final INattableModelManager manager) {
+ super(manager);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#getRowCount()
+ *
+ * @return
+ */
+ @Override
+ public int getRowCount() {
+ return this.rowCount;
+ }
+
+
+ /**
+ * This class does not support multiple rows in the column header layer.
+ */
+ public Object getDataValue(final int columnIndex, final int rowIndex) {
+ switch(this.rowCount) {
+ case 0:
+ return null;
+ case 1:
+ if(this.displayFilter) {
+ return null;//FIXME not tested
+ } else if(this.displayIndex) {
+ return getAxisIndex(columnIndex);
+ } else if(this.displayLabel) {
+ return this.manager.getColumnElement(columnIndex);
+ }
+ case 2:
+ if(!this.displayFilter) {
+ if(rowIndex == 0) {
+ return getAxisIndex(columnIndex);
+ }
+ if(rowIndex == 1) {
+ return this.manager.getColumnElement(columnIndex);
+ }
+ } else {
+ //FIXME not tested
+ }
+ break;
+ case 3:
+ if(!this.displayFilter) {
+ if(rowIndex == 0) {
+ return getAxisIndex(columnIndex);
+ }
+ if(rowIndex == 1) {
+ return this.manager.getColumnElement(columnIndex);
+ }
+ if(rowIndex == 2) {
+ //FIXME not tested
+ }
+ }
+ break;
+ }
+ return null;
+ }
+
+ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ //TODO
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractHeaderDataProvider#getAxisConfiguration()
+ *
+ * @return
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(this.manager.getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractHeaderDataProvider#updateAxisCount()
+ *
+ */
+ @Override
+ protected void updateAxisCount() {
+ int newAxisCOunt = 0;
+ if(this.displayFilter) {
+ newAxisCOunt++;
+ }
+ if(this.displayIndex) {
+ newAxisCOunt++;
+ }
+ if(this.displayLabel) {
+ newAxisCOunt++;
+ }
+ this.rowCount = newAxisCOunt;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/RowHeaderDataProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/RowHeaderDataProvider.java
new file mode 100644
index 00000000000..e1d733ba457
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/RowHeaderDataProvider.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Original authors 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:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+/**
+ *
+ * this manager allows to manage the rows of the table. It provides
+ * a row header with 0,1 or 2 columns
+ *
+ */
+public class RowHeaderDataProvider extends AbstractHeaderDataProvider {
+
+ private int axisCount;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the table manager
+ */
+ public RowHeaderDataProvider(final INattableModelManager manager) {
+ super(manager);
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getColumnCount()
+ *
+ * @return
+ *
+ */
+ @Override
+ public int getColumnCount() {
+ return this.axisCount;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getDataValue(int, int)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @return
+ */
+ public Object getDataValue(final int columnIndex, final int rowIndex) {
+ switch(this.axisCount) {
+ case 0:
+ return null;
+ case 1:
+ if(this.displayFilter) {
+ return null;//FIXME not tested
+ } else if(this.displayIndex) {
+ return getAxisIndex(rowIndex);
+ } else if(this.displayLabel) {
+ return this.manager.getRowElement(rowIndex);
+ }
+ case 2:
+ if(!this.displayFilter) {
+ if(columnIndex == 0) {
+ return getAxisIndex(rowIndex);
+ }
+ if(columnIndex == 1) {
+ return this.manager.getRowElement(rowIndex);
+ }
+ } else {
+ //FIXME not tested
+ }
+ break;
+ case 3:
+ if(!this.displayFilter) {
+ if(columnIndex == 0) {
+ return getAxisIndex(rowIndex);
+ }
+ if(columnIndex == 1) {
+ return this.manager.getRowElement(rowIndex);
+ }
+ if(columnIndex == 2) {
+ //FIXME not tested
+ }
+ }
+ break;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#setDataValue(int, int, java.lang.Object)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @param newValue
+ */
+ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractHeaderDataProvider#getAxisConfiguration()
+ *
+ * @return
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getAbstractHeaderAxisConfigurationUsedInTable(this.manager.getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractHeaderDataProvider#updateAxisCount()
+ *
+ */
+ @Override
+ protected void updateAxisCount() {
+ int newAxisCOunt = 0;
+ if(this.displayFilter) {
+ //newAxisCOunt++; //we ignore this value for rows headers
+ }
+ if(this.displayIndex) {
+ newAxisCOunt++;
+ }
+ if(this.displayLabel) {
+ newAxisCOunt++;
+ }
+ this.axisCount = newAxisCOunt;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/DisplayedAxisSelectorDialog.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/DisplayedAxisSelectorDialog.java
new file mode 100644
index 00000000000..72391a24b7e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/DisplayedAxisSelectorDialog.java
@@ -0,0 +1,127 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dialog;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.infra.widgets.editors.IElementSelector;
+import org.eclipse.papyrus.infra.widgets.editors.MultipleValueSelectorDialogWithCheckBox;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This dialog adds a specific action on the okPressed() (opening a dialog)
+ *
+ * @author vl222926
+ *
+ */
+public class DisplayedAxisSelectorDialog extends MultipleValueSelectorDialogWithCheckBox {
+
+ /**
+ * the title of the information dialog
+ */
+ private String informationDialogTitle;
+
+ /**
+ * the message of the information dialog
+ */
+ private String informationDialogMessage;
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * @param selector
+ * @param unique
+ */
+ public DisplayedAxisSelectorDialog(Shell parentShell, IElementSelector selector, boolean unique) {
+ super(parentShell, selector, unique);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * @param selector
+ * @param title
+ * @param unique
+ * @param ordered
+ * @param upperBound
+ */
+ public DisplayedAxisSelectorDialog(Shell parentShell, IElementSelector selector, String title, boolean unique, boolean ordered, int upperBound) {
+ super(parentShell, selector, title, unique, ordered, upperBound);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * @param selector
+ * @param title
+ * @param unique
+ * @param ordered
+ */
+ public DisplayedAxisSelectorDialog(Shell parentShell, IElementSelector selector, String title, boolean unique, boolean ordered) {
+ super(parentShell, selector, title, unique, ordered);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * @param selector
+ * @param title
+ */
+ public DisplayedAxisSelectorDialog(Shell parentShell, IElementSelector selector, String title) {
+ super(parentShell, selector, title);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param parentShell
+ * @param selector
+ */
+ public DisplayedAxisSelectorDialog(Shell parentShell, IElementSelector selector) {
+ super(parentShell, selector);
+ }
+
+ /**
+ *
+ * @param title
+ * the title for the information dialog
+ * @param message
+ * the message for the information dialog
+ */
+ public void setInformationDialogValues(final String title, final String message) {
+ this.informationDialogTitle = title;
+ this.informationDialogMessage = message;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.editors.MultipleValueSelectorDialog#okPressed()
+ *
+ */
+ @Override
+ protected void okPressed() {
+ boolean mustContinue = true;;
+ if(displayCheckBox && !isChecked) {
+ mustContinue = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), informationDialogTitle, informationDialogMessage);
+ }
+ if(mustContinue) {
+ super.okPressed();
+ }
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/exception/ErrorInPastePreparationException.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/exception/ErrorInPastePreparationException.java
new file mode 100644
index 00000000000..4d23eedff62
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/exception/ErrorInPastePreparationException.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.exception;
+
+
+public class ErrorInPastePreparationException extends Exception {
+
+
+ /**
+ * the serial version UID
+ */
+ private static final long serialVersionUID = -2707065012620342372L;
+
+
+ public ErrorInPastePreparationException(final String message) {
+ super(message);
+ }
+
+
+ public ErrorInPastePreparationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/formatter/PapyrusExportFormatter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/formatter/PapyrusExportFormatter.java
new file mode 100644
index 00000000000..b7a7f90a1cc
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/formatter/PapyrusExportFormatter.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.formatter;
+
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.export.excel.DefaultExportFormatter;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+
+/**
+ * The export formatter to use to export the same text as the text displayed in the cells
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class PapyrusExportFormatter extends DefaultExportFormatter {
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.export.IExportFormatter#formatForExport(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ public Object formatForExport(ILayerCell cell, IConfigRegistry configRegistry) {
+ Object dataValue = cell.getDataValue();
+ IDisplayConverter displayConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
+ return displayConverter.canonicalToDisplayValue(cell, configRegistry, dataValue);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeHeaderConfigurationHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeHeaderConfigurationHandler.java
new file mode 100644
index 00000000000..92bc377a3c2
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeHeaderConfigurationHandler.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract class to edit the header cofniguration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractChangeHeaderConfigurationHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ AbstractHeaderAxisConfiguration configuration = getEditedAxisConfiguration();
+ final CompositeCommand cmd = new CompositeCommand("ChangeHeaderConfigurationCommand"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ if(configuration instanceof TableHeaderAxisConfiguration) {
+ //we can't edit it, because it's comes from the initial configuration
+ configuration = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration((TableHeaderAxisConfiguration)configuration);
+ final Table table = getCurrentNattableModelManager().getTable();
+ final IEditCommandRequest request = new SetRequest(domain, table, getLocalHeaderAxisConfigurationFeature(), configuration);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(table);
+ cmd.add(provider.getEditCommand(request));
+ }
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+ final IEditCommandRequest request = new SetRequest(domain, configuration, getEditedFeature(), !oldValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(configuration);
+ cmd.add(provider.getEditCommand(request));
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ *
+ */
+ protected abstract EStructuralFeature getLocalHeaderAxisConfigurationFeature();
+
+ /**
+ *
+ * @return
+ * the edited feature
+ */
+ protected abstract EStructuralFeature getEditedFeature();
+
+ /**
+ *
+ * @return
+ * the edited axis configuration
+ */
+ protected abstract AbstractHeaderAxisConfiguration getEditedAxisConfiguration();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeIndexStyleHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeIndexStyleHandler.java
new file mode 100644
index 00000000000..dde3cf17fa6
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeIndexStyleHandler.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisIndexStyle;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.RadioState;
+
+
+/**
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractChangeIndexStyleHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final AbstractHeaderAxisConfiguration configuration = getAxisConfiguration();
+
+ if(HandlerUtil.matchesRadioState(event)) {
+ return null; // we are already in the updated state - do nothing
+ }
+ String currentState = event.getParameter(RadioState.PARAMETER_ID);
+
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ AxisIndexStyle newStyle = AxisIndexStyle.get(currentState);
+ final IEditCommandRequest request = new SetRequest(domain, configuration, NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_IndexStyle(), newStyle);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(configuration);
+ final ICommand cmd = provider.getEditCommand(request);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+
+ // and finally update the current state
+ HandlerUtil.updateRadioState(event.getCommand(), currentState);
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the axis configuration to edit
+ */
+ protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration();
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeLabelConfigurationValueHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeLabelConfigurationValueHandler.java
new file mode 100644
index 00000000000..f5488c9a93f
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractChangeLabelConfigurationValueHandler.java
@@ -0,0 +1,177 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.LocalTableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract class used to change label configuration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractChangeLabelConfigurationValueHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final CompositeCommand cmd = new CompositeCommand("ChangeLabelConfigurationValueCommand"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ ILabelProviderConfiguration labelConf = getLabelProviderConfiguration();
+ ILabelProviderConfiguration editedLabelConf;
+ if(labelConf.eContainer() instanceof TableHeaderAxisConfiguration) {
+ editedLabelConf = EcoreUtil.copy(labelConf);
+ cmd.add(getRegisterLocalLabelConfigurationCommand(labelConf, editedLabelConf));
+ } else {
+ editedLabelConf = labelConf;
+ }
+ Command command = event.getCommand();
+ boolean oldValue = HandlerUtil.toggleCommandState(command);
+ final IEditCommandRequest request = new SetRequest(domain, editedLabelConf, getEditedFeature(), !oldValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(editedLabelConf);
+ cmd.add(provider.getEditCommand(request));
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the edited label configuration
+ */
+ protected abstract ILabelProviderConfiguration getLabelProviderConfiguration();
+
+ /**
+ *
+ * @return
+ * the edited feature
+ */
+ protected abstract EStructuralFeature getEditedFeature();
+
+ /**
+ *
+ * @param conf
+ *
+ */
+ protected ICommand getRegisterLocalLabelConfigurationCommand(ILabelProviderConfiguration tableLabelConfiguration, ILabelProviderConfiguration localTableLabelConfiguration) {
+ TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ final CompositeCommand cmd = new CompositeCommand("ChangeHeaderLabelConfigurationCommand"); //$NON-NLS-1$
+ final Table table = getCurrentNattableModelManager().getTable();
+
+ //1. we must get or create the required LocalTableHeaderAxisConfiguration
+ AbstractHeaderAxisConfiguration configuration = getHeaderAxisConfiguration();
+ LocalTableHeaderAxisConfiguration localConfig = null;
+ if(configuration instanceof LocalTableHeaderAxisConfiguration) {
+ localConfig = (LocalTableHeaderAxisConfiguration)configuration;
+ } else if(configuration instanceof TableHeaderAxisConfiguration) {
+ //we can't edit it, because it's comes from the initial configuration
+ configuration = HeaderAxisConfigurationManagementUtils.transformToLocalHeaderConfiguration((TableHeaderAxisConfiguration)configuration);
+ localConfig = (LocalTableHeaderAxisConfiguration)configuration;
+ final IEditCommandRequest request = new SetRequest(domain, table, getLocalHeaderAxisConfigurationFeature(), configuration);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(table);
+ cmd.add(provider.getEditCommand(request));
+ }
+
+ //2. this one must store the new label configuration
+ final IEditCommandRequest request = new SetRequest(domain, configuration, NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_OwnedLabelConfigurations(), localTableLabelConfiguration);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(configuration);
+ cmd.add(provider.getEditCommand(request));
+
+ //3. we must get or create the AxisManagerConfiguration(s)
+ final TableHeaderAxisConfiguration headerAxisConfig = getTableHeaderAxisConfiguration();
+
+ final List<AxisManagerConfiguration> axisManagerConfiguration = new ArrayList<AxisManagerConfiguration>();
+ for(final AxisManagerRepresentation current : headerAxisConfig.getAxisManagers()) {
+ //we look for defined axis manager which uses the labelconfiguration defined in the table config
+ if(current.getHeaderLabelConfiguration() == tableLabelConfiguration) {
+ AxisManagerConfiguration currentConf = null;
+ //we look for an axis manager configuration mapped in this axis manager representation
+ for(final AxisManagerConfiguration axisConf : localConfig.getAxisManagerConfigurations()) {
+ if(axisConf.getAxisManager() == current) {
+ currentConf = axisConf;
+ }
+ }
+ if(currentConf == null) {
+ currentConf = NattableaxisconfigurationFactory.eINSTANCE.createAxisManagerConfiguration();
+ currentConf.setAxisManager(current);
+ final IEditCommandRequest request2 = new SetRequest(domain, localConfig, NattableaxisconfigurationPackage.eINSTANCE.getLocalTableHeaderAxisConfiguration_AxisManagerConfigurations(), currentConf);
+ final IElementEditService provider2 = ElementEditServiceUtils.getCommandProvider(localConfig);
+ cmd.add(provider2.getEditCommand(request2));
+ }
+ axisManagerConfiguration.add(currentConf);
+ }
+ }
+
+ //4. these one must reference the LabelConfiguration
+ for(final AxisManagerConfiguration current : axisManagerConfiguration) {
+ final IEditCommandRequest request2 = new SetRequest(domain, current, NattableaxisconfigurationPackage.eINSTANCE.getAxisManagerConfiguration_LocalHeaderLabelConfiguration(), localTableLabelConfiguration);
+ final IElementEditService provider2 = ElementEditServiceUtils.getCommandProvider(current);
+ cmd.add(provider2.getEditCommand(request2));
+ }
+ return cmd;
+ }
+
+ /**
+ *
+ * @return
+ * the feature to use to edit the local header axis configuration
+ */
+ protected abstract EStructuralFeature getLocalHeaderAxisConfigurationFeature();
+
+ /**
+ *
+ * @return
+ * the edited axis configuration
+ */
+ protected abstract AbstractHeaderAxisConfiguration getHeaderAxisConfiguration();
+
+ /**
+ *
+ * @return
+ * the table header axis defined in the TableConfiguration and used for edited label axis configuration
+ */
+ protected abstract TableHeaderAxisConfiguration getTableHeaderAxisConfiguration();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeHeaderConfigurationHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeHeaderConfigurationHandler.java
new file mode 100644
index 00000000000..ae1a6ee03c7
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeHeaderConfigurationHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+/**
+ * Abstract class to edit the header cofniguration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractColumnChangeHeaderConfigurationHandler extends AbstractChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @return
+ * the edited axis configuration or <code>null</code> if it doesn't exists in the table
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getEditedAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(getCurrentNattableModelManager().getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getLocalHeaderAxisConfigurationFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getLocalHeaderAxisConfigurationFeature() {
+ final Table table = getCurrentNattableModelManager().getTable();
+ if(!table.isInvertAxis()) {
+ return NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ }
+ return NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeLabelConfigurationValueHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeLabelConfigurationValueHandler.java
new file mode 100644
index 00000000000..2abbce920f3
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractColumnChangeLabelConfigurationValueHandler.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtils;
+
+/**
+ * The abstract handler used to change the column header label configuration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractColumnChangeLabelConfigurationValueHandler extends AbstractChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getLabelProviderConfiguration()
+ *
+ * @return
+ */
+ @Override
+ protected ILabelProviderConfiguration getLabelProviderConfiguration() {
+ return LabelConfigurationManagementUtils.getUsedColumnFeatureLabelConfiguration(getCurrentNattableModelManager().getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getLocalHeaderAxisConfigurationFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getLocalHeaderAxisConfigurationFeature() {
+ Table table = getCurrentNattableModelManager().getTable();
+ if(!table.isInvertAxis()) {
+ return NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ }
+ return NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+
+ /**
+ *
+ * @return
+ * the edited axis configuration
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getHeaderAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(getCurrentNattableModelManager().getTable());
+ }
+
+
+ /**
+ *
+ * @return
+ * the table header axis defined in the TableConfiguration and used for edited label axis configuration
+ */
+ @Override
+ protected TableHeaderAxisConfiguration getTableHeaderAxisConfiguration() {
+ return (TableHeaderAxisConfiguration)HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisInTableConfiguration(getCurrentNattableModelManager().getTable());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java
new file mode 100644
index 00000000000..215e1e52642
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.MasterObjectAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract handler used to change the value of the property IMasterAxisProvider#disconnectSlave
+ *
+ * @author vl222926
+ *
+ */
+public abstract class AbstractDisconnectSlaveHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final AbstractAxisProvider axisProvider = getAxisProviderToEdit();
+ if(axisProvider instanceof MasterObjectAxisProvider) {
+ boolean newState = !HandlerUtil.toggleCommandState(event.getCommand());
+ final TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ final IEditCommandRequest request = new SetRequest(domain, axisProvider, NattableaxisproviderPackage.eINSTANCE.getIMasterAxisProvider_DisconnectSlave(), newState);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(axisProvider);
+ final ICommand cmd = provider.getEditCommand(request);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the axis provider to edit
+ */
+ protected abstract AbstractAxisProvider getAxisProviderToEdit();
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ setBaseEnabled(getAxisProviderToEdit() instanceof MasterObjectAxisProvider);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeHeaderConfigurationHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeHeaderConfigurationHandler.java
new file mode 100644
index 00000000000..069e61acd12
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeHeaderConfigurationHandler.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+/**
+ * Abstract class to edit the header cofniguration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractRowChangeHeaderConfigurationHandler extends AbstractChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @return
+ * the axis configuration used by the table, can't be <code>null</code>;
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getEditedAxisConfiguration() {
+ AbstractHeaderAxisConfiguration conf = HeaderAxisConfigurationManagementUtils.getAbstractHeaderAxisConfigurationUsedInTable(getCurrentNattableModelManager().getTable());
+ return conf;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getLocalHeaderAxisConfigurationFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getLocalHeaderAxisConfigurationFeature() {
+ final Table table = getCurrentNattableModelManager().getTable();
+ if(table.isInvertAxis()) {
+ return NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ }
+ return NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeLabelConfigurationValueHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeLabelConfigurationValueHandler.java
new file mode 100644
index 00000000000..a1917a8bc25
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractRowChangeLabelConfigurationValueHandler.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtils;
+
+
+/**
+ * The abstract handler used to change the row header label configuration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractRowChangeLabelConfigurationValueHandler extends AbstractChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getLabelProviderConfiguration()
+ *
+ * @return
+ */
+ @Override
+ protected ILabelProviderConfiguration getLabelProviderConfiguration() {
+ return LabelConfigurationManagementUtils.getUsedRowObjectLabelConfiguration(getCurrentNattableModelManager().getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getLocalHeaderAxisConfigurationFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getLocalHeaderAxisConfigurationFeature() {
+ Table table = getCurrentNattableModelManager().getTable();
+ if(table.isInvertAxis()) {
+ return NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration();
+ }
+ return NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration();
+ }
+
+ /**
+ *
+ * @return
+ * the edited axis configuration
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getHeaderAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisUsedInTable(getCurrentNattableModelManager().getTable());
+ }
+
+
+ /**
+ *
+ * @return
+ * the table header axis defined in the TableConfiguration and used for edited label axis configuration
+ */
+ @Override
+ protected TableHeaderAxisConfiguration getTableHeaderAxisConfiguration() {
+ return (TableHeaderAxisConfiguration)HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(getCurrentNattableModelManager().getTable());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
new file mode 100644
index 00000000000..1ab42467f20
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -0,0 +1,238 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The abstract handler to use for the table actions
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractTableHandler extends AbstractHandler {
+
+ /** the id used to find the NatEvent in the EclipseContext */
+ public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId";
+
+ /**
+ * the event which have declenched the call to setEnable(Object evaluationContext. This event contains the location of the mouse pointer when
+ * the popup menu for this handler have been created
+ */
+ //FIXME : should maybe be remove with the future usage of e4 and the Eclispe Context
+ protected NatEventData eventData;
+
+
+ /**
+ *
+ * @return
+ * the current active part
+ */
+ protected IWorkbenchPart getActivePart() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+ }
+
+ /**
+ *
+ * @return
+ * the current table manager or <code>null</code> if not found
+ */
+ protected INattableModelManager getCurrentNattableModelManager() {
+ final IWorkbenchPart currentPart = getActivePart();
+ if(currentPart != null) {
+ final INattableModelManager manager = (INattableModelManager)currentPart.getAdapter(INattableModelManager.class);
+ return manager;
+ }
+ return null;
+ }
+
+
+ /**
+ * Returns the EditingDomain associated to the table
+ *
+ * @return
+ */
+ protected EditingDomain getTableEditingDomain() {//duplicated code from NattableModelManager
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(getCurrentNattableModelManager().getTable());
+ return registry.getService(EditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the EditingDomain associated to the context
+ *
+ * @return
+ */
+ protected EditingDomain getContextEditingDomain() {//duplicated code from NattableModelManager
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(getCurrentNattableModelManager().getTable());
+ return registry.getService(EditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param evaluationContext
+ * the evaluation context
+ * @return
+ * the NatEventData from this evaluation context
+ */
+ protected NatEventData getNatEventData(final Object evaluationContext) {
+ if(evaluationContext instanceof NatEventData) {
+ return (NatEventData)evaluationContext;
+ }
+ NatEventData eventData = null;
+ if(evaluationContext instanceof IEvaluationContext) {
+ Object value = ((IEvaluationContext)evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID);
+ if(value instanceof NatEventData) {
+ eventData = (NatEventData)value;
+ }
+ }
+ //FIXME : currently we can't have dependency on org.eclipse.e4....
+ //that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext
+ if(eventData == null) {
+ Point cursorLocation = Display.getDefault().getCursorLocation();
+ Control control = Display.getDefault().getCursorControl();
+ if(control instanceof NatTable) {//FIXME : not nice, but required
+ cursorLocation = control.toControl(cursorLocation);
+ Event e = new Event();
+ e.x = cursorLocation.x;
+ e.y = cursorLocation.y;
+ e.display = Display.getDefault();
+ e.widget = control;
+ MouseEvent event = new MouseEvent(e);
+ eventData = NatEventData.createInstanceFromEvent(event);
+ }
+ }
+ return eventData;
+ }
+
+ /**
+ *
+ * @param evaluationContext
+ * @return
+ * the index of the rows which are fully selected
+ */
+ protected List<Integer> getFullSelectedRowsIndex(Object evaluationContext) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ final NatEventData data = getNatEventData(evaluationContext);
+ if(data != null) {
+ final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
+ int[] fullSelectedColumnsPosition = layer.getFullySelectedRowPositions();
+ List<Integer> positions = new ArrayList<Integer>();
+ for(int i : fullSelectedColumnsPosition) {
+ positions.add(layer.getRowIndexByPosition(i));
+ }
+ return positions;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ *
+ * @param evaluationContext
+ * @return
+ * the index of the columns which are fully selected
+ */
+ protected List<Integer> getFullSelectedColumnsIndex(Object evaluationContext) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ final NatEventData data = getNatEventData(evaluationContext);
+ if(data != null) {
+ final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
+ int[] fullSelectedColumnsPosition = layer.getFullySelectedColumnPositions();
+ List<Integer> positions = new ArrayList<Integer>();
+ for(int i : fullSelectedColumnsPosition) {
+ positions.add(layer.getColumnIndexByPosition(i));
+ }
+ return positions;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+
+ /**
+ *
+ * @return
+ * the row axis manager
+ */
+ protected IAxisManager getRowAxisManager() {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ return manager.getRowAxisManager();
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the column axis manager
+ */
+ protected IAxisManager getColumnAxisManager() {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ return manager.getColumnAxisManager();
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ this.eventData = getNatEventData(evaluationContext);
+ setBaseEnabled(getCurrentNattableModelManager() != null);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexColumnStyleHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexColumnStyleHandler.java
new file mode 100644
index 00000000000..b5c64308220
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexColumnStyleHandler.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+/**
+ * the handler used to change the index style of the column
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ChangeIndexColumnStyleHandler extends AbstractChangeIndexStyleHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeIndexStyleHandler#getAxisConfiguration()
+ *
+ * @return
+ */
+ @Override
+ protected AbstractHeaderAxisConfiguration getAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisInTable(getCurrentNattableModelManager().getTable());
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexRowStyleHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexRowStyleHandler.java
new file mode 100644
index 00000000000..43bde668b45
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeIndexRowStyleHandler.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+
+
+/**
+ * the handler used to change the index style of the column
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ChangeIndexRowStyleHandler extends AbstractChangeIndexStyleHandler {
+
+ @Override
+ protected AbstractHeaderAxisConfiguration getAxisConfiguration() {
+ return HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTable(getCurrentNattableModelManager().getTable());
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnAutoResizeHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnAutoResizeHandler.java
new file mode 100644
index 00000000000..bb76fed59e0
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnAutoResizeHandler.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeColumnsCommand;
+import org.eclipse.nebula.widgets.nattable.util.GCFactory;
+
+/**
+ * Handler to resize columns
+ *
+ * @author VL222926
+ *
+ */
+public class ColumnAutoResizeHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final NatTable natTable = this.eventData.getNatTable();
+ natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, this.eventData.getColumnPosition(), natTable.getConfigRegistry(), new GCFactory(natTable)));
+ return null;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java
new file mode 100644
index 00000000000..db2a5de40cf
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the elements represented by the selected columns
+ *
+ * @author VL222926
+ *
+ */
+public class ColumnDestroyAxisElementHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxisElement(getFullSelectedColumnsIndex(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedColumnsIndex(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxisElement(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java
new file mode 100644
index 00000000000..039e0d90d62
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the selected columns
+ *
+ * @author VL222926
+ *
+ */
+public class ColumnDestroyAxisHandler extends AbstractTableHandler {
+
+ /**
+ * @Override
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxis(getFullSelectedColumnsIndex(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedColumnsIndex(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxis(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayIndexHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayIndexHeaderHandler.java
new file mode 100644
index 00000000000..688687030ca
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayIndexHeaderHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+
+
+/**
+ * The handler to change the boolean value to display index header for column
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayIndexHeaderHandler extends AbstractColumnChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureIsDerivedHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureIsDerivedHandler.java
new file mode 100644
index 00000000000..7d3380de7bb
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureIsDerivedHandler.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the "/" for derived feature in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelFeatureIsDerivedHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayIsDerived();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureMultiplicityHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureMultiplicityHandler.java
new file mode 100644
index 00000000000..f7e5f767787
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureMultiplicityHandler.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the feature multiplicity in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelFeatureMultiplicityHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayMultiplicity();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureNameHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureNameHandler.java
new file mode 100644
index 00000000000..64e4a5f51cf
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureNameHandler.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the name of the feature in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelFeatureNameHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayName();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureTypeHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureTypeHandler.java
new file mode 100644
index 00000000000..36c01f4cff4
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelFeatureTypeHandler.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the type of the feature in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelFeatureTypeHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayType();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelHeaderHandler.java
new file mode 100644
index 00000000000..34f1869cdc5
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelHeaderHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+
+/**
+ * The handler to change the boolean value to display label header for column
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelHeaderHandler extends AbstractColumnChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelImageHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelImageHandler.java
new file mode 100644
index 00000000000..9b7cc1b05dc
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelImageHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the image in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelImageHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayIcon();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelTextHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelTextHandler.java
new file mode 100644
index 00000000000..f8587b9fd40
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDisplayLabelTextHandler.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the text in the column label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class ColumnDisplayLabelTextHandler extends AbstractColumnChangeLabelConfigurationValueHandler {
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayLabel();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
new file mode 100644
index 00000000000..ad5123cc8b5
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+
+//FIXME : this handler should be declare on org.eclipse.ui.edit (or something like this) to be binded on F2
+
+public class ColumnEditAliasHeaderHandler extends AbstractTableHandler {
+
+ //FIXME : this attribute must be removed when we introduce the dependency on e4.
+ private NatEventData eventData;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(this.eventData != null) {
+ AbstractNattableWidgetManager manager = (AbstractNattableWidgetManager)getCurrentNattableModelManager();
+ manager.openEditColumnAliasDialog(this.eventData);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {//it must be the nattable selection event
+ final NatEventData eventData = getNatEventData(evaluationContext);
+ this.eventData = eventData;
+ final NattableModelManager manager = (NattableModelManager)getCurrentNattableModelManager();
+ if(eventData != null && manager != null) {
+ setBaseEnabled(manager.canEditColumnHeader(eventData));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnMasterDisconnectRowSlaveHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnMasterDisconnectRowSlaveHandler.java
new file mode 100644
index 00000000000..f6bb5abc124
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnMasterDisconnectRowSlaveHandler.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class ColumnMasterDisconnectRowSlaveHandler extends AbstractDisconnectSlaveHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractDisconnectSlaveHandler#getAxisProviderToEdit()
+ *
+ * @return
+ */
+ protected AbstractAxisProvider getAxisProviderToEdit() {
+ return AxisUtils.getAxisProviderUsedForColumns(getCurrentNattableModelManager());
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ExportToXLSHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ExportToXLSHandler.java
new file mode 100644
index 00000000000..5fc206bf76a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ExportToXLSHandler.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+
+public class ExportToXLSHandler extends AbstractTableHandler {
+
+ public Object execute(ExecutionEvent arg0) throws ExecutionException {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ manager.exportToXLS();
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java
new file mode 100644
index 00000000000..279ebbed901
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * The handler for the invert axis action
+ *
+ * @author vl222926
+ *
+ */
+public class InvertAxisHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ getCurrentNattableModelManager().invertAxis();
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PrintTableHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PrintTableHandler.java
new file mode 100644
index 00000000000..71a93b210b9
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PrintTableHandler.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * Handler for the print table action
+ *
+ */
+public class PrintTableHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ manager.print();
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowAutoResizeHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowAutoResizeHandler.java
new file mode 100644
index 00000000000..a8410990dbf
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowAutoResizeHandler.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand;
+import org.eclipse.nebula.widgets.nattable.util.GCFactory;
+
+/**
+ * Handler used to resize rows
+ *
+ * @author VL222926
+ *
+ */
+public class RowAutoResizeHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final NatTable natTable = this.eventData.getNatTable();
+ natTable.doCommand(new InitializeAutoResizeRowsCommand(natTable, this.eventData.getRowPosition(), natTable.getConfigRegistry(), new GCFactory(natTable)));
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java
new file mode 100644
index 00000000000..412372eb5c6
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the element represented by the selected rows
+ *
+ * @author VL222926
+ *
+ */
+public class RowDestroyAxisElementHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxisElement(getFullSelectedRowsIndex(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedRowsIndex(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxisElement(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java
new file mode 100644
index 00000000000..d8be0b721ef
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the element represented by the selected rows
+ *
+ * @author VL222926
+ *
+ */
+public class RowDestroyAxisHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxis(getFullSelectedRowsIndex(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> rows = getFullSelectedRowsIndex(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxis(rows));
+ }
+ super.setBaseEnabled(false);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayIndexHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayIndexHeaderHandler.java
new file mode 100644
index 00000000000..90d6ecfafa7
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayIndexHeaderHandler.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+
+/**
+ * The handler to change the boolean value to display index header for row
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayIndexHeaderHandler extends AbstractRowChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabeTextHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabeTextHandler.java
new file mode 100644
index 00000000000..651291bac86
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabeTextHandler.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the text in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabeTextHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayLabel();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureIsDerivedHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureIsDerivedHandler.java
new file mode 100644
index 00000000000..6932a7635bf
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureIsDerivedHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the "/" for derived feature in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelFeatureIsDerivedHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayIsDerived();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureMultiplicityHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureMultiplicityHandler.java
new file mode 100644
index 00000000000..040b102eee3
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureMultiplicityHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the feature multiplicity in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelFeatureMultiplicityHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayMultiplicity();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureNameHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureNameHandler.java
new file mode 100644
index 00000000000..484860e0cf7
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureNameHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+
+/**
+ * The handler to change the boolean value used to display the name of the feature in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelFeatureNameHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayName();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureTypeHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureTypeHandler.java
new file mode 100644
index 00000000000..d04c70da14d
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelFeatureTypeHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the type of the feature in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelFeatureTypeHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getFeatureLabelProviderConfiguration_DisplayType();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelHeaderHandler.java
new file mode 100644
index 00000000000..79c36a1a805
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelHeaderHandler.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+
+/**
+ * The handler to change the boolean value to display label header for row
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelHeaderHandler extends AbstractRowChangeHeaderConfigurationHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeHeaderConfigurationHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelImageHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelImageHandler.java
new file mode 100644
index 00000000000..ee8a66d8c20
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDisplayLabelImageHandler.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.NattablelabelproviderPackage;
+
+/**
+ * The handler to change the boolean value used to display the image in the row label header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class RowDisplayLabelImageHandler extends AbstractRowChangeLabelConfigurationValueHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractChangeLabelConfigurationValueHandler#getEditedFeature()
+ *
+ * @return
+ */
+ @Override
+ protected EStructuralFeature getEditedFeature() {
+ return NattablelabelproviderPackage.eINSTANCE.getObjectLabelProviderConfiguration_DisplayIcon();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
new file mode 100644
index 00000000000..0e91f69a74b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+
+//FIXME : this handler should be declare on org.eclipse.ui.edit (or something like this) to be binded on F2
+
+public class RowEditAliasHeaderHandler extends AbstractTableHandler {
+
+ //FIXME : this attribute must be removed when we introduce the dependency on e4.
+ private NatEventData eventData;
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(this.eventData != null) {
+ AbstractNattableWidgetManager manager = (AbstractNattableWidgetManager)getCurrentNattableModelManager();
+ manager.openEditRowAliasDialog(this.eventData);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {//it must be the nattable selection event
+ final NatEventData eventData = getNatEventData(evaluationContext);
+ this.eventData = eventData;
+ final NattableModelManager manager = (NattableModelManager)getCurrentNattableModelManager();
+ if(eventData != null && manager != null) {
+ setBaseEnabled(manager.canEditRowHeader(eventData));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowMasterDisconnectColumnSlaveHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowMasterDisconnectColumnSlaveHandler.java
new file mode 100644
index 00000000000..cdac44637b7
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowMasterDisconnectColumnSlaveHandler.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class RowMasterDisconnectColumnSlaveHandler extends AbstractDisconnectSlaveHandler {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractDisconnectSlaveHandler#getAxisProviderToEdit()
+ *
+ * @return
+ */
+ protected AbstractAxisProvider getAxisProviderToEdit() {
+ return AxisUtils.getAxisProviderUsedForRows(getCurrentNattableModelManager());
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectAllHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectAllHandler.java
new file mode 100644
index 00000000000..8f91be66414
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectAllHandler.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public class SelectAllHandler extends AbstractTableHandler {
+
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ manager.selectAll();
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
new file mode 100644
index 00000000000..cc2b7fdd7d5
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * Handler for the Create/Destroy columns Papyrus version
+ *
+ */
+public class SelectColumnsHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final INattableModelManager currentNattableModelManager = this.getCurrentNattableModelManager();
+ currentNattableModelManager.openCreateDestroyColumnsManagerDialog();
+ return event;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
+ setBaseEnabled(currentNattableModelManager.canCreateDestroyColumnsAxis());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
new file mode 100644
index 00000000000..ff0afee70c9
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+
+/**
+ *
+ * Handler for the Create/Destroy columns Papyrus version
+ *
+ */
+public class SelectRowsHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final INattableModelManager currentNattableModelManager = this.getCurrentNattableModelManager();
+ currentNattableModelManager.openCreateDestroyRowsManagerDialog();
+ return event;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
+ setBaseEnabled(currentNattableModelManager.canCreateDestroyRowsAxis());
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java
new file mode 100644
index 00000000000..48d313cce0f
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+
+/**
+ * Handler used to sort the columns
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class SortColumnsHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final String directionParameter = event.getParameter(Constants.SORT_COMMAND_PARAMETER);
+ INattableModelManager manager = getCurrentNattableModelManager();
+ boolean alphabeticOrder = "true".equals(directionParameter);
+ manager.sortColumnsByName(alphabeticOrder);
+ return null;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ setBaseEnabled(manager.canMoveColumns());
+ }
+ setBaseEnabled(false);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java
new file mode 100644
index 00000000000..0ff9f6b4c71
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+
+/**
+ * The handler for the sort rows action
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class SortRowsHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final String directionParameter = event.getParameter(Constants.SORT_COMMAND_PARAMETER);
+ INattableModelManager manager = getCurrentNattableModelManager();
+ boolean alphabeticOrder = Boolean.TRUE.toString().equals(directionParameter);
+ manager.sortRowsByName(alphabeticOrder);
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ setBaseEnabled(manager.canMoveColumns());
+ }
+ super.setBaseEnabled(false);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/DestroyTableAdviceHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/DestroyTableAdviceHelper.java
new file mode 100644
index 00000000000..2dab02f944a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/DestroyTableAdviceHelper.java
@@ -0,0 +1,9 @@
+package org.eclipse.papyrus.infra.nattable.helper.advice;
+
+
+public class DestroyTableAdviceHelper {
+
+ public DestroyTableAdviceHelper() {
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/TableContentsAdviceHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/TableContentsAdviceHelper.java
new file mode 100644
index 00000000000..663b1e5c4ca
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/helper/advice/TableContentsAdviceHelper.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.helper.advice;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisPackage;
+
+/**
+ *
+ * This helper allows to destroy table elements when a destroy element is referenced by a table
+ *
+ */
+public class TableContentsAdviceHelper extends AbstractEditHelperAdvice {
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
+ final EObject destroyedElement = request.getElementToDestroy();
+ return request.getDestroyDependentsCommand(getAssociatedElementToDestroy(destroyedElement));
+ // return null;
+ }
+
+ @Override
+ protected ICommand getAfterDestroyDependentsCommand(DestroyDependentsRequest request) {
+ // final EObject destroyedElement = request.getElementToDestroy();
+ // return request.getDestroyDependentsCommand(getAssociatedElementToDestroy(destroyedElement));
+ return null;
+ }
+
+ /**
+ *
+ * @param eobject
+ * the destroyed element
+ * @return
+ * the associated element to destroy in the same time than the eobject
+ */
+ protected List<EObject> getAssociatedElementToDestroy(final EObject eobject) {
+ final CrossReferenceAdapter adapter = getCrossReferenceAdapter(eobject);
+ Set<EObject> elementsToDestroy = adapter.getInverseReferencers(eobject, NattableaxisPackage.eINSTANCE.getEObjectAxis_Element(), NattableaxisPackage.eINSTANCE.getEObjectAxis());
+ return new ArrayList<EObject>(elementsToDestroy);
+ }
+
+ //Duplicated code from UML Diagram common
+ /**
+ * Returns the {@link CrossReferenceAdapter} corresponding to an {@link EObject}
+ *
+ * @param element
+ * the {@link EObject} element
+ * @return the {@link CrossReferenceAdapter} corresponding to element
+ */
+ public static CrossReferenceAdapter getCrossReferenceAdapter(EObject element) {
+
+ CrossReferenceAdapter crossReferenceAdapter = CrossReferenceAdapter.getExistingCrossReferenceAdapter(element);
+ if(crossReferenceAdapter == null) {
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(element);
+ if(domain != null) {
+ crossReferenceAdapter = CrossReferenceAdapter.getCrossReferenceAdapter(domain.getResourceSet());
+ }
+ }
+
+ return crossReferenceAdapter;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusGridLayer.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusGridLayer.java
new file mode 100644
index 00000000000..f0dc17d9864
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusGridLayer.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layer;
+
+import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusGridLayerConfiguration;
+
+/**
+ * This grid layer ovverride the default edition behavior
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class PapyrusGridLayer extends GridLayer {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param bodyLayer
+ * @param columnHeaderLayer
+ * @param rowHeaderLayer
+ * @param cornerLayer
+ */
+ public PapyrusGridLayer(ILayer bodyLayer, ILayer columnHeaderLayer, ILayer rowHeaderLayer, ILayer cornerLayer) {
+ super(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param bodyLayer
+ * @param columnHeaderLayer
+ * @param rowHeaderLayer
+ * @param cornerLayer
+ * @param useDefaultConfiguration
+ */
+ public PapyrusGridLayer(ILayer bodyLayer, ILayer columnHeaderLayer, ILayer rowHeaderLayer, ILayer cornerLayer, boolean useDefaultConfiguration) {
+ super(bodyLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer, useDefaultConfiguration);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param useDefaultConfiguration
+ */
+ public PapyrusGridLayer(boolean useDefaultConfiguration) {
+ super(useDefaultConfiguration);
+ }
+
+ @Override
+ protected void init(boolean useDefaultConfiguration) {
+ registerCommandHandlers();
+
+ if(useDefaultConfiguration) {
+ addConfiguration(new PapyrusGridLayerConfiguration(this));
+ }
+ }
+
+
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSelectionLayer.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSelectionLayer.java
new file mode 100644
index 00000000000..b5e3e023c04
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layer/PapyrusSelectionLayer.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layer;
+
+import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataCommandHandler;
+import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand;
+import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer;
+import org.eclipse.nebula.widgets.nattable.selection.ISelectionModel;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+
+/**
+ * Papyrus selection layer
+ *
+ * @author vl222926
+ *
+ */
+public class PapyrusSelectionLayer extends SelectionLayer {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param underlyingLayer
+ * @param useDefaultConfiguration
+ */
+ public PapyrusSelectionLayer(IUniqueIndexLayer underlyingLayer, boolean useDefaultConfiguration) {
+ super(underlyingLayer, useDefaultConfiguration);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param underlyingLayer
+ * @param selectionModel
+ * @param useDefaultConfiguration
+ * @param registerDefaultEventHandler
+ */
+ public PapyrusSelectionLayer(IUniqueIndexLayer underlyingLayer, ISelectionModel selectionModel, boolean useDefaultConfiguration, boolean registerDefaultEventHandler) {
+ super(underlyingLayer, selectionModel, useDefaultConfiguration, registerDefaultEventHandler);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param underlyingLayer
+ * @param selectionModel
+ * @param useDefaultConfiguration
+ */
+ public PapyrusSelectionLayer(IUniqueIndexLayer underlyingLayer, ISelectionModel selectionModel, boolean useDefaultConfiguration) {
+ super(underlyingLayer, selectionModel, useDefaultConfiguration);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param underlyingLayer
+ */
+ public PapyrusSelectionLayer(IUniqueIndexLayer underlyingLayer) {
+ super(underlyingLayer);
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.selection.SelectionLayer#registerCommandHandlers()
+ *
+ */
+ protected void registerCommandHandlers() {
+ super.registerCommandHandlers();
+ unregisterCommandHandler(CopyDataToClipboardCommand.class);
+ final CopyDataCommandHandler handler = new CopyDataCommandHandler(this);
+ handler.setCopyFormattedText(true);
+ registerCommandHandler(handler);
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java
new file mode 100644
index 00000000000..06848ae064b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/BodyLayerStack.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layerstack;
+
+import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.action.KeyEditAction;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
+import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
+import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
+import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
+import org.eclipse.papyrus.infra.nattable.configuration.StyleConfiguration;
+import org.eclipse.papyrus.infra.nattable.layer.PapyrusSelectionLayer;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.reorder.CustomDefaultColumnReorderBindings;
+import org.eclipse.swt.SWT;
+
+
+
+public class BodyLayerStack extends AbstractLayerTransform {
+
+ private final SelectionLayer selectionLayer;
+
+ private final DataLayer bodyDataLayer;
+
+ private final ViewportLayer viewportLayer;
+
+ private final ColumnHideShowLayer columnHideShowLayer;
+
+ private final ColumnReorderLayer columnReorderLayer;
+
+ // private final RowReorderLayer rowReoderLayer;
+
+ public BodyLayerStack(final IDataProvider dataProvider, final INattableModelManager manager) {
+ this.bodyDataLayer = new DataLayer(dataProvider);
+ this.bodyDataLayer.addConfiguration(new StyleConfiguration());
+ this.bodyDataLayer.setDefaultColumnWidth(200);
+
+ this.columnReorderLayer = new ColumnReorderLayer(this.bodyDataLayer, false);
+
+ //we register a custom configuration to manage the case where the reorder is forbidden
+ this.columnReorderLayer.addConfiguration(new CustomDefaultColumnReorderBindings(manager));
+
+
+ //to allow the reorder on the lines
+ // this.rowReoderLayer = null;
+ // this.rowReoderLayer = new RowReorderLayer(columnReorderLayer);
+ // this.columnHideShowLayer = new ColumnHideShowLayer(this.rowReoderLayer);
+
+ this.columnHideShowLayer = new ColumnHideShowLayer(this.columnReorderLayer);
+
+
+
+ this.selectionLayer = new PapyrusSelectionLayer(this.columnHideShowLayer);
+ // CopyDataCommandHandler handler = new CopyDataCommandHandler(this.selectionLayer);
+ //// handler.setCopyFormattedText(true);//to do the paste using the label provider
+ // this.selectionLayer.registerCommandHandler(handler);
+
+ this.viewportLayer = new ViewportLayer(this.selectionLayer);
+ setUnderlyingLayer(this.viewportLayer);
+ setRegionName(GridRegion.BODY);
+ }
+
+
+ public SelectionLayer getSelectionLayer() {
+ return this.selectionLayer;
+ }
+
+ public DataLayer getBodyDataLayer() {
+ return this.bodyDataLayer;
+ }
+
+ public ViewportLayer getViewportLayer() {
+ return this.viewportLayer;
+ }
+
+ public ColumnHideShowLayer getColumnHideShowLayer() {
+ return this.columnHideShowLayer;
+ }
+
+ public ColumnReorderLayer getColumnReorderLayer() {
+ return this.columnReorderLayer;
+ }
+
+ @Override
+ public void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) {
+ super.configure(configRegistry, uiBindingRegistry);
+ uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.F2), new KeyEditAction());
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE);
+ // uiBindingRegistry.registerKeyBinding(new Mouse, new KeyEditAction());
+ // uiBindingRegistry.
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CustomizedCellPainter(), DisplayMode.NORMAL, GridRegion.BODY);
+ }
+
+
+ // public RowReorderLayer getRowReoderLayer() {
+ // return this.rowReoderLayer;
+ // }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java
new file mode 100644
index 00000000000..dbed1ca9539
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/ColumnHeaderLayerStack.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layerstack;
+
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
+import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
+import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusColumnHeaderStyleConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusColumnResizeBindingsConfiguration;
+import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
+
+
+public class ColumnHeaderLayerStack extends AbstractLayerTransform {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dataProvider
+ * @param bodyLayer
+ * @param bodyDataProvider
+ */
+ public ColumnHeaderLayerStack(final IDataProvider dataProvider, final BodyLayerStack bodyLayer, final BodyDataProvider bodyDataProvider) {
+ DataLayer dataLayer = new DataLayer(dataProvider);
+ ColumnHeaderLayer colHeaderLayer = new ColumnHeaderLayer(dataLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer(), false);
+ colHeaderLayer.addConfiguration(new PapyrusColumnResizeBindingsConfiguration());
+ colHeaderLayer.addConfiguration(new PapyrusColumnHeaderStyleConfiguration());
+ setUnderlyingLayer(colHeaderLayer);
+ setRegionName(GridRegion.COLUMN_HEADER);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderLayerStack.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderLayerStack.java
new file mode 100644
index 00000000000..70b262761a9
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/layerstack/RowHeaderLayerStack.java
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.layerstack;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
+import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
+import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.nebula.widgets.nattable.reorder.action.RowReorderDragMode;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionBindings;
+import org.eclipse.nebula.widgets.nattable.ui.action.AggregateDragMode;
+import org.eclipse.nebula.widgets.nattable.ui.action.CellDragMode;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusRowHeaderStyleConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusRowResizeBindingsConfiguration;
+import org.eclipse.swt.SWT;
+
+
+public class RowHeaderLayerStack extends AbstractLayerTransform {
+
+ private static final int DEFAULT_COLUMN_WIDTH = 150;
+
+ private static final int DEFAULT_ROW_HEIGHT = 20;
+
+ public RowHeaderLayerStack(final IDataProvider dataProvider, final BodyLayerStack bodyLayer) {
+ final DataLayer dataLayer = new DataLayer(dataProvider, RowHeaderLayerStack.DEFAULT_COLUMN_WIDTH, RowHeaderLayerStack.DEFAULT_ROW_HEIGHT);
+ //I know that selection layer is probably false
+ final RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(dataLayer, bodyLayer, /* bodyLayer.getSelectionLayer() */new SelectionLayer(dataLayer), false);
+ rowHeaderLayer.addConfiguration(new PapyrusRowResizeBindingsConfiguration());
+ //ne marche pas! but : avoir le même type de cellule dans les headers des lignes et des colonnes
+ rowHeaderLayer.addConfiguration(new PapyrusRowHeaderStyleConfiguration());
+ // final IConfiguration configuration = new CustomConfig();
+ // setUnderlyingLayer(sortHeaderLayer);
+ // rowHeaderLayer.addConfiguration(configuration);
+ // rowHeaderLayer.addConfiguration(new RowOnlySelectionBindings());
+ setUnderlyingLayer(rowHeaderLayer);
+ setRegionName(GridRegion.ROW_HEADER);
+ }
+
+ public class CustomConfig extends DefaultSelectionBindings {
+
+
+
+ @Override
+ protected void configureRowHeaderMouseClickBindings(final UiBindingRegistry uiBindingRegistry) {
+
+ // uiBindingRegistry.registerDoubleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new SelectCellAction());
+ uiBindingRegistry.registerDoubleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new MouseEditAction());
+ // new BodyCellEditorMouseEventMatcher(TextCellEditor.class),
+ // new MouseEditAction());
+ // uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new ViewportSelectColumnAction(false, false));
+ // uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.SHIFT), new ViewportSelectColumnAction(true, false));
+ // uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.CONTROL), new ViewportSelectColumnAction(false, true));
+ // uiBindingRegistry.registerSingleClickBinding(MouseEventMatcher.columnHeaderLeftClick(SWT.SHIFT | SWT.CONTROL), new ViewportSelectColumnAction(true, true));
+ }
+ }
+
+ public class ReoderRowConfid extends AbstractUiBindingConfiguration {//This configuration should be added by the same kind of layer that DefaultColumnReorderLayerConfiguration but for row!
+
+ public void configureUiBindings(final UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.rowHeaderLeftClick(SWT.NONE), new AggregateDragMode(new CellDragMode(), new RowReorderDragMode()));
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDropListener.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDropListener.java
new file mode 100644
index 00000000000..0201d1ea8f1
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDropListener.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.listener;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.LocationValue;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.graphics.Point;
+
+
+public class NatTableDropListener implements DropTargetListener {
+
+
+ private final INattableModelManager manager;
+
+ private LocationValue dropKindValue;
+
+ public NatTableDropListener(final INattableModelManager manager) {
+ this.manager = manager;
+ }
+
+ public void dragEnter(final DropTargetEvent event) {
+
+ }
+
+ public void dragLeave(final DropTargetEvent event) {
+
+ }
+
+ public void dragOperationChanged(final DropTargetEvent event) {
+
+ }
+
+ public void dragOver(final DropTargetEvent event) {
+ this.dropKindValue = null;
+ final LocalTransfer localTransfer = LocalTransfer.getInstance();
+ final Object data = localTransfer.nativeToJava(event.currentDataType);
+ IStructuredSelection structuredSelection = null;
+ if(data instanceof IStructuredSelection) {
+ structuredSelection = (IStructuredSelection)data;
+ }
+ final Collection<Object> objectsToAdd = Collections.checkedCollection(structuredSelection.toList(), Object.class);
+ this.dropKindValue = this.manager.getLocationInTheTable(new Point(event.x, event.y));
+ int drop = DND.DROP_NONE;
+ switch(this.dropKindValue.getKind()) {
+ case AFTER_COLUMN_HEADER:
+ if(this.manager.canDropColumnsElement(objectsToAdd)) {
+ drop = DND.DROP_DEFAULT;
+ }
+ break;
+ case AFTER_ROW_HEADER:
+ if(this.manager.canDropRowElement(objectsToAdd)) {
+ drop = DND.DROP_DEFAULT;
+ }
+ break;
+ case COLUMN_HEADER:
+ if(this.manager.canInsertColumns(objectsToAdd, this.dropKindValue.getColumnIndex())) {
+ drop = DND.DROP_DEFAULT;
+ }
+ break;
+ case ROW_HEADER:
+ if(this.manager.canInsertRow(objectsToAdd, this.dropKindValue.getRowIndex())) {
+ drop = DND.DROP_DEFAULT;
+ }
+ break;
+ case CELL:
+ //FIXME
+ drop = DND.DROP_NONE;
+ break;
+ case UNKNOWN:
+ drop = DND.DROP_NONE;
+ break;
+ default:
+ drop = DND.DROP_NONE;
+ break;
+ }
+ event.detail = drop;
+ }
+
+ public void drop(final DropTargetEvent event) {
+ //we drop the elements into the table
+ LocalTransfer localTransfer = LocalTransfer.getInstance();
+ Object data = localTransfer.nativeToJava(event.currentDataType);
+ if(data instanceof StructuredSelection) {
+ final IStructuredSelection selection = (IStructuredSelection)data;
+ final List<Object> droppedElements = selection.toList();
+ if(this.dropKindValue != null) {
+ switch(this.dropKindValue.getKind()) {
+ case AFTER_COLUMN_HEADER:
+ this.manager.addColumns(droppedElements);
+ break;
+ case AFTER_ROW_HEADER:
+ this.manager.addRows(droppedElements);
+ break;
+ case COLUMN_HEADER:
+ this.manager.insertColumns(droppedElements, this.dropKindValue.getColumnIndex());
+ break;
+ case ROW_HEADER:
+ this.manager.insertRows(droppedElements, this.dropKindValue.getRowIndex());
+ break;
+ case CELL:
+ //FIXME
+ break;
+ case UNKNOWN:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ this.dropKindValue = null;
+ }
+
+
+ public void dropAccept(final DropTargetEvent event) {
+
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
new file mode 100644
index 00000000000..225615cbed6
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
@@ -0,0 +1,567 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.widgets.editors.InputDialog;
+import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+public abstract class AbstractAxisManager implements IAxisManager {
+
+ /**
+ * the represented axis manager
+ */
+ protected AxisManagerRepresentation representedAxisManager;
+
+ /**
+ * the represented axis provider
+ */
+ private AbstractAxisProvider representedContentProvider;
+
+ /**
+ * the global manager for the table
+ */
+ protected INattableModelManager tableManager;
+
+ /**
+ * the listener on the axis
+ */
+ protected Adapter axisListener;
+
+ /**
+ * the context of the table. We need to keep it, to be able to remove listeners on it, when the table is destroying
+ */
+ private EObject tableContext;
+
+ /**
+ *
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#init(org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager,
+ * java.lang.String, org.eclipse.papyrus.infra.nattable.model.nattable.nattablecontentprovider.IAxisContentsProvider)
+ *
+ * @param manager
+ * the globale table manager
+ * @param provider
+ * the represented axis provider
+ * @param managerId
+ * the id of this manager
+ */
+ public void init(final INattableModelManager manager, final AxisManagerRepresentation rep, final AbstractAxisProvider provider) {
+ this.tableManager = manager;
+ this.representedAxisManager = rep;
+ this.representedContentProvider = provider;
+ this.tableContext = manager.getTable().getContext();
+ this.axisListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(org.eclipse.emf.common.notify.Notification msg) {
+ getTableManager().updateAxisContents(getRepresentedContentProvider());
+ }
+ };
+ this.representedContentProvider.eAdapters().add(this.axisListener);
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getTableManager()
+ *
+ * @return
+ */
+ public NattableModelManager getTableManager() {
+ return (NattableModelManager)this.tableManager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canInsertAxis(java.util.Collection, int)
+ *
+ * @param objectsToAdd
+ * @param index
+ * @return
+ */
+ public boolean canInsertAxis(Collection<Object> objectsToAdd, int index) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canCreateAxisElement(java.lang.String)
+ *
+ * @param elementId
+ * @return
+ */
+ @Override
+ public boolean canCreateAxisElement(String elementId) {
+ return ElementTypeRegistry.getInstance().getType(elementId)!=null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDropAxisElement(java.util.Collection)
+ *
+ * @param objectsToAdd
+ * @return
+ */
+ public boolean canDropAxisElement(Collection<Object> objectsToAdd) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ *
+ */
+ public void dispose() {
+ if(this.axisListener != null) {
+ this.representedContentProvider.eAdapters().remove(this.axisListener);
+ this.axisListener = null;
+ }
+ this.tableContext = null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canBeUsedAsRowManager()
+ *
+ * @return
+ */
+ public boolean canBeUsedAsRowManager() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canBeUsedAsColumnManager()
+ *
+ * @return
+ */
+ public boolean canBeUsedAsColumnManager() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToAdd
+ * @return
+ */
+ public Command getAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getInsertAxisCommand(java.util.Collection, int)
+ *
+ * @param objectsToAdd
+ * @param index
+ * @return
+ */
+ public Command getInsertAxisCommand(Collection<Object> objectsToAdd, int index) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getComplementaryAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToAdd
+ * @return
+ */
+ public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getRepresentedContentProvider()
+ *
+ * @return
+ */
+ public AbstractAxisProvider getRepresentedContentProvider() {
+ return this.representedContentProvider;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#setHeaderDataValue(int, int, java.lang.Object)
+ *
+ * @param columnIndex
+ * @param rowIndex
+ * @param newValue
+ */
+ public void setHeaderDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ // nothing to do
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isAllowedContents(java.lang.Object)
+ *
+ * @param object
+ * @return <code>true</code> if the object is not yet represented by an axis
+ */
+ public boolean isAllowedContents(Object object) {
+ return !getTableManager().getElementsList(getRepresentedContentProvider()).contains(object);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canMoveAxis()
+ *
+ * @return
+ */
+ public boolean canMoveAxis() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#createPossibleAxisContentProvider(boolean)
+ *
+ * @param isRestricted
+ * @return
+ */
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {
+ return null;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToDestroy
+ * @return
+ */
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getDestroyAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToDestroy
+ * @return
+ */
+ @Override
+ public Command getDestroyAxisCommand(EditingDomain domain, Collection<Object> objectToDestroy) {//FIXME must be done in the abstract class
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(getRepresentedContentProvider());
+ final CompositeCommand compositeCommand = new CompositeCommand("Destroy IAxis Command");
+ for(final IAxis current : getRepresentedContentProvider().getAxis()) {
+ if(current.getManager() == this.representedAxisManager) {
+ if(objectToDestroy.contains(current) || objectToDestroy.contains(current.getElement())) {
+ final DestroyElementRequest request = new DestroyElementRequest((TransactionalEditingDomain)domain, current, false);
+ compositeCommand.add(provider.getEditCommand(request));
+ }
+ }
+ }
+ if(!compositeCommand.isEmpty()) {
+ return new GMFtoEMFCommandWrapper(compositeCommand);
+ }
+ return null;
+
+ }
+
+
+ /**
+ *
+ * @return
+ * the context of the managed table
+ */
+ protected final EObject getTableContext() {
+ return this.tableContext;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAllManagedAxis()
+ *
+ * @return
+ */
+ public Collection<Object> getAllManagedAxis() {
+ Set<Object> eObjects = new HashSet<Object>();
+ for(final IAxis current : getRepresentedContentProvider().getAxis()) {
+ if(current.getManager() == this.representedAxisManager) {
+ eObjects.add(current.getElement());
+ }
+ }
+ return eObjects;
+ }
+
+ /**
+ * Returns the EditingDomain associated to the table
+ *
+ * @return
+ */
+ protected EditingDomain getTableEditingDomain() {//Duplicated from NatTableModelManager
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(getTableManager().getTable());
+ return registry.getService(EditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the EditingDomain associated to the context
+ *
+ * @return
+ */
+ protected EditingDomain getContextEditingDomain() { //Duplicated from NatTableModelManager
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(getTableContext());
+ return registry.getService(TransactionalEditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+ return null;
+ }
+
+ public void moveAxis(Object elementToMove, int newIndex) {
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#openEditAxisAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData,
+ * int)
+ *
+ * @param event
+ * @param axisPosition
+ */
+ @Override
+ public void openEditAxisAliasDialog(final NatEventData event, int axisPosition) {
+ final IAxis axis = this.representedContentProvider.getAxis().get(axisPosition);
+ String alias = axis.getAlias();
+ if(alias == null) {
+ alias = ""; //$NON-NLS-1$
+ }
+
+ final String dialogMessage = String.format(Messages.AbstractAxisManager_InputDialogMessage, getElementAxisName(axis));
+ Point location = new Point(event.getOriginalEvent().x, event.getOriginalEvent().y);
+ Control natTable = event.getNatTable();
+ location = natTable.toDisplay(location);
+ final InputDialog dialog = new InputDialogWithLocation(Display.getDefault().getActiveShell(), Messages.AbstractAxisManager_InputDialogTitle, dialogMessage, alias, null, location);
+ int result = dialog.open();
+ if(result == IDialogConstants.OK_ID) {
+ String newAlias = dialog.getText();
+ if("".equals(newAlias)) { //$NON-NLS-1$
+ newAlias = null;
+ }
+ final TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ final SetRequest request = new SetRequest(domain, axis, NattableaxisPackage.eINSTANCE.getIAxis_Alias(), newAlias);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(axis);
+ final ICommand cmd = provider.getEditCommand(request);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ }
+ }
+
+ /**
+ * This method mustt be overriden by the children classes
+ *
+ * @param axis
+ * an axis
+ * @return
+ * <code>null</code> or an {@link UnsupportedOperationException} when the method {@link #canEditAxisHeader()} returns <code>false</code>
+ */
+ public String getElementAxisName(final IAxis axis) {
+ if(canEditAxisHeader()) {
+ return null;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getAxisManagerRepresentation()
+ *
+ * @return
+ */
+ @Override
+ public AxisManagerRepresentation getAxisManagerRepresentation() {
+ return this.representedAxisManager;
+ }
+
+ /**
+ *
+ * @param axisPositions
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxis(final List<Integer> axisPositions) {
+ if(axisPositions.isEmpty()) {
+ return false;
+ }
+ for(final Integer integer : axisPositions) {
+ if(!canDestroyAxis(integer)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean canDestroyAxisElement(List<Integer> axisPositions) {
+ if(axisPositions.isEmpty()) {
+ return false;
+ }
+ for(final Integer integer : axisPositions) {
+ if(!canDestroyAxisElement(integer)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @param axisPositions
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#destroyAxis(java.util.List)
+ */
+ @Override
+ public void destroyAxis(final List<Integer> axisPositions) {
+ final List<Object> toDestroy = getElements(axisPositions);
+ EditingDomain domain = getTableEditingDomain();
+ final Command cmd = getDestroyAxisCommand(domain, toDestroy);
+ domain.getCommandStack().execute(cmd);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxis(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ public boolean canDestroyAxis(final Integer axisPosition) {
+ return !isDynamic();
+ }
+
+
+ /**
+ *
+ * @param axisPositions
+ * axis positions
+ * @return
+ * the elements located at these axis position
+ */
+ protected List<Object> getElements(final List<Integer> axisPositions) {
+ final List<Object> elements = getElements();
+ final List<Object> toDestroy = new ArrayList<Object>();
+ for(final Integer position : axisPositions) {
+ final Object element = elements.get(position);
+ toDestroy.add(element);
+ }
+ return toDestroy;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#destroyAxisElement(java.util.List)
+ *
+ * @param axisPosition
+ */
+ @Override
+ public void destroyAxisElement(final List<Integer> axisPosition) {
+ final CompoundCommand cmd = new CompoundCommand("Destroy Axis Element Command");
+ EditingDomain domain = getContextEditingDomain();
+ for(Integer integer : axisPosition) {
+ cmd.append(getDestroyAxisElementCommand(domain, integer));
+ }
+
+ domain.getCommandStack().execute(cmd);
+ }
+
+ /**
+ *
+ * @return
+ * the list owning the elements displayed on the managed axis
+ */
+ protected List<Object> getElements() {
+ return this.tableManager.getElementsList(getRepresentedContentProvider());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getPasteCommand(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ @Override
+ public ICommand getPasteCommand(IPasteConfiguration configuration) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canPaste(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ @Override
+ public boolean canPaste(IPasteConfiguration configuration) {
+ return false;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java
new file mode 100644
index 00000000000..436349a2bd6
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractSynchronizedOnFeatureAxisManager.java
@@ -0,0 +1,306 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.EStructuralFeatureValueFillingConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+
+/**
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+//FIXME : this abstract class must inherits from the UML Element axis manager
+//FIXME : must be moved into infra.emf.nattable
+public abstract class AbstractSynchronizedOnFeatureAxisManager extends AbstractAxisManager {
+
+ /**
+ * the feature listener
+ */
+ protected Adapter featureListener;
+
+ /**
+ * the features currently listen
+ */
+ protected Collection<EStructuralFeature> listenFeatures;
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#init(org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager,
+ * org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation,
+ * org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider)
+ *
+ * @param manager
+ * @param provider
+ * @param rep
+ */
+ @Override
+ public void init(final INattableModelManager manager, final AxisManagerRepresentation rep, final AbstractAxisProvider provider) {
+ super.init(manager, rep, provider);
+ verifyValues();
+
+ addContextFeatureValueListener();
+ }
+
+
+ /**
+ * add a listener on the table context to listen the required feature
+ */
+ protected void addContextFeatureValueListener() {
+ this.featureListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if(getListenFeatures().contains(msg.getFeature())) {//FIXME : create our own adapter for derived/subset feature
+ getTableManager().updateAxisContents(getRepresentedContentProvider());
+ }
+ };
+ };
+
+ getTableContext().eAdapters().add(this.featureListener);
+ }
+
+ /**
+ * this method verify that the fields and the parameters are correct for this synchronized table
+ *
+ */
+ protected void verifyValues() {
+ Assert.isTrue(!getListenFeatures().isEmpty());
+ verifyFeatureMultiplicity();
+ }
+
+ /**
+ *
+ * @return
+ * the features to listen according to the current table configuration or <code>null</code> if it is not definedS
+ */
+ protected Collection<EStructuralFeature> getListenFeatures() {
+ if(this.listenFeatures == null) {
+ this.listenFeatures = new ArrayList<EStructuralFeature>();
+ final Collection<EStructuralFeatureValueFillingConfiguration> configs = getFillingConfigurations();
+ final Collection<EStructuralFeature> avalaibleFeatures = getTableContext().eClass().getEAllStructuralFeatures();
+ for(EStructuralFeatureValueFillingConfiguration eStructuralFeatureValueFillingConfiguration : configs) {
+ final EStructuralFeature feature = eStructuralFeatureValueFillingConfiguration.getListenFeature();
+ if(feature != null && avalaibleFeatures.contains(feature) && !this.listenFeatures.contains(feature)) {
+ listenFeatures.add(feature);
+ }
+ }
+ }
+ return this.listenFeatures;
+ }
+
+ /**
+ *
+ * @return
+ * the filling configuration used by the table or <code>null</code> if any is defined
+ */
+ protected Collection<EStructuralFeatureValueFillingConfiguration> getFillingConfigurations() {//FIXME : local configuration not yet managed
+ final Collection<EStructuralFeatureValueFillingConfiguration> configs = new ArrayList<EStructuralFeatureValueFillingConfiguration>();
+ for(final IAxisConfiguration current : this.representedAxisManager.getSpecificAxisConfigurations()) {
+ if(current instanceof EStructuralFeatureValueFillingConfiguration) {
+ configs.add((EStructuralFeatureValueFillingConfiguration)current);
+ }
+ }
+ return configs;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ getTableContext().eAdapters().remove(this.featureListener);
+ super.dispose();
+ }
+
+ /**
+ * verify that the context contains the feature
+ *
+ */
+ protected void verifyFeatureMultiplicity() {
+ for(final EStructuralFeature feature : getListenFeatures()) {
+ Assert.isTrue(feature.isMany());
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDropAxisElement(java.util.Collection)
+ *
+ * @param objectsToAdd
+ * @return
+ */
+ @Override
+ public boolean canDropAxisElement(Collection<Object> objectsToAdd) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canInsertAxis(java.util.Collection, int)
+ *
+ * @param objectsToAdd
+ * @param index
+ * @return
+ */
+ @Override
+ public boolean canInsertAxis(Collection<Object> objectsToAdd, int index) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAllManagedAxis()
+ *
+ * @return
+ */
+ @Override
+ public Collection<Object> getAllManagedAxis() {
+ final EObject context = getTableContext();
+ final Collection<Object> valuesAsSet = new LinkedHashSet<Object>();
+ for(final EStructuralFeature current : getListenFeatures()) {
+ Object value = context.eGet(current);
+ Assert.isTrue(value instanceof Collection<?>);
+ valuesAsSet.addAll((Collection<? extends Object>)value);
+ }
+ final List<Object> values = new ArrayList<Object>(valuesAsSet);
+ List<Object> interestingObject = filterObject(values);
+ interestingObject = sortObjects(interestingObject);
+ return interestingObject;
+ }
+
+ /**
+ *
+ * @param objects
+ * @return
+ */
+ protected List<Object> sortObjects(final List<Object> objects) {
+ return objects;
+ }
+
+ /**
+ *
+ * @param objects
+ * @return
+ */
+ protected List<Object> filterObject(final List<Object> objects) {
+ return objects;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canMoveAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canMoveAxis() {
+ return false;
+ }
+
+ public final boolean isDynamic() {
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isSlave()
+ *
+ * @return
+ */
+ public boolean isSlave() {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canEditAxisHeader()
+ *
+ * @return
+ */
+ @Override
+ public boolean canEditAxisHeader() {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canPaste(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ //FIXME : must be in emf EObject Axis Manager
+ @Override
+ public boolean canPaste(final IPasteConfiguration configuration) {
+ if(configuration instanceof PasteEObjectConfiguration) {
+ final String elementId = ((PasteEObjectConfiguration)configuration).getPastedElementId();
+ final EStructuralFeature containmentFeature = ((PasteEObjectConfiguration)configuration).getPasteElementContainementFeature();
+ if(elementId != null && canCreateAxisElement(elementId)) {
+ if(containmentFeature != null && getTableContext().eClass().getEAllStructuralFeatures().contains(containmentFeature)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getPasteCommand(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ // /FIXME : must be in emf EObject Axis Manager
+ @Override
+ public ICommand getPasteCommand(final IPasteConfiguration configuration) {
+ final CompositeCommand command = new CompositeCommand("Paste In Table Command"); //$NON-NLS-1$
+ final PasteEObjectConfiguration config = (PasteEObjectConfiguration)configuration;
+ IElementType elementType = ElementTypeRegistry.getInstance().getType(config.getPastedElementId());
+ final EObject tableContext = getTableContext();
+ final CreateElementRequest createRequest = new CreateElementRequest((TransactionalEditingDomain)getContextEditingDomain(), tableContext, elementType, (EReference)config.getPasteElementContainementFeature());
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(tableContext);
+ final ICommand commandCreation = provider.getEditCommand(createRequest);
+ command.add(commandCreation);
+ return command;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AxisManagerFactory.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AxisManagerFactory.java
new file mode 100644
index 00000000000..426a2c7609a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AxisManagerFactory.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+
+/**
+ * The axis manager factory
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class AxisManagerFactory {
+
+ private static final String CLASS_MANAGER = "manager"; //$NON-NLS-1$
+
+ private static final String CLASS_ID = "id"; //$NON-NLS-1$
+
+ private final Map<String, Class<IAxisManager>> map;
+
+ private static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.axismanager"; //$NON-NLS-1$
+
+ public static final AxisManagerFactory INSTANCE = new AxisManagerFactory();
+
+ private AxisManagerFactory() {
+ this.map = new HashMap<String, Class<IAxisManager>>();
+
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+ final String id = iConfigurationElement.getAttribute(CLASS_ID);
+ try {
+ //to avoid problem when the provided class in not this plugin!
+ IAxisManager axisManager = (IAxisManager)iConfigurationElement.createExecutableExtension(CLASS_MANAGER);
+ @SuppressWarnings("unchecked")
+ final Class<IAxisManager> myClass = (Class<IAxisManager>)axisManager.getClass();
+ this.map.put(id, myClass);
+ } catch (final CoreException e) {
+ Activator.log.error(String.format(Messages.AxisManagerFactory_AxisManagerClassCantBeLoaded, id), e);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param axisManagerRepresentation
+ * @return
+ * the axis manager for this axisManagerRepresentation. The class calling this method must initialize itself the IAxisManager with its
+ * method #init
+ */
+ public IAxisManager getAxisManager(final AxisManagerRepresentation axisManagerRepresentation) {
+ final Class<IAxisManager> managerClass = this.map.get(axisManagerRepresentation.getAxisManagerId());
+ IAxisManager axisManager = null;
+ if(managerClass != null) {
+ try {
+ axisManager = managerClass.newInstance();
+ } catch (final InstantiationException e) {
+ Activator.log.error(Messages.AxisManagerFactory_TheClassCantBeInstanciated, e);
+ } catch (final IllegalAccessException e) {
+ Activator.log.error(e);
+ }
+ }
+ return axisManager;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
new file mode 100644
index 00000000000..d7108f53915
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
@@ -0,0 +1,562 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.IElementTypeFactory;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.nattable.provider.tmp.CompoundFilteredRestrictedContentProvider;
+import org.eclipse.papyrus.infra.nattable.utils.AxisComparator;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
+
+
+public class CompositeAxisManager extends AbstractAxisManager implements ICompositeAxisManager {
+
+ /**
+ * the id of this manager
+ */
+ private static final String MANAGER_ID = "org.eclipse.papyrus.infra.nattable.composite.axis.manager"; //$NON-NLS-1$
+
+ /**
+ * the sub managers
+ */
+ protected List<IAxisManager> subManagers;
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#setSubAxisManager(java.util.List)
+ *
+ * @param managers
+ */
+ public void setSubAxisManager(final List<IAxisManager> managers) {
+ this.subManagers = managers;
+ updateAxisContents();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ for(final IAxisManager current : this.subManagers) {
+ current.dispose();
+ }
+ this.subManagers.clear();
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canBeUsedAsRowManager()
+ *
+ * @return
+ */
+ @Override
+ public boolean canBeUsedAsRowManager() {
+ boolean answer = true;
+ final Iterator<IAxisManager> iter = this.subManagers.iterator();
+ while(iter.hasNext() && answer) {
+ answer = iter.next().canBeUsedAsRowManager();
+ }
+ return answer;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canBeUsedAsColumnManager()
+ *
+ * @return
+ */
+ @Override
+ public boolean canBeUsedAsColumnManager() {
+ boolean answer = true;
+ final Iterator<IAxisManager> iter = this.subManagers.iterator();
+ while(iter.hasNext() && answer) {
+ answer = iter.next().canBeUsedAsColumnManager();
+ }
+ return answer;
+ }
+
+ @Override
+ public boolean canCreateAxisElement(String elementId) {
+ boolean canCreateAxisElement = false;
+ for(IAxisManager manager : subManagers) {
+ canCreateAxisElement |= manager.canCreateAxisElement(elementId);
+ }
+ return canCreateAxisElement;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToAdd
+ * @return
+ */
+ @Override
+ public Command getAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
+ final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
+ for(final IAxisManager current : this.subManagers) {
+ final Command tmp = current.getAddAxisCommand(domain, objectToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ }
+ if(cmd.isEmpty()) {
+ return null;
+ }
+ return cmd;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getComplementaryAddAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToAdd
+ * @return
+ */
+ @Override
+ public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd) {
+ final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_AddAxisCommand);
+ for(final IAxisManager current : this.subManagers) {
+ final Command tmp = current.getComplementaryAddAxisCommand(domain, objectToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ }
+ if(cmd.isEmpty()) {
+ return null;
+ }
+ return cmd;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#updateAxisContents()
+ *
+ */
+ public synchronized void updateAxisContents() {
+ final List<Object> displayedElement = getTableManager().getElementsList(getRepresentedContentProvider());
+ synchronized(displayedElement) {
+ displayedElement.clear();
+ displayedElement.addAll(getRepresentedContentProvider().getAxis());
+ if(this.subManagers != null) {
+ for(final IAxisManager current : this.subManagers) {
+ if(current.isDynamic()) {
+ displayedElement.addAll(current.getAllManagedAxis());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#isAllowedContents(java.lang.Object)
+ *
+ * @param object
+ * @return
+ */
+ @Override
+ public boolean isAllowedContents(Object object) {
+ for(final IAxisManager current : this.subManagers) {
+ if(current.isAllowedContents(object)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canMoveAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canMoveAxis() {
+ for(final IAxisManager current : this.subManagers) {
+ if(!current.canMoveAxis() || current.isDynamic()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#sortAxisByName(boolean,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param inverted
+ * @param configRegistry
+ */
+ public void sortAxisByName(boolean alphabeticOrder, final IConfigRegistry configRegistry) {
+ if(canMoveAxis()) {
+ final List<IAxis> axis = new ArrayList<IAxis>(getRepresentedContentProvider().getAxis());
+ Collections.sort(axis, new AxisComparator(alphabeticOrder, configRegistry));
+ final TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(getRepresentedContentProvider());
+ final AbstractEditCommandRequest request = new SetRequest(domain, getRepresentedContentProvider(), NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), axis);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(getRepresentedContentProvider());
+ final ICommand cmd = provider.getEditCommand(request);
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
+ }
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#createPossibleAxisContentProvider(boolean)
+ *
+ * @param isRestricted
+ * @return a contents provider for this axis or <code>null</code> if it is not allowed
+ */
+ @Override
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted) {
+
+ CompoundFilteredRestrictedContentProvider compoundContentProvider = null;
+ for(final IAxisManager current : this.subManagers) {
+ IRestrictedContentProvider contentProvider = current.createPossibleAxisContentProvider(isRestricted);
+ if(contentProvider != null) {
+ if(compoundContentProvider == null) {
+ compoundContentProvider = new CompoundFilteredRestrictedContentProvider();
+ }
+ compoundContentProvider.add(contentProvider);
+ }
+ }
+ return compoundContentProvider;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getDestroyAxisCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.util.Collection)
+ *
+ * @param domain
+ * @param objectToDestroy
+ * @return
+ */
+ @Override
+ public Command getDestroyAxisCommand(EditingDomain domain, Collection<Object> objectToDestroy) {
+ final CompoundCommand cmd = new CompoundCommand(Messages.CompositeAxisManager_DestroyAxisCommand);
+ for(final IAxisManager current : this.subManagers) {
+ final Command tmp = current.getDestroyAxisCommand(domain, objectToDestroy);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ }
+ if(cmd.isEmpty()) {
+ return null;
+ }
+ return cmd;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAllManagedAxis()
+ *
+ * @return
+ */
+ @Override
+ public Collection<Object> getAllManagedAxis() {
+ Set<Object> allExistingAxis = new HashSet<Object>();
+ for(IAxisManager manager : this.subManagers) {
+ Collection<Object> managerPossibleElements = manager.getAllManagedAxis();
+ if(managerPossibleElements != null) {
+ allExistingAxis.addAll(managerPossibleElements);
+ }
+ }
+ return allExistingAxis;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isSlave()
+ *
+ * @return
+ * <code>true</code> if one of the encapsulated manager is a slave
+ */
+ public boolean isSlave() {
+ for(final IAxisManager manager : this.subManagers) {
+ if(manager.isSlave()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isDynamic()
+ *
+ * @return
+ * <code>true</code> if one of the embedded axis manager is dynamic
+ */
+ public boolean isDynamic() {
+ for(final IAxisManager manager : this.subManagers) {
+ if(manager.isDynamic()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDropAxisElement(java.util.Collection)
+ *
+ * @param objectsToAdd
+ * @return
+ */
+ @Override
+ public boolean canDropAxisElement(Collection<Object> objectsToAdd) {
+ for(final IAxisManager current : this.subManagers) {
+ if(current.canDropAxisElement(objectsToAdd)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ *
+ * @param elementToMove
+ * @param newIndex
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#moveAxis(java.lang.Object, int)
+ */
+ public void moveAxis(Object elementToMove, int newIndex) {
+ if(!isDynamic() && elementToMove instanceof IAxis) {
+ EditingDomain domain = getTableEditingDomain();
+ final Command command = MoveCommand.create(domain, getRepresentedContentProvider(), NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), elementToMove, newIndex);
+ domain.getCommandStack().execute(command);
+ };
+ }
+
+ @Override
+ public boolean canEditAxisHeader(final NatEventData axisIndex) {
+ axisIndex.getColumnPosition();//FIXME
+ if(canEditAxisHeader()) {//FIXME
+ return true;
+ } else {
+ return false;//FIXME : we need to iterate on the contents to know if it is possible or not
+ }
+ }
+
+ @Override
+ public boolean canEditAxisHeader() {
+ for(final IAxisManager current : this.subManagers) {
+ if(!current.canEditAxisHeader()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getElementAxisName(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ public String getElementAxisName(final IAxis axis) {
+ final AxisManagerRepresentation manager = axis.getManager();
+ for(final IAxisManager man : this.subManagers) {
+ if(man.getAxisManagerRepresentation() == manager) {
+ return man.getElementAxisName(axis);
+ }
+ }
+ if(canEditAxisHeader()) {
+ return null;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ * @param axis
+ * an axis
+ * @return
+ * the axis manager managing this axis
+ */
+ protected IAxisManager getAxisManager(final IAxis axis) {
+ final AxisManagerRepresentation rep = axis.getManager();
+ for(final IAxisManager man : this.subManagers) {
+ if(man.getAxisManagerRepresentation() == rep) {
+ return man;
+ }
+ }
+ return null;//must be impossible
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDestroyAxis(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxis(final Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).canDestroyAxis(axisPosition);
+ }
+ //not yet managed
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).canDestroyAxisElement(axisPosition);
+ } else if(subManagers.size() == 1) {
+ return subManagers.get(0).canDestroyAxisElement(axisPosition);
+ }
+ //not yet managed
+ return false;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).getDestroyAxisElementCommand(domain, axisPosition);
+ } else if(subManagers.size() == 1) {
+ return subManagers.get(0).getDestroyAxisElementCommand(domain, axisPosition);
+ }
+ //not yet managed
+ return UnexecutableCommand.INSTANCE;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canPaste(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ @Override
+ public boolean canPaste(IPasteConfiguration configuration) {
+ for(final IAxisManager current : this.subManagers) {
+ if(current.canPaste(configuration)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getPasteCommand(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration)
+ *
+ * @param configuration
+ * @return
+ */
+ @Override
+ public ICommand getPasteCommand(IPasteConfiguration configuration) {
+ final CompositeCommand command = new CompositeCommand("Paste In Table Command"); //$NON-NLS-1$
+ final PasteEObjectConfiguration config = (PasteEObjectConfiguration)configuration;
+ IElementType elementType = ElementTypeRegistry.getInstance().getType(config.getPastedElementId());
+ final EObject tableContext = getTableContext();
+ CreateElementRequest createRequest = new CreateElementRequest((TransactionalEditingDomain)getContextEditingDomain(), tableContext, elementType, (EReference)config.getPasteElementContainementFeature());
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(tableContext);
+ final ICommand commandCreation = provider.getEditCommand(createRequest);
+ command.add(commandCreation);
+ // for(final IAxisManager current : this.subManagers) {
+ // final ICommand cmd = current.getPasteCommand(configuration);
+ // if(cmd != null) {
+ // command.add(cmd);
+ // }
+ // }
+ return command;
+ }
+
+// @Override
+// public Object getAxisType(Object object) {
+// for(final IAxisManager current : subManagers){
+// Object result = current.getAxisType(object);
+// if(result!=null){
+// return result;
+// }
+// }
+// return null;
+// }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
new file mode 100644
index 00000000000..71ff1fa0e5a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
@@ -0,0 +1,295 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
+import org.eclipse.ui.services.IDisposable;
+
+/**
+ * The common interface used by the axis manager
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public interface IAxisManager extends IDisposable {
+
+ /**
+ *
+ * @return <code>true</code> if the manager can be used horizontally
+ */
+ public boolean canBeUsedAsRowManager();
+
+ /**
+ *
+ * @return <code>true</code> if the manager can be used vertically
+ */
+ public boolean canBeUsedAsColumnManager();
+
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param objectToAdd
+ * the object to add
+ * @return the command to add an axis to the emf model
+ */
+ public Command getAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd);
+
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param objectToAdd
+ * the object to add
+ * @return the complementary command, which is called by the master on the
+ * slave to add required axis
+ */
+ public Command getComplementaryAddAxisCommand(final EditingDomain domain, final Collection<Object> objectToAdd);
+
+ /**
+ *
+ * @param manager
+ * the table model manager
+ * @param managerRep
+ * its axis manager representation
+ * @param provider
+ * //FIXME : realy usefule?
+ * the managed axis provider
+ */
+ public void init(final INattableModelManager manager, AxisManagerRepresentation managerRep, final AbstractAxisProvider provider);
+
+ public void setHeaderDataValue(int columnIndex, int rowIndex, Object newValue);
+
+ /**
+ *
+ * @return
+ * the managed axis provider
+ */
+ public AbstractAxisProvider getRepresentedContentProvider();
+
+ /**
+ *
+ *
+ * @return
+ * the table manager using this axis manager
+ */
+ public NattableModelManager getTableManager(); //FIXME : we must use an interface with a small set of accessible method...
+
+
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the contents provided by the axis manager is derived of the contents provided by the others axis manager
+ */
+ public boolean isSlave();
+
+ public boolean canInsertAxis(Collection<Object> objectsToAdd, int index);
+
+ public boolean canDropAxisElement(Collection<Object> objectsToAdd);
+
+ public Command getInsertAxisCommand(Collection<Object> objectsToAdd, int index);
+
+ /**
+ *
+ * @param object
+ * an object
+ * @return
+ * <code>true</code> if the object can be managed by the AxisManager
+ */
+ public boolean isAllowedContents(final Object object);
+
+ /**
+ *
+ * @return <code>true</code> if we can move elements on the axis
+ */
+ public boolean canMoveAxis();
+
+ /**
+ *
+ * @param isRestricted
+ * @return
+ * a content provider or <code>null</code> if the dialog to add/destroy axis is not supported
+ */
+ public IRestrictedContentProvider createPossibleAxisContentProvider(boolean isRestricted);
+
+
+ /**
+ *
+ * @param domain
+ * @param objectToDestroy
+ * @return
+ */
+ public Command getDestroyAxisCommand(EditingDomain domain, Collection<Object> objectToDestroy);
+
+ /**
+ *
+ * @return
+ * the list of the existing axis managed by the axis manager
+ */
+ public Collection<Object> getAllManagedAxis();
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the contents provided by this axis manager is derived of the (UML) model
+ */
+ public boolean isDynamic();
+
+ /**
+ *
+ * @param newIndex
+ * @param axisToMove
+ */
+ public void moveAxis(final Object elementToMove, final int newIndex);
+
+ /**
+ *
+ * @param elementId
+ * the id of the element to create
+ * @return
+ * <code>true</code> if the element can be created
+ */
+ public boolean canCreateAxisElement(final String elementId);
+
+ /**
+ *
+ * @return
+ * <code>true</code> if we allows to edit the string of all axis headers.
+ */
+ public boolean canEditAxisHeader();
+
+ /**
+ * Open a dialog to edit the alias of an axis and set the value
+ *
+ * @param event
+ * the event
+ * @param axisIndex
+ * the position of the axis
+ */
+ public void openEditAxisAliasDialog(final NatEventData event, int axisIndex);
+
+ /**
+ *
+ * @return
+ * the axis manager representation
+ */
+ public AxisManagerRepresentation getAxisManagerRepresentation();
+
+ /**
+ *
+ * @param axis
+ * an axis
+ * @return
+ * the name used for this axis
+ */
+ public String getElementAxisName(final IAxis axis);//FIXME pb if the axisManager returns Object and not IAxis... -> use the index!
+
+ /**
+ *
+ * @param axisIndex
+ * axis index
+ * @return
+ * <code>true</code> if ALL axis identified by the axisIndex can be destroyed
+ */
+ public boolean canDestroyAxis(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * @return
+ * <code>true</code> if the axis identified by the axisIndex can be destroyed
+ */
+ public boolean canDestroyAxis(final Integer axisIndex);
+
+ /**
+ * Destroy all axis represented by their index
+ *
+ * @param axisIndex
+ * a list of axis index
+ */
+ public void destroyAxis(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * a list of axis index
+ * @return
+ * <code>true</code> if ALL elements represented by the axis located to these index can be destroyed
+ */
+ public boolean canDestroyAxisElement(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * the index of an element
+ * @return
+ * <code>true</code> if we can destroy the element represented by the axis located to this index
+ */
+ public boolean canDestroyAxisElement(final Integer axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * the list of the index of the elements to destroy
+ */
+ public void destroyAxisElement(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ public Command getDestroyAxisElementCommand(final EditingDomain domain, final Integer axisPosition);
+
+ /**
+ *
+ * @param configuration
+ * the paste configuration
+ * @return
+ * <code>true</code> if the axis manager support this paste configuration
+ */
+ public boolean canPaste(IPasteConfiguration configuration);
+
+ /**
+ *
+ * @param configuration
+ * @return
+ * the command to use for the paste, or <code>null</code> if the paste is not possible for this axis manager
+ */
+ public ICommand getPasteCommand(final IPasteConfiguration configuration);
+
+// /**
+// *
+// * @param object
+// * @return
+// */
+// //FIXME : should be in an FeatureAxisManager?
+// public Object getAxisType(final Object object);
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
new file mode 100644
index 00000000000..829e8a67be0
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+
+
+/**
+ *
+ * This interfaces provides the methods for the CompositeAxisManager
+ *
+ */
+public interface ICompositeAxisManager extends IAxisManager {
+
+ /**
+ *
+ * @param subAxisManager
+ * the managed axis manager
+ */
+ public void setSubAxisManager(final List<IAxisManager> subAxisManager);
+
+ /**
+ * update the contents of the list representing the managed axis
+ */
+ public void updateAxisContents();
+
+ /**
+ *
+ * @param alpabeticOrder
+ * <code>true</code> if we sort the axis by alphabetic order, <code>false</code> if not
+ * @param iConfigRegistry
+ * the config registry used to find the label provider
+ */
+ public void sortAxisByName(final boolean alpabeticOrder, IConfigRegistry iConfigRegistry);
+
+ public boolean canEditAxisHeader(NatEventData evaluationContext);
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java
new file mode 100644
index 00000000000..21ab5b76034
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/InputDialogWithLocation.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.axis;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.papyrus.infra.widgets.editors.InputDialog;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * The developper can define the location of this input dialog
+ *
+ * @author vl222926
+ *
+ */
+public class InputDialogWithLocation extends InputDialog {
+
+ /**
+ * the location wanted to display the dialog
+ */
+ private Point location;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see InputDialog#InputDialog(Shell, String, String, String, IInputValidator)
+ * @param parentShell
+ * @param title
+ * @param label
+ * @param initialValue
+ * @param validator
+ * @param dialogLocation
+ * the location to use for the dialog
+ */
+ public InputDialogWithLocation(Shell parentShell, String title, String label, String initialValue, IInputValidator validator, final Point dialogLocation) {
+ super(parentShell, title, label, initialValue, validator);
+ this.location = dialogLocation;
+ }
+
+ @Override
+ public void create() {
+ super.create();
+ //adapted code from AbstractStyleEditorDialog in nattable plugin
+ if(location != null) {
+ if(location.x < getParentShell().getDisplay().getBounds().x) {
+ location.x = getParentShell().getDisplay().getBounds().x;
+ } else if(location.x + getShell().getBounds().width > getParentShell().getDisplay().getBounds().x + getParentShell().getDisplay().getBounds().width) {
+ location.x = getParentShell().getDisplay().getBounds().x + getParentShell().getDisplay().getBounds().width - getShell().getBounds().width;
+ }
+ if(location.y + getShell().getBounds().height > getParentShell().getDisplay().getBounds().y + getParentShell().getDisplay().getBounds().height) {
+ location.y = getParentShell().getDisplay().getBounds().y + getParentShell().getDisplay().getBounds().height - getShell().getBounds().height;
+ }
+ }
+ getShell().setLocation(location);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java
new file mode 100644
index 00000000000..4cb1f032355
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.cell;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+/**
+ * The abstract class for the cell manager
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public abstract class AbstractCellManager implements ICellManager {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager#setValue(org.eclipse.emf.edit.domain.EditingDomain, java.lang.Object,
+ * java.lang.Object, java.lang.Object)
+ *
+ * @param domain
+ * @param obj1
+ * @param obj2
+ * @param newValue
+ */
+ public void setValue(EditingDomain domain, Object obj1, Object obj2, Object newValue) {
+ final Command cmd = getSetValueCommand(domain, obj1, obj2, newValue);
+ assert cmd != null;
+ domain.getCommandStack().execute(cmd);
+ }
+
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java
new file mode 100644
index 00000000000..20120a5ffdf
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.cell;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.edit.domain.EditingDomain;
+
+//FIXME : should implements ICrossValueSolver?
+//FIXME : should implements ICellManager or returns getCellManger
+public class CellManagerFactory {
+
+ public static final String CLASS_MANAGER = "manager"; //$NON-NLS-1$
+
+ public static final String ORDER = "order"; //$NON-NLS-1$
+
+ public static final String SOLVER_ID = "id"; //$NON-NLS-1$
+
+ // private final Map<String, Class<IAxisManager>> map;
+
+ private final Collection<ICellManager> solvers;
+
+ private final Map<Integer, ICellManager> managersMap;
+
+ private static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.cellmanager"; //$NON-NLS-1$
+
+ public static final CellManagerFactory INSTANCE = new CellManagerFactory();
+
+ private CellManagerFactory() {
+ this.solvers = new ArrayList<ICellManager>();
+ this.managersMap = new TreeMap<Integer, ICellManager>();
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+
+ final String id = iConfigurationElement.getAttribute(SOLVER_ID);
+ final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER));
+ try {
+
+ //to avoid pb when the provided class in not this plugin!
+ final ICellManager solver = (ICellManager)iConfigurationElement.createExecutableExtension(CLASS_MANAGER);
+ this.managersMap.put(order, solver);
+ this.solvers.add(solver);
+ } catch (final CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Object getCrossValue(final Object obj1, final Object obj2) {
+ final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ if(cellManager != null) {
+ return cellManager.getValue(obj1, obj2);
+ }
+ //FIXME should return a specific error or a message?
+ return null;
+ }
+
+ /**
+ *
+ * @param obj1
+ * @param obj2
+ * @return
+ */
+ public ICellManager getCellManager(final Object obj1, final Object obj2) {
+ return getCrossValueSolver(obj1, obj2);
+ }
+
+ //FIXME : should me removed
+ private ICellManager getCrossValueSolver(final Object obj1, final Object obj2) {
+ for(final Integer integer : this.managersMap.keySet()) {
+ ICellManager current = this.managersMap.get(integer);
+ // for(final ICellManager current : this.solvers) {
+ if(current.handles(obj1, obj2)) {
+ return current;
+ }
+ // }
+ }
+ //FIXME should return a specific error or a message?
+ return null;
+ }
+
+ public boolean isCellEditable(final Object obj1, final Object obj2) {
+ final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ if(cellManager != null) {
+ return cellManager.isCellEditable(obj1, obj2);
+ }
+ return false;
+
+ }
+
+ public void setCellValue(final EditingDomain domain, final Object obj1, final Object obj2, final Object newValue) {
+ final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ if(cellManager != null) {
+ cellManager.setValue(domain, obj1, obj2, newValue);
+ }
+ }
+
+ // public ICellEditor getCellEditor (final Table table, final Object obj1, final Object obj2){
+ // final ICellManager cellManager = getCrossValueSolver(obj1, obj2);
+ // if(cellManager!=null){
+ // return cellManager.getCellEditor(table, obj1);
+ // }
+ // return null;
+ // }
+
+ // public void
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java
new file mode 100644
index 00000000000..d895767b980
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.cell;
+
+import java.util.Map;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.infra.emf.utils.EMFStringValueConverter;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ * The interface to implements for a cell manager
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public interface ICellManager {
+
+ /**
+ * The string displayed for Not_AVAILABLE
+ */
+ public static final String NOT_AVALAIBLE = Messages.ICellManager_NotAvailable;
+
+
+ public boolean handles(final Object obj1, final Object obj2);//FIXME : add the table as parameter
+
+ public boolean handlesAxisElement(final Object obj);
+
+ /**
+ *
+ * @param axisElement1
+ * one of the axis
+ * @param axisElement2
+ * the other axis
+ * @return
+ * the value of the cell or {@value #NOT_AVALAIBLE} if the cell is meaningless for the couple of parameters
+ *
+ * THIS METHOD MUST NOT BE USED IN REPLACEMENT OF A SPECIFIC LABEL PROVIDER
+ */
+ public Object getValue(final Object axisElement1, final Object axisElement2);
+
+ /**
+ * Set the newValue to the intersection of the 2 objects
+ *
+ * @param domain
+ * the editing domain
+ * @param obj1
+ * the first object
+ * @param obj2
+ * the second object
+ * @param newValue
+ * the new value
+ */
+ public void setValue(final EditingDomain domain, final Object obj1, final Object obj2, final Object newValue);
+
+
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param tableContext
+ * TODO
+ * @param obj1
+ * the first object
+ * @param obj2
+ * the second object
+ * @param newValue
+ * the newValue, represented by a String
+ * @param valueSolver
+ * the solver used to resolve values
+ */
+ //FIXME : remove EMF dependency for the solver!
+ //FIXME : remove tableContext
+ public ICommand getSetStringValueCommand(final EditingDomain domain, final Table table, EObject tableContext, final Object obj1, final Object obj2, final String newValue, final EMFStringValueConverter valueSolver);
+
+ /**
+ *
+ * @param obj1
+ * @param obj2
+ * @return
+ * <code>true</code> if the intersection of the 2 objects is editable
+ */
+ public boolean isCellEditable(final Object obj1, final Object obj2);
+
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @param obj1
+ * the first object
+ * @param obj2
+ * the second object
+ * @param newValue
+ * the new value to set to the intersection of these 2 objects
+ * @return
+ * the command to set the value
+ */
+ public Command getSetValueCommand(final EditingDomain domain, final Object obj1, final Object obj2, final Object newValue);
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
new file mode 100644
index 00000000000..7e825fc406d
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -0,0 +1,461 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.table;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.config.EditableRule;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.config.IConfiguration;
+import org.eclipse.nebula.widgets.nattable.coordinate.Range;
+import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
+import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
+import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
+import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.print.command.PrintCommand;
+import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand;
+import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand;
+import org.eclipse.nebula.widgets.nattable.print.config.DefaultPrintBindings;
+import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
+import org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent;
+import org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.configuration.CornerConfiguration;
+import org.eclipse.papyrus.infra.nattable.configuration.PapyrusHeaderMenuConfiguration;
+import org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider;
+import org.eclipse.papyrus.infra.nattable.dataprovider.BodyDataProvider;
+import org.eclipse.papyrus.infra.nattable.dataprovider.ColumnHeaderDataProvider;
+import org.eclipse.papyrus.infra.nattable.dataprovider.RowHeaderDataProvider;
+import org.eclipse.papyrus.infra.nattable.formatter.PapyrusExportFormatter;
+import org.eclipse.papyrus.infra.nattable.layer.PapyrusGridLayer;
+import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
+import org.eclipse.papyrus.infra.nattable.layerstack.ColumnHeaderLayerStack;
+import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack;
+import org.eclipse.papyrus.infra.nattable.listener.NatTableDropListener;
+import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.provider.TableSelectionProvider;
+import org.eclipse.papyrus.infra.nattable.utils.LocationValue;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.nattable.utils.TableGridRegion;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+/**
+ *
+ * This class allows to create, configure and manipulate the NatTable Widget
+ *
+ */
+public abstract class AbstractNattableWidgetManager implements INattableModelManager {
+
+ /**
+ * the managed table
+ */
+ private Table table;
+
+ /**
+ * we need to keep it, to be able to remove the listener on it, when the table is destroying
+ */
+ private EObject tableContext;
+
+ /**
+ * the nattable widget
+ */
+ protected NatTable natTable;
+
+ /**
+ * the grid layer
+ */
+ private GridLayer gridLayer;
+
+ /**
+ * the columnHeaderLayerStack
+ */
+ private ColumnHeaderLayerStack columnHeaderLayerStack;
+
+ /**
+ * the rowHeaderLayerStack
+ */
+ private RowHeaderLayerStack rowHeaderLayerStack;
+
+ /**
+ * the selection provider
+ */
+ private TableSelectionProvider selectionProvider;
+
+ /**
+ * the body layer stack
+ */
+ private BodyLayerStack bodyLayerStack;
+
+ private AbstractDataProvider columnHeaderDataProvider;
+
+ private AbstractDataProvider rowHeaderDataProvider;
+
+ private BodyDataProvider bodyDataProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the model of the table
+ */
+ public AbstractNattableWidgetManager(final Table table) {
+ this.table = table;
+ this.tableContext = table.getContext();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#createNattable(org.eclipse.swt.widgets.Composite, int,
+ * org.eclipse.ui.IWorkbenchPartSite)
+ *
+ * @param parent
+ * @param style
+ * @param site
+ * @return
+ */
+ public NatTable createNattable(final Composite parent, final int style, final IWorkbenchPartSite site) {
+ this.bodyDataProvider = new BodyDataProvider(this);
+ this.bodyLayerStack = new BodyLayerStack(this.bodyDataProvider, this);
+
+ this.columnHeaderDataProvider = new ColumnHeaderDataProvider(this);
+ this.columnHeaderLayerStack = new ColumnHeaderLayerStack(this.columnHeaderDataProvider, this.bodyLayerStack, this.bodyDataProvider);
+
+ this.rowHeaderDataProvider = new RowHeaderDataProvider(this);
+
+
+ this.rowHeaderLayerStack = new RowHeaderLayerStack(this.rowHeaderDataProvider, this.bodyLayerStack);
+
+
+ final IDataProvider cornerDataProvider = new DefaultCornerDataProvider(this.columnHeaderDataProvider, this.rowHeaderDataProvider);
+ final CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), this.rowHeaderLayerStack, this.columnHeaderLayerStack);
+ cornerLayer.addConfiguration(new CornerConfiguration(this));
+ this.gridLayer = new PapyrusGridLayer(this.bodyLayerStack, this.columnHeaderLayerStack, this.rowHeaderLayerStack, cornerLayer);
+ this.gridLayer.addConfiguration(new DefaultPrintBindings());
+ // gridLayer.addConfiguration(new StyleConfiguration());
+ // fBodyLayer.getBodyDataLayer().addConfiguration(new StyleConfiguration());
+ // fBodyLayer.addConfiguration(new StyleConfiguration());
+
+
+
+
+ this.natTable = new NatTable(parent, this.gridLayer, false);
+
+
+ //for the edition
+ // configureEdition(this.natTable, this.bodyLayerStack);
+ this.natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
+ // this.natTable.addConfiguration(new HeaderMenuConfiguration(this.natTable));
+ this.natTable.addConfiguration(new IConfiguration() {
+
+
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, new EditableRule() {
+
+ @Override
+ public boolean isEditable(int columnIndex, int rowIndex) {
+
+ final Object obj1 = AbstractNattableWidgetManager.this.rowHeaderDataProvider.getDataValue(1, rowIndex);
+ final Object obj2 = AbstractNattableWidgetManager.this.columnHeaderDataProvider.getDataValue(columnIndex, 1);
+ return CellManagerFactory.INSTANCE.isCellEditable(obj1, obj2);
+ }
+ });
+
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, null, DisplayMode.EDIT, ""); //$NON-NLS-1$
+
+ }
+
+
+ public void configureLayer(ILayer layer) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+
+ configureNatTable();
+ addColumnReorderListener(this.bodyLayerStack.getColumnReorderLayer());
+ addDragAndDropSupport(this.natTable);
+
+
+ if(site != null) {
+ final MenuManager menuMgr = createMenuManager(this.natTable);
+ final Menu menu = menuMgr.createContextMenu(this.natTable);
+ this.natTable.setMenu(menu);
+
+ this.selectionProvider = new TableSelectionProvider(this.bodyLayerStack.getSelectionLayer());
+ site.registerContextMenu(menuMgr, this.selectionProvider);
+ site.setSelectionProvider(this.selectionProvider);
+ }
+
+ return this.natTable;
+ }
+
+ protected void configureNatTable() {
+ if(this.natTable != null && !this.natTable.isDisposed()) {
+ this.natTable.setConfigRegistry(createAndInitializeNewConfigRegistry());
+ this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable));
+ this.natTable.configure();
+ }
+ }
+
+ protected IConfigRegistry createAndInitializeNewConfigRegistry() {
+ final IConfigRegistry newRegistry = new ConfigRegistry();
+ if(!this.natTable.isDisposed()) {
+ newRegistry.registerConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, this, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ newRegistry.registerConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, getLabelProviderService(), DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ //commented because seems generate several bugs with edition
+ //newRegistry.registerConfigAttribute( CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter(), DisplayMode.NORMAL, GridRegion.BODY);
+ newRegistry.registerConfigAttribute(CellConfigAttributes.EXPORT_FORMATTER, new PapyrusExportFormatter());
+ }
+ return newRegistry;
+ }
+
+ private LabelProviderService getLabelProviderService() {
+ try {
+ ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(this.table.getContext());//get context and NOT get table for the usecase where the table is not in a resource
+ return serviceRegistry.getService(LabelProviderService.class);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param natTable
+ * @return
+ */
+ public MenuManager createMenuManager(final NatTable natTable) {
+ final MenuManager menuManager = new MenuManager("#PopUp", "org.eclipse.papyrus.infra.nattable.widget.menu") { //$NON-NLS-1$ //$NON-NLS-2$
+
+ @Override
+ public void add(final IAction action) {
+ super.add(action);
+ }
+
+ @Override
+ public void add(final IContributionItem item) {
+ super.add(item);
+ }
+ };
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+
+ menuManager.setRemoveAllWhenShown(true);
+ return menuManager;
+ }
+
+ /**
+ * Enable the table to receive dropped elements
+ *
+ * @param nattable
+ * the nattable widget in which we add the drag&drop support
+ */
+ protected void addDragAndDropSupport(final NatTable nattable) {
+ final int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
+ final DropTarget target = new DropTarget(nattable, operations);
+ final LocalTransfer localTransfer = LocalTransfer.getInstance();
+ final Transfer[] types = new Transfer[]{ localTransfer };
+ target.setTransfer(types);
+ final NatTableDropListener dropListener = new NatTableDropListener(this);
+ target.addDropListener(dropListener);
+ }
+
+ /**
+ * Add a listener on the column reorder layer in order to update the model
+ *
+ * @param columnReorderLayer
+ * the column reorder layer
+ */
+ private void addColumnReorderListener(final ColumnReorderLayer columnReorderLayer) {
+ columnReorderLayer.addLayerListener(new ILayerListener() {
+
+
+ public void handleLayerEvent(final ILayerEvent event) {
+ if(event instanceof ColumnReorderEvent) {
+ ColumnReorderEvent columnReorderEvent = (ColumnReorderEvent)event;
+ int start = -1;
+ int end = columnReorderEvent.getBeforeToColumnPosition();
+ for(Range range : columnReorderEvent.getBeforeFromColumnPositionRanges()) {
+ start = range.start;
+ break;
+ }
+ if(start != -1) {
+ // This solve an index difference between moving
+ // a column from right to left and moving a
+ // column from left to right
+ if(start >= 0 && start < end) {
+ end--;
+ }
+ final List<IAxis> allAxis = AbstractNattableWidgetManager.this.table.getCurrentColumnAxisProvider().getAxis();
+ final IAxis axisToMove = allAxis.get(start);
+ if(axisToMove != null) {
+ moveColumnElement(axisToMove, end);
+ }
+ }
+ }
+ }
+ });
+ }
+
+
+
+ /**
+ *
+ * @param event
+ * an event
+ * @return
+ * a LocationValue for the point, which contains informations about this location (TableGridRegion, row and column index, row and column
+ * elements, the cell, the point and its translation).
+ * Some of these values can be <code>null</code> or not depending of the region of the table
+ */
+ public LocationValue getLocationInTheTable(final Point absolutePoint) {
+ final Point widgetPoint = this.natTable.toControl(absolutePoint.x, absolutePoint.y);
+ TableGridRegion kind = TableGridRegion.UNKNOWN;
+ int columnPosition = this.natTable.getColumnPositionByX(widgetPoint.x);
+ int columnIndex = this.natTable.getColumnIndexByPosition(columnPosition);
+ int rowPosition = this.natTable.getRowPositionByY(widgetPoint.y);
+ int rowIndex = this.natTable.getRowIndexByPosition(rowPosition);
+ final ILayerCell cell = this.natTable.getCellByPosition(columnPosition, rowPosition);
+ Object columnObject = null;
+ Object rowObject = null;
+ if(rowIndex == -1 && columnIndex == -1) {
+ kind = TableGridRegion.UNKNOWN;
+ } else if(rowIndex == -1) {
+ kind = TableGridRegion.AFTER_ROW_HEADER;
+ } else if(columnIndex == -1) {
+ kind = TableGridRegion.AFTER_COLUMN_HEADER;
+ } else {
+ if(cell != null) {
+ LabelStack label = cell.getConfigLabels();
+ if(label.hasLabel(GridRegion.ROW_HEADER)) {
+ kind = TableGridRegion.ROW_HEADER;
+
+ } else if(label.hasLabel(GridRegion.COLUMN_HEADER)) {
+ kind = TableGridRegion.COLUMN_HEADER;
+
+ } else if(label.hasLabel(GridRegion.CORNER)) {
+ kind = TableGridRegion.CORNER;
+ } else if(label.hasLabel(GridRegion.BODY)) {
+ kind = TableGridRegion.CELL;
+ columnObject = getColumnElement(columnIndex);
+ rowObject = getRowElement(rowIndex);
+ }
+ }
+ }
+ return new LocationValue(absolutePoint, widgetPoint, kind, cell, columnIndex, rowIndex, columnObject, rowObject);
+ }
+
+
+ public GridLayer getGridLayer() {
+ return this.gridLayer;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#print()
+ *
+ */
+ public void print() {
+ this.natTable.doCommand(new TurnViewportOffCommand());
+ this.natTable.doCommand(new PrintCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
+ this.natTable.doCommand(new TurnViewportOnCommand());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#selectAll()
+ *
+ */
+ public void selectAll() {
+ this.natTable.doCommand(new SelectAllCommand());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#exportToXLS()
+ *
+ */
+ public void exportToXLS() {
+ this.natTable.doCommand(new ExportCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
+ }
+
+ public void copyToClipboard() {
+ this.natTable.doCommand(new CopyDataToClipboardCommand("\t", "\n", this.natTable.getConfigRegistry()));
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getBodyLayerStack()
+ *
+ * @return
+ */
+ public BodyLayerStack getBodyLayerStack() {
+ return this.bodyLayerStack;
+ }
+
+ public void dispose() {
+ this.bodyDataProvider.dispose();
+ this.rowHeaderDataProvider.dispose();
+ this.columnHeaderDataProvider.dispose();
+ this.tableContext = null;
+ }
+
+ public EObject getTableContext() {
+ return this.tableContext;
+ }
+
+ public Table getTable() {
+ return this.table;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ILimitedNattableModelManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ILimitedNattableModelManager.java
new file mode 100644
index 00000000000..49dd414f783
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ILimitedNattableModelManager.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.table;
+
+import java.util.List;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+
+
+public interface ILimitedNattableModelManager {
+
+ public List<Object> getElementsList(final AbstractAxisProvider axisProvider);
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
new file mode 100644
index 00000000000..1430f17e68b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
@@ -0,0 +1,184 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.table;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.utils.LocationValue;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.services.IDisposable;
+
+
+public interface INattableModelManager extends ILimitedNattableModelManager, ITableAxisElementProvider, IDisposable, IDataProvider {
+
+
+ public int getColumnCount();
+
+ public int getRowCount();
+
+ public void addRows(final Collection<Object> objectsToAdd);
+
+ public void addColumns(final Collection<Object> objectsToAdd);
+
+ public boolean canInsertRow(final Collection<Object> objectsToAdd, int index);
+
+ public boolean canInsertColumns(final Collection<Object> objectsToAdd, int index);
+
+ public boolean canDropColumnsElement(final Collection<Object> objectsToAdd);
+
+ public boolean canDropRowElement(final Collection<Object> objectsToAdd);
+
+ public void insertRows(final Collection<Object> objectsToAdd, int index);
+
+ public void insertColumns(final Collection<Object> objectsToAdd, int index);
+
+ public IDataProvider getBodyDataProvider();
+
+ public boolean canMoveColumns();
+
+ public boolean canMoveRows();
+
+ public void moveColumnElement(final Object axisToMove, final int newIndex);
+
+ public void moveRowElement(final Object axisToMove, final int newIndex);
+
+ public void invertAxis();
+
+ public boolean canInvertAxis();
+
+ public boolean declareEditorsOnColumns();
+
+ public boolean declareEditorsOnRows();
+
+ public Table getTable();
+
+ public ITableAxisElementProvider getTableAxisElementProvider();
+
+ public NatTable createNattable(final Composite parent, int style, IWorkbenchPartSite site);
+
+ public LocationValue getLocationInTheTable(final Point location);
+
+ public List<Object> getElementsList(final AbstractAxisProvider axisProvider);
+
+ public boolean canCreateRowElement(String elementType);
+
+ public boolean canCreateColumnElement(String elementType);
+
+ public Command getAddRowElementCommand(Collection<Object> objectsToAdd);
+
+ public Command getAddColumnElementCommand(Collection<Object> objectsToAdd);
+
+ public void setTableName(String name);
+
+ public String getTableName();
+
+
+ public void print();
+
+ public void selectAll();
+
+ public void exportToXLS();
+
+ /**
+ * Opens a dialog to choose the columns to display or to destroy. This action doesn't create or destroy model element. It can only create/destroy
+ * axis
+ */
+ public void openCreateDestroyColumnsManagerDialog();
+
+ /**
+ * Opens a dialog to choose the columns to display or to destroy. This action doesn't create or destroy model element. It can only create/destroy
+ * axis
+ */
+ public void openCreateDestroyRowsManagerDialog();
+
+ /**
+ * Returns <code>true</code> if columns axis can be destroyed (only are will be destroyed, the model element won't be destroyed)
+ *
+ * @return
+ */
+ public boolean canCreateDestroyColumnsAxis();
+
+ /**
+ * Returns <code>true</code> if columns axis can be destroyed (only are will be destroyed, the model element won't be destroyed)
+ *
+ * @return
+ */
+ public boolean canCreateDestroyRowsAxis();
+
+ public void sortColumnsByName(final boolean alphabeticOrder);
+
+ public void sortRowsByName(final boolean alphabeticOrder);
+
+
+ /**
+ *
+ * @return
+ * the "real"{@link AbstractAxisProvider}, that's to say that this method use the property {@link Table#isInvertAxis()} to return the real
+ * vertical axis
+ */
+ public AbstractAxisProvider getVerticalAxisProvider();
+
+ /**
+ *
+ * @return
+ * the "real"{@link AbstractAxisProvider}, that's to say that this method use the property {@link Table#isInvertAxis()} to return the real
+ * horizontal axis
+ */
+ public AbstractAxisProvider getHorizontalAxisProvider();
+
+ public BodyLayerStack getBodyLayerStack();
+
+ /**
+ * Opens a dialog to edit the alias of the row
+ *
+ * @param event
+ */
+ public void openEditRowAliasDialog(final NatEventData event);
+
+ /**
+ * Opens a dialog to edit the alias of the column
+ *
+ * @param event
+ */
+ public void openEditColumnAliasDialog(final NatEventData event);
+
+ public boolean canEditColumnHeader(final NatEventData eventData);
+
+ public boolean canEditRowHeader(final NatEventData eventData);
+
+ /**
+ *
+ * @return
+ * the column axis manager, managing the axis inversion
+ */
+ public IAxisManager getColumnAxisManager();
+
+ /**
+ *
+ * @return
+ * the row axis manager, managing the axis inversion
+ */
+ public IAxisManager getRowAxisManager();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ITableAxisElementProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ITableAxisElementProvider.java
new file mode 100644
index 00000000000..fca9006646b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/ITableAxisElementProvider.java
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.table;
+
+import java.util.List;
+
+
+public interface ITableAxisElementProvider {
+
+ public List<Object> getColumnElementsList();
+
+ public List<Object> getRowElementsList();
+
+ public Object getColumnElement(int index);
+
+ public Object getRowElement(int index);
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
new file mode 100644
index 00000000000..45132d44a62
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -0,0 +1,1036 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.manager.table;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.List;
+
+import org.eclipse.core.commands.State;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.command.CommandIds;
+import org.eclipse.papyrus.infra.nattable.dialog.DisplayedAxisSelectorDialog;
+import org.eclipse.papyrus.infra.nattable.manager.axis.AxisManagerFactory;
+import org.eclipse.papyrus.infra.nattable.manager.axis.CompositeAxisManager;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+import org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager;
+import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.IMasterAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.ISlaveAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.CellEditorDeclaration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.FeatureLabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ObjectLabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainuUtils;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.nattable.utils.StringComparator;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.widgets.providers.FlattenableRestrictedFilteredContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+
+public class NattableModelManager extends AbstractNattableWidgetManager implements INattableModelManager {
+
+ /**
+ * the column manager
+ */
+ private ICompositeAxisManager columnManager;
+
+ /**
+ * the line manager
+ */
+ private ICompositeAxisManager rowManager;
+
+ /**
+ * the model of the table on which we are working
+ */
+ private List<Object> verticalElements;
+
+ private List<Object> horizontalElements;
+
+ private Adapter invertAxisListener;
+
+ private AbstractAxisProvider rowProvider;
+
+ private AbstractAxisProvider columnProvider;
+
+ /**
+ * this listener listen the stack events and refresh nattable
+ */
+ private CommandStackListener refreshListener;
+
+ /**
+ * the focus listener
+ */
+ private FocusListener focusListener;
+
+ /**
+ * we need to keep it to be able to remove listener (required when we destroy the context of the table)
+ */
+ private TransactionalEditingDomain contextEditingDomain;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param rawModel
+ *
+ * the model of the managed table
+ */
+ public NattableModelManager(final Table rawModel) {
+ super(rawModel);
+ this.rowProvider = rawModel.getCurrentRowAxisProvider();
+ this.columnProvider = rawModel.getCurrentColumnAxisProvider();
+ this.verticalElements = Collections.synchronizedList(new ArrayList<Object>());
+ this.horizontalElements = Collections.synchronizedList(new ArrayList<Object>());
+
+
+ this.invertAxisListener = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ if(msg.getEventType() == Notification.SET) {
+ final Object oldValue = msg.getOldValue();
+ final Object newValue = msg.getNewValue();
+ if(oldValue != null && newValue != null) {
+ if(msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) {
+ invertJavaObject();
+
+ }
+ }
+ }
+ }
+ };
+
+ rawModel.eAdapters().add(this.invertAxisListener);
+ init();
+ if(rawModel.isInvertAxis()) {
+ invertJavaObject();
+ }
+ }
+
+
+ @Override
+ public NatTable createNattable(Composite parent, int style, IWorkbenchPartSite site) {
+ final NatTable nattable = super.createNattable(parent, style, site);
+ this.refreshListener = new CommandStackListener() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.command.CommandStackListener#commandStackChanged(java.util.EventObject)
+ *
+ * @param event
+ */
+ public void commandStackChanged(EventObject event) {
+ //we refresh the table after each command, only when it is visible
+ //its allows to refresh the text and the appearance of the table
+ //this refresh doesn't manage the add/remove axis
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ if(nattable != null && !nattable.isDisposed() && nattable.isVisible()) {
+ nattable.refresh();
+ }
+ }
+ });
+
+ }
+ };
+
+ getContextEditingDomain().getCommandStack().addCommandStackListener(this.refreshListener);
+
+ this.focusListener = new FocusListener() {
+
+ public void focusLost(FocusEvent e) {
+ //nothing to do
+ }
+
+ public void focusGained(FocusEvent e) {
+ updateToggleActionState();
+ }
+ };
+ nattable.addFocusListener(this.focusListener);
+ updateToggleActionState();//required, because the focus listener is not notified just after the creation of the widget
+ return nattable;
+ }
+
+ /**
+ * this command update the status of the toggle actions
+ */
+ protected void updateToggleActionState() {
+ final ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class);
+ if(commandService != null) {
+
+ final AbstractHeaderAxisConfiguration columnAxisConfiguration = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisUsedInTable(getTable());
+ final AbstractHeaderAxisConfiguration rowAxisConfiguration = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisUsedInTable(getTable());
+ //update the header configuration
+ org.eclipse.core.commands.Command command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_INDEX_ID);
+ updateToggleCommandState(command, columnAxisConfiguration.isDisplayIndex());
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_LABEL_ID);
+ updateToggleCommandState(command, columnAxisConfiguration.isDisplayLabel());
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISPLAY_INDEX_STYLE_ID);
+ updateRadioCommandState(command, columnAxisConfiguration.getIndexStyle().getLiteral());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_INDEX_ID);
+ updateToggleCommandState(command, rowAxisConfiguration.isDisplayIndex());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_LABEL_ID);
+ updateToggleCommandState(command, rowAxisConfiguration.isDisplayLabel());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_DISPLAY_INDEX_STYLE_ID);
+ updateRadioCommandState(command, rowAxisConfiguration.getIndexStyle().getLiteral());
+
+
+ //update the label header configuration
+ final List<ILabelProviderConfiguration> columnLabelConfigurations = columnAxisConfiguration.getOwnedLabelConfigurations();
+ final List<ILabelProviderConfiguration> rowLabelConfigurations = rowAxisConfiguration.getOwnedLabelConfigurations();
+ for(final ILabelProviderConfiguration current : columnLabelConfigurations) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ final ObjectLabelProviderConfiguration labelConfig = (ObjectLabelProviderConfiguration)current;
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_DISPLAY_ICON);
+ updateToggleCommandState(command, labelConfig.isDisplayIcon());
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_DISPLAY_LABEL);
+ updateToggleCommandState(command, labelConfig.isDisplayLabel());
+
+ if(labelConfig instanceof FeatureLabelProviderConfiguration) {
+ final FeatureLabelProviderConfiguration labelFeatureConf = (FeatureLabelProviderConfiguration)labelConfig;
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_IS_DERIVED);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayIsDerived());
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_MULTIPLICITY);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayMultiplicity());
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_TYPE);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayType());
+
+
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_LABEL_FEATURE_DISPLAY_NAME);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayName());
+ }
+ }
+ }
+
+ for(final ILabelProviderConfiguration current : rowLabelConfigurations) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ final ObjectLabelProviderConfiguration labelConfig = (ObjectLabelProviderConfiguration)current;
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_DISPLAY_ICON);
+ updateToggleCommandState(command, labelConfig.isDisplayIcon());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_DISPLAY_LABEL);
+ updateToggleCommandState(command, labelConfig.isDisplayLabel());
+
+ if(labelConfig instanceof FeatureLabelProviderConfiguration) {
+ final FeatureLabelProviderConfiguration labelFeatureConf = (FeatureLabelProviderConfiguration)labelConfig;
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_IS_DERIVED);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayIsDerived());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_MULTIPLICITY);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayMultiplicity());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_TYPE);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayType());
+
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_LABEL_FEATURE_DISPLAY_NAME);
+ updateToggleCommandState(command, labelFeatureConf.isDisplayName());
+ }
+ }
+ }
+
+ //update the property IMasterObjectAxisProvider#disconnectslave
+ if(columnProvider instanceof ISlaveAxisProvider) {
+ command = commandService.getCommand(CommandIds.COMMAND_ROW_DISCONNECT_SLAVE);
+ updateToggleCommandState(command, ((IMasterAxisProvider)rowProvider).isDisconnectSlave());
+ }
+
+ if(rowProvider instanceof ISlaveAxisProvider) {
+ command = commandService.getCommand(CommandIds.COMMAND_COLUMN_DISCONNECT_SLAVE);
+ updateToggleCommandState(command, ((IMasterAxisProvider)columnProvider).isDisconnectSlave());
+ }
+
+ //we update the state for the invert axis command
+ command = commandService.getCommand(CommandIds.COMMAND_INVERT_AXIS);
+ updateToggleCommandState(command, getTable().isInvertAxis());
+
+ } else {
+ throw new RuntimeException(String.format("The Eclipse service {0} has not been found", ICommandService.class)); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ *
+ * @param command
+ * an eclipse command
+ * @param newValue
+ * the new boolean value to set to the state of this command
+ */
+ private void updateToggleCommandState(final org.eclipse.core.commands.Command command, final boolean newValue) {
+ if(command != null) {
+ final State state = command.getState(CommandIds.TOGGLE_STATE);
+ if(state != null) {
+ state.setValue(newValue);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param command
+ * an eclispe command
+ * @param newValue
+ * the new value to set to the state of this command
+ */
+ private void updateRadioCommandState(final org.eclipse.core.commands.Command command, final Object newValue) {
+ if(command != null) {
+ final State state = command.getState(CommandIds.RADIO_STATE);
+ if(state != null) {
+ state.setValue(newValue);
+ }
+ }
+ }
+
+ public void invertJavaObject() {
+ AbstractAxisProvider newColumProvider = this.rowProvider;
+ AbstractAxisProvider newRowProvider = this.columnProvider;
+ List<Object> newVerticalElementList = this.horizontalElements;
+ List<Object> newHorizontalElementList = this.verticalElements;
+ ICompositeAxisManager newRowManager = this.columnManager;
+ ICompositeAxisManager newColumnManager = this.rowManager;
+
+ NattableModelManager.this.columnProvider = newColumProvider;
+ NattableModelManager.this.rowProvider = newRowProvider;
+
+ NattableModelManager.this.verticalElements = newVerticalElementList;
+ NattableModelManager.this.horizontalElements = newHorizontalElementList;
+
+ NattableModelManager.this.rowManager = newRowManager;
+ NattableModelManager.this.columnManager = newColumnManager;
+ updateToggleActionState();
+ configureNatTable();
+ refreshNatTable();
+ }
+
+ /**
+ * create the line and the columns managers
+ */
+ protected void init() {
+ this.columnManager = createAxisManager(getTable().getTableConfiguration().getColumnHeaderAxisConfiguration().getAxisManagers(), getTable().getCurrentColumnAxisProvider());
+ this.rowManager = createAxisManager(getTable().getTableConfiguration().getRowHeaderAxisConfiguration().getAxisManagers(), getTable().getCurrentRowAxisProvider());
+ boolean allIsSlave = this.columnManager.isSlave() && this.rowManager.isSlave();
+ Assert.isTrue(!allIsSlave, Messages.NattableModelManager_AtLeastOfOneTheAxisManagerMustBeAMaster);
+ }
+
+ /**
+ *
+ * @param ids
+ * the ids of the axis manager to use
+ * @param contentProvider
+ * the content provider in the model
+ * @return the created axis manager to use to manage the {@link IAxisContentsProvider}
+ */
+ protected ICompositeAxisManager createAxisManager(final List<AxisManagerRepresentation> representations, final AbstractAxisProvider contentProvider) {
+ final List<IAxisManager> managers = new ArrayList<IAxisManager>();
+ for(AxisManagerRepresentation current : representations) {
+ final IAxisManager manager = AxisManagerFactory.INSTANCE.getAxisManager(current);
+ assert manager != null;
+ manager.init(this, current, contentProvider);
+ managers.add(manager);
+ }
+ final ICompositeAxisManager compositeAxisManager = new CompositeAxisManager();
+ compositeAxisManager.init(this, null, contentProvider);
+ compositeAxisManager.setSubAxisManager(managers);
+ return compositeAxisManager;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.ui.services.IDisposable#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ this.columnManager.dispose();
+ this.rowManager.dispose();
+ getContextEditingDomain().getCommandStack().removeCommandStackListener(this.refreshListener);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#addRows(java.util.Collection)
+ *
+ * @param objectsToAdd
+ * the list of the objects to add in rows
+ */
+ public void addRows(final Collection<Object> objectsToAdd) {
+ final EditingDomain domain = getContextEditingDomain();
+ final Command cmd = getAddRowElementCommand(objectsToAdd);
+ if(cmd != null && cmd.canExecute()) {
+ domain.getCommandStack().execute(cmd);
+ }
+ }
+
+ /**
+ * called when the manager is used vertically
+ */
+ public int getColumnCount() {
+ return this.getColumnElementsList().size();
+ }
+
+ /**
+ * called when the manager is used horizontally
+ */
+
+ public int getRowCount() {
+ return this.getRowElementsList().size();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#addColumns(java.util.Collection)
+ *
+ * @param objectsToAdd
+ * the list of the objects to add in columns
+ */
+ public void addColumns(final Collection<Object> objectsToAdd) {
+ final EditingDomain domain = getContextEditingDomain();
+ final Command cmd = getAddColumnElementCommand(objectsToAdd);
+ if(cmd != null && cmd.canExecute()) {
+ domain.getCommandStack().execute(cmd);
+ }
+ }
+
+ /**
+ * Returns the EditingDomain associated to the table
+ *
+ * @return
+ */
+ private EditingDomain getTableEditingDomain() {
+ return TableEditingDomainuUtils.getTableContextEditingDomain(getTable());
+ }
+
+ /**
+ * Returns the EditingDomain associated to the context
+ *
+ * @return
+ */
+ private EditingDomain getContextEditingDomain() {
+ return TableEditingDomainuUtils.getTableContextEditingDomain(getTable());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getBodyDataProvider()
+ *
+ * @return the data provider for the body of the table
+ */
+ public IDataProvider getBodyDataProvider() {
+ return this;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.IDataProvider#getDataValue(int, int)
+ *
+ * @param columnIndex
+ * the index of the column
+ * @param rowIndex
+ * the index of the row
+ * @return the contents to display in the cell localted to columnIndex and
+ * rowIndex
+ */
+ public Object getDataValue(final int columnIndex, final int rowIndex) {
+ final Object obj1 = this.verticalElements.get(columnIndex);
+ final Object obj2 = this.horizontalElements.get(rowIndex);
+ return CellManagerFactory.INSTANCE.getCrossValue(obj1, obj2);
+ }
+
+ public void setDataValue(final int columnIndex, final int rowIndex, final Object newValue) {
+ final Object obj1 = this.verticalElements.get(columnIndex);
+ final Object obj2 = this.horizontalElements.get(rowIndex);
+ CellManagerFactory.INSTANCE.setCellValue(getContextEditingDomain(), obj1, obj2, newValue);
+ }
+
+ /**
+ * refresh NatTable (asyncExec)
+ */
+ public void refreshNatTable() {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ NattableModelManager.this.natTable.refresh();
+ }
+ });
+ }
+
+
+ /**
+ *
+ * @param axis
+ * the axis for which must refresh the contents
+ */
+ public void updateAxisContents(final AbstractAxisProvider axis) {
+ Display.getDefault().asyncExec(new Runnable() {//required, because we get the event before the changes
+
+ public void run() {
+ if(NattableModelManager.this.natTable != null && !NattableModelManager.this.natTable.isDisposed()) {
+ if(axis == NattableModelManager.this.columnProvider) {
+ updateColumnContents();
+ } else {
+ updateRowContents();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * refresh the row contents
+ */
+ private void updateRowContents() {
+ NattableModelManager.this.rowManager.updateAxisContents();
+ CellEditorDeclaration declaration = getCellEditorDeclarationToUse(getTable());
+ if(declaration.equals(CellEditorDeclaration.ROW)) {
+ configureNatTable();
+ refreshNatTable();
+ } else {
+ refreshNatTable();
+ }
+ }
+
+
+
+ /**
+ * refresh the column contents
+ */
+ private void updateColumnContents() {
+ NattableModelManager.this.columnManager.updateAxisContents();
+ CellEditorDeclaration declaration = getCellEditorDeclarationToUse(getTable());
+ if(declaration.equals(CellEditorDeclaration.COLUMN)) {
+ configureNatTable();
+ refreshNatTable();
+ } else {
+ refreshNatTable();
+ }
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the celleditor declaration to use according to the table configuration and {@link Table#isInvertAxis()}
+ */
+ private CellEditorDeclaration getCellEditorDeclarationToUse(final Table table) {
+ CellEditorDeclaration declaration = table.getTableConfiguration().getCellEditorDeclaration();
+ if(getTable().isInvertAxis()) {
+ if(declaration.equals(CellEditorDeclaration.COLUMN)) {
+ declaration = CellEditorDeclaration.ROW;
+ } else if(declaration.equals(CellEditorDeclaration.ROW)) {
+ declaration = CellEditorDeclaration.COLUMN;
+ }
+ }
+ return declaration;
+ }
+
+ public List<Object> getColumnElementsList() {
+ return this.verticalElements;
+ }
+
+ public List<Object> getRowElementsList() {
+ return this.horizontalElements;
+ }
+
+ public boolean canInsertRow(Collection<Object> objectsToAdd, int index) {
+ return this.rowManager.canInsertAxis(objectsToAdd, index);
+ }
+
+ public boolean canInsertColumns(Collection<Object> objectsToAdd, int index) {
+ return this.columnManager.canInsertAxis(objectsToAdd, index);
+ }
+
+ public boolean canDropColumnsElement(Collection<Object> objectsToAdd) {
+ return this.columnManager.canDropAxisElement(objectsToAdd);
+ }
+
+ public boolean canDropRowElement(Collection<Object> objectsToAdd) {
+ return this.rowManager.canDropAxisElement(objectsToAdd);
+ }
+
+ public void insertRows(Collection<Object> objectsToAdd, int index) {
+ this.rowManager.getInsertAxisCommand(objectsToAdd, index);
+
+ }
+
+ public void insertColumns(Collection<Object> objectsToAdd, int index) {
+ this.columnManager.getInsertAxisCommand(objectsToAdd, index);
+ }
+
+ public Object getColumnElement(int index) {
+ return this.verticalElements.get(index);
+ }
+
+ public Object getRowElement(int index) {
+ return this.horizontalElements.get(index);
+ }
+
+ public List<Object> getElementsList(AbstractAxisProvider axisProvider) {
+ if(axisProvider == this.columnProvider) {
+ return this.verticalElements;
+ } else if(axisProvider == this.rowProvider) {
+ return this.horizontalElements;
+ }
+ return null;
+ }
+
+ public boolean canMoveRows() {
+ return this.rowManager.canMoveAxis();
+ }
+
+ public boolean canMoveColumns() {
+ return this.columnManager.canMoveAxis();
+ }
+
+ public void moveColumnElement(final Object axisToMove, final int newIndex) {
+ this.columnManager.moveAxis(axisToMove, newIndex);
+ }
+
+ // not tested
+ public void moveRowElement(final Object axisToMove, final int newIndex) {
+ this.rowManager.moveAxis(axisToMove, newIndex);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#invertAxis()
+ *
+ */
+ public void invertAxis() {
+ final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_SwitchLinesAndColumns);
+ final EditingDomain domain = getContextEditingDomain();
+ boolean oldValue = getTable().isInvertAxis();
+ if(canInvertAxis()) {
+ Command tmp = new SetCommand(domain, getTable(), NattablePackage.eINSTANCE.getTable_InvertAxis(), !oldValue);
+ cmd.append(tmp);
+ domain.getCommandStack().execute(cmd);
+ }
+ }
+
+ public boolean canInvertAxis() {
+ return this.columnManager.canBeUsedAsRowManager() && this.rowManager.canBeUsedAsColumnManager();
+ }
+
+ public boolean canCreateRowElement(String elementType) {
+ return this.rowManager.canCreateAxisElement(elementType);
+ }
+
+ public boolean canCreateColumnElement(String elementType) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public Command getAddRowElementCommand(Collection<Object> objectsToAdd) {
+ final EditingDomain domain = getContextEditingDomain();
+ final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddRowCommand);
+ Command tmp = this.rowManager.getAddAxisCommand(domain, objectsToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ final AbstractAxisProvider rowsProvider = AxisUtils.getAxisProviderUsedForRows(this);
+ final AbstractAxisProvider columnsProvider = AxisUtils.getAxisProviderUsedForColumns(this);
+ boolean addComplementaryAxis = rowsProvider instanceof IMasterAxisProvider && columnsProvider instanceof ISlaveAxisProvider && !((IMasterAxisProvider)rowsProvider).isDisconnectSlave();
+ if(addComplementaryAxis) {
+ tmp = this.columnManager.getComplementaryAddAxisCommand(domain, objectsToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ }
+ return cmd;
+ }
+
+ public Command getAddColumnElementCommand(Collection<Object> objectsToAdd) {
+ final EditingDomain domain = getContextEditingDomain();
+ final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddColumnCommand);
+ Command tmp = this.columnManager.getAddAxisCommand(domain, objectsToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ final AbstractAxisProvider rowsProvider = AxisUtils.getAxisProviderUsedForRows(this);
+ final AbstractAxisProvider columnsProvider = AxisUtils.getAxisProviderUsedForColumns(this);
+ boolean addComplementaryAxis = columnsProvider instanceof IMasterAxisProvider && rowsProvider instanceof ISlaveAxisProvider && !((IMasterAxisProvider)columnsProvider).isDisconnectSlave();
+ if(addComplementaryAxis) {
+ tmp = this.rowManager.getComplementaryAddAxisCommand(domain, objectsToAdd);
+ if(tmp != null) {
+ cmd.append(tmp);
+ }
+ }
+ return cmd;
+ }
+
+ public Command getDestroyColumnElementCommand(Collection<Object> objectsToDestroy) {
+ final EditingDomain domain = getContextEditingDomain();
+ final Command cmd = this.columnManager.getDestroyAxisCommand(domain, objectsToDestroy);
+ return cmd;
+ }
+
+ public Command getDestroyRowElementCommand(Collection<Object> objectsToDestroy) {
+ final EditingDomain domain = getContextEditingDomain();
+ final Command cmd = this.rowManager.getDestroyAxisCommand(domain, objectsToDestroy);
+ return cmd;
+ }
+
+
+ public boolean declareEditorsOnColumns() {
+ return true;
+ }
+
+ public boolean declareEditorsOnRows() {
+ return false;
+ }
+
+ public ITableAxisElementProvider getTableAxisElementProvider() {// FIXME :
+ // must be
+ // renamed?
+ return this;
+ }
+
+
+
+
+ /**
+ * When the axis manager is dynamic, we can't destroy axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canCreateDestroyColumnsAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canCreateDestroyColumnsAxis() {
+ return !this.columnManager.isDynamic() && this.columnManager.createPossibleAxisContentProvider(true) != null;
+ }
+
+ /**
+ * When the axis manager is dynamic, we can't destroy axis
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canCreateDestroyRowsAxis()
+ *
+ * @return
+ */
+ @Override
+ public boolean canCreateDestroyRowsAxis() {
+ return !this.rowManager.isDynamic() && this.rowManager.createPossibleAxisContentProvider(true) != null;
+ }
+
+ /**
+ *
+ * @param serv
+ * the label provider service
+ * @param editedAxisManager
+ * the manager used for the edited axis
+ * @param secondAxisManager
+ * the manager used for the other axis
+ * @param isEditingColumns
+ * boolean indicating if we are editing columns or rows
+ */
+ private final void openCreateDestroyAxisManagerDialog(boolean isEditingColumns) {
+ final String dialogTitle;
+ final String dialogCheckBoxTootip;
+ final String dialogQuestion;
+
+ final IAxisManager editedAxisManager;
+ final IAxisManager secondAxisManager;
+ final String checkBoxMessage = Messages.NattableModelManager_DisconnectThisAxisManager;
+ if(isEditingColumns) {
+ dialogTitle = Messages.NattableModelManager_SelectColumns;
+ dialogCheckBoxTootip = Messages.NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded;
+ dialogQuestion = String.format(Messages.NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition, checkBoxMessage);
+
+ editedAxisManager = columnManager;
+ secondAxisManager = rowManager;
+ } else {
+ dialogTitle = Messages.NattableModelManager_SelectRows;
+ dialogCheckBoxTootip = Messages.NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded;
+ dialogQuestion = String.format(Messages.NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition, checkBoxMessage);
+
+ editedAxisManager = rowManager;
+ secondAxisManager = columnManager;
+ }
+ final LabelProviderService serv = this.natTable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ final ILabelProvider labelProvider = serv.getLabelProvider();
+ final AbstractAxisProvider editedAxisProvider = editedAxisManager.getRepresentedContentProvider();
+ final AbstractAxisProvider secondAxisProvider = secondAxisManager.getRepresentedContentProvider();
+ ReferenceSelector selector = new ReferenceSelector(true) {
+
+ @Override
+ public void createControls(Composite parent) {
+ super.createControls(parent);
+ this.treeViewer.setComparator(new ViewerComparator(new StringComparator()));//should always be string element
+ }
+ };
+ selector.setLabelProvider(labelProvider);
+
+ IStaticContentProvider provider = editedAxisManager.createPossibleAxisContentProvider(true);
+ if(provider != null) {
+ selector.setContentProvider(new FlattenableRestrictedFilteredContentProvider((IRestrictedContentProvider)provider, selector));
+
+ final DisplayedAxisSelectorDialog dialog = new DisplayedAxisSelectorDialog(Display.getDefault().getActiveShell(), selector, dialogTitle, true, false, -1);
+ boolean displayCheckBox = editedAxisProvider instanceof ISlaveAxisProvider;
+ dialog.setDisplayCheckBox(displayCheckBox);
+ boolean checkboxValue = secondAxisProvider instanceof IMasterAxisProvider && ((IMasterAxisProvider)secondAxisProvider).isDisconnectSlave();
+ if(displayCheckBox) {
+ dialog.setCheckBoxValues(checkBoxMessage, dialogCheckBoxTootip, checkboxValue);
+ }
+
+ dialog.setInformationDialogValues(Messages.NattableModelManager_DisconnectAxisManagerInformationDialogTitle, dialogQuestion);
+ dialog.setLabelProvider(labelProvider);
+ dialog.setInitialElementSelections(new ArrayList<Object>(editedAxisManager.getAllManagedAxis()));
+
+ int open = dialog.open();
+ if(open == Window.OK) {
+ Collection<Object> existingColumns = editedAxisManager.getAllManagedAxis();
+ ArrayList<Object> checkedColumns = new ArrayList<Object>();
+ checkedColumns.addAll(Arrays.asList(dialog.getResult()));
+
+ ArrayList<Object> columnsToAdd = new ArrayList<Object>(checkedColumns);
+ columnsToAdd.removeAll(existingColumns);
+ CompoundCommand compoundCommand = new CompoundCommand("Update Existing Axis Command"); //$NON-NLS-1$
+ if(columnsToAdd.size() > 0) {
+ Command addAxisElementCommand = null;
+ if(isEditingColumns) {
+ addAxisElementCommand = getAddColumnElementCommand(columnsToAdd);
+ } else {
+ addAxisElementCommand = getAddRowElementCommand(columnsToAdd);
+ }
+ compoundCommand.append(addAxisElementCommand);
+ }
+
+ ArrayList<Object> axisToDestroy = new ArrayList<Object>(existingColumns);
+ axisToDestroy.removeAll(checkedColumns);
+ if(axisToDestroy.size() > 0) {
+ Command destroyAxisElementCommand = null;
+ if(isEditingColumns) {
+ destroyAxisElementCommand = getDestroyColumnElementCommand(axisToDestroy);
+ } else {
+ destroyAxisElementCommand = getDestroyRowElementCommand(axisToDestroy);
+ }
+ compoundCommand.append(destroyAxisElementCommand);
+ }
+
+ final boolean newState = dialog.isChecked();
+ if(displayCheckBox && checkboxValue != newState) {
+ final TransactionalEditingDomain domain = (TransactionalEditingDomain)getTableEditingDomain();
+ final IEditCommandRequest request = new SetRequest(domain, secondAxisProvider, NattableaxisproviderPackage.eINSTANCE.getIMasterAxisProvider_DisconnectSlave(), newState);
+ final IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(secondAxisProvider);
+ compoundCommand.append(new GMFtoEMFCommandWrapper(commandProvider.getEditCommand(request)));
+ }
+
+ if(!compoundCommand.isEmpty()) {
+ getContextEditingDomain().getCommandStack().execute(compoundCommand);
+ updateToggleActionState();
+ }
+ }
+ } else {
+ MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.NattableModelManager_CreateDestroyAxis, Messages.NattableModelManager_ActionNotYetSupported);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openCreateDestroyRowsManagerDialog()
+ *
+ */
+ @Override
+ public void openCreateDestroyRowsManagerDialog() {
+ openCreateDestroyAxisManagerDialog(false);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openCreateDestroyColumnsManagerDialog()
+ *
+ */
+ public void openCreateDestroyColumnsManagerDialog() {
+ openCreateDestroyAxisManagerDialog(true);
+ }
+
+ public void sortColumnsByName(final boolean alphabeticOrder) {
+ this.columnManager.sortAxisByName(alphabeticOrder, this.natTable.getConfigRegistry());
+ }
+
+
+ public void sortRowsByName(final boolean alphabeticOrder) {
+ this.rowManager.sortAxisByName(alphabeticOrder, this.natTable.getConfigRegistry());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getVerticalAxisProvider()
+ *
+ * @return
+ */
+ public AbstractAxisProvider getVerticalAxisProvider() {
+ if(getTable().isInvertAxis()) {
+ return getTable().getCurrentRowAxisProvider();
+ } else {
+ return getTable().getCurrentColumnAxisProvider();
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getHorizontalAxisProvider()
+ *
+ * @return
+ */
+ public AbstractAxisProvider getHorizontalAxisProvider() {
+ if(getTable().isInvertAxis()) {
+ return getTable().getCurrentColumnAxisProvider();
+ } else {
+ return getTable().getCurrentRowAxisProvider();
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canEditColumnHeader(int)
+ *
+ * @param evaluationContext
+ * @return
+ */
+ public boolean canEditColumnHeader(final NatEventData evaluationContext) {
+ return this.columnManager.canEditAxisHeader(evaluationContext);
+ }
+
+ /***
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#canEditRowHeader(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param eventData
+ * @return
+ */
+ @Override
+ public boolean canEditRowHeader(NatEventData evaluationContext) {
+ return this.rowManager.canEditAxisHeader(evaluationContext);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openEditRowAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param event
+ */
+ public void openEditRowAliasDialog(NatEventData event) {
+ this.rowManager.openEditAxisAliasDialog(event, event.getNatTable().getRowIndexByPosition(event.getRowPosition()));
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#openEditColumnAliasDialog(org.eclipse.nebula.widgets.nattable.ui.NatEventData)
+ *
+ * @param event
+ */
+ public void openEditColumnAliasDialog(NatEventData event) {
+ this.columnManager.openEditAxisAliasDialog(event, event.getNatTable().getColumnIndexByPosition(event.getColumnPosition()));
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getColumnAxisManager()
+ *
+ * @return
+ */
+ @Override
+ public IAxisManager getColumnAxisManager() {
+ return this.columnManager;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getRowAxisManager()
+ *
+ * @return
+ */
+ @Override
+ public IAxisManager getRowAxisManager() {
+ return this.rowManager;
+ }
+
+
+ public void setTableName(String name) {
+ SetRequest setNameRequest = new SetRequest(getTable(), NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name(), name);
+ IElementEditService editService = ElementEditServiceUtils.getCommandProvider(getTable());
+ ICommand setNameCommand = editService.getEditCommand(setNameRequest);
+ getTableEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(setNameCommand));
+ }
+
+
+ public String getTableName() {
+ return getTable().getName();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
new file mode 100644
index 00000000000..e3e98cb6f7f
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
@@ -0,0 +1,192 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.nattable.messages.messages"; //$NON-NLS-1$
+
+ public static String CompositeAxisManager_DestroyAxisCommand;
+
+ public static String AbstractAxisManager_InputDialogMessage;
+
+ public static String AbstractAxisManager_InputDialogTitle;
+
+ public static String AbstractCreateNattableEditorHandler_EnterTheNameForTheNewTable;
+
+ public static String AbstractCreateNattableEditorHandler_PapyrusTableCreation;
+
+ public static String AbstractTableHandler_CurrentEditorCantBeFound;
+
+ public static String AxisManagerFactory_AxisManagerClassCantBeLoaded;
+
+ public static String AxisManagerFactory_TheClassCantBeInstanciated;
+
+ public static String CompositeAxisManager_AddAxisCommand;
+
+ public static String DeleteNatTableContextAdvice_DestroyNattableCommand;
+
+ public static String EditConfiguration_ConfigurationFactoryNotFound;
+
+ public static String EditConfiguration_ConfigurationNotFound;
+
+ public static String EditConfiguration_DeclarationNotYetSupported;
+
+ public static String EditConfiguration_FactoryHandlesElementButDoesntProvideEditor;
+
+ public static String EObjectManager_AddAxisElement;
+
+ public static String NattableConfigurationRegistry_ConfigurationNotFound;
+
+ public static String NattableConfigurationRegistry_NoTesterForThisConfiguration;
+
+ public static String NattableConfigurationRegistry_NoTypeForAConfiguration;
+
+ public static String NattableConfigurationRegistry_ResourceEmpty;
+
+ public static String NattableConfigurationRegistry_SeveralConfigurationsWithTheSameType;
+
+ public static String NattableConfigurationRegistry_TableConfigurationNotFound;
+
+ public static String NattableConfigurationRegistry_TesterNotFound;
+
+ public static String NattableConfigurationRegistry_TesterNotManager;
+
+ public static String NattableModelManager_ActionNotYetSupported;
+
+ public static String NattableModelManager_AddColumnCommand;
+
+ public static String NattableModelManager_AddRowCommand;
+
+ public static String NattableModelManager_AtLeastOfOneTheAxisManagerMustBeAMaster;
+
+ public static String NattableModelManager_CreateDestroyAxis;
+
+ public static String NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded;
+
+ public static String NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded;
+
+ public static String NattableModelManager_DisconnectAxisManagerCheckBoxMessage;
+
+ public static String NattableModelManager_DisconnectAxisManagerCheckBoxTooltip;
+
+ public static String NattableModelManager_DisconnectAxisManagerInformationDialogMessage;
+
+ public static String NattableModelManager_DisconnectAxisManagerInformationDialogTitle;
+
+ public static String NattableModelManager_DisconnectColumnAxisManager;
+
+ public static String NattableModelManager_DisconnectColumnAxisManagerMessageInInformationDialog;
+
+ public static String NattableModelManager_DisconnectThisAxisManager;
+
+ public static String NattableModelManager_EditingDomainNotFound;
+
+ public static String NattableModelManager_SelectColumns;
+
+ public static String NattableModelManager_SelectRows;
+
+ public static String NattableModelManager_ServiceRegistryNotFound;
+
+ public static String NattableModelManager_SwitchLinesAndColumns;
+
+ public static String NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition;
+
+ public static String NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition;
+
+ public static String PrintTableHandler_PrintCantBeDone;
+
+ public static String PrintTableHandler_TablePrint;
+
+ public static String TableLabelProvider_ErrorGettingIconForTable;
+
+ public static String TableTesterRegistry_SeveralTesterAreRegisteredWithTheSameId;
+
+ public static String TableTesterRegistry_TheClassCantBeLoaded;
+
+ public static String ICellManager_NotAvailable;
+
+ public static String AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage;
+
+ public static String ColumnsToShowDialog_AdditionalFeatures;
+
+ public static String ColumnsToShowDialog_AdvancedMode;
+
+ public static String ColumnsToShowDialog_default_columns;
+
+ public static String ColumnsToShowDialog_DeselectAll;
+
+ public static String ColumnsToShowDialog_DeselectAllAvailableAdditionalFeatures;
+
+ public static String ColumnsToShowDialog_DeselecteAllAvailableFeatures;
+
+ public static String ColumnsToShowDialog_DeselectedAll;
+
+ public static String ColumnsToShowDialog_DirectFeatures;
+
+ public static String ColumnsToShowDialog_SelecColumnsToShow;
+
+ public static String ColumnsToShowDialog_SelectAll;
+
+ public static String ColumnsToShowDialog_SelectAllAvailableAdditionalFeatures;
+
+ public static String ColumnsToShowDialog_SelectAllAvailablesFeatures;
+
+ public static String ColumnsToShowDialog_ShowAllPossibilities;
+
+ public static String PasteInPapyrusTableCommandProvider_0;
+
+ public static String PasteInPapyrusTableCommandProvider_1;
+
+ public static String PasteInPapyrusTableCommandProvider_2;
+
+ public static String PasteInPapyrusTableCommandProvider_3;
+
+ public static String PasteInPapyrusTableCommandProvider_Pasting;
+
+ public static String PasteInPapyrusTableCommandProvider_PastingInTable;
+
+ public static String PasteInPapyrusTableCommandProvider_ProblemsToSetPropertyValue;
+
+ public static String PasteInPapyrusTableCommandProvider_ProblemToApplyStereotype;
+
+ public static String PasteInPapyrusTableCommandProvider_ProblemToSetStereotypeValue;
+
+ public static String PasteInPapyrusTableCommandProvider_RequiredStereotypeCantBeFound;
+
+ public static String PasteInPapyrusTableCommandProvider_RequiredStereotypeNotApplied;
+
+ public static String PasteInPapyrusTableCommandProvider_StereotypePropertyCantBeResolved;
+
+ public static String PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound;
+
+ public static String PasteInPapyrusTableCommandProvider_TheStereotypeCantBeApplied;
+
+ public static String PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement;
+
+ public static String PasteInTableHandler_PasteCancelled;
+
+ public static String PasteInTableHandler_PasteCreation;
+
+ public static String PasteInTableHandler_ThePasteCommandCantBeExecuted;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
new file mode 100644
index 00000000000..cc6af72e69a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
@@ -0,0 +1,82 @@
+AbstractAxisManager_InputDialogMessage=The real name for the header is: \n\t %s \n \n Alias:
+AbstractAxisManager_InputDialogTitle=Edit Header Alias Dialog
+AbstractCreateNattableEditorHandler_EnterTheNameForTheNewTable=Enter the name for the new table
+AbstractCreateNattableEditorHandler_PapyrusTableCreation=Papyrus Table Creation
+AbstractTableHandler_CurrentEditorCantBeFound=Current Editor can't be found
+AxisManagerFactory_AxisManagerClassCantBeLoaded=The AxisManager registered with the id {0} can't be loaded
+AxisManagerFactory_TheClassCantBeInstanciated=The class {0} can't be instanciated
+CompositeAxisManager_AddAxisCommand=Add Axis Command
+DeleteNatTableContextAdvice_DestroyNattableCommand=Destroy NatTables command
+EditConfiguration_ConfigurationFactoryNotFound=I can't find config factory for {0}
+EditConfiguration_ConfigurationNotFound=I can't find configuration for {0}
+EditConfiguration_DeclarationNotYetSupported=The declaration of celleditor on cell is not yet supported
+EditConfiguration_FactoryHandlesElementButDoesntProvideEditor=The factory {0} handles the element {1} but doesn't provide CellEditor
+EObjectManager_AddAxisElement=Add Axis Element
+NattableConfigurationRegistry_ConfigurationNotFound=Configuration can't be found
+NattableConfigurationRegistry_NoTesterForThisConfiguration=no tester for this configuration
+NattableConfigurationRegistry_NoTypeForAConfiguration=TableConfiguration in {0} has no type.
+NattableConfigurationRegistry_ResourceEmpty=The resource {0} is empty.
+NattableConfigurationRegistry_SeveralConfigurationsWithTheSameType=Several configuration are registered with the same type : {0}. We keep only the first one
+NattableConfigurationRegistry_TableConfigurationNotFound=TableConfiguration not found in {0}.
+NattableConfigurationRegistry_TesterNotFound=tester notfound
+NattableConfigurationRegistry_TesterNotManager=tester not managed
+NattableModelManager_ActionNotYetSupported=This action is not yet supported
+NattableModelManager_AddColumnCommand=Add column command
+CompositeAxisManager_DestroyAxisCommand=Destroy column command
+NattableModelManager_AddRowCommand=Add rows command
+NattableModelManager_AtLeastOfOneTheAxisManagerMustBeAMaster=At least one of the AxisManager must be a Master
+NattableModelManager_CreateDestroyAxis=Create / Destroy Axis
+NattableModelManager_DisableTheAutomaticAdditionOfColumnsWhenARowIsAdded=Disable the automatic addition of columns when a row is added
+NattableModelManager_DisableTheAutomaticAdditionOfRowsWhenAColumnIsAdded=Disable the automatic addition of rows when a column is added
+NattableModelManager_DisconnectAxisManagerCheckBoxMessage=Disconnect this axis manager
+NattableModelManager_DisconnectAxisManagerCheckBoxTooltip=Disable the automatic addition of columns when a row is added.
+NattableModelManager_DisconnectAxisManagerInformationDialogMessage=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of columns. \n \n Do you want to continue?
+NattableModelManager_DisconnectAxisManagerInformationDialogTitle=Axis Selection Question
+NattableModelManager_DisconnectColumnAxisManager=Disable the automatic addition of rows when a column is added.
+NattableModelManager_DisconnectColumnAxisManagerMessageInInformationDialog=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of rows. \n\n Do you want to continue?
+NattableModelManager_DisconnectThisAxisManager=Disconnect this axis manager
+NattableModelManager_EditingDomainNotFound=EditingDomain not found
+NattableModelManager_SelectColumns=Select Columns
+NattableModelManager_SelectRows=Select Rows
+NattableModelManager_ServiceRegistryNotFound=ServiceRegistry not found
+NattableModelManager_SwitchLinesAndColumns=Switch Lines and Columns
+NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticColumnAddition=The checkbox '%s' has not been checked, so the next row addition could be followed by a columns addition, ignoring your current selection of columns. Do you want to continue?
+NattableModelManager_TheCheckBoxHasNotBeenCheckedToAvoidAutomaticRowAddition=The checkbox '%s' has not been checked, so the next column addition could be followed by a rows addition, ignoring your current selection of rows. Do you want to continue?
+PrintTableHandler_PrintCantBeDone=Print can't be done
+PrintTableHandler_TablePrint=Table Print
+TableLabelProvider_ErrorGettingIconForTable=Error getting icon image for tables:
+TableTesterRegistry_SeveralTesterAreRegisteredWithTheSameId=Several classes are registered for the id {0}
+TableTesterRegistry_TheClassCantBeLoaded=Class registrered with id {0} can't be loaded
+ICellManager_NotAvailable=N/A
+AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage=A UML Table can't be created with a non-UML element as context ({0})
+ColumnsToShowDialog_AdditionalFeatures=Additional Features
+ColumnsToShowDialog_AdvancedMode=Advanced Mode
+ColumnsToShowDialog_default_columns=Default Columns
+ColumnsToShowDialog_DeselectAll=Deselect All
+ColumnsToShowDialog_DeselectAllAvailableAdditionalFeatures=Deselect all available additional features.
+ColumnsToShowDialog_DeselecteAllAvailableFeatures=Deselect all available features.
+ColumnsToShowDialog_DeselectedAll=Deselect All
+ColumnsToShowDialog_DirectFeatures=Direct Features
+ColumnsToShowDialog_SelecColumnsToShow=Select the columns to show
+ColumnsToShowDialog_SelectAll=Select All
+ColumnsToShowDialog_SelectAllAvailableAdditionalFeatures=Select all available additional features.
+ColumnsToShowDialog_SelectAllAvailablesFeatures=Select all available features.
+ColumnsToShowDialog_ShowAllPossibilities=Show all possibilities
+PasteInPapyrusTableCommandProvider_0=The String {0} is not valid to create a {1}.
+PasteInPapyrusTableCommandProvider_1=Paste Command In FlowPort Table
+PasteInPapyrusTableCommandProvider_2=Create Paste Action
+PasteInPapyrusTableCommandProvider_3=Launch Progress Monitor Dialog
+PasteInPapyrusTableCommandProvider_Pasting=Pasting
+PasteInPapyrusTableCommandProvider_PastingInTable=Pasting in Table
+PasteInPapyrusTableCommandProvider_ProblemsToSetPropertyValue=Problems to set properties value
+PasteInPapyrusTableCommandProvider_ProblemToApplyStereotype=Problems to apply stereotype
+PasteInPapyrusTableCommandProvider_ProblemToSetStereotypeValue=Problems to set stereotype properties value
+PasteInPapyrusTableCommandProvider_RequiredStereotypeCantBeFound=Stereotype {0} required by the column can' be found
+PasteInPapyrusTableCommandProvider_RequiredStereotypeNotApplied=The required stereotype {0} is not applied on the element {1}.
+PasteInPapyrusTableCommandProvider_StereotypePropertyCantBeResolved=The stereotype property called by {0} can't be resolved
+PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound=The enumeration literal {0} can't be found
+PasteInPapyrusTableCommandProvider_TheStereotypeCantBeApplied=The stereotype {0} can' be applied on {1}
+PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement=The text {0} can't be mapped to an existing element
+PasteInTableHandler_PasteCancelled=Paste Action Canceled
+PasteInTableHandler_PasteCreation=Paste creation...
+PasteInTableHandler_ThePasteCommandCantBeExecuted=The paste command can't be executed
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/nattableconfiguration/NattableConfigurationRegistry.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/nattableconfiguration/NattableConfigurationRegistry.java
new file mode 100644
index 00000000000..26309c73190
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/nattableconfiguration/NattableConfigurationRegistry.java
@@ -0,0 +1,158 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.nattableconfiguration;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattabletester.AbstractTableTester;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattabletester.JavaTableTester;
+import org.eclipse.papyrus.infra.nattable.tester.ITableTester;
+import org.eclipse.papyrus.infra.nattable.tester.TableTesterRegistry;
+
+
+public class NattableConfigurationRegistry {
+
+ public static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.configuration"; //$NON-NLS-1$
+
+ public static final String FILE_ATTRIBUTE = "file"; //$NON-NLS-1$
+
+ /**
+ * the table configuration identified by the type of the table
+ */
+ private Map<String, TableConfiguration> configsURI;
+
+ private ResourceSet resourceSet;
+
+ public static final NattableConfigurationRegistry INSTANCE = new NattableConfigurationRegistry();
+
+ private NattableConfigurationRegistry() {
+ //to prevent instantiation
+ initFields();
+ }
+
+
+ /**
+ *
+ * @return
+ * the list of the known table configuration
+ */
+ public Collection<TableConfiguration> getTableConfigurations() {
+ return configsURI.values();
+ }
+
+ /**
+ *
+ *
+ * @param newTableConfiguration
+ * @return
+ */
+ public void registerTableConfiguration(final TableConfiguration newTableConfiguration) {
+ configsURI.put(newTableConfiguration.getType(), newTableConfiguration);
+ }
+
+
+ /**
+ *
+ * @param tableType
+ * the type of the table
+ * @return
+ * the URI of the configuration to use for this table or <code>null</code> if not found
+ */
+ public URI getConfigurationURI(final String tableType) {
+ return this.configsURI.get(tableType).eResource().getURI();
+ }
+
+ /**
+ * inits the fields of the class
+ */
+ private void initFields() {
+ if(this.configsURI == null) {
+ this.configsURI = new HashMap<String, TableConfiguration>();
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ this.resourceSet = new ResourceSetImpl();
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+ Object file = iConfigurationElement.getAttribute(FILE_ATTRIBUTE);
+ IContributor contributor = iConfigurationElement.getContributor();
+ //we build the uri for the file
+ URI uri = URI.createPlatformPluginURI(contributor.getName() + "/" + file.toString(), true);//$NON-NLS-1$ //FIXME : maybe a best way?
+ Resource res = this.resourceSet.getResource(uri, true);
+ if(res.getContents().size() > 0) {
+ EObject first = res.getContents().get(0);
+ if(first instanceof TableConfiguration) {
+ String type = ((TableConfiguration)first).getType();
+ if(type != null) {
+ if(!this.configsURI.containsKey(type)) {
+ this.configsURI.put(type, (TableConfiguration)first);
+ } else {
+ Activator.log.warn(String.format(Messages.NattableConfigurationRegistry_SeveralConfigurationsWithTheSameType, type));
+ }
+ } else {
+ Activator.log.warn(String.format(Messages.NattableConfigurationRegistry_NoTypeForAConfiguration, uri));
+ }
+ } else {
+ Activator.log.warn(String.format(Messages.NattableConfigurationRegistry_TableConfigurationNotFound, uri));
+ }
+ } else {
+ Activator.log.warn(String.format(Messages.NattableConfigurationRegistry_ResourceEmpty, uri));
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param tableType
+ * the table type to create
+ * @param tableContext
+ * the table context
+ * @return
+ * a status {@link IStatus#OK} when wa can create the table or {@link IStatus#ERROR} if not
+ */
+ public IStatus canCreateTable(final String tableType, final Object tableContext) {
+ TableConfiguration config = this.configsURI.get(tableType);
+ if(config != null) {
+ AbstractTableTester tester = config.getCreationTester();
+ if(tester instanceof JavaTableTester) {
+ final String testerId = ((JavaTableTester)tester).getTester();
+ final ITableTester myTester = TableTesterRegistry.INSTANCE.getTableTester(testerId);
+ if(myTester != null) {
+ return myTester.isAllowed(tableContext);
+ } else {
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NattableConfigurationRegistry_TesterNotFound);
+ }
+ } else if(tester == null) {
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.NattableConfigurationRegistry_NoTesterForThisConfiguration);
+ } else {
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NattableConfigurationRegistry_TesterNotManager);
+ }
+ }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NattableConfigurationRegistry_ConfigurationNotFound);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomCheckBoxPainter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomCheckBoxPainter.java
new file mode 100644
index 00000000000..f75ce5c193d
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomCheckBoxPainter.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.painter;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
+import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+
+
+public class CustomCheckBoxPainter extends CheckBoxPainter {
+
+ @Override
+ public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
+ try {
+ isChecked(cell, configRegistry);
+ } catch (Exception e) {
+ TextPainter painter = new TextPainter();
+ return painter.getCellPainterAt(x, y, cell, gc, bounds, configRegistry);
+ }
+ return super.getCellPainterAt(x, y, cell, gc, bounds, configRegistry);
+ }
+
+ @Override
+ public void paintCell(ILayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
+ try {
+ isChecked(cell, configRegistry);
+ } catch (Exception e) {
+ TextPainter painter = new TextPainter();
+ painter.paintCell(cell, gc, bounds, configRegistry);
+ return;
+ }
+ super.paintCell(cell, gc, bounds, configRegistry);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomImagePainter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomImagePainter.java
new file mode 100644
index 00000000000..8ab8cf77e6a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/CustomImagePainter.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.painter;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * Custom Image painter for the header of the table
+ *
+ */
+public class CustomImagePainter extends ImagePainter {
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter#getImage(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell,
+ * org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ @Override
+ protected Image getImage(ILayerCell cell, IConfigRegistry configRegistry) {
+ final LabelProviderService serv = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ final ILabelProviderContextElementWrapper contextElement = new LabelProviderCellContextElementWrapper(cell, configRegistry);
+ final ILabelProvider provider = serv.getLabelProvider(Constants.TABLE_LABEL_PROVIDER_CONTEXT, contextElement);
+ return provider.getImage(contextElement);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractNattableCellLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractNattableCellLabelProvider.java
new file mode 100644
index 00000000000..813f4fea68b
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractNattableCellLabelProvider.java
@@ -0,0 +1,175 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.graphics.Image;
+
+
+public abstract class AbstractNattableCellLabelProvider implements IFilteredLabelProvider {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider#accept(java.lang.Object)
+ *
+ * @param element
+ * @return
+ *
+ */
+ public boolean accept(Object element) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ *
+ * @param element
+ * @return
+ *
+ */
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ *
+ */
+ public String getText(Object element) {
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ *
+ * @param listener
+ * always throws {@link UnsupportedOperationException}
+ */
+ public void addListener(ILabelProviderListener listener) {
+ // throw new UnsupportedOperationException();
+ }
+
+ public void dispose() {
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
+ *
+ * @param element
+ * @param property
+ * @return
+ * false
+ */
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ *
+ * @param listener
+ * always throws {@link UnsupportedOperationException}
+ */
+ public void removeListener(ILabelProviderListener listener) {
+ // throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param cell
+ * @param registry
+ * @return
+ * the row object for this cell
+ */
+ protected Object getRowObject(final ILayerCell cell, final IConfigRegistry registry) {
+ int rowIndex = cell.getRowIndex();
+ ITableAxisElementProvider provider = getAxisContentProvider(registry);
+ return provider.getRowElement(rowIndex);
+ }
+
+ /**
+ *
+ * @param cell
+ * @param registry
+ * @return
+ * the column object for this cell
+ */
+ protected Object getColumnObject(final ILayerCell cell, final IConfigRegistry registry) {
+ int columnIndex = cell.getColumnIndex();
+ ITableAxisElementProvider provider = getAxisContentProvider(registry);
+ return provider.getColumnElement(columnIndex);
+ }
+
+ /**
+ *
+ * @param registry
+ * @return
+ * the table axis element provider
+ */
+ protected ITableAxisElementProvider getAxisContentProvider(final IConfigRegistry registry) {
+ return registry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ }
+
+ /**
+ *
+ * @param registry
+ * @return
+ * the label provider service
+ */
+ protected LabelProviderService getLabelProviderService(final IConfigRegistry registry) {
+ return registry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ }
+
+ /**
+ *
+ * @param element
+ * a label provider context element
+ * @return
+ * the configuration to use for this element
+ */
+ protected ILabelProviderConfiguration getLabelConfiguration(final LabelProviderCellContextElementWrapper element) {
+ ILabelProviderConfiguration conf = null;
+ final IConfigRegistry configRegistry = ((ILabelProviderContextElementWrapper)element).getConfigRegistry();
+ INattableModelManager manager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ LabelStack labels = element.getConfigLabels();
+ if(labels.hasLabel(GridRegion.COLUMN_HEADER)) {
+ conf = LabelConfigurationManagementUtils.getUsedColumnObjectLabelConfiguration(manager.getTable());
+ } else if(labels.hasLabel(GridRegion.ROW_HEADER)) {
+ conf = LabelConfigurationManagementUtils.getUsedRowObjectLabelConfiguration(manager.getTable());
+ }
+ return conf;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java
new file mode 100644
index 00000000000..fd1fac6b157
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+
+/**
+ * The generic label provider for the cells
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class GenericCellLabelProvider extends AbstractNattableCellLabelProvider {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#accept(java.lang.Object)
+ *
+ * @param element
+ * @return
+ * <code>true</code> if the element is an instance of {@link ILabelProviderContextElementWrapper} and if the cell represents an
+ * {@link EStructuralFeature} of an {@link EObject}
+ */
+ @Override
+ public boolean accept(Object element) {
+ return element instanceof ILabelProviderCellContextElementWrapper;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public String getText(Object element) {
+ final ILabelProviderCellContextElementWrapper contextElement = (ILabelProviderCellContextElementWrapper)element;
+ final IConfigRegistry registry = ((ILabelProviderContextElementWrapper)element).getConfigRegistry();
+ Object value = contextElement.getObject();
+ String label = ""; //$NON-NLS-1$
+ final LabelProviderService service = getLabelProviderService(registry);
+ if(value instanceof Collection<?>) {
+ Iterator<?> iter = ((Collection<?>)value).iterator();
+ label += Constants.BEGIN_OF_COLLECTION;
+ while(iter.hasNext()) {
+ Object current = iter.next();
+ label += service.getLabelProvider(current).getText(current);
+ if(iter.hasNext()) {
+ label += Constants.SEPARATOR;
+ }
+ }
+ label += Constants.END_OF_COLLECTION;
+ } else {
+ label = service.getLabelProvider(value).getText(value);
+ }
+ return label;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/IndexHeaderLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/IndexHeaderLabelProvider.java
new file mode 100644
index 00000000000..6fef13f8b7e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/IndexHeaderLabelProvider.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+
+/**
+ * The label provider used for the index of the header
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class IndexHeaderLabelProvider extends AbstractNattableCellLabelProvider {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#accept(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public boolean accept(Object element) {
+ if(element instanceof ILabelProviderContextElementWrapper) {
+ Object object = ((ILabelProviderContextElementWrapper)element).getObject();
+ return object instanceof String || object instanceof Integer;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public String getText(Object element) {
+ return ((ILabelProviderContextElementWrapper)element).getObject().toString();
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/NattableTopLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/NattableTopLabelProvider.java
new file mode 100644
index 00000000000..32ba131f182
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/NattableTopLabelProvider.java
@@ -0,0 +1,255 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * The LabelProvider used in the table
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class NattableTopLabelProvider extends AbstractNattableCellLabelProvider {
+
+
+ /**
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ protected String getColumnHeaderLabel(final ILabelProviderCellContextElementWrapper cell, final IConfigRegistry configRegistry) {
+ return getLabel(cell, configRegistry, Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ }
+
+ /**
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ protected String getRowHeaderLabel(final ILabelProviderCellContextElementWrapper cell, final IConfigRegistry configRegistry) {
+ return getLabel(cell, configRegistry, Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public String getText(Object element) {
+ final ILabelProviderCellContextElementWrapper contextElement = (ILabelProviderCellContextElementWrapper)element;
+ final IConfigRegistry configRegistry = contextElement.getConfigRegistry();
+ final LabelStack labels = getLabelStack(contextElement, configRegistry);
+ if(labels.hasLabel(GridRegion.COLUMN_HEADER)) {
+ return getColumnHeaderLabel(contextElement, configRegistry);
+ } else if(labels.hasLabel(GridRegion.ROW_HEADER)) {
+ return getRowHeaderLabel(contextElement, configRegistry);
+ } else if(labels.hasLabel(GridRegion.BODY)) {
+ return getBodyLabel(contextElement, configRegistry);
+ }
+ Object value = contextElement.getObject();
+ if(value != null) {
+ return value.toString();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ protected LabelStack getLabelStack(final ILabelProviderCellContextElementWrapper contextElement, final IConfigRegistry configRegistry) {
+ LabelStack labels = contextElement.getConfigLabels();
+ if(labels.getLabels().isEmpty()) {
+ //in case of copy, we don't have the label
+ final INattableModelManager manager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ labels = ((AbstractNattableWidgetManager)manager).getGridLayer().getBodyLayer().getConfigLabelsByPosition(contextElement.getColumnPosition(), contextElement.getRowPosition());
+ }
+ return labels;
+ }
+
+ /**
+ *
+ * @param cell
+ * @param configRegistry
+ * @param labelproviderContext
+ * @return
+ */
+ protected String getLabel(final ILabelProviderCellContextElementWrapper contextElement, final IConfigRegistry configRegistry, final String labelproviderContext) {
+ String txt = ""; //$NON-NLS-1$
+ // Object value = cell.getDataValue();
+ // final ILabelProviderContextElement contextElement = new LabelProviderCellContextElement(cell, configRegistry);
+ LabelProviderService serv = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ ILabelProvider labelProvider = serv.getLabelProvider(labelproviderContext, contextElement);
+ if(labelProvider != null) {
+ txt = labelProvider.getText(contextElement);
+ } else {
+ labelProvider = serv.getLabelProvider(labelproviderContext, contextElement.getObject());
+ if(labelProvider != null) {
+ txt = labelProvider.getText(contextElement.getObject());
+ } else {
+ labelProvider = serv.getLabelProvider(contextElement.getObject());
+ if(labelProvider != null) {
+ txt = labelProvider.getText(contextElement.getObject());
+ } else {
+ txt = contextElement.getObject().toString();
+ }
+ }
+ }
+ return txt;
+ }
+
+ /**
+ *
+ * @param cellWrapperContextElement
+ * @param configRegistry
+ * @return
+ */
+ protected String getBodyLabel(final ILabelProviderCellContextElementWrapper cellWrapperContextElement, final IConfigRegistry configRegistry) {//Body or data grid?
+ return getLabel(cellWrapperContextElement, configRegistry, Constants.BODY_LABEL_PROVIDER_CONTEXT);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#accept(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public boolean accept(Object element) {
+ return element instanceof ILabelProviderCellContextElementWrapper;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getImage(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public Image getImage(Object element) {
+ final ILabelProviderCellContextElementWrapper contextElement = (ILabelProviderCellContextElementWrapper)element;
+
+
+ Object object = contextElement.getObject();
+ String labelProviderContextId = null;
+ final IConfigRegistry configRegistry = contextElement.getConfigRegistry();
+ if(object instanceof IAxis) {
+ labelProviderContextId = ((IAxis)object).getManager().getLabelProviderContext();
+ return getImage(contextElement, configRegistry, labelProviderContextId);
+ }
+ final LabelStack labels = getLabelStack(contextElement, configRegistry);
+ if(labels.hasLabel(GridRegion.COLUMN_HEADER)) {
+ return getColumnHeaderImage(contextElement, configRegistry);
+ } else if(labels.hasLabel(GridRegion.ROW_HEADER)) {
+ return getRowHeaderImage(contextElement, configRegistry);
+ } else if(labels.hasLabel(GridRegion.BODY)) {
+ return getBodyLabelImage(contextElement, configRegistry);
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+ private Image getBodyLabelImage(ILabelProviderCellContextElementWrapper cell, IConfigRegistry configRegistry) {
+ return null;
+ }
+
+ /**
+ *
+ * @param cell
+ * the cell
+ * @param configRegistry
+ * the config registry
+ * @return
+ * the image to display in the row
+ */
+ private Image getRowHeaderImage(ILabelProviderCellContextElementWrapper cell, IConfigRegistry configRegistry) {
+ return getImage(cell, configRegistry, Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ }
+
+ /**
+ *
+ * @param cell
+ * the cell
+ * @param configRegistry
+ * the config registry
+ * @param labelproviderContext
+ * the context to used to find the label provider
+ * @return
+ */
+ private Image getImage(ILabelProviderCellContextElementWrapper contextElement, IConfigRegistry configRegistry, String labelproviderContext) {
+ Image image = null;
+ LabelProviderService serv = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ ILabelProvider labelProvider = serv.getLabelProvider(labelproviderContext, contextElement);
+ if(labelProvider != null) {
+ image = labelProvider.getImage(contextElement);
+ } else {
+ Object value = contextElement.getObject();
+ labelProvider = serv.getLabelProvider(labelproviderContext, value);
+ if(labelProvider != null) {
+ image = labelProvider.getImage(value);
+ } else {
+ labelProvider = serv.getLabelProvider(value);
+ if(labelProvider != null) {
+ image = labelProvider.getImage(value);
+ }
+ }
+ }
+ return image;
+ }
+
+ /**
+ *
+ * @param cell
+ * the cell
+ * @param configRegistry
+ * the config registry
+ * @return
+ * the image to display for the header
+ */
+ private Image getColumnHeaderImage(ILabelProviderCellContextElementWrapper cell, IConfigRegistry configRegistry) {
+ return getImage(cell, configRegistry, Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java
new file mode 100644
index 00000000000..28b2847bf76
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java
@@ -0,0 +1,157 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
+import org.eclipse.papyrus.infra.widgets.Activator;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * This labelprovider provides icon and text for tables to display them in treeviewer AND in the property view
+ *
+ */
+public class TableLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider#getText(java.lang.Object)
+ *
+ * @param table
+ * @return
+ */
+ @Override
+ public String getText(Object table) {
+ if(table instanceof IStructuredSelection) {
+ return super.getText((IStructuredSelection)table);
+ }
+ Object el = table;
+ if(table instanceof IAdaptable) {
+ el = ((IAdaptable)table).getAdapter(EObject.class);
+ }
+ if(el != null && el instanceof Table) {
+ return ((Table)el).getName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider#getImage(java.lang.Object)
+ *
+ * @param table
+ * @return
+ */
+ @Override
+ public Image getImage(Object table) {
+ if(table instanceof IStructuredSelection) {
+ return getImage(((IStructuredSelection)table));
+ }
+ if(table instanceof IAdaptable) {
+ table = ((IAdaptable)table).getAdapter(EObject.class);
+ }
+ if(table instanceof Table) {
+ final String iconPath = ((Table)table).getTableConfiguration().getIconPath();
+ if(iconPath != null) {
+ return Activator.getDefault().getImage(iconPath);
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider#accept(java.lang.Object)
+ *
+ * @param object
+ * @return
+ */
+ public boolean accept(Object object) {
+ if(object instanceof IStructuredSelection) {
+ return accept((IStructuredSelection)object);
+ }
+ Object el = object;
+ if(object instanceof IAdaptable) {
+ el = EMFHelper.getEObject(object);
+ }
+ if(el != null) {
+ return el instanceof Table;
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ * @param selection
+ * a selection
+ * @return
+ * <code>true</code> if all elements in the selection are accepted
+ */
+ protected boolean accept(final IStructuredSelection selection) {
+ for(final Object current : selection.toList()) {
+ if(!accept(current)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider#hasCommonImage(java.util.Collection)
+ *
+ * @param objects
+ * @return
+ * <code>true</code> if all selected table have the same icon
+ */
+ @Override
+ protected boolean hasCommonImage(Collection<?> objects) {
+ String iconPath = null;
+ for(Object current : objects) {
+ Assert.isTrue(current instanceof Table);
+ Table table = (Table)current;
+ String icon = table.getTableConfiguration().getIconPath();
+ Assert.isNotNull(icon);
+ if(iconPath == null) {
+ iconPath = icon;
+ }
+ if(!iconPath.equals(icon)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider#getNonCommonIcon(java.lang.Object)
+ *
+ * @param commonObject
+ * @return
+ */
+ protected Image getNonCommonIcon(final Object commonObject) {
+ return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(org.eclipse.papyrus.infra.nattable.Activator.PLUGIN_ID, "/icons/table.gif");
+ }
+
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
new file mode 100644
index 00000000000..8c6ab4fa7f4
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
+import org.eclipse.nebula.widgets.nattable.selection.event.ColumnSelectionEvent;
+import org.eclipse.ui.services.IDisposable;
+
+
+public class TableSelectionProvider implements ISelectionProvider, IDisposable {
+
+ private SelectionLayer selectionLayer;
+
+ private final ILayerListener selectionListener;
+
+ private ISelection currentSelection;
+
+ private final List<ISelectionChangedListener> listeners;
+
+ public TableSelectionProvider(final SelectionLayer selectionLayer) {
+ this.selectionLayer = selectionLayer;
+ this.selectionListener = new ILayerListener() {
+
+ public void handleLayerEvent(final ILayerEvent event) {
+ calculateAndStoreNewSelection(event);
+ }
+ };
+ this.selectionLayer.addLayerListener(this.selectionListener);
+ this.currentSelection = new StructuredSelection();
+ this.listeners = new ArrayList<ISelectionChangedListener>();
+ }
+
+
+ public void addSelectionChangedListener(final ISelectionChangedListener listener) {
+ this.listeners.add(listener);
+
+ }
+
+ public ISelection getSelection() {
+ return this.currentSelection;
+ }
+
+ public void removeSelectionChangedListener(final ISelectionChangedListener listener) {
+ this.listeners.remove(listener);
+ }
+
+ public synchronized void setSelection(final ISelection selection) {
+ this.currentSelection = selection;
+ final SelectionChangedEvent event = new SelectionChangedEvent(this, this.currentSelection);
+ for(final ISelectionChangedListener current : this.listeners) {
+ current.selectionChanged(event);
+ }
+ }
+
+ protected/* synchronized */void calculateAndStoreNewSelection(final ILayerEvent event) {
+ if(event instanceof ColumnSelectionEvent) {
+ final ColumnSelectionEvent e = (ColumnSelectionEvent)event;
+ final int[] positions = this.selectionLayer.getSelectedColumnPositions();
+ // System.out.println(positions);
+ // this.selectionLayer.
+
+ } else if(event instanceof CellSelectionEvent) {
+ final CellSelectionEvent e = (CellSelectionEvent)event;
+ final int colPos = e.getColumnPosition();
+ final int rowPos = e.getRowPosition();
+ // System.out.println(colPos);
+ // System.out.println(rowPos);
+ int i = 0;
+ i++;
+ final ILayerCell cell = this.selectionLayer.getCellByPosition(colPos, rowPos);
+ if(cell != null) {
+ final Object value = cell.getDataValue();
+
+ if(value != null) {
+ if(value instanceof Collection<?>) {
+ final List<Object> selection = new ArrayList<Object>();
+ final Iterator<?> iter = ((Collection<?>)value).iterator();
+ while(iter.hasNext()) {
+ final Object current = iter.next();
+ selection.add(current);
+ setSelection(new StructuredSelection(selection));
+ }
+ } else {
+ setSelection(new StructuredSelection(value));
+ }
+
+ } else {
+ setSelection(new StructuredSelection());
+ }
+ } else {
+ setSelection(new StructuredSelection());
+ }
+
+ }
+ //must be done in a new thread?
+ }
+
+
+ public void dispose() {
+ this.selectionLayer.removeLayerListener(this.selectionListener);
+ this.selectionLayer = null;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/CompoundFilteredRestrictedContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/CompoundFilteredRestrictedContentProvider.java
new file mode 100644
index 00000000000..e0a8fef01b9
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/CompoundFilteredRestrictedContentProvider.java
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider.tmp;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;;
+/**
+ * This class allows to use several content provider for the same widget
+ * + restriction behavior see {@link IRestrictedContentProvider} documentation
+ *
+ * @author JC236769
+ *
+ */
+//FIXME must be deleted after the official extraplugins build and before Papyrus 0.10SR1
+public class CompoundFilteredRestrictedContentProvider extends org.eclipse.papyrus.infra.widgets.providers.CompoundFilteredRestrictedContentProvider implements org.eclipse.papyrus.infra.nattable.provider.tmp.IRestrictedContentProvider {
+
+ private List<IRestrictedContentProvider> encapsulatedContentProviders2 = new ArrayList<IRestrictedContentProvider>();
+
+ public boolean add(IRestrictedContentProvider o) {
+ super.add(o);
+ if(o != null) {
+ return encapsulatedContentProviders2.add(o);
+ }
+ return false;
+ }
+
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ List<Object> asList = new ArrayList<Object>();
+
+ for(IRestrictedContentProvider encapsulatedContentProvider : encapsulatedContentProviders2) {
+ Object[] directElements = encapsulatedContentProvider.getElements(inputElement);
+ asList.addAll(Arrays.asList(directElements));
+ }
+ return asList.toArray();
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ List<Object> asList = new ArrayList<Object>();
+
+ for(IRestrictedContentProvider encapsulatedContentProvider : encapsulatedContentProviders2) {
+ Object[] directElements = encapsulatedContentProvider.getChildren(parentElement);
+ if(directElements != null && directElements.length != 0) {
+ asList.addAll(Arrays.asList(directElements));
+ }
+ }
+ return asList.toArray();
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ for(IRestrictedContentProvider encapsulatedContentProvider : encapsulatedContentProviders2) {
+ Object parent = encapsulatedContentProvider.getParent(element);
+ if(parent != null) {
+ return parent;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return true;
+ }
+
+
+
+ @Override
+ public void dispose() {
+ // super.dispose();
+ this.encapsulatedContentProviders2.clear();
+ }
+
+ @Override
+ public void setRestriction(boolean isRestricted) {
+ for(IRestrictedContentProvider current : encapsulatedContentProviders2) {
+ current.setRestriction(isRestricted);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider#isRestricted()
+ *
+ * @return
+ */
+ public boolean isRestricted() {
+ if(!encapsulatedContentProviders2.isEmpty()) {
+ return ((org.eclipse.papyrus.infra.nattable.provider.tmp.IRestrictedContentProvider)encapsulatedContentProviders2.get(0)).isRestricted();
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isValidValue(Object element) {
+ boolean result = false;
+ for(final IRestrictedContentProvider current : encapsulatedContentProviders2) {
+ result = result || current.isValidValue(element);
+ }
+ return result;
+ }
+
+ @Override
+ public Object[] getElements() {
+ return getElements(null);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.tmp.IInheritedElementContentProvider#setIgnoreInheritedElements(boolean)
+ *
+ * @param ignoreInheritedElements
+ */
+ public void setIgnoreInheritedElements(boolean ignoreInheritedElements) {
+ for(final IRestrictedContentProvider current : encapsulatedContentProviders2) {
+ ((IInheritedElementContentProvider)current).setIgnoreInheritedElements(ignoreInheritedElements);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.tmp.IInheritedElementContentProvider#isIgnoringInheritedElements()
+ *
+ * @return
+ */
+ public boolean isIgnoringInheritedElements() {
+ return ((IInheritedElementContentProvider)encapsulatedContentProviders2.get(0)).isIgnoringInheritedElements();//the value is the same for all encapsulated content provider
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/FlattenableRestrictedFilteredContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/FlattenableRestrictedFilteredContentProvider.java
new file mode 100644
index 00000000000..292dbd2ed06
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/FlattenableRestrictedFilteredContentProvider.java
@@ -0,0 +1,192 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider.tmp;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractFilteredContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.HierarchicToFlatContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IFlattenableContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.selectors.ReferenceSelector;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ * @author JC236769
+ *
+ */
+//FIXME must be deleted after the official extraplugins build and before Papyrus 0.10SR1
+public class FlattenableRestrictedFilteredContentProvider extends AbstractFilteredContentProvider implements IStaticContentProvider, IRestrictedContentProvider, IFlattenableContentProvider {
+
+ private boolean isFlat = false;
+
+ private ReferenceSelector selector;
+
+ protected IRestrictedContentProvider provider;
+
+ protected HierarchicToFlatContentProvider flatProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param provider
+ * the encapsulated content provider
+ * @param selector
+ * the reference selector (we need it to refresh it)
+ */
+ public FlattenableRestrictedFilteredContentProvider(IRestrictedContentProvider provider, ReferenceSelector selector) {
+ this.provider = provider;
+ flatProvider = new HierarchicToFlatContentProvider(provider);
+ this.selector = selector;
+ }
+
+ /**
+ * Add 2 checkboxes to the dialog
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.AbstractFilteredContentProvider#createAfter(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ public void createAfter(final Composite parent) {
+
+ super.createAfter(parent);
+ Composite checkboxSection = new Composite(parent, SWT.NONE);
+ checkboxSection.setLayout(new FillLayout(SWT.VERTICAL));
+ final Button onlyCurrentContainersCheckbox = new Button(checkboxSection, SWT.CHECK);
+ onlyCurrentContainersCheckbox.setText("Show all possible values");
+
+ final Button showFlatListOfFeaturesCheckbox = new Button(checkboxSection, SWT.CHECK);
+ showFlatListOfFeaturesCheckbox.setText("Flat View");
+ onlyCurrentContainersCheckbox.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ setRestriction(!onlyCurrentContainersCheckbox.getSelection());
+ viewer.refresh();
+ selector.refresh();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+ showFlatListOfFeaturesCheckbox.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+
+ setFlat(showFlatListOfFeaturesCheckbox.getSelection());
+ viewer.refresh();
+ selector.refresh();
+
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if(isFlat) {
+ return flatProvider.getElements(inputElement);
+ }
+ return provider.getElements(inputElement);
+ }
+
+ @Override
+ public void dispose() {
+ flatProvider.dispose();
+ provider.dispose();
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ flatProvider.inputChanged(viewer, oldInput, newInput);
+ provider.inputChanged(viewer, oldInput, newInput);
+ }
+
+ public boolean isValidValue(Object element) {
+ return provider.isValidValue(element);
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if(isFlat) {
+ return new Object[0];
+ }
+ return provider.getChildren(parentElement);
+ }
+
+ public Object getParent(Object element) {
+ if(isFlat) {
+ return null;
+ }
+ return provider.getParent(element);
+ }
+
+ public boolean hasChildren(Object element) {
+ if(isFlat) {
+ return false;
+ }
+ return provider.hasChildren(element);
+ }
+
+ public void setRestriction(boolean isRestricted) {
+ provider.setRestriction(isRestricted);
+ }
+
+ public void setFlat(boolean flat) {
+ this.isFlat = flat;
+
+ }
+
+ public Object[] getElements() {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.tmp.IInheritedElementContentProvider#setIgnoreInheritedElements(boolean)
+ *
+ * @param ignoreInheritedElements
+ */
+ public void setIgnoreInheritedElements(boolean ignoreInheritedElements) {
+ provider.setIgnoreInheritedElements(ignoreInheritedElements);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.tmp.IInheritedElementContentProvider#isIgnoringInheritedElements()
+ *
+ * @return
+ */
+ public boolean isIgnoringInheritedElements() {
+ return provider.isIgnoringInheritedElements();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider#isRestricted()
+ *
+ * @return
+ */
+ public boolean isRestricted() {
+ return provider.isRestricted();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IIgnoreStereotypeBasePropertyContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IIgnoreStereotypeBasePropertyContentProvider.java
new file mode 100644
index 00000000000..f839849f992
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IIgnoreStereotypeBasePropertyContentProvider.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider.tmp;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+
+/**
+ * This interface adds 2 methods to allow to the content provider to ignore or not the properties base_ExtendedMetaclass
+ * in the stereotype properties
+ *
+ * @author vl222926
+ *
+ */
+//FIXME must be deleted after the official extraplugins build and before Papyrus 0.10SR1
+public interface IIgnoreStereotypeBasePropertyContentProvider extends IStructuredContentProvider {
+
+ /**
+ *
+ * @param ignoreBaseProperty
+ * the new value to use for the content provider. if <code>true</code> the base properties won't be returned
+ */
+ public void setIgnoreBaseProperty(final boolean ignoreBaseProperty);
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the content provider doesn't return the base properties
+ */
+ public boolean isIgnoringBaseProperty();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IInheritedElementContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IInheritedElementContentProvider.java
new file mode 100644
index 00000000000..33f01b2dd56
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IInheritedElementContentProvider.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider.tmp;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+
+/**
+ * This interface
+ *
+ * @author vl222926
+ *
+ */
+//FIXME must be deleted after the official extraplugins build and before Papyrus 0.10SR1
+public interface IInheritedElementContentProvider extends IStructuredContentProvider {
+
+ /**
+ *
+ * @param ignoreInheritedElements
+ * if <code>true</code> the inherited elements won't be returned
+ */
+ public void setIgnoreInheritedElements(final boolean ignoreInheritedElements);
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the content provider is ignoring the inherited elements
+ */
+ public boolean isIgnoringInheritedElements();
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IRestrictedContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IRestrictedContentProvider.java
new file mode 100644
index 00000000000..151b012e218
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/tmp/IRestrictedContentProvider.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider.tmp;
+
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+
+
+/**
+ * Add a boolean to choose the display mode :
+ * <ul>
+ * <li>display all possible values according to the model (restricted==false)</li>
+ * <li>display all possible values according to current edited object (restricted==true)</li>
+ * </ul>
+ *
+ * @author JC236769
+ *
+ */
+//FIXME must be deleted after the official extraplugins build and before Papyrus 0.10SR1
+public interface IRestrictedContentProvider extends IHierarchicContentProvider, IStaticContentProvider, org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider, IInheritedElementContentProvider {
+
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the content provider is restricted
+ */
+ public boolean isRestricted();
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomCellDragModeForColumn.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomCellDragModeForColumn.java
new file mode 100644
index 00000000000..d0589d99080
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomCellDragModeForColumn.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.reorder;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.action.CellDragMode;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ *
+ * This custom Cell Drag Mode allows to hide the phantom of the header when the drag of column is forbidden
+ *
+ */
+public class CustomCellDragModeForColumn extends CellDragMode {
+
+ /**
+ * The manager of the table
+ */
+ private final INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the manager of the table
+ */
+ public CustomCellDragModeForColumn(final INattableModelManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.action.CellDragMode#mouseDown(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseDown(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseDown(natTable, event);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.action.CellDragMode#mouseMove(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseMove(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseMove(natTable, event);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.action.CellDragMode#mouseUp(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseUp(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseUp(natTable, event);
+ }
+
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomColumnReorderDragMode.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomColumnReorderDragMode.java
new file mode 100644
index 00000000000..06d894cf01a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomColumnReorderDragMode.java
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.reorder;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.reorder.action.ColumnReorderDragMode;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ *
+ * This custom Drag Mode for columns allows to restrict the Drag of the Column
+ *
+ */
+public class CustomColumnReorderDragMode extends ColumnReorderDragMode {
+
+ /**
+ * the table manager
+ */
+ private INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the table manager
+ */
+ public CustomColumnReorderDragMode(final INattableModelManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.reorder.action.ColumnReorderDragMode#mouseDown(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseDown(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseDown(natTable, event);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.reorder.action.ColumnReorderDragMode#mouseMove(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseMove(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseMove(natTable, event);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.reorder.action.ColumnReorderDragMode#mouseUp(org.eclipse.nebula.widgets.nattable.NatTable,
+ * org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ public void mouseUp(NatTable natTable, MouseEvent event) {
+ if(this.manager.canMoveColumns()) {
+ super.mouseUp(natTable, event);
+ }
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomDefaultColumnReorderBindings.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomDefaultColumnReorderBindings.java
new file mode 100644
index 00000000000..1fb16f6a614
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/reorder/CustomDefaultColumnReorderBindings.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.reorder;
+
+import org.eclipse.nebula.widgets.nattable.reorder.config.DefaultColumnReorderBindings;
+import org.eclipse.nebula.widgets.nattable.ui.action.AggregateDragMode;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.swt.SWT;
+
+/**
+ *
+ * This bindings allows to move the columns, only when the manager allows it.
+ *
+ */
+public class CustomDefaultColumnReorderBindings extends DefaultColumnReorderBindings {
+
+ /**
+ * the table manager
+ */
+ private final INattableModelManager manager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param manager
+ * the table manager
+ */
+ public CustomDefaultColumnReorderBindings(final INattableModelManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.reorder.config.DefaultReorderBindings#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+ assert manager != null;
+ uiBindingRegistry.registerMouseDragMode(MouseEventMatcher.columnHeaderLeftClick(SWT.NONE), new AggregateDragMode(new CustomCellDragModeForColumn(this.manager), new CustomColumnReorderDragMode(this.manager)));
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/ITableTester.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/ITableTester.java
new file mode 100644
index 00000000000..6044e85572e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/ITableTester.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.tester;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * The interface to implements for the table creation tester
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public interface ITableTester {
+
+ /**
+ *
+ * @param context
+ * @return
+ * a status indicating if the table can be created
+ */
+ public IStatus isAllowed(final Object context);
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/TableTesterRegistry.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/TableTesterRegistry.java
new file mode 100644
index 00000000000..08bc630f184
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/tester/TableTesterRegistry.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.tester;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+
+
+public class TableTesterRegistry {
+
+
+ private static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.tester"; //$NON-NLS-1$
+
+ private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
+
+ private Map<String, ITableTester> testers;
+
+ public static final TableTesterRegistry INSTANCE = new TableTesterRegistry();
+
+ private TableTesterRegistry() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param tableType
+ * the type of the table
+ * @return
+ * the URI of the configuration to use for this table or <code>null</code> if not found
+ */
+ public ITableTester getTableTester(final String testerId) {
+ if(this.testers == null) {
+ this.testers = new HashMap<String, ITableTester>();
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ for(final IConfigurationElement iConfigurationElement : configElements) {
+ String id = iConfigurationElement.getAttribute(ID_ATTRIBUTE);
+ if(this.testers.containsKey(id)) {
+ Activator.log.warn(String.format(Messages.TableTesterRegistry_SeveralTesterAreRegisteredWithTheSameId, id));
+ } else {
+ ITableTester tester = null;
+ try {
+ tester = (ITableTester)iConfigurationElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ this.testers.put(id, tester);
+ } catch (CoreException e) {
+ Activator.log.error(String.format(Messages.TableTesterRegistry_TheClassCantBeLoaded, id), e);
+ }
+
+ }
+ }
+ }
+ return this.testers.get(testerId);
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisComparator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisComparator.java
new file mode 100644
index 00000000000..a623bdc7129
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisComparator.java
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import java.util.Comparator;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+
+
+/**
+ * The comparator used to sort IAxis
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class AxisComparator implements Comparator<IAxis> {
+
+ /**
+ * indicates the direction of the sort
+ */
+ private boolean alphabeticOrder;
+
+ /**
+ * the config registry is used to find the label provider service
+ */
+ private IConfigRegistry configRegistry;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param alphabeticOrder
+ * indicates the direction of the sort
+ * @param configRegistry
+ * the config registry used by the table
+ */
+ public AxisComparator(boolean alphabticOrder, final IConfigRegistry configRegistry) {
+ this.alphabeticOrder = alphabticOrder;
+ this.configRegistry = configRegistry;
+ }
+
+ /**
+ * Compare 2 {@link IAxis}
+ *
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param arg0
+ * @param arg1
+ * @return
+ */
+ public int compare(IAxis arg0, IAxis arg1) {
+ LabelProviderService serv = this.configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ Object element0 = arg0.getElement();
+ Object element1 = arg1.getElement();
+ final String str1 = getText(serv, element0).replaceAll(AxisUtils.REGEX, "");//we keep only words characters (letters + numbers) + whitespace
+ final String str2 = getText(serv, element1).replaceAll(AxisUtils.REGEX, "");
+ if(this.alphabeticOrder) {
+ return str1.compareToIgnoreCase(str2);
+ }
+ return str2.compareToIgnoreCase(str1);
+
+ }
+
+ /**
+ *
+ * @param serv
+ * the label provider service
+ * @param obj
+ * the object for which we want the displayed text
+ * @return
+ */
+ protected String getText(final LabelProviderService serv, final Object obj) {
+ final ILabelProvider provider = serv.getLabelProvider(Constants.HEADER_LABEL_PROVIDER_CONTEXT);
+ return provider.getText(new LabelProviderContextElementWrapper(obj, this.configRegistry));
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisUtils.java
new file mode 100644
index 00000000000..d0bbb8df3a9
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/AxisUtils.java
@@ -0,0 +1,127 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IdAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+
+/**
+ * Common methods for axis management
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class AxisUtils {
+
+ private AxisUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ * This regex allows to find all word character (letters + numbers)+ the whitespace
+ */
+ public static final String REGEX = "[^\\w\\s]";
+
+ /**
+ * This methods avoid to duplicate these some lines
+ *
+ * @param axisElement
+ * an axis element
+ * @return
+ * if the axis element is a String returns it and if the axis element is an instance of IdAxis, returns the String represented by this
+ * axis
+ */
+ public static final String getPropertyId(final Object axisElement) {
+ String id = null;
+ if(axisElement instanceof IdAxis) {
+ id = ((IdAxis)axisElement).getElement();
+ } else if(axisElement instanceof String) {
+ id = (String)axisElement;
+ }
+ return id;
+ }
+
+ /**
+ *
+ * @param axisElement
+ * an axis element
+ * @return
+ * if axisElement is an IAxis, we return the element represented by the IAxis using IAxis.getElement() else we return the element itself
+ */
+ public static final Object getRepresentedElement(final Object axisElement) {
+ Object representedElement;
+ if(axisElement instanceof IAxis) {
+ representedElement = ((IAxis)axisElement).getElement();
+ } else {
+ representedElement = axisElement;
+ }
+ return representedElement;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the axismanager used for rows, managing the invert axis
+ */
+ public static final AbstractAxisProvider getAxisProviderUsedForRows(final Table table) {
+ AbstractAxisProvider provider = table.getCurrentRowAxisProvider();
+ if(table.isInvertAxis()) {
+ provider = table.getCurrentColumnAxisProvider();
+ }
+ return provider;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the axismanager used for columns, managing the invert axis
+ */
+ public static final AbstractAxisProvider getAxisProviderUsedForColumns(final Table table) {
+ AbstractAxisProvider provider = table.getCurrentColumnAxisProvider();
+ if(table.isInvertAxis()) {
+ provider = table.getCurrentRowAxisProvider();
+ }
+ return provider;
+ }
+
+ /**
+ *
+ * @param manager
+ * a table manager
+ * @return
+ * the axismanager used for rows, managing the invert axis
+ */
+ public static final AbstractAxisProvider getAxisProviderUsedForRows(final INattableModelManager manager) {
+ return getAxisProviderUsedForRows(manager.getTable());
+ }
+
+ /**
+ *
+ * @param manager
+ * a table manager
+ * @return
+ * the axismanager used for columns, managing the invert axis
+ */
+ public static final AbstractAxisProvider getAxisProviderUsedForColumns(final INattableModelManager manager) {
+ return getAxisProviderUsedForColumns(manager.getTable());
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/Constants.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/Constants.java
new file mode 100644
index 00000000000..69ecc790412
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/Constants.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+
+
+public class Constants {
+
+ private Constants() {
+ //to prevent instanciation
+ }
+
+ public static final String BEGIN_OF_COLLECTION = "["; //$NON-NLS-1$
+
+ public static final String END_OF_COLLECTION = "]"; //$NON-NLS-1$
+
+ public static final String SEPARATOR = ", "; //$NON-NLS-1$
+
+ public static final String NOT_AVALAIBLE = "N/A";//$NON-NLS-1$
+
+ public static final String INFINITY_STAR = "*";
+
+ public static final String INFINITE_MINUS_ONE = "-1";
+
+ /**
+ * the context to use to find the label provider used to display values in cells and headers
+ */
+ public static final String TABLE_LABEL_PROVIDER_CONTEXT = "org.eclipse.papyrus.infra.nattable.full.labelprovider";
+
+ /**
+ * the context to use to find the label provider used to display values in the headers
+ */
+ public static final String HEADER_LABEL_PROVIDER_CONTEXT = "org.eclipse.papyrus.infra.nattable.header.labelprovider";
+
+ /**
+ * the context to use to find the label provider used to display values in the body of the table
+ */
+
+ public static final String BODY_LABEL_PROVIDER_CONTEXT = "org.eclipse.papyrus.infra.nattable.body.labelprovider";
+
+ /**
+ * The name of the parameter used for the sort command
+ */
+ public static final String SORT_COMMAND_PARAMETER = "org.eclipse.papyrus.infra.nattable.sort.command.alphabetic.order.parameter";
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/HeaderAxisConfigurationManagementUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/HeaderAxisConfigurationManagementUtils.java
new file mode 100644
index 00000000000..eae0469748c
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/HeaderAxisConfigurationManagementUtils.java
@@ -0,0 +1,167 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.emf.validation.internal.service.GetLiveConstraintsOperation;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.LocalTableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+
+/**
+ * Utils class for AxisConfiguration
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class HeaderAxisConfigurationManagementUtils {
+
+ private HeaderAxisConfigurationManagementUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the header configuration defined in the table and used for rows, mananing the inversion of the axis or <code>null</code> if we aer
+ * using the
+ * configuration defined in the table configuration
+ */
+ public static final AbstractHeaderAxisConfiguration getRowAbstractHeaderAxisInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getLocalColumnHeaderAxisConfiguration();
+ }
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the header configuration defined in the tableconfiguration for rows, mananing the inversion of the axis. The result can't be
+ * <code>null</code>
+ */
+ public static final AbstractHeaderAxisConfiguration getRowAbstractHeaderAxisInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ }
+ assert config != null;
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the header configuration used for rows in the table. The result can't be <code>null</code>
+ */
+ public static final AbstractHeaderAxisConfiguration getAbstractHeaderAxisConfigurationUsedInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = getRowAbstractHeaderAxisInTable(table);
+ if(config == null) {
+ config = getRowAbstractHeaderAxisInTableConfiguration(table);
+ }
+ assert config != null;
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the header configuration defined in the table and used for columns, managing the inversion of the axis or <code>null</code> if we are
+ * using the configuration defined in the table configuration
+ */
+ public static final AbstractHeaderAxisConfiguration getColumnAbstractHeaderAxisInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalColumnHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getLocalRowHeaderAxisConfiguration();
+ }
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the header configuration defined in the tableconfiguration for columns, mananing the inversion of the axis. The result can't be
+ * <code>null</code>
+ */
+ public static final AbstractHeaderAxisConfiguration getColumnAbstractHeaderAxisInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ }
+ assert config != null;
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the header configuration used for columns in the table. The result can't be <code>null</code>
+ */
+ public static final AbstractHeaderAxisConfiguration getColumnAbstractHeaderAxisUsedInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = getColumnAbstractHeaderAxisInTable(table);
+ if(config == null) {
+ config = getColumnAbstractHeaderAxisInTableConfiguration(table);
+ }
+ assert config != null;
+ return config;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the header configuration used for row in the table. The result can't be <code>null</code>
+ */
+ public static final AbstractHeaderAxisConfiguration getRowAbstractHeaderAxisUsedInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = getRowAbstractHeaderAxisInTable(table);
+ if(config == null) {
+ config = getRowAbstractHeaderAxisInTableConfiguration(table);
+ }
+ assert config != null;
+ return config;
+ }
+
+ /**
+ *
+ * @param configuration
+ * the configuration to duplicate
+ * @return
+ * the {@link LocalTableHeaderAxisConfiguration} mapped on the {@link TableHeaderAxisConfiguration}
+ */
+ public static LocalTableHeaderAxisConfiguration transformToLocalHeaderConfiguration(final TableHeaderAxisConfiguration configuration) {
+ LocalTableHeaderAxisConfiguration conf = NattableaxisconfigurationFactory.eINSTANCE.createLocalTableHeaderAxisConfiguration();
+ conf.setDisplayFilter(configuration.isDisplayFilter());
+ conf.setDisplayIndex(configuration.isDisplayIndex());
+ conf.setDisplayLabel(configuration.isDisplayLabel());
+ conf.setIndexStyle(configuration.getIndexStyle());
+ return conf;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderCellContextElementWrapper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderCellContextElementWrapper.java
new file mode 100644
index 00000000000..ae7cf708c22
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderCellContextElementWrapper.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+
+
+/**
+ * This interface provides specific methods to allows to get a label with its context (object and edited feature)
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+//FIXME : must implements ILayerCell
+public interface ILabelProviderCellContextElementWrapper extends ILabelProviderContextElementWrapper , ILayerCell{
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderContextElementWrapper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderContextElementWrapper.java
new file mode 100644
index 00000000000..d9a90866edd
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/ILabelProviderContextElementWrapper.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+
+
+/**
+ * This interface provides specific methods to allows to get a label with its context (object and edited feature)
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public interface ILabelProviderContextElementWrapper {
+
+ /**
+ *
+ * @return
+ * the config registry which can provide useful information
+ */
+ public IConfigRegistry getConfigRegistry();
+
+ /**
+ *
+ * @return
+ * the object for which we want the label
+ */
+ public Object getObject();
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/IPasteInTableCommandProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/IPasteInTableCommandProvider.java
new file mode 100644
index 00000000000..51e2003373a
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/IPasteInTableCommandProvider.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.papyrus.infra.nattable.exception.ErrorInPastePreparationException;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ *
+ * Interface for paste in table command provider
+ *
+ */
+public interface IPasteInTableCommandProvider {
+
+ /**
+ *
+ * @param table
+ * the table where the clipboard contents is pasted
+ * @param commandCreationCancelProvider
+ * a progress monitor enabled to provide a cancel during the command creation (can be <code>null</code>)
+ * @param commandExecutionProgressMonitor
+ * the progress monitor used during the command execution (can be <code>null</code>)
+ * @param clipboardContents
+ * the clipboard contents
+ *
+ * @return
+ * the command to create the paste in the table command
+ * @throws ErrorInPastePreparationException
+ */
+ //FIXME : update documentation
+ public ICommand getPasteFromFromStringCommand(final TransactionalEditingDomain editingDomain,final Table table, final IProgressMonitor commandCreationCancelProvider, final ProgressMonitorDialog commandExecutionProgressMonitor, final String clipboardContents, final INattableModelManager tableManager) throws ErrorInPastePreparationException;
+
+ /**
+ *
+ * @param papyrusTable
+ * the paste table where the paste is done
+ * @param clipboardContents
+ * the clipboard contents
+ * @param iTableWidget
+ * the nattable widget
+ * @return
+ * <code>true</code> if the paste is allowed in the table
+ */
+ //FIXME : update documentation
+// public boolean isPasteEnabled(final Table papyrusTable, final String clipboardContents);
+
+ /**
+ *
+ * @return
+ * a string represented an error message. This message will be displayed to the user
+ */
+// public String getPasteErrorMessage();
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelConfigurationManagementUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelConfigurationManagementUtils.java
new file mode 100644
index 00000000000..411f23cb9dd
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelConfigurationManagementUtils.java
@@ -0,0 +1,310 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.FeatureLabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ILabelProviderConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablelabelprovider.ObjectLabelProviderConfiguration;
+
+/**
+ * Utils class for LabelConfiguration management
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class LabelConfigurationManagementUtils {
+
+ private LabelConfigurationManagementUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the FeatureLabelProviderConfiguration for rows defined in the table, managing the inversion of the axis or <code>null</code>
+ */
+ public static final FeatureLabelProviderConfiguration getRowFeatureLabelConfigurationInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getLocalColumnHeaderAxisConfiguration();
+ }
+ if(config != null) {
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof FeatureLabelProviderConfiguration) {
+ return (FeatureLabelProviderConfiguration)current;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the FeatureLabelProviderConfiguration for rows defined in the configuration, managing the inversion of the axis or <code>null</code>
+ */
+ public static final FeatureLabelProviderConfiguration getRowFeatureLabelConfigurationInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ }
+ //can be null according to the metamodel
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof FeatureLabelProviderConfiguration) {
+ return (FeatureLabelProviderConfiguration)current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * <code>true</code> if a FeatureLabelProviderConfiguration is defined for rows for the table, managing the inversion of the axis
+ */
+ public static final boolean hasRowFeatureLabelConfiguration(final Table table) {
+ return getRowFeatureLabelConfigurationInTable(table) != null || getRowFeatureLabelConfigurationInTableConfiguration(table) != null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the FeatureLabelProviderConfiguration for columns defined in the table, managing the inversion of the axis or <code>null</code>
+ */
+ public static final FeatureLabelProviderConfiguration getColumnFeatureLabelConfigurationInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalRowHeaderAxisConfiguration();
+ if(!table.isInvertAxis()) {
+ config = table.getLocalColumnHeaderAxisConfiguration();
+ }
+ if(config != null) {
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof FeatureLabelProviderConfiguration) {
+ return (FeatureLabelProviderConfiguration)current;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the FeatureLabelProviderConfiguration for columns defined in the configuration, managing the inversion of the axis or <code>null</code>
+ */
+ public static final FeatureLabelProviderConfiguration getColumnFeatureLabelConfigurationInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ if(!table.isInvertAxis()) {
+ config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ }
+ //can be null according to the metamodel
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof FeatureLabelProviderConfiguration) {
+ return (FeatureLabelProviderConfiguration)current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * <code>true</code> if a FeatureLabelProviderConfiguration is defined for columns for the table, managing the inversion of the axis
+ */
+ public static final boolean hasColumnFeatureLabelConfiguration(final Table table) {
+ return getColumnFeatureLabelConfigurationInTable(table) != null || getColumnFeatureLabelConfigurationInTableConfiguration(table) != null;
+ }
+
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the ObjectLabelProviderConfiguration for rows defined in the table, managing the inversion of the axis or <code>null</code>
+ */
+ public static final ObjectLabelProviderConfiguration getRowObjectLabelConfigurationInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getLocalColumnHeaderAxisConfiguration();
+ }
+ if(config != null) {
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ return (ObjectLabelProviderConfiguration)current;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the ObjectLabelProviderConfiguration for rows defined in the configuration, managing the inversion of the axis or <code>null</code>
+ */
+ public static final ObjectLabelProviderConfiguration getRowObjectLabelConfigurationInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ if(table.isInvertAxis()) {
+ config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ }
+ //can be null according to the metamodel
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ return (ObjectLabelProviderConfiguration)current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * <code>true</code> if a ObjectLabelProviderConfiguration is defined for rows for the table, managing the inversion of the axis
+ */
+ public static final boolean hasRowObjectLabelConfiguration(final Table table) {
+ return getRowObjectLabelConfigurationInTable(table) != null || getRowObjectLabelConfigurationInTableConfiguration(table) != null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the ObjectLabelProviderConfiguration for columns defined in the table, managing the inversion of the axis or <code>null</code>
+ */
+ public static final ObjectLabelProviderConfiguration getColumnObjectLabelConfigurationInTable(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getLocalRowHeaderAxisConfiguration();
+ if(!table.isInvertAxis()) {
+ config = table.getLocalColumnHeaderAxisConfiguration();
+ }
+ if(config != null) {
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ return (ObjectLabelProviderConfiguration)current;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * the ObjectLabelProviderConfiguration for columns defined in the configuration, managing the inversion of the axis or <code>null</code>
+ */
+ public static final ObjectLabelProviderConfiguration getColumnObjectLabelConfigurationInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration config = table.getTableConfiguration().getRowHeaderAxisConfiguration();
+ if(!table.isInvertAxis()) {
+ config = table.getTableConfiguration().getColumnHeaderAxisConfiguration();
+ }
+ //can be null according to the metamodel
+ for(final ILabelProviderConfiguration current : config.getOwnedLabelConfigurations()) {
+ if(current instanceof ObjectLabelProviderConfiguration) {
+ return (ObjectLabelProviderConfiguration)current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * a table
+ * @return
+ * <code>true</code> if a ObjectLabelProviderConfiguration is defined for columns for the table, managing the inversion of the axis
+ */
+ public static final boolean hasColumnObjectLabelConfiguration(final Table table) {
+ return getColumnObjectLabelConfigurationInTable(table) != null || getColumnObjectLabelConfigurationInTableConfiguration(table) != null;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the object label configuration currently used in the table
+ */
+ public static final FeatureLabelProviderConfiguration getUsedColumnFeatureLabelConfiguration(final Table table) {
+ FeatureLabelProviderConfiguration conf = getColumnFeatureLabelConfigurationInTable(table);
+ if(conf == null) {
+ conf = getColumnFeatureLabelConfigurationInTableConfiguration(table);
+ }
+ return conf;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the object label configuration currently used in the table
+ */
+ public static final FeatureLabelProviderConfiguration getUsedRowFeatureLabelConfiguration(final Table table) {
+ FeatureLabelProviderConfiguration conf = getRowFeatureLabelConfigurationInTable(table);
+ if(conf == null) {
+ conf = getRowFeatureLabelConfigurationInTableConfiguration(table);
+ }
+ return conf;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the object label configuration currently used in the table
+ */
+ public static final ObjectLabelProviderConfiguration getUsedColumnObjectLabelConfiguration(final Table table) {
+ ObjectLabelProviderConfiguration conf = getColumnObjectLabelConfigurationInTable(table);
+ if(conf == null) {
+ conf = getColumnObjectLabelConfigurationInTableConfiguration(table);
+ }
+ return conf;
+ }
+
+ /**
+ *
+ * @param table
+ * the table
+ * @return
+ * the object label configuration currently used in the table
+ */
+ public static final ObjectLabelProviderConfiguration getUsedRowObjectLabelConfiguration(final Table table) {
+ ObjectLabelProviderConfiguration conf = getRowObjectLabelConfigurationInTable(table);
+ if(conf == null) {
+ conf = getRowObjectLabelConfigurationInTableConfiguration(table);
+ }
+ return conf;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderCellContextElementWrapper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderCellContextElementWrapper.java
new file mode 100644
index 00000000000..687aa30df76
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderCellContextElementWrapper.java
@@ -0,0 +1,221 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * This object can used as context to find the best label provider and get the text to display.
+ * Its allows to have the context of the value to use it in the label provider
+ *
+ * This objects can be used to get the label of an object which is not the current value of the cell, using the label provider used by the cell.
+ * example to get the value of the enumeration literal in the combo box for uml stereotype properties
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+
+public class LabelProviderCellContextElementWrapper extends LabelProviderContextElementWrapper implements ILabelProviderCellContextElementWrapper {
+
+ /** the cell. */
+ private ILayerCell cell;
+
+ /**
+ * *
+ * Constructor.
+ *
+ * @param cell
+ * the cell for which we want the label/icon, ...
+ * @param registry
+ * the registry used by nattable
+ */
+ public LabelProviderCellContextElementWrapper(ILayerCell cell, final IConfigRegistry registry) {
+ this(cell, cell.getDataValue(), registry);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param cell
+ * the cell
+ * @param value
+ * a value
+ * @param registry
+ * the registry used by nattable
+ */
+ public LabelProviderCellContextElementWrapper(ILayerCell cell, final Object value, final IConfigRegistry registry) {
+ super(value, registry);
+ this.cell = cell;
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getConfigLabels()
+ *
+ * @return
+ */
+
+ @Override
+ public LabelStack getConfigLabels() {
+ return this.cell.getConfigLabels();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getOriginColumnPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public int getOriginColumnPosition() {
+ return cell.getOriginColumnPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getOriginRowPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public int getOriginRowPosition() {
+ return cell.getOriginRowPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getLayer()
+ *
+ * @return
+ */
+
+ @Override
+ public ILayer getLayer() {
+ return cell.getLayer();
+ }
+
+ /**
+ * Gets the column position.
+ *
+ * @return the column position
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getColumnPosition()
+ */
+
+ @Override
+ public int getColumnPosition() {
+ return cell.getColumnPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getRowPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public int getRowPosition() {
+ return cell.getRowPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getColumnIndex()
+ *
+ * @return
+ */
+
+ @Override
+ public int getColumnIndex() {
+ return cell.getColumnIndex();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getRowIndex()
+ *
+ * @return
+ */
+
+ @Override
+ public int getRowIndex() {
+ return cell.getRowIndex();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getColumnSpan()
+ *
+ * @return
+ */
+
+ @Override
+ public int getColumnSpan() {
+ return cell.getColumnSpan();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getRowSpan()
+ *
+ * @return
+ */
+
+ @Override
+ public int getRowSpan() {
+ return cell.getRowSpan();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#isSpannedCell()
+ *
+ * @return
+ */
+
+ @Override
+ public boolean isSpannedCell() {
+ return cell.isSpannedCell();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getDisplayMode()
+ *
+ * @return
+ */
+
+ @Override
+ public String getDisplayMode() {
+ return cell.getDisplayMode();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getDataValue()
+ *
+ * @return
+ */
+ @Override
+ public final Object getDataValue() {
+ throw new UnsupportedOperationException("You must use ILabelProviderCellContextElement#getObject()"); //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell#getBounds()
+ *
+ * @return
+ */
+
+ @Override
+ public Rectangle getBounds() {
+ return cell.getBounds();
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderContextElementWrapper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderContextElementWrapper.java
new file mode 100644
index 00000000000..6b44ccb6353
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LabelProviderContextElementWrapper.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+
+/**
+ * This object can used as context to find the best label provider and get the text to display.
+ * Its allows to have the context of the value to use it in the label provider
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class LabelProviderContextElementWrapper implements ILabelProviderContextElementWrapper {
+
+ /**
+ * the config registry of the table
+ */
+ private IConfigRegistry registry;
+
+ /**
+ * the object for which we want the label
+ */
+ private Object object;
+
+ /**
+ * *
+ * Constructor.
+ *
+ * @param object
+ * the cell for which we want the label/icon, ...
+ * @param registry
+ * the registry used by nattable
+ */
+ public LabelProviderContextElementWrapper(final Object object, final IConfigRegistry registry) {
+ this.object = object;
+ this.registry = registry;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper#getConfigRegistry()
+ *
+ * @return
+ */
+ public IConfigRegistry getConfigRegistry() {
+ return this.registry;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Object getObject() {
+ return this.object;
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LocationValue.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LocationValue.java
new file mode 100644
index 00000000000..9013e936401
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/LocationValue.java
@@ -0,0 +1,229 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ *
+ * This class allows to store information about a location
+ *
+ */
+public class LocationValue {
+
+ /**
+ * the initial point (mouse information)
+ */
+ final private Point absolutePoint;
+
+ /**
+ * the same point, but in the coordinate of the widget
+ */
+ final private Point widgetPoint;
+
+
+ /**
+ * the kind of the location
+ */
+ final private TableGridRegion kind;
+
+ /**
+ * the column index
+ */
+ final private int columnIndex;
+
+ /**
+ * the row index
+ */
+ final private int rowIndex;
+
+ /**
+ * the layerCell if this location
+ */
+ final private ILayerCell layerCell;
+
+ /**
+ * the columnObject
+ */
+ final private Object columnObject;
+
+ /**
+ * the rowObject
+ */
+ final private Object rowObject;
+
+ /**
+ * Constructor.
+ *
+ * @param kind
+ * the kind of location
+ * @param cell
+ * the cell located as this place
+ * @param columnIndex
+ * the columnIndex
+ * @param rowIndex
+ * the rowIndex
+ * @param columnObject
+ * the column object
+ * @param rowObject
+ * the row object
+ */
+ public LocationValue(final TableGridRegion kind, final ILayerCell cell, final int columnIndex, final int rowIndex, final Object columnObject, final Object rowObject) {
+ this(null, null, kind, cell, columnIndex, rowIndex, columnObject, rowObject);
+ }
+
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param absoluteLocation
+ * a location in the absolute coordinate
+ * @param widgetLocation
+ * the same point, but with the widget coordinate
+ * @param kind
+ * the kind of location
+ * @param cell
+ * the cell located as this place
+ * @param columnIndex
+ * the columnIndex
+ * @param rowIndex
+ * the rowIndex
+ * @param columnObject
+ * the column object
+ * @param rowObject
+ * the row object
+ */
+ public LocationValue(final Point absoluteLocation, final Point widgetLocation, final TableGridRegion kind, final ILayerCell cell, final int columnIndex, final int rowIndex, final Object columnObject, final Object rowObject) {
+ this.absolutePoint = absoluteLocation;
+ this.widgetPoint = widgetLocation;
+ this.kind = kind;
+ this.layerCell = cell;
+ this.columnIndex = columnIndex;
+ this.rowIndex = rowIndex;
+ this.columnObject = columnObject;
+ this.rowObject = rowObject;
+ }
+
+ /**
+ * Gets the point.
+ *
+ * @return the point
+ */
+ public Point getPoint() {
+ return absolutePoint;
+ }
+
+
+ /**
+ * Gets the translated point.
+ *
+ * @return the translated point
+ */
+ public Point getTranslatedPoint() {
+ return widgetPoint;
+ }
+
+ /**
+ * Gets the kind.
+ *
+ * @return the kind
+ */
+ public TableGridRegion getKind() {
+ return kind;
+ }
+
+
+ /**
+ * Gets the column index.
+ *
+ * @return the column index
+ */
+ public int getColumnIndex() {
+ return columnIndex;
+ }
+
+
+ /**
+ * Gets the row index.
+ *
+ * @return the row index
+ */
+ public int getRowIndex() {
+ return rowIndex;
+ }
+
+
+ /**
+ * Gets the layer cell.
+ *
+ * @return the layer cell
+ */
+ public ILayerCell getLayerCell() {
+ return layerCell;
+ }
+
+ /**
+ * Gets the absolute point.
+ *
+ * @return the absolute point
+ */
+ public Point getAbsolutePoint() {
+ return absolutePoint;
+ }
+
+
+ /**
+ * Gets the widget point.
+ *
+ * @return the widget point
+ */
+ public Point getWidgetPoint() {
+ return widgetPoint;
+ }
+
+
+ /**
+ * Gets the column object.
+ *
+ * @return the column object
+ */
+ public Object getColumnObject() {
+ return columnObject;
+ }
+
+
+ /**
+ * Gets the row object.
+ *
+ * @return the row object
+ */
+ public Object getRowObject() {
+ return rowObject;
+ }
+
+ /**
+ *
+ * @see java.lang.Object#toString()
+ *
+ * @return
+ */
+ @Override
+ public String toString() {
+ String message = "location : " + this.kind + ", columnIndex :" + this.columnIndex + ", rowIndex :" + this.rowIndex + ", columnObject :" + this.columnObject + ", rowObject :" + this.rowObject;
+ return message;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigAttributes.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigAttributes.java
new file mode 100644
index 00000000000..262a8d7c924
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigAttributes.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.nebula.widgets.nattable.style.ConfigAttribute;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+
+/**
+ * This class references the keys registered in the ConfigRegistry of the table to facilitate access to these objects
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class NattableConfigAttributes {
+
+ private NattableConfigAttributes() {
+ //to prevent instaciantionF
+ }
+
+ /**
+ * The config attribute used to register the table model manager
+ *
+ * <ul>
+ * <li>To store it :
+ * <code> configRegistry.registerConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, YOUR_NATTABLE_MODEL_MANAGER, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);</code>
+ * </li>
+ * <li>To get it : <code></code></li>
+ * </ul>
+ */
+ public static final ConfigAttribute<INattableModelManager> NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE = new ConfigAttribute<INattableModelManager>();//FIXME : try to create a new interface to limit the access of the method
+
+ /**
+ * The config attribute used to register the label provider service
+ *
+ * <ul>
+ * <li>To store it :
+ * <code> configRegistry.registerConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, YOUR_LABEL_PROVER_SERVICE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);</code>
+ * </li>
+ * <li>To get it : <code></code></li>
+ * LabelProviderService serv = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE,
+ * DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ * </ul>
+ */
+ public static final ConfigAttribute<LabelProviderService> LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE = new ConfigAttribute<LabelProviderService>();
+
+ /**
+ * Id used to register the label provider service
+ */
+ public static final String LABEL_PROVIDER_SERVICE_ID = "label_provider_service_id";
+
+ /**
+ * Id used to registrer the table model manager
+ */
+ public static final String NATTABLE_MODEL_MANAGER_ID = "nattable_model_manager_id";
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java
new file mode 100644
index 00000000000..819ae160b3d
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableWidgetPropertyTester.java
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.ISlaveAxisProvider;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+
+public class NattableWidgetPropertyTester extends PropertyTester {
+
+ public static final String IS_NATTABLE_WIDGET = "isNattableWidget"; //$NON-NLS-1$
+
+ private static final String HAS_FEATURE_ROW_HEADER_CONFIGURATION = "hasFeatureRowHeaderConfiguration"; //$NON-NLS-1$
+
+ private static final String HAS_FEATURE_COLUMN_HEADER_CONFIGURATION = "hasFeatureColumnHeaderConfiguration"; //$NON-NLS-1$
+
+ private static final String HAS_SLAVE_ROWS_AXIS_PROVIDER = "hasSlaveRowAxisProvider"; //$NON-NLS-1$
+
+ private static final String HAS_SLAVE_COLUMNS_AXIS_PROVIDER = "hasSlaveColumnAxisProvider"; //$NON-NLS-1$
+
+ private static final String CAN_INVERT_AXIS = "canInvertAxis";//$NON-NLS-1$
+
+ public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
+ final INattableModelManager manager = getNattableModelManager();
+ if(IS_NATTABLE_WIDGET.equals(property) && expectedValue instanceof Boolean) {
+ return expectedValue.equals(manager != null);
+ }
+ if(manager != null && expectedValue instanceof Boolean) {
+ if(HAS_FEATURE_ROW_HEADER_CONFIGURATION.equals(property)) {
+ LabelConfigurationManagementUtils.getRowFeatureLabelConfigurationInTable(manager.getTable());
+ return expectedValue.equals(LabelConfigurationManagementUtils.hasRowFeatureLabelConfiguration(manager.getTable()));
+ } else if(HAS_FEATURE_COLUMN_HEADER_CONFIGURATION.equals(property)) {
+ return expectedValue.equals(LabelConfigurationManagementUtils.hasColumnFeatureLabelConfiguration(manager.getTable()));
+ } else if(HAS_SLAVE_COLUMNS_AXIS_PROVIDER.equals(property)) {
+ return expectedValue.equals(AxisUtils.getAxisProviderUsedForColumns(manager) instanceof ISlaveAxisProvider);
+ } else if(HAS_SLAVE_ROWS_AXIS_PROVIDER.equals(property)) {
+ return expectedValue.equals(AxisUtils.getAxisProviderUsedForRows(manager) instanceof ISlaveAxisProvider);
+ } else if(CAN_INVERT_AXIS.equals(property)) {
+ return expectedValue.equals(manager.canInvertAxis());
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return
+ * the current nattable model manager or <code>null</code> if not found
+ */
+ protected INattableModelManager getNattableModelManager() {
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchPart current = null;
+ if(workbench != null) {
+ final IWorkbenchWindow activeWorkbench = workbench.getActiveWorkbenchWindow();
+ if(activeWorkbench != null) {
+ final IWorkbenchPage activePage = activeWorkbench.getActivePage();
+ if(activePage != null) {
+ current = activePage.getActivePart();
+ }
+ }
+ }
+
+ if(current != null) {
+ return (INattableModelManager)current.getAdapter(INattableModelManager.class);
+ }
+ return null;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtil.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtil.java
new file mode 100644
index 00000000000..4dd1b51e9e3
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtil.java
@@ -0,0 +1,35 @@
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+
+
+public class PasteConfigurationUtil {
+
+
+ private PasteConfigurationUtil() {
+ //to prevent instanciation
+ }
+
+ public static final IPasteConfiguration getRowPasteConfigurationDefinedInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration conf = HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(table);
+ for(final IAxisConfiguration current : conf.getOwnedAxisConfigurations()) {
+ if(current instanceof IPasteConfiguration) {
+ return (IPasteConfiguration)current;
+ }
+ }
+ return null;
+ }
+
+ public static final IPasteConfiguration getColumnPasteConfigurationDefinedInTableConfiguration(final Table table) {
+ AbstractHeaderAxisConfiguration conf = HeaderAxisConfigurationManagementUtils.getColumnAbstractHeaderAxisInTableConfiguration(table);
+ for(final IAxisConfiguration current : conf.getOwnedAxisConfigurations()) {
+ if(current instanceof IPasteConfiguration) {
+ return (IPasteConfiguration)current;
+ }
+ }
+ return null;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java
new file mode 100644
index 00000000000..585d6832f0e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/StringComparator.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * 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:
+ * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import java.util.Comparator;
+
+/**
+ *
+ * String comparator ignoring all non-words character
+ *
+ */
+public class StringComparator implements Comparator<String> {
+
+ /**
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ public int compare(String str1, String str2) {
+ str1 = str1.replaceAll(AxisUtils.REGEX, "");//$NON-NLS-1$ //we keep only words characters (letters + numbers) + whitespace
+ str2 = str2.replaceAll(AxisUtils.REGEX, ""); //$NON-NLS-1$
+ return str1.compareToIgnoreCase(str2);
+ };
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java
new file mode 100644
index 00000000000..c6436cf359f
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+
+public class TableClipboardUtils {
+
+ /**
+ * row separator in the clipboard contents
+ */
+ public static final String ROW_SEPARATOR = "\n"; //$NON-NLS-1$
+
+ /**
+ * column separator in the clipboard contents
+ */
+ public static final String COLUMN_SEPARATOR = "\t"; //$NON-NLS-1$
+
+ /**
+ * the separator used for multivalue
+ */
+ public static final String MULTI_VALUE_SEPARATOR = ","; //$NON-NLS-1$
+
+ private TableClipboardUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param fullContents
+ * a table represented by a String
+ * @return the rows for this table
+ */
+ public static final String[] getRows(final String fullContents) {
+ final String[] rows = fullContents.split(ROW_SEPARATOR);
+ return rows;
+ }
+
+ /**
+ *
+ * @param row
+ * a row represented by a String
+ * @return the cells for this row
+ */
+ public static final String[] getCells(final String row) {
+ return row.split(COLUMN_SEPARATOR);
+ }
+
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableEditingDomainuUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableEditingDomainuUtils.java
new file mode 100644
index 00000000000..95d82922775
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableEditingDomainuUtils.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ *
+ * Utils class to get the best editing domain to use
+ *
+ */
+public class TableEditingDomainuUtils {
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ private TableEditingDomainuUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ * Returns the EditingDomain associated to the table
+ *
+ * @return
+ * the EditingDomain associated to the table
+ */
+ public static final TransactionalEditingDomain getTableEditingDomain(final Table table) {
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(table);
+ return (TransactionalEditingDomain)registry.getService(EditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+ return null;
+
+ }
+
+ /**
+ * Returns the EditingDomain associated to the context
+ *
+ * @return
+ * the EditingDomain associated to the context
+ */
+ public static final TransactionalEditingDomain getTableContextEditingDomain(final Table table) {
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(table.getContext());
+ return (TransactionalEditingDomain)registry.getService(EditingDomain.class);
+ } catch (final ServiceException e) {
+ Activator.log.error(Messages.NattableModelManager_ServiceRegistryNotFound, e);
+ }
+ return null;
+ }
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableGridRegion.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableGridRegion.java
new file mode 100644
index 00000000000..965031183c5
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableGridRegion.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+/**
+ * the enumeration for the table region
+ *
+ *
+ */
+public enum TableGridRegion {
+ AFTER_COLUMN_HEADER, AFTER_ROW_HEADER, ROW_HEADER, COLUMN_HEADER, CELL, UNKNOWN, CORNER;
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableHelper.java
new file mode 100644
index 00000000000..4756fd67690
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableHelper.java
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattableFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
+
+/**
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class TableHelper {
+
+ private TableHelper() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param configuration
+ * the configuration used to create the table
+ * @return
+ * the table created from this configuration
+ */
+ public static final Table createTable(final TableConfiguration configuration) {
+ return createTable(configuration, null);
+ }
+
+ /**
+ *
+ * @param configuration
+ * the configuration used to create the table
+ * @param context
+ * the context of the table
+ * @return
+ * the table created from these parameters
+ */
+ public static final Table createTable(final TableConfiguration configuration, final EObject context) {
+ return createTable(configuration, null, null);
+ }
+
+ /**
+ *
+ * @param configuration
+ * the configuration used to create the table
+ * @param context
+ * the context of the table
+ * @param name
+ * the name for the table
+ * @return
+ * the table created from these parameters
+ */
+ public static final Table createTable(final TableConfiguration configuration, final EObject context, final String name) {
+ return createTable(configuration, null, null, null);
+ }
+
+ /**
+ *
+ * @param configuration
+ * the configuration used to create the table
+ * @param context
+ * the context of the table
+ * @param name
+ * the name for the table
+ * @param description
+ * the description for the table
+ * @return
+ * the table created from these parameters
+ */
+ public static final Table createTable(final TableConfiguration configuration, final EObject context, final String name, final String description) {
+ assert configuration != null;
+
+ Table table = NattableFactory.eINSTANCE.createTable();
+ table.setTableConfiguration(configuration);
+ table.setDescription(description);
+ table.setName(name);
+ table.setContext(context);
+
+ //the configuration always provides axis provider
+ AbstractAxisProvider rowProvider = configuration.getDefaultRowAxisProvider();
+ rowProvider = EcoreUtil.copy(rowProvider);
+
+ AbstractAxisProvider columnProvider = configuration.getDefaultColumnAxisProvider();
+ columnProvider = EcoreUtil.copy(columnProvider);
+
+ table.setCurrentRowAxisProvider(rowProvider);
+ table.setCurrentColumnAxisProvider(columnProvider);
+ table.getRowAxisProvidersHistory().add(rowProvider);
+ table.getColumnAxisProvidersHistory().add(columnProvider);
+ return table;
+
+ }
+
+}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/widget/NatComboButton.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/widget/NatComboButton.java
new file mode 100644
index 00000000000..f4c7cbd554e
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/widget/NatComboButton.java
@@ -0,0 +1,256 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.widget;
+
+import org.eclipse.nebula.widgets.nattable.style.IStyle;
+import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
+import org.eclipse.papyrus.infra.nattable.celleditor.ButtonConfiguration;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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;
+
+/**
+ *
+ * This widget provides a Combo with a button
+ *
+ */
+public class NatComboButton extends NatCombo {
+
+ /**
+ * the configuration of the button
+ */
+ private ButtonConfiguration buttonConfiguration;
+
+ /**
+ * the button
+ */
+ private Button button;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see NatCombo#NatCombo(Composite, IStyle, int)
+ * @param parent
+ * @param cellStyle
+ * @param style
+ * @param buttonConfiguration
+ * the configuration of the button
+ */
+ public NatComboButton(Composite parent, IStyle cellStyle, int style, ButtonConfiguration buttonConfiguration) {
+ super(parent, cellStyle, style);
+ this.buttonConfiguration = buttonConfiguration;
+ configureButton();
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see NatCombo#NatCombo(Composite, IStyle, int, int)
+ * @param parent
+ * @param cellStyle
+ * @param maxVisibleItems
+ * @param style
+ * @param buttonConfiguration
+ * the configuration of the button
+ */
+ public NatComboButton(Composite parent, IStyle cellStyle, int maxVisibleItems, int style, ButtonConfiguration buttonConfiguration) {
+ super(parent, cellStyle, maxVisibleItems, style);
+ this.buttonConfiguration = buttonConfiguration;
+ configureButton();
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see NatCombo#NatCombo(Composite, IStyle, int, boolean, int)
+ * @param parent
+ * @param cellStyle
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param style
+ * @param buttonConfiguration
+ * the configuration of the button
+ * @deprecated freeEdit parameter is deprecated. Use the SWT.READ_ONLY flag to specify freeEdit = false
+ */
+ @Deprecated
+ public NatComboButton(Composite parent, IStyle cellStyle, int maxVisibleItems, boolean freeEdit, int style, ButtonConfiguration buttonConfiguration) {
+ super(parent, cellStyle, maxVisibleItems, computeFreeEditStyle(freeEdit, style));
+ this.buttonConfiguration = buttonConfiguration;
+ configureButton();
+ }
+
+ //NatCombo computes freeEdit from the style
+ //freeEdit == true <=> style | SWT.READ_ONLY = false
+ @Deprecated
+ private static int computeFreeEditStyle(boolean freeEdit, int style) {
+ if(freeEdit) {
+ return style & ~SWT.READ_ONLY;
+ } else {
+ return style | SWT.READ_ONLY;
+ }
+ }
+
+ @Deprecated
+ private static int computeMultiSelectStyle(boolean multiselect, int style) {
+ if(multiselect) {
+ return style | SWT.MULTI; //Add the SWT.MULTI style
+ } else {
+ return style & ~SWT.MULTI; //Remove the SWT.MULTI style
+ }
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see NatCombo#NatCombo(Composite, IStyle, int, boolean, boolean, int)
+ * @param parent
+ * @param cellStyle
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param multiselect
+ * @param style
+ * @param buttonConfiguration
+ * the configuration of the button
+ *
+ * @deprecated multiselect parameter is deprecated. Use the SWT.MULTI flag instead
+ */
+ @Deprecated
+ public NatComboButton(Composite parent, IStyle cellStyle, int maxVisibleItems, boolean freeEdit, boolean multiselect, int style, ButtonConfiguration buttonConfiguration) {
+ this(parent, cellStyle, maxVisibleItems, multiselect, computeMultiSelectStyle(multiselect, style), buttonConfiguration);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @see NatCombo#NatCombo(Composite, IStyle, int, boolean, boolean, int, Image)
+ * @param parent
+ * @param cellStyle
+ * @param maxVisibleItems
+ * @param freeEdit
+ * @param multiselect
+ * @param style
+ * @param iconImage
+ * @param buttonConfiguration
+ * the configuration of the button
+ *
+ * @deprecated The freeEdit and multiselect parameter. Use the SWT.READ_ONLY flag to specify freeEdit = False. Use SWT.MULTI flag to specify
+ * multiselect = True
+ */
+ @Deprecated
+ public NatComboButton(Composite parent, IStyle cellStyle, int maxVisibleItems, boolean freeEdit, boolean multiselect, int style, Image iconImage, ButtonConfiguration buttonConfiguration) {
+ this(parent, cellStyle, maxVisibleItems, computeMultiSelectStyle(multiselect, computeFreeEditStyle(freeEdit, style)), buttonConfiguration);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param parent
+ * @param cellStyle
+ * @param maxVisibleItems
+ * @param style
+ * @param iconImage
+ * @param buttonConfiguration
+ */
+ public NatComboButton(Composite parent, IStyle cellStyle, int maxVisibleItems, int style, Image iconImage, ButtonConfiguration buttonConfiguration) {
+ super(parent, cellStyle, maxVisibleItems, style, iconImage);
+ this.buttonConfiguration = buttonConfiguration;
+ configureButton();
+ }
+
+ /**
+ * Configure the created button
+ */
+ protected void configureButton() {
+ final String txt = buttonConfiguration.getText();
+ if(txt != null) {
+ button.setText(txt);
+ }
+ final String toolTip = buttonConfiguration.getTooltipText();
+ if(toolTip != null) {
+ button.setToolTipText(toolTip);
+ }
+
+ final Image img = buttonConfiguration.getImage();
+ if(img != null) {
+ button.setImage(img);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.widget.NatCombo#createTextControl(int)
+ *
+ * @param style
+ */
+ @Override
+ protected void createTextControl(int style) {
+ super.createTextControl(style);
+ createButton();
+ //we change the layout because there is 3 elements now!
+ GridLayout gridLayout = new GridLayout(3, false);
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ gridLayout.horizontalSpacing = 0;
+ setLayout(gridLayout);
+ }
+
+ protected void createButton() {
+ button = new Button(this, SWT.NONE);
+
+
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, true);
+ button.setLayoutData(gridData);
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ runAction();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * execute the action done by the button
+ */
+ protected void runAction() {
+ buttonConfiguration.getAction().run();
+ }
+
+ /**
+ *
+ * @see org.eclipse.nebula.widgets.nattable.widget.NatCombo#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ buttonConfiguration = null;
+ button = null;
+ }
+
+
+}

Back to the top