From 717004d3a228efc8dfb3c37c5ab64e1608fb5064 Mon Sep 17 00:00:00 2001 From: serge-rider Date: Wed, 9 Sep 2020 23:51:49 +0300 Subject: [PATCH] dbeaver#9732 ERD plugin split --- .../feature.xml | 1 + .../org.jkiss.dbeaver.ui.feature/feature.xml | 2 +- .../META-INF/MANIFEST.MF | 16 + .../OSGI-INF/l10n/bundle.properties | 2 + .../build.properties | 6 + .../org.jkiss.dbeaver.erd.model/plugin.xml | 30 + .../pom.xml | 4 +- .../org/jkiss/dbeaver/erd/model/ERDModel.java | 23 + .../META-INF/MANIFEST.MF | 13 +- .../OSGI-INF/l10n/bundle.properties | 2 +- .../OSGI-INF/l10n/bundle_de.properties | 2 - .../OSGI-INF/l10n/bundle_es.properties | 0 .../OSGI-INF/l10n/bundle_it.properties | 1 - .../OSGI-INF/l10n/bundle_ja.properties | 0 .../OSGI-INF/l10n/bundle_ko.properties | 5 - .../OSGI-INF/l10n/bundle_pt_BR.properties | 5 - .../OSGI-INF/l10n/bundle_ru.properties | 0 .../OSGI-INF/l10n/bundle_zh.properties | 6 - .../build.properties | 0 .../css/e4-dark_erd_prefstyle.css | 0 .../docs/erd-model.doc | Bin .../icons/arrangeall.png | Bin .../icons/arrangeselected.png | Bin .../icons/connect.png | Bin .../icons/erd.png | Bin .../icons/erd@2x.png | Bin .../icons/erd_folder.png | Bin .../icons/erd_folder@2x.png | Bin .../icons/layer_grid.png | Bin .../icons/note.png | Bin .../plugin.xml | 0 plugins/org.jkiss.dbeaver.erd.ui/pom.xml | 14 + ...g.jkiss.dbeaver.ext.erd.export.format.exsd | 0 .../jkiss/dbeaver/ext/erd/ERDActivator.java | 208 +- .../org/jkiss/dbeaver/ext/erd/ERDColors.java | 0 .../jkiss/dbeaver/ext/erd/ERDConstants.java | 170 +- .../jkiss/dbeaver/ext/erd/ERDMessages.java | 0 .../ext/erd/ERDPreferencesInitializer.java | 64 +- .../dbeaver/ext/erd/ERDResources.properties | 142 +- .../ext/erd/ERDResources_de.properties | 0 .../ext/erd/ERDResources_it.properties | 0 .../ext/erd/ERDResources_ja.properties | 0 .../ext/erd/ERDResources_ru.properties | 0 .../ext/erd/ERDResources_zh.properties | 0 .../ext/erd/action/DiagramLayoutAction.java | 98 +- .../ext/erd/action/DiagramRefreshAction.java | 98 +- .../erd/action/DiagramToggleGridAction.java | 98 +- .../action/DiagramTogglePersistAction.java | 0 .../erd/action/ERDEditorPropertyTester.java | 110 +- .../ext/erd/action/ERDHandlerCopy.java | 0 .../ext/erd/action/ERDHandlerDelete.java | 102 +- .../ext/erd/action/ERDHandlerPaste.java | 158 +- .../ext/erd/action/ERDHandlerPrint.java | 90 +- .../ext/erd/action/ERDHandlerRedo.java | 84 +- .../ext/erd/action/ERDHandlerRefresh.java | 0 .../ext/erd/action/ERDHandlerSaveImage.java | 90 +- .../ext/erd/action/ERDHandlerSelectAll.java | 94 +- .../ext/erd/action/ERDHandlerUndo.java | 90 +- .../erd/action/FlyoutChangeLayoutAction.java | 200 +- .../erd/command/AssociationCreateCommand.java | 330 +-- .../erd/command/AssociationDeleteCommand.java | 196 +- .../AssociationReconnectSourceCommand.java | 192 +- .../AssociationReconnectTargetCommand.java | 178 +- .../erd/command/AttributeCheckCommand.java | 0 .../ext/erd/command/BendpointCommand.java | 62 +- .../erd/command/BendpointCreateCommand.java | 92 +- .../erd/command/BendpointDeleteCommand.java | 90 +- .../ext/erd/command/BendpointMoveCommand.java | 118 +- .../ext/erd/command/EntityAddCommand.java | 280 +- .../ext/erd/command/EntityDeleteCommand.java | 256 +- .../ext/erd/command/NodeMoveCommand.java | 126 +- .../ext/erd/command/NoteCreateCommand.java | 152 +- .../ext/erd/command/NoteDeleteCommand.java | 138 +- .../ext/erd/command/NoteSetTextCommand.java | 0 .../ColumnNameTypeCellEditorValidator.java | 194 +- .../directedit/ExtendedDirectEditManager.java | 402 +-- .../erd/directedit/FigureEditorLocator.java | 0 .../directedit/LabelCellEditorLocator.java | 178 +- .../StatusLineValidationMessageHandler.java | 118 +- .../TableNameCellEditorValidator.java | 162 +- .../directedit/ValidationMessageHandler.java | 70 +- .../erd/dnd/DataEditDropTargetListener.java | 88 +- .../ext/erd/dnd/DataElementFactory.java | 136 +- .../ext/erd/dnd/NodeDropTargetListener.java | 162 +- .../ext/erd/dnd/ObjectCreationFactory.java | 92 +- .../erd/editor/ERDAttributeVisibility.java | 142 +- .../ext/erd/editor/ERDEditPartFactory.java | 104 +- .../ext/erd/editor/ERDEditorAdapter.java | 122 +- .../editor/ERDEditorContextMenuProvider.java | 176 +- .../ext/erd/editor/ERDEditorContributor.java | 0 .../ext/erd/editor/ERDEditorEmbedded.java | 816 +++--- .../dbeaver/ext/erd/editor/ERDEditorPart.java | 2450 ++++++++--------- .../ext/erd/editor/ERDEditorStandalone.java | 0 .../ext/erd/editor/ERDEditorViewer.java | 0 .../ext/erd/editor/ERDGraphicalViewer.java | 760 ++--- .../ext/erd/editor/ERDOutlinePage.java | 264 +- .../ext/erd/editor/ERDPalettePreferences.java | 166 +- .../erd/editor/ERDPaletteViewerProvider.java | 96 +- .../ext/erd/editor/ERDPreferencePage.java | 468 ++-- .../dbeaver/ext/erd/editor/ERDViewStyle.java | 0 .../ext/erd/editor/tools/ActionToolEntry.java | 0 .../editor/tools/BringToFrontToolEntry.java | 0 .../erd/editor/tools/ChangeZOrderAction.java | 0 .../erd/editor/tools/CommandToolEntry.java | 0 .../editor/tools/ResetPartColorAction.java | 0 .../erd/editor/tools/SetPartColorAction.java | 0 .../editor/tools/SetPartSettingsAction.java | 0 .../erd/export/ERDExportFormatHandler.java | 0 .../erd/export/ERDExportFormatRegistry.java | 5 +- .../ext/erd/export/ERDExportGraphML.java | 0 .../ext/erd/export/ERDExportRasterImage.java | 0 .../ext/erd/figures/AttributeItemFigure.java | 300 +- .../ext/erd/figures/AttributeListFigure.java | 168 +- .../ext/erd/figures/CustomCheckBoxFigure.java | 0 .../ext/erd/figures/EditableLabel.java | 204 +- .../ext/erd/figures/EntityDiagramFigure.java | 198 +- .../dbeaver/ext/erd/figures/EntityFigure.java | 556 ++-- .../dbeaver/ext/erd/figures/NoteFigure.java | 170 +- .../ext/erd/figures/RoundedLineBorder.java | 0 .../erd/layout/DelegatingLayoutManager.java | 352 +-- .../ext/erd/layout/GraphAnimation.java | 628 ++--- .../ext/erd/layout/GraphLayoutAuto.java | 156 +- .../dbeaver/ext/erd/layout/GraphLayoutXY.java | 152 +- .../ext/erd/layout/ZestGraphLayout.java | 394 +-- .../algorithm/direct/ClusterEdgeCreator.java | 384 +-- .../direct/DirectedGraphLayoutVisitor.java | 458 +-- .../algorithm/direct/DummyEdgePart.java | 106 +- .../NodeJoiningDirectedGraphLayout.java | 120 +- .../direct/StandaloneNodeConnector.java | 234 +- .../dbeaver/ext/erd/model/DiagramLoader.java | 1438 +++++----- .../ext/erd/model/DiagramObjectCollector.java | 430 +-- .../dbeaver/ext/erd/model/ERDAssociation.java | 402 +-- .../dbeaver/ext/erd/model/ERDContainer.java | 0 .../dbeaver/ext/erd/model/ERDDecorator.java | 0 .../ext/erd/model/ERDDecoratorDefault.java | 0 .../dbeaver/ext/erd/model/ERDElement.java | 0 .../dbeaver/ext/erd/model/ERDEntity.java | 0 .../ext/erd/model/ERDEntityAttribute.java | 194 +- .../ext/erd/model/ERDLogicalAssociation.java | 0 .../ext/erd/model/ERDLogicalPrimaryKey.java | 182 +- .../jkiss/dbeaver/ext/erd/model/ERDNote.java | 82 +- .../dbeaver/ext/erd/model/ERDObject.java | 188 +- .../ext/erd/model/ERDObjectAdapter.java | 158 +- .../jkiss/dbeaver/ext/erd/model/ERDUtils.java | 0 .../dbeaver/ext/erd/model/EntityDiagram.java | 992 +++---- .../erd/navigator/CreateDiagramHandler.java | 74 +- .../dbeaver/ext/erd/navigator/DBNDiagram.java | 104 +- .../ext/erd/navigator/DBNDiagramFolder.java | 138 +- .../erd/navigator/DiagramCreateWizard.java | 337 +-- .../navigator/DiagramCreateWizardPage.java | 0 .../ext/erd/navigator/ERDResourceHandler.java | 378 +-- .../ext/erd/navigator/ViewDiagramHandler.java | 0 .../dbeaver/ext/erd/part/AssociationPart.java | 826 +++--- .../dbeaver/ext/erd/part/AttributePart.java | 466 ++-- .../dbeaver/ext/erd/part/DiagramPart.java | 774 +++--- .../dbeaver/ext/erd/part/EntityPart.java | 630 ++--- .../ext/erd/part/ICustomizablePart.java | 0 .../jkiss/dbeaver/ext/erd/part/NodePart.java | 382 +-- .../jkiss/dbeaver/ext/erd/part/NotePart.java | 542 ++-- .../erd/part/PropertyAwareConnectionPart.java | 198 +- .../ext/erd/part/PropertyAwarePart.java | 540 ++-- .../erd/policy/AssociationBendEditPolicy.java | 126 +- .../ext/erd/policy/AssociationEditPolicy.java | 74 +- .../policy/AttributeConnectionEditPolicy.java | 0 .../policy/AttributeContainerEditPolicy.java | 0 .../erd/policy/AttributeDirectEditPolicy.java | 0 .../AttributeDragAndDropEditPolicy.java | 0 .../ext/erd/policy/AttributeEditPolicy.java | 82 +- .../policy/DiagramContainerEditPolicy.java | 208 +- .../ext/erd/policy/DiagramXYLayoutPolicy.java | 228 +- .../policy/EntityConnectionEditPolicy.java | 0 .../erd/policy/EntityContainerEditPolicy.java | 108 +- .../erd/policy/EntityDirectEditPolicy.java | 134 +- .../ext/erd/policy/EntityEditPolicy.java | 74 +- .../erd/policy/EntityLayoutEditPolicy.java | 214 +- .../ext/erd/policy/NoteDirectEditPolicy.java | 128 +- .../ext/erd/policy/NoteEditPolicy.java | 84 +- .../META-INF/MANIFEST.MF | 5 +- plugins/pom.xml | 3 +- 179 files changed, 13498 insertions(+), 13414 deletions(-) create mode 100644 plugins/org.jkiss.dbeaver.erd.model/META-INF/MANIFEST.MF create mode 100644 plugins/org.jkiss.dbeaver.erd.model/OSGI-INF/l10n/bundle.properties create mode 100644 plugins/org.jkiss.dbeaver.erd.model/build.properties create mode 100644 plugins/org.jkiss.dbeaver.erd.model/plugin.xml rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.model}/pom.xml (84%) create mode 100644 plugins/org.jkiss.dbeaver.erd.model/src/org/jkiss/dbeaver/erd/model/ERDModel.java rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/META-INF/MANIFEST.MF (72%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle.properties (99%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_de.properties (99%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_es.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_it.properties (90%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_ja.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_ko.properties (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_pt_BR.properties (98%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_ru.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/OSGI-INF/l10n/bundle_zh.properties (95%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/build.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/css/e4-dark_erd_prefstyle.css (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/docs/erd-model.doc (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/arrangeall.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/arrangeselected.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/connect.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/erd.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/erd@2x.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/erd_folder.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/erd_folder@2x.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/layer_grid.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/icons/note.png (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/plugin.xml (100%) create mode 100644 plugins/org.jkiss.dbeaver.erd.ui/pom.xml rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/schema/org.jkiss.dbeaver.ext.erd.export.format.exsd (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDColors.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java (98%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java (98%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources_de.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources_it.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources_ja.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources_ru.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/ERDResources_zh.properties (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/DiagramTogglePersistAction.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerCopy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRefresh.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/AttributeCheckCommand.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/command/NoteSetTextCommand.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java (95%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/FigureEditorLocator.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java (95%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java (95%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContributor.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorStandalone.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorViewer.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/ERDViewStyle.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/ActionToolEntry.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/BringToFrontToolEntry.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/ChangeZOrderAction.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/CommandToolEntry.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/ResetPartColorAction.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/SetPartColorAction.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/editor/tools/SetPartSettingsAction.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/export/ERDExportFormatHandler.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/export/ERDExportFormatRegistry.java (92%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/export/ERDExportGraphML.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/export/ERDExportRasterImage.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/AttributeItemFigure.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/AttributeListFigure.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/CustomCheckBoxFigure.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/EditableLabel.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/EntityDiagramFigure.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/NoteFigure.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/figures/RoundedLineBorder.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/DelegatingLayoutManager.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/GraphAnimation.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/GraphLayoutAuto.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/GraphLayoutXY.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/ZestGraphLayout.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/algorithm/direct/ClusterEdgeCreator.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/algorithm/direct/DirectedGraphLayoutVisitor.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/algorithm/direct/DummyEdgePart.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/algorithm/direct/NodeJoiningDirectedGraphLayout.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/layout/algorithm/direct/StandaloneNodeConnector.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/DiagramLoader.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/DiagramObjectCollector.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDAssociation.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDContainer.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDDecorator.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDDecoratorDefault.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDElement.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDEntity.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDEntityAttribute.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDLogicalAssociation.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDLogicalPrimaryKey.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDNote.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDObject.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDObjectAdapter.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/ERDUtils.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/model/EntityDiagram.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/CreateDiagramHandler.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/DBNDiagram.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/DBNDiagramFolder.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/DiagramCreateWizard.java (92%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/DiagramCreateWizardPage.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/ERDResourceHandler.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/navigator/ViewDiagramHandler.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/AssociationPart.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/AttributePart.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/DiagramPart.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/EntityPart.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/ICustomizablePart.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/NodePart.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/NotePart.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/PropertyAwareConnectionPart.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/part/PropertyAwarePart.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AssociationBendEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AssociationEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AttributeConnectionEditPolicy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AttributeContainerEditPolicy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AttributeDirectEditPolicy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AttributeDragAndDropEditPolicy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/AttributeEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/DiagramContainerEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/DiagramXYLayoutPolicy.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/EntityConnectionEditPolicy.java (100%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/EntityContainerEditPolicy.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/EntityDirectEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/EntityEditPolicy.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/EntityLayoutEditPolicy.java (96%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/NoteDirectEditPolicy.java (97%) rename plugins/{org.jkiss.dbeaver.ext.erd => org.jkiss.dbeaver.erd.ui}/src/org/jkiss/dbeaver/ext/erd/policy/NoteEditPolicy.java (97%) diff --git a/features/org.jkiss.dbeaver.runtime.feature/feature.xml b/features/org.jkiss.dbeaver.runtime.feature/feature.xml index 8a4f1ddc31..44fdf3e2d5 100644 --- a/features/org.jkiss.dbeaver.runtime.feature/feature.xml +++ b/features/org.jkiss.dbeaver.runtime.feature/feature.xml @@ -34,6 +34,7 @@ + diff --git a/features/org.jkiss.dbeaver.ui.feature/feature.xml b/features/org.jkiss.dbeaver.ui.feature/feature.xml index f6384b39f9..3e1aeee690 100644 --- a/features/org.jkiss.dbeaver.ui.feature/feature.xml +++ b/features/org.jkiss.dbeaver.ui.feature/feature.xml @@ -50,7 +50,7 @@ - + diff --git a/plugins/org.jkiss.dbeaver.erd.model/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.erd.model/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..26e8c2b4ea --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.model/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Vendor: %Bundle-Vendor +Bundle-Name: %Bundle-Name +Bundle-SymbolicName: org.jkiss.dbeaver.erd.model;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Release-Date: 20200831 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.core.expressions, + org.jkiss.dbeaver.model +Bundle-ClassPath: . +Export-Package: org.jkiss.dbeaver.erd.model +Automatic-Module-Name: org.jkiss.dbeaver.erd.model diff --git a/plugins/org.jkiss.dbeaver.erd.model/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.erd.model/OSGI-INF/l10n/bundle.properties new file mode 100644 index 0000000000..4c46d870cc --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.model/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,2 @@ +Bundle-Vendor = JKISS +Bundle-Name = DBeaver ERD Model diff --git a/plugins/org.jkiss.dbeaver.erd.model/build.properties b/plugins/org.jkiss.dbeaver.erd.model/build.properties new file mode 100644 index 0000000000..3c833df018 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.model/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = target/classes/ +bin.includes = .,\ + META-INF/,\ + OSGI-INF/,\ + plugin.xml diff --git a/plugins/org.jkiss.dbeaver.erd.model/plugin.xml b/plugins/org.jkiss.dbeaver.erd.model/plugin.xml new file mode 100644 index 0000000000..d7da23c410 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.model/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/pom.xml b/plugins/org.jkiss.dbeaver.erd.model/pom.xml similarity index 84% rename from plugins/org.jkiss.dbeaver.ext.erd/pom.xml rename to plugins/org.jkiss.dbeaver.erd.model/pom.xml index 9b0335613c..c141aadef1 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/pom.xml +++ b/plugins/org.jkiss.dbeaver.erd.model/pom.xml @@ -8,7 +8,7 @@ 1.0.0-SNAPSHOT ../ - org.jkiss.dbeaver.ext.erd - 2.0.142-SNAPSHOT + org.jkiss.dbeaver.erd.model + 1.0.0-SNAPSHOT eclipse-plugin diff --git a/plugins/org.jkiss.dbeaver.erd.model/src/org/jkiss/dbeaver/erd/model/ERDModel.java b/plugins/org.jkiss.dbeaver.erd.model/src/org/jkiss/dbeaver/erd/model/ERDModel.java new file mode 100644 index 0000000000..c10821c9e6 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.model/src/org/jkiss/dbeaver/erd/model/ERDModel.java @@ -0,0 +1,23 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 13, 2004 + */ +package org.jkiss.dbeaver.erd.model; + +public class ERDModel { +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.erd.ui/META-INF/MANIFEST.MF similarity index 72% rename from plugins/org.jkiss.dbeaver.ext.erd/META-INF/MANIFEST.MF rename to plugins/org.jkiss.dbeaver.erd.ui/META-INF/MANIFEST.MF index 1ad03156e2..f2fe6dadd8 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/META-INF/MANIFEST.MF +++ b/plugins/org.jkiss.dbeaver.erd.ui/META-INF/MANIFEST.MF @@ -2,8 +2,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Vendor: %Bundle-Vendor Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.jkiss.dbeaver.ext.erd;singleton:=true -Bundle-Version: 2.0.142.qualifier +Bundle-SymbolicName: org.jkiss.dbeaver.erd.ui;singleton:=true +Bundle-Version: 3.0.0.qualifier Bundle-Release-Date: 20200831 Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Activator: org.jkiss.dbeaver.ext.erd.ERDActivator @@ -15,8 +15,11 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.ide, org.eclipse.ui.views, org.eclipse.gef;visibility:=reexport, - org.jkiss.dbeaver.core, - org.jkiss.dbeaver.ui + org.jkiss.dbeaver.model, + org.jkiss.dbeaver.erd.model, + org.jkiss.dbeaver.ui, + org.jkiss.dbeaver.ui.editors.base, + org.jkiss.dbeaver.ui.navigator Bundle-ClassPath: . Export-Package: org.jkiss.dbeaver.ext.erd, org.jkiss.dbeaver.ext.erd.command, @@ -26,4 +29,4 @@ Export-Package: org.jkiss.dbeaver.ext.erd, org.jkiss.dbeaver.ext.erd.model, org.jkiss.dbeaver.ext.erd.part, org.jkiss.dbeaver.ext.erd.policy -Automatic-Module-Name: org.jkiss.dbeaver.ext.erd +Automatic-Module-Name: org.jkiss.dbeaver.erd.ui diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle.properties similarity index 99% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle.properties index 90c2ec97fe..c687e72b4f 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle.properties @@ -1,5 +1,5 @@ Bundle-Vendor = JKISS -Bundle-Name = DBeaver ER Diagram +Bundle-Name = DBeaver ERD UI extension-point.org.jkiss.dbeaver.ext.erd.export.format.name = Workbench handlers diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_de.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_de.properties similarity index 99% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_de.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_de.properties index 91a8104cbd..42ffda4cd0 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_de.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_de.properties @@ -1,7 +1,5 @@ #Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/) -Bundle-Name = DBeaver ER Diagramm - colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.background.description = Hintergrundfarbe des Attributnamens colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.background.label = Hintergrundfarbe des Attributs colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.foreground.description = Vordergrundfarbe des Attributnamens diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_es.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_es.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_es.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_es.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_it.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_it.properties similarity index 90% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_it.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_it.properties index 3bb544791a..00c3ce788e 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_it.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_it.properties @@ -1,5 +1,4 @@ # Copyright (C) 2012 Roberto Rossi (impiastro@gmail.com) -Bundle-Name = DBeaver Diagramma ER editor.erd.name = Diagramma ER editor.erd.description = Diagramma Entit\u00E0 Relazioni diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ja.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ja.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ja.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ja.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ko.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ko.properties similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ko.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ko.properties index bab1417961..7abf7f50aa 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ko.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ko.properties @@ -1,10 +1,5 @@ # Copyright (C) 2019 Seongbae Chang (dorbae.io@gmail.com) -#Bundle-Vendor = JKISS -#Bundle-Name = DBeaver ER Diagram - -#extension-point.org.jkiss.dbeaver.ext.erd.export.format.name = Workbench handlers - editor.erd.name=\uC5D4\uD2F0\uD2F0 \uAD00\uACC4\uB3C4 editor.erd.description=\uC5D4\uD2F0\uD2F0 \uAD00\uACC4\uB3C4 editor.org.jkiss.dbeaver.ext.erd.editor.ERDEditorStandalone.name = ERD \uD3B8\uC9D1\uAE30 diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_pt_BR.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_pt_BR.properties similarity index 98% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_pt_BR.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_pt_BR.properties index aa08c732c1..6bf2864377 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_pt_BR.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_pt_BR.properties @@ -1,8 +1,3 @@ - -Bundle-Name = DBeaver ER Diagram - -Bundle-Vendor = JKISS - colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.background.description = Fundo do nome do atributo colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.background.label = Atributos de fundo colorDefinition.org.jkiss.dbeaver.erd.diagram.attributes.foreground.description = Nome do atributo em primeiro plano diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ru.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ru.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_ru.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_ru.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_zh.properties b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_zh.properties similarity index 95% rename from plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_zh.properties rename to plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_zh.properties index 956b479220..43edd6b7e6 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/OSGI-INF/l10n/bundle_zh.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/OSGI-INF/l10n/bundle_zh.properties @@ -1,10 +1,4 @@ # Copyright (C) 2017 Liu, Yuanyuan (liuyuanyuan@highgo.com) - -Bundle-Vendor = JKISS -Bundle-Name = DBeaver ER Diagram - -extension-point.org.jkiss.dbeaver.ext.erd.export.format.name = Workbench handlers - editor.erd.name = ER \u56FE editor.erd.description = \u5B9E\u4F53\u5173\u7CFB\u56FE editor.org.jkiss.dbeaver.ext.erd.editor.ERDEditorStandalone.name = ERD \u7F16\u8F91\u5668 diff --git a/plugins/org.jkiss.dbeaver.ext.erd/build.properties b/plugins/org.jkiss.dbeaver.erd.ui/build.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/build.properties rename to plugins/org.jkiss.dbeaver.erd.ui/build.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/css/e4-dark_erd_prefstyle.css b/plugins/org.jkiss.dbeaver.erd.ui/css/e4-dark_erd_prefstyle.css similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/css/e4-dark_erd_prefstyle.css rename to plugins/org.jkiss.dbeaver.erd.ui/css/e4-dark_erd_prefstyle.css diff --git a/plugins/org.jkiss.dbeaver.ext.erd/docs/erd-model.doc b/plugins/org.jkiss.dbeaver.erd.ui/docs/erd-model.doc similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/docs/erd-model.doc rename to plugins/org.jkiss.dbeaver.erd.ui/docs/erd-model.doc diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/arrangeall.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/arrangeall.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/arrangeall.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/arrangeall.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/arrangeselected.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/arrangeselected.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/arrangeselected.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/arrangeselected.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/connect.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/connect.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/connect.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/connect.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/erd.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/erd.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/erd.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/erd.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/erd@2x.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/erd@2x.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/erd@2x.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/erd@2x.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/erd_folder.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/erd_folder.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/erd_folder.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/erd_folder.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/erd_folder@2x.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/erd_folder@2x.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/erd_folder@2x.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/erd_folder@2x.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/layer_grid.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/layer_grid.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/layer_grid.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/layer_grid.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/icons/note.png b/plugins/org.jkiss.dbeaver.erd.ui/icons/note.png similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/icons/note.png rename to plugins/org.jkiss.dbeaver.erd.ui/icons/note.png diff --git a/plugins/org.jkiss.dbeaver.ext.erd/plugin.xml b/plugins/org.jkiss.dbeaver.erd.ui/plugin.xml similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/plugin.xml rename to plugins/org.jkiss.dbeaver.erd.ui/plugin.xml diff --git a/plugins/org.jkiss.dbeaver.erd.ui/pom.xml b/plugins/org.jkiss.dbeaver.erd.ui/pom.xml new file mode 100644 index 0000000000..6662b805e4 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.erd.ui/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + org.jkiss.dbeaver + plugins + 1.0.0-SNAPSHOT + ../ + + org.jkiss.dbeaver.erd.ui + 3.0.0-SNAPSHOT + eclipse-plugin + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/schema/org.jkiss.dbeaver.ext.erd.export.format.exsd b/plugins/org.jkiss.dbeaver.erd.ui/schema/org.jkiss.dbeaver.ext.erd.export.format.exsd similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/schema/org.jkiss.dbeaver.ext.erd.export.format.exsd rename to plugins/org.jkiss.dbeaver.erd.ui/schema/org.jkiss.dbeaver.ext.erd.export.format.exsd diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java index 1f5ba5440e..ee1b531579 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDActivator.java @@ -1,104 +1,104 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore; -import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; -import org.osgi.framework.BundleContext; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * The activator class controls the plug-in life cycle - */ -public class ERDActivator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.jkiss.dbeaver.ext.erd"; - - // The shared instance - private static ERDActivator plugin; - - private static ResourceBundle resourceBundle; - - private DBPPreferenceStore preferences; - - /** - * The constructor - */ - public ERDActivator() { - } - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - preferences = new BundlePreferenceStore(getBundle()); - - try { - resourceBundle = ResourceBundle.getBundle(ERDMessages.BUNDLE_NAME); - } catch (MissingResourceException x) { - resourceBundle = null; - } - - // Switch off D3D because of Sun XOR painting bug - // See http://www.jgraph.com/forum/viewtopic.php?t=4066 - System.setProperty("sun.java2d.d3d", Boolean.FALSE.toString()); //$NON-NLS-1$ - } - - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static ERDActivator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - /** - * Returns the plugin's resource bundle, - * @return core resource bundle - */ - public static ResourceBundle getResourceBundle() - { - return resourceBundle; - } - - public DBPPreferenceStore getPreferences() { - return preferences; - } -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore; +import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; +import org.osgi.framework.BundleContext; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * The activator class controls the plug-in life cycle + */ +public class ERDActivator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.jkiss.dbeaver.ext.erd"; + + // The shared instance + private static ERDActivator plugin; + + private static ResourceBundle resourceBundle; + + private DBPPreferenceStore preferences; + + /** + * The constructor + */ + public ERDActivator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + preferences = new BundlePreferenceStore(getBundle()); + + try { + resourceBundle = ResourceBundle.getBundle(ERDMessages.BUNDLE_NAME); + } catch (MissingResourceException x) { + resourceBundle = null; + } + + // Switch off D3D because of Sun XOR painting bug + // See http://www.jgraph.com/forum/viewtopic.php?t=4066 + System.setProperty("sun.java2d.d3d", Boolean.FALSE.toString()); //$NON-NLS-1$ + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static ERDActivator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + /** + * Returns the plugin's resource bundle, + * @return core resource bundle + */ + public static ResourceBundle getResourceBundle() + { + return resourceBundle; + } + + public DBPPreferenceStore getPreferences() { + return preferences; + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDColors.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDColors.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDColors.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDColors.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java similarity index 98% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java index f84e9088b5..3a29d0d631 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDConstants.java @@ -1,85 +1,85 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jkiss.dbeaver.ext.erd; - -import org.eclipse.draw2d.PrintFigureOperation; -import org.jkiss.dbeaver.model.struct.DBSEntityConstraintType; - -/** - * ERD constants - */ -public class ERDConstants { - - public static final String ERD_CONTROL_ID = "org.jkiss.dbeaver.erd.ERDEditor"; - - public static final String PREF_PRINT_PAGE_MODE = "erd.print.page-mode"; - public static final String PREF_PRINT_MARGIN_TOP = "erd.print.margin-top"; - public static final String PREF_PRINT_MARGIN_BOTTOM = "erd.print.margin-bottom"; - public static final String PREF_PRINT_MARGIN_LEFT = "erd.print.margin-left"; - public static final String PREF_PRINT_MARGIN_RIGHT = "erd.print.margin-right"; - - public static final int PRINT_MODE_DEFAULT = PrintFigureOperation.TILE; - public static final int PRINT_MARGIN_DEFAULT = 0; - - public static final String PROP_DIAGRAM_FONT = "org.jkiss.dbeaver.erd.diagram.font"; - - public static final String PREF_DIAGRAM_SHOW_VIEWS = "erd.diagram.show.views"; - public static final String PREF_DIAGRAM_SHOW_PARTITIONS = "erd.diagram.show.partitions"; - public static final String PREF_DIAGRAM_CHANGE_BORDER_COLORS = "erd.diagram.change.borders.colors"; - public static final String PREF_DIAGRAM_CHANGE_HEADER_COLORS = "erd.diagram.change.header.colors"; - public static final String PREF_GRID_ENABLED = "erd.grid.enabled"; - public static final String PREF_GRID_SNAP_ENABLED = "erd.grid.snap"; - public static final String PREF_GRID_WIDTH = "erd.grid.width"; - public static final String PREF_GRID_HEIGHT = "erd.grid.height"; - public static final String PREF_ATTR_VISIBILITY = "erd.attr.visibility"; - public static final String PREF_ATTR_STYLES = "erd.attr.styles"; - public static final String COLOR_ERD_DIAGRAM_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.background"; - public static final String COLOR_ERD_ENTITY_PRIMARY_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.primary.background"; - public static final String COLOR_ERD_ENTITY_ASSOCIATION_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.association.background"; - public static final String COLOR_ERD_ENTITY_REGULAR_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.regular.background"; - public static final String COLOR_ERD_ENTITY_NAME_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.entity.name.foreground"; - public static final String COLOR_ERD_LINES_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.lines.foreground"; - public static final String COLOR_ERD_ATTR_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.attributes.background"; - public static final String COLOR_ERD_ATTR_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.attributes.foreground"; - public static final String COLOR_ERD_NOTE_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.notes.background"; - public static final String COLOR_ERD_NOTE_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.notes.foreground"; - - public static final String COLOR_ERD_BORDERS_COLOR_1 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.1"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_2 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.2"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_3 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.3"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_4 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.4"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_5 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.5"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_6 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.6"; //$NON-NLS-1$ - public static final String COLOR_ERD_BORDERS_COLOR_7 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.7"; //$NON-NLS-1$ - - public static final String COLOR_ERD_HEADER_COLOR_1 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.1"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_2 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.2"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_3 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.3"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_4 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.4"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_5 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.5"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_6 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.6"; //$NON-NLS-1$ - public static final String COLOR_ERD_HEADER_COLOR_7 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.7"; //$NON-NLS-1$ - - public static final String ICON_LOCATION_PREFIX = "platform:/plugin/" + ERDActivator.PLUGIN_ID + "/icons/"; - - public static final int DEFAULT_NOTE_BORDER_WIDTH = 1; - public static final int DEFAULT_ENTITY_BORDER_WIDTH = 2; - - public static DBSEntityConstraintType CONSTRAINT_LOGICAL_FK = new DBSEntityConstraintType("erdkey", "Logical Key", null, true, false, false, true); - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jkiss.dbeaver.ext.erd; + +import org.eclipse.draw2d.PrintFigureOperation; +import org.jkiss.dbeaver.model.struct.DBSEntityConstraintType; + +/** + * ERD constants + */ +public class ERDConstants { + + public static final String ERD_CONTROL_ID = "org.jkiss.dbeaver.erd.ERDEditor"; + + public static final String PREF_PRINT_PAGE_MODE = "erd.print.page-mode"; + public static final String PREF_PRINT_MARGIN_TOP = "erd.print.margin-top"; + public static final String PREF_PRINT_MARGIN_BOTTOM = "erd.print.margin-bottom"; + public static final String PREF_PRINT_MARGIN_LEFT = "erd.print.margin-left"; + public static final String PREF_PRINT_MARGIN_RIGHT = "erd.print.margin-right"; + + public static final int PRINT_MODE_DEFAULT = PrintFigureOperation.TILE; + public static final int PRINT_MARGIN_DEFAULT = 0; + + public static final String PROP_DIAGRAM_FONT = "org.jkiss.dbeaver.erd.diagram.font"; + + public static final String PREF_DIAGRAM_SHOW_VIEWS = "erd.diagram.show.views"; + public static final String PREF_DIAGRAM_SHOW_PARTITIONS = "erd.diagram.show.partitions"; + public static final String PREF_DIAGRAM_CHANGE_BORDER_COLORS = "erd.diagram.change.borders.colors"; + public static final String PREF_DIAGRAM_CHANGE_HEADER_COLORS = "erd.diagram.change.header.colors"; + public static final String PREF_GRID_ENABLED = "erd.grid.enabled"; + public static final String PREF_GRID_SNAP_ENABLED = "erd.grid.snap"; + public static final String PREF_GRID_WIDTH = "erd.grid.width"; + public static final String PREF_GRID_HEIGHT = "erd.grid.height"; + public static final String PREF_ATTR_VISIBILITY = "erd.attr.visibility"; + public static final String PREF_ATTR_STYLES = "erd.attr.styles"; + public static final String COLOR_ERD_DIAGRAM_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.background"; + public static final String COLOR_ERD_ENTITY_PRIMARY_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.primary.background"; + public static final String COLOR_ERD_ENTITY_ASSOCIATION_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.association.background"; + public static final String COLOR_ERD_ENTITY_REGULAR_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.entity.regular.background"; + public static final String COLOR_ERD_ENTITY_NAME_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.entity.name.foreground"; + public static final String COLOR_ERD_LINES_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.lines.foreground"; + public static final String COLOR_ERD_ATTR_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.attributes.background"; + public static final String COLOR_ERD_ATTR_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.attributes.foreground"; + public static final String COLOR_ERD_NOTE_BACKGROUND = "org.jkiss.dbeaver.erd.diagram.notes.background"; + public static final String COLOR_ERD_NOTE_FOREGROUND = "org.jkiss.dbeaver.erd.diagram.notes.foreground"; + + public static final String COLOR_ERD_BORDERS_COLOR_1 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.1"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_2 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.2"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_3 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.3"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_4 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.4"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_5 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.5"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_6 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.6"; //$NON-NLS-1$ + public static final String COLOR_ERD_BORDERS_COLOR_7 = "org.jkiss.dbeaver.ui.presentation.erd.borders.color.7"; //$NON-NLS-1$ + + public static final String COLOR_ERD_HEADER_COLOR_1 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.1"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_2 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.2"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_3 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.3"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_4 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.4"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_5 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.5"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_6 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.6"; //$NON-NLS-1$ + public static final String COLOR_ERD_HEADER_COLOR_7 = "org.jkiss.dbeaver.ui.presentation.erd.headers.color.7"; //$NON-NLS-1$ + + public static final String ICON_LOCATION_PREFIX = "platform:/plugin/" + ERDActivator.PLUGIN_ID + "/icons/"; + + public static final int DEFAULT_NOTE_BORDER_WIDTH = 1; + public static final int DEFAULT_ENTITY_BORDER_WIDTH = 2; + + public static DBSEntityConstraintType CONSTRAINT_LOGICAL_FK = new DBSEntityConstraintType("erdkey", "Logical Key", null, true, false, false, true); + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDMessages.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java similarity index 98% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java index f825b9eee5..688dd7387d 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDPreferencesInitializer.java @@ -1,33 +1,33 @@ -package org.jkiss.dbeaver.ext.erd; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore; -import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; -import org.jkiss.dbeaver.utils.PrefUtils; - -public class ERDPreferencesInitializer extends AbstractPreferenceInitializer { - - public ERDPreferencesInitializer() { - } - - @Override - public void initializeDefaultPreferences() { - // Init default preferences - DBPPreferenceStore store = new BundlePreferenceStore(ERDActivator.getDefault().getBundle()); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_SHOW_VIEWS, true); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS, false); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_CHANGE_BORDER_COLORS, true); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_CHANGE_HEADER_COLORS, true); - - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_PAGE_MODE, ERDConstants.PRINT_MODE_DEFAULT); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_TOP, ERDConstants.PRINT_MARGIN_DEFAULT); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_BOTTOM, ERDConstants.PRINT_MARGIN_DEFAULT); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_LEFT, ERDConstants.PRINT_MARGIN_DEFAULT); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_RIGHT, ERDConstants.PRINT_MARGIN_DEFAULT); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_ENABLED, false); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_SNAP_ENABLED, true); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_WIDTH, 20); - PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_HEIGHT, 20); - } - +package org.jkiss.dbeaver.ext.erd; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore; +import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; +import org.jkiss.dbeaver.utils.PrefUtils; + +public class ERDPreferencesInitializer extends AbstractPreferenceInitializer { + + public ERDPreferencesInitializer() { + } + + @Override + public void initializeDefaultPreferences() { + // Init default preferences + DBPPreferenceStore store = new BundlePreferenceStore(ERDActivator.getDefault().getBundle()); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_SHOW_VIEWS, true); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS, false); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_CHANGE_BORDER_COLORS, true); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_DIAGRAM_CHANGE_HEADER_COLORS, true); + + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_PAGE_MODE, ERDConstants.PRINT_MODE_DEFAULT); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_TOP, ERDConstants.PRINT_MARGIN_DEFAULT); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_BOTTOM, ERDConstants.PRINT_MARGIN_DEFAULT); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_LEFT, ERDConstants.PRINT_MARGIN_DEFAULT); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_PRINT_MARGIN_RIGHT, ERDConstants.PRINT_MARGIN_DEFAULT); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_ENABLED, false); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_SNAP_ENABLED, true); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_WIDTH, 20); + PrefUtils.setDefaultPreferenceValue(store, ERDConstants.PREF_GRID_HEIGHT, 20); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties index e15e553ddc..b362468e57 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources.properties @@ -1,71 +1,71 @@ - -#navigator -action_diagram_layout_name=Arrange Diagram -wizard_diagram_create_title=Diagram Create Wizard - -#part -column_=Column -entity_diagram_=Entity Diagram -part_note_title=Note -pref_page_erd_checkbox_grid_enabled=Grid Enabled -pref_page_erd_checkbox_snap_to_grid=Snap To Grid -pref_page_erd_combo_page_mode=Page Mode -pref_page_erd_group_grid=Grid -pref_page_erd_group_print=Print -pref_page_erd_item_fit_height=Fit Height -pref_page_erd_item_fit_page=Fit Page -pref_page_erd_item_fit_width=Fit Width -pref_page_erd_item_tile=Tile -pref_page_erd_spinner_grid_height=Grid Height -pref_page_erd_spinner_grid_width=Grid Width -pref_page_erd_spinner_margin_bottom=Margin Bottom -pref_page_erd_spinner_margin_left=Margin Left -pref_page_erd_spinner_margin_right=Margin Right -pref_page_erd_spinner_margin_top=Margin Top -wizard_page_diagram_create_description=Manage diagram content. -wizard_page_diagram_create_group_settings=Settings -wizard_page_diagram_create_label_init_content=Initial content (optional) -wizard_page_diagram_create_name=Create new diagram -wizard_page_diagram_create_title=Create new diagram - -## ERD editor action item control ## -erd_attribute_visibility_selection_item_all=All -erd_attribute_visibility_selection_item_any_keys=Any keys -erd_attribute_visibility_selection_item_none=None -erd_attribute_visibility_selection_item_primary_key=Primary key -erd_editor_control_action_toggle_grid = Toggle Grid -erd_editor_control_action_refresh_diagram = Refresh Diagram -erd_editor_control_action_save_external_format = Save diagram in external format -erd_editor_control_action_print_diagram = Print Diagram -erd_editor_control_action_configuration = Configuration -erd_preference_page_title_attribute_style=Attribute styles -erd_preference_page_title_attributes_visibility=Attributes visibility -erd_preference_page_title_diagram_contents=Diagram contents -erd_preference_page_title_shows_views=Show views -erd_preference_page_title_shows_partitions=Show partitions -erd_preference_page_title_color_pref = Color settings -erd_preference_page_title_change_border_colors = Colorize other connections -erd_preference_page_title_change_header_colors = Colorize other schemas -## ERD editor action item control ## - -erd_tool_color_action_text_set_color=Set color -erd_tool_color_action_tip_text_set_figure_color=Set figure color -erd_tool_create_connection = Connection -erd_tool_create_connection_tip = Create logical connection (foreign key) -erd_tool_create_note = Note -erd_tool_create_note_tip = Create diagram note -erd_tool_create_default = Note -erd_tool_set_text_text_bring_to_front=Bring to front -erd_tool_set_text_text_send_to_back=Send to back -erd_tool_set_text_tip_text_bring_to_front=Bring to front -erd_tool_set_text_tip_text_send_to_back=Send to back -erd_view_style_selection_item_comments=Comments -erd_view_style_selection_item_data_types=Data Types -erd_view_style_selection_item_fully_qualified_names=Fully qualified names -erd_view_style_selection_item_icons=Icons -erd_view_style_selection_item_nullability=Nullability - -menu_view_style = View Styles -menu_attribute_visibility = Show Attributes -menu_attribute_visibility_default = All Entities -menu_attribute_visibility_entity = Selected Entity + +#navigator +action_diagram_layout_name=Arrange Diagram +wizard_diagram_create_title=Diagram Create Wizard + +#part +column_=Column +entity_diagram_=Entity Diagram +part_note_title=Note +pref_page_erd_checkbox_grid_enabled=Grid Enabled +pref_page_erd_checkbox_snap_to_grid=Snap To Grid +pref_page_erd_combo_page_mode=Page Mode +pref_page_erd_group_grid=Grid +pref_page_erd_group_print=Print +pref_page_erd_item_fit_height=Fit Height +pref_page_erd_item_fit_page=Fit Page +pref_page_erd_item_fit_width=Fit Width +pref_page_erd_item_tile=Tile +pref_page_erd_spinner_grid_height=Grid Height +pref_page_erd_spinner_grid_width=Grid Width +pref_page_erd_spinner_margin_bottom=Margin Bottom +pref_page_erd_spinner_margin_left=Margin Left +pref_page_erd_spinner_margin_right=Margin Right +pref_page_erd_spinner_margin_top=Margin Top +wizard_page_diagram_create_description=Manage diagram content. +wizard_page_diagram_create_group_settings=Settings +wizard_page_diagram_create_label_init_content=Initial content (optional) +wizard_page_diagram_create_name=Create new diagram +wizard_page_diagram_create_title=Create new diagram + +## ERD editor action item control ## +erd_attribute_visibility_selection_item_all=All +erd_attribute_visibility_selection_item_any_keys=Any keys +erd_attribute_visibility_selection_item_none=None +erd_attribute_visibility_selection_item_primary_key=Primary key +erd_editor_control_action_toggle_grid = Toggle Grid +erd_editor_control_action_refresh_diagram = Refresh Diagram +erd_editor_control_action_save_external_format = Save diagram in external format +erd_editor_control_action_print_diagram = Print Diagram +erd_editor_control_action_configuration = Configuration +erd_preference_page_title_attribute_style=Attribute styles +erd_preference_page_title_attributes_visibility=Attributes visibility +erd_preference_page_title_diagram_contents=Diagram contents +erd_preference_page_title_shows_views=Show views +erd_preference_page_title_shows_partitions=Show partitions +erd_preference_page_title_color_pref = Color settings +erd_preference_page_title_change_border_colors = Colorize other connections +erd_preference_page_title_change_header_colors = Colorize other schemas +## ERD editor action item control ## + +erd_tool_color_action_text_set_color=Set color +erd_tool_color_action_tip_text_set_figure_color=Set figure color +erd_tool_create_connection = Connection +erd_tool_create_connection_tip = Create logical connection (foreign key) +erd_tool_create_note = Note +erd_tool_create_note_tip = Create diagram note +erd_tool_create_default = Note +erd_tool_set_text_text_bring_to_front=Bring to front +erd_tool_set_text_text_send_to_back=Send to back +erd_tool_set_text_tip_text_bring_to_front=Bring to front +erd_tool_set_text_tip_text_send_to_back=Send to back +erd_view_style_selection_item_comments=Comments +erd_view_style_selection_item_data_types=Data Types +erd_view_style_selection_item_fully_qualified_names=Fully qualified names +erd_view_style_selection_item_icons=Icons +erd_view_style_selection_item_nullability=Nullability + +menu_view_style = View Styles +menu_attribute_visibility = Show Attributes +menu_attribute_visibility_default = All Entities +menu_attribute_visibility_entity = Selected Entity diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_de.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_de.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_de.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_de.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_it.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_it.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_it.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_it.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_ja.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_ja.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_ja.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_ja.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_ru.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_ru.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_ru.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_ru.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_zh.properties b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_zh.properties similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/ERDResources_zh.properties rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/ERDResources_zh.properties diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java index c34e559ac8..c4d7e6d1cf 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramLayoutAction.java @@ -1,50 +1,50 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 23, 2004 - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.jface.action.Action; -import org.jkiss.dbeaver.ext.erd.ERDActivator; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -/** - * Action to toggle the layout between manual and automatic - * - * @author Serge Rider - */ -public class DiagramLayoutAction extends Action -{ - private ERDEditorPart editor; - - public DiagramLayoutAction(ERDEditorPart editor) - { - super(ERDMessages.action_diagram_layout_name, ERDActivator.getImageDescriptor("icons/arrangeall.png")); //$NON-NLS-2$ - this.editor = editor; - } - - @Override - public void run() - { - //editor.get - editor.getDiagramPart().rearrangeDiagram(); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 23, 2004 + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.jface.action.Action; +import org.jkiss.dbeaver.ext.erd.ERDActivator; +import org.jkiss.dbeaver.ext.erd.ERDMessages; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +/** + * Action to toggle the layout between manual and automatic + * + * @author Serge Rider + */ +public class DiagramLayoutAction extends Action +{ + private ERDEditorPart editor; + + public DiagramLayoutAction(ERDEditorPart editor) + { + super(ERDMessages.action_diagram_layout_name, ERDActivator.getImageDescriptor("icons/arrangeall.png")); //$NON-NLS-2$ + this.editor = editor; + } + + @Override + public void run() + { + //editor.get + editor.getDiagramPart().rearrangeDiagram(); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java index cf84cd1e88..cb0fcc241c 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramRefreshAction.java @@ -1,50 +1,50 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 23, 2004 - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.jface.action.Action; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; -import org.jkiss.dbeaver.ui.DBeaverIcons; -import org.jkiss.dbeaver.ui.UIIcon; - -/** - * Action to toggle the layout between manual and automatic - * - * @author Serge Rider - */ -public class DiagramRefreshAction extends Action -{ - private ERDEditorPart editor; - - public DiagramRefreshAction(ERDEditorPart editor) - { - super(ERDMessages.erd_editor_control_action_refresh_diagram, DBeaverIcons.getImageDescriptor(UIIcon.REFRESH)); - this.editor = editor; - } - - @Override - public void run() - { - //editor.get - editor.refreshDiagram(true, true); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 23, 2004 + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.jface.action.Action; +import org.jkiss.dbeaver.ext.erd.ERDMessages; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; +import org.jkiss.dbeaver.ui.DBeaverIcons; +import org.jkiss.dbeaver.ui.UIIcon; + +/** + * Action to toggle the layout between manual and automatic + * + * @author Serge Rider + */ +public class DiagramRefreshAction extends Action +{ + private ERDEditorPart editor; + + public DiagramRefreshAction(ERDEditorPart editor) + { + super(ERDMessages.erd_editor_control_action_refresh_diagram, DBeaverIcons.getImageDescriptor(UIIcon.REFRESH)); + this.editor = editor; + } + + @Override + public void run() + { + //editor.get + editor.refreshDiagram(true, true); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java index 0dafa70d27..7aecc9d272 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramToggleGridAction.java @@ -1,50 +1,50 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 23, 2004 - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.jface.action.Action; -import org.jkiss.dbeaver.ext.erd.ERDActivator; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; -import org.jkiss.dbeaver.utils.PrefUtils; - -/** - * Action to toggle the layout between manual and automatic - * - * @author Serge Rider - */ -public class DiagramToggleGridAction extends Action -{ - public DiagramToggleGridAction() - { - super(ERDMessages.erd_editor_control_action_toggle_grid, ERDActivator.getImageDescriptor("icons/layer_grid.png")); - } - - @Override - public void run() - { - final DBPPreferenceStore store = ERDActivator.getDefault().getPreferences(); - final boolean gridEnabled = store.getBoolean(ERDConstants.PREF_GRID_ENABLED); - store.setValue(ERDConstants.PREF_GRID_ENABLED, !gridEnabled); - PrefUtils.savePreferenceStore(store); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 23, 2004 + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.jface.action.Action; +import org.jkiss.dbeaver.ext.erd.ERDActivator; +import org.jkiss.dbeaver.ext.erd.ERDConstants; +import org.jkiss.dbeaver.ext.erd.ERDMessages; +import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; +import org.jkiss.dbeaver.utils.PrefUtils; + +/** + * Action to toggle the layout between manual and automatic + * + * @author Serge Rider + */ +public class DiagramToggleGridAction extends Action +{ + public DiagramToggleGridAction() + { + super(ERDMessages.erd_editor_control_action_toggle_grid, ERDActivator.getImageDescriptor("icons/layer_grid.png")); + } + + @Override + public void run() + { + final DBPPreferenceStore store = ERDActivator.getDefault().getPreferences(); + final boolean gridEnabled = store.getBoolean(ERDConstants.PREF_GRID_ENABLED); + store.setValue(ERDConstants.PREF_GRID_ENABLED, !gridEnabled); + PrefUtils.savePreferenceStore(store); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramTogglePersistAction.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramTogglePersistAction.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/DiagramTogglePersistAction.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/DiagramTogglePersistAction.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java index f4b3c65d78..cd07d8d04b 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDEditorPropertyTester.java @@ -1,56 +1,56 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.gef.ui.actions.DeleteAction; -import org.eclipse.ui.IWorkbenchPart; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -/** - * DatabaseEditorPropertyTester - */ -public class ERDEditorPropertyTester extends PropertyTester -{ - public static final String NAMESPACE = "org.jkiss.dbeaver.ext.erd.editor"; - public static final String PROP_CAN_UNDO = "canUndo"; - public static final String PROP_CAN_REDO = "canRedo"; - public static final String PROP_CAN_DELETE = "canDelete"; - public static final String PROP_EDITABLE = "editable"; - - @Override - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (!(receiver instanceof ERDEditorPart)) { - return false; - } - ERDEditorPart erdEditor = (ERDEditorPart) receiver; - switch (property) { - case PROP_CAN_UNDO: - return erdEditor.getCommandStack().canUndo(); - case PROP_CAN_REDO: - return erdEditor.getCommandStack().canRedo(); - case PROP_EDITABLE: - return !erdEditor.isReadOnly(); - case PROP_CAN_DELETE: - DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) erdEditor); - deleteAction.update(); - return deleteAction.isEnabled(); - } - return false; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.gef.ui.actions.DeleteAction; +import org.eclipse.ui.IWorkbenchPart; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +/** + * DatabaseEditorPropertyTester + */ +public class ERDEditorPropertyTester extends PropertyTester +{ + public static final String NAMESPACE = "org.jkiss.dbeaver.ext.erd.editor"; + public static final String PROP_CAN_UNDO = "canUndo"; + public static final String PROP_CAN_REDO = "canRedo"; + public static final String PROP_CAN_DELETE = "canDelete"; + public static final String PROP_EDITABLE = "editable"; + + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (!(receiver instanceof ERDEditorPart)) { + return false; + } + ERDEditorPart erdEditor = (ERDEditorPart) receiver; + switch (property) { + case PROP_CAN_UNDO: + return erdEditor.getCommandStack().canUndo(); + case PROP_CAN_REDO: + return erdEditor.getCommandStack().canRedo(); + case PROP_EDITABLE: + return !erdEditor.isReadOnly(); + case PROP_CAN_DELETE: + DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) erdEditor); + deleteAction.update(); + return deleteAction.isEnabled(); + } + return false; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerCopy.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerCopy.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerCopy.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerCopy.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java index 23be5a68b0..769b1b0a28 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerDelete.java @@ -1,51 +1,51 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.gef.ui.actions.DeleteAction; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerDelete extends AbstractHandler { - public ERDHandlerDelete() { - - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null && !editor.isReadOnly()) { - DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) editor); - deleteAction.update(); - if (deleteAction.isEnabled()) { - deleteAction.run(); - } - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.gef.ui.actions.DeleteAction; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerDelete extends AbstractHandler { + public ERDHandlerDelete() { + + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null && !editor.isReadOnly()) { + DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) editor); + deleteAction.update(); + if (deleteAction.isEnabled()) { + deleteAction.run(); + } + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java index ca1daf198d..e03af0cb73 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPaste.java @@ -1,79 +1,79 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; -import org.jkiss.dbeaver.ext.erd.model.DiagramObjectCollector; -import org.jkiss.dbeaver.ext.erd.model.ERDEntity; -import org.jkiss.dbeaver.model.DBPNamedObject; -import org.jkiss.dbeaver.model.struct.DBSObjectContainer; -import org.jkiss.dbeaver.model.struct.rdb.DBSTable; -import org.jkiss.dbeaver.ui.dnd.DatabaseObjectTransfer; -import org.jkiss.utils.CommonUtils; - -import java.util.Collection; -import java.util.List; - -public class ERDHandlerPaste extends AbstractHandler { - public ERDHandlerPaste() { - - } - - @Override - public boolean isEnabled() - { - final Collection objects = DatabaseObjectTransfer.getFromClipboard(); - if (objects == null || CommonUtils.isEmpty(objects)) { - return false; - } - for (DBPNamedObject object : objects) { - if (object instanceof DBSTable || object instanceof DBSObjectContainer) { - return true; - } - } - return false; - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null && !editor.isReadOnly()) { - final Collection objects = DatabaseObjectTransfer.getInstance().getObject(); - if (!CommonUtils.isEmpty(objects)) { - final List erdEntities = DiagramObjectCollector.generateEntityList(editor.getDiagram(), objects, true); - if (!CommonUtils.isEmpty(erdEntities)) { - Command command = editor.getDiagramPart().createEntityAddCommand(erdEntities, new Point(10, 10)); - editor.getCommandStack().execute(command); - } - } - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.commands.Command; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; +import org.jkiss.dbeaver.ext.erd.model.DiagramObjectCollector; +import org.jkiss.dbeaver.ext.erd.model.ERDEntity; +import org.jkiss.dbeaver.model.DBPNamedObject; +import org.jkiss.dbeaver.model.struct.DBSObjectContainer; +import org.jkiss.dbeaver.model.struct.rdb.DBSTable; +import org.jkiss.dbeaver.ui.dnd.DatabaseObjectTransfer; +import org.jkiss.utils.CommonUtils; + +import java.util.Collection; +import java.util.List; + +public class ERDHandlerPaste extends AbstractHandler { + public ERDHandlerPaste() { + + } + + @Override + public boolean isEnabled() + { + final Collection objects = DatabaseObjectTransfer.getFromClipboard(); + if (objects == null || CommonUtils.isEmpty(objects)) { + return false; + } + for (DBPNamedObject object : objects) { + if (object instanceof DBSTable || object instanceof DBSObjectContainer) { + return true; + } + } + return false; + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null && !editor.isReadOnly()) { + final Collection objects = DatabaseObjectTransfer.getInstance().getObject(); + if (!CommonUtils.isEmpty(objects)) { + final List erdEntities = DiagramObjectCollector.generateEntityList(editor.getDiagram(), objects, true); + if (!CommonUtils.isEmpty(erdEntities)) { + Command command = editor.getDiagramPart().createEntityAddCommand(erdEntities, new Point(10, 10)); + editor.getCommandStack().execute(command); + } + } + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java index 8432a05790..b5557c9fa3 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerPrint.java @@ -1,45 +1,45 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerPrint extends AbstractHandler { - public ERDHandlerPrint() { - - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null) { - editor.printDiagram(); - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerPrint extends AbstractHandler { + public ERDHandlerPrint() { + + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null) { + editor.printDiagram(); + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java index bfe8247811..357f3ee956 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRedo.java @@ -1,42 +1,42 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerRedo extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null && editor.getCommandStack().canRedo()) { - editor.getCommandStack().redo(); - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerRedo extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null && editor.getCommandStack().canRedo()) { + editor.getCommandStack().redo(); + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRefresh.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRefresh.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRefresh.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerRefresh.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java index 0f3bb6eba0..ab10f08b5e 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSaveImage.java @@ -1,45 +1,45 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerSaveImage extends AbstractHandler { - public ERDHandlerSaveImage() { - - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null) { - editor.saveDiagramAs(); - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerSaveImage extends AbstractHandler { + public ERDHandlerSaveImage() { + + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null) { + editor.saveDiagramAs(); + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java index 2c61929c43..2b5dfa76ae 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerSelectAll.java @@ -1,47 +1,47 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.gef.ui.actions.SelectAllAction; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerSelectAll extends AbstractHandler { - public ERDHandlerSelectAll() { - - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null) { - SelectAllAction selectAllAction = new SelectAllAction(editor); - selectAllAction.run(); - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.gef.ui.actions.SelectAllAction; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerSelectAll extends AbstractHandler { + public ERDHandlerSelectAll() { + + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null) { + SelectAllAction selectAllAction = new SelectAllAction(editor); + selectAllAction.run(); + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java index 858f030df6..e11fb1ff61 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/ERDHandlerUndo.java @@ -1,45 +1,45 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; - -public class ERDHandlerUndo extends AbstractHandler { - public ERDHandlerUndo() { - - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); - if (control != null) { - ERDEditorPart editor = ERDEditorAdapter.getEditor(control); - if (editor != null && editor.getCommandStack().canUndo()) { - editor.getCommandStack().undo(); - } - } - return null; - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.ISources; +import org.eclipse.ui.handlers.HandlerUtil; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorAdapter; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; + +public class ERDHandlerUndo extends AbstractHandler { + public ERDHandlerUndo() { + + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME); + if (control != null) { + ERDEditorPart editor = ERDEditorAdapter.getEditor(control); + if (editor != null && editor.getCommandStack().canUndo()) { + editor.getCommandStack().undo(); + } + } + return null; + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java index 37fb7ef7af..84acc38534 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/action/FlyoutChangeLayoutAction.java @@ -1,101 +1,101 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 23, 2004 - */ -package org.jkiss.dbeaver.ext.erd.action; - -import org.eclipse.jface.action.Action; -import org.eclipse.ui.IEditorPart; -import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; -import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; - -/** - * Action to toggle the layout between manual and automatic - * - * @author Serge Rider - */ -public class FlyoutChangeLayoutAction extends Action -{ - - private IEditorPart editor; - private boolean checked; - - public FlyoutChangeLayoutAction(IEditorPart editor) - { - super("Automatic Layout", Action.AS_CHECK_BOX); - this.editor = editor; - } - - @Override - public void run() - { - if (editor instanceof ERDEditorPart) - { - ERDEditorPart erdEditor = (ERDEditorPart) editor; - EntityDiagram entityDiagram = erdEditor.getDiagram(); - boolean isManual = entityDiagram.isLayoutManualDesired(); - entityDiagram.setLayoutManualDesired(!isManual); - erdEditor.getDiagramPart().changeLayout(); - - checked = !isManual; - setChecked(checked); - } - } - - @Override - public boolean isChecked() - { - if (editor != null) - return isChecked(editor); - else - return super.isChecked(); - } - - /** - * @see org.eclipse.jface.action.IAction#isChecked() - */ - public boolean isChecked(IEditorPart editor) - { - - if (editor instanceof ERDEditorPart) - { - ERDEditorPart schemaEditor = (ERDEditorPart) editor; - EntityDiagram entityDiagram = schemaEditor.getDiagram(); - boolean checkTrue = entityDiagram.isLayoutManualDesired(); - return (!checkTrue); - } - else - { - return false; - } - - } - - public void setActiveEditor(IEditorPart editor) - { - this.editor = editor; - boolean localChecked = isChecked(editor); - - //there appears to be a bug in the framework which necessitates this - if (localChecked) - firePropertyChange(CHECKED, Boolean.FALSE, Boolean.TRUE); - else - firePropertyChange(CHECKED, Boolean.TRUE, Boolean.FALSE); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 23, 2004 + */ +package org.jkiss.dbeaver.ext.erd.action; + +import org.eclipse.jface.action.Action; +import org.eclipse.ui.IEditorPart; +import org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart; +import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; + +/** + * Action to toggle the layout between manual and automatic + * + * @author Serge Rider + */ +public class FlyoutChangeLayoutAction extends Action +{ + + private IEditorPart editor; + private boolean checked; + + public FlyoutChangeLayoutAction(IEditorPart editor) + { + super("Automatic Layout", Action.AS_CHECK_BOX); + this.editor = editor; + } + + @Override + public void run() + { + if (editor instanceof ERDEditorPart) + { + ERDEditorPart erdEditor = (ERDEditorPart) editor; + EntityDiagram entityDiagram = erdEditor.getDiagram(); + boolean isManual = entityDiagram.isLayoutManualDesired(); + entityDiagram.setLayoutManualDesired(!isManual); + erdEditor.getDiagramPart().changeLayout(); + + checked = !isManual; + setChecked(checked); + } + } + + @Override + public boolean isChecked() + { + if (editor != null) + return isChecked(editor); + else + return super.isChecked(); + } + + /** + * @see org.eclipse.jface.action.IAction#isChecked() + */ + public boolean isChecked(IEditorPart editor) + { + + if (editor instanceof ERDEditorPart) + { + ERDEditorPart schemaEditor = (ERDEditorPart) editor; + EntityDiagram entityDiagram = schemaEditor.getDiagram(); + boolean checkTrue = entityDiagram.isLayoutManualDesired(); + return (!checkTrue); + } + else + { + return false; + } + + } + + public void setActiveEditor(IEditorPart editor) + { + this.editor = editor; + boolean localChecked = isChecked(editor); + + //there appears to be a bug in the framework which necessitates this + if (localChecked) + firePropertyChange(CHECKED, Boolean.FALSE, Boolean.TRUE); + else + firePropertyChange(CHECKED, Boolean.TRUE, Boolean.FALSE); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java index 4580d17472..a7cd8cda92 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationCreateCommand.java @@ -1,165 +1,165 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.*; -import org.jkiss.dbeaver.model.struct.DBSEntity; -import org.jkiss.dbeaver.model.struct.DBSEntityAttribute; -import org.jkiss.dbeaver.model.virtual.DBVEntity; -import org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey; -import org.jkiss.dbeaver.model.virtual.DBVUtils; -import org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage; -import org.jkiss.utils.CommonUtils; - -import java.util.Collections; -import java.util.List; - -/** - * Command to create association - */ -public class AssociationCreateCommand extends Command { - - protected ERDAssociation association; - protected ERDElement sourceEntity; - protected ERDElement targetEntity; - - private List sourceAttributes; - private List targetAttributes; - - public AssociationCreateCommand() { - } - - public ERDEntityAttribute getSourceAttribute() { - return CommonUtils.isEmpty(sourceAttributes) ? null : sourceAttributes.get(0); - } - - public ERDEntityAttribute getTargetAttribute() { - return CommonUtils.isEmpty(targetAttributes) ? null : targetAttributes.get(0); - } - - public void setAttributes(List sourceAttributes, List targetAttributes) { - this.sourceAttributes = sourceAttributes; - this.targetAttributes = targetAttributes; - - } - public void setAttributes(ERDEntityAttribute sourceAttribute, ERDEntityAttribute targetAttribute) { - this.sourceAttributes = Collections.singletonList(sourceAttribute); - this.targetAttributes = Collections.singletonList(targetAttribute); - } - - @Override - public boolean canExecute() { - - boolean returnValue = true; - if (sourceEntity.equals(targetEntity)) { - returnValue = false; - } else { - - if (targetEntity == null) { - return false; - } else { - // Check for existence of relationship already - List relationships = targetEntity.getReferences(); - for (ERDAssociation currentRelationship : relationships) { - if (currentRelationship.getSourceEntity().equals(sourceEntity)) { - returnValue = false; - break; - } - } - } - - } - - return returnValue; - - } - - @Override - public void execute() { - if (sourceEntity instanceof ERDEntity && targetEntity instanceof ERDEntity) { - DBSEntity srcEntityObject = ((ERDEntity)sourceEntity).getObject(); - DBSEntity targetEntityObject = ((ERDEntity)targetEntity).getObject(); - - List srcAttrs = ERDUtils.getObjectsFromERD(sourceAttributes); - List refAttrs = ERDUtils.getObjectsFromERD(targetAttributes); - - DBVEntity vEntity = DBVUtils.getVirtualEntity(srcEntityObject, true); - DBVEntityForeignKey vfk = EditForeignKeyPage.createVirtualForeignKey( - vEntity, - targetEntityObject, - new EditForeignKeyPage.FKType[] { - EditForeignKeyPage.FK_TYPE_LOGICAL - }, - srcAttrs, - refAttrs); - if (vfk == null) { - return; - } - vEntity.persistConfiguration(); - association = new ERDAssociation(vfk, (ERDEntity)sourceEntity, (ERDEntity)targetEntity, true); - } else { - association = createAssociation(sourceEntity, targetEntity, true); - } - } - - public ERDElement getSourceEntity() { - return sourceEntity; - } - - public void setSourceEntity(ERDElement sourceEntity) { - this.sourceEntity = sourceEntity; - } - - public ERDElement getTargetEntity() { - return targetEntity; - } - - public void setTargetEntity(ERDElement targetEntity) { - this.targetEntity = targetEntity; - } - - public ERDAssociation getAssociation() { - return association; - } - - public void setAssociation(ERDAssociation association) { - this.association = association; - } - - @Override - public void redo() { - if (association != null) { - sourceEntity.addAssociation(association, true); - targetEntity.addReferenceAssociation(association, true); - } - } - - @Override - public void undo() { - if (association != null) { - sourceEntity.removeAssociation(association, true); - targetEntity.removeReferenceAssociation(association, true); - } - } - - protected ERDAssociation createAssociation(ERDElement sourceEntity, ERDElement targetEntity, boolean reflect) { - return new ERDAssociation(sourceEntity, targetEntity, true); - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.*; +import org.jkiss.dbeaver.model.struct.DBSEntity; +import org.jkiss.dbeaver.model.struct.DBSEntityAttribute; +import org.jkiss.dbeaver.model.virtual.DBVEntity; +import org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey; +import org.jkiss.dbeaver.model.virtual.DBVUtils; +import org.jkiss.dbeaver.ui.editors.object.struct.EditForeignKeyPage; +import org.jkiss.utils.CommonUtils; + +import java.util.Collections; +import java.util.List; + +/** + * Command to create association + */ +public class AssociationCreateCommand extends Command { + + protected ERDAssociation association; + protected ERDElement sourceEntity; + protected ERDElement targetEntity; + + private List sourceAttributes; + private List targetAttributes; + + public AssociationCreateCommand() { + } + + public ERDEntityAttribute getSourceAttribute() { + return CommonUtils.isEmpty(sourceAttributes) ? null : sourceAttributes.get(0); + } + + public ERDEntityAttribute getTargetAttribute() { + return CommonUtils.isEmpty(targetAttributes) ? null : targetAttributes.get(0); + } + + public void setAttributes(List sourceAttributes, List targetAttributes) { + this.sourceAttributes = sourceAttributes; + this.targetAttributes = targetAttributes; + + } + public void setAttributes(ERDEntityAttribute sourceAttribute, ERDEntityAttribute targetAttribute) { + this.sourceAttributes = Collections.singletonList(sourceAttribute); + this.targetAttributes = Collections.singletonList(targetAttribute); + } + + @Override + public boolean canExecute() { + + boolean returnValue = true; + if (sourceEntity.equals(targetEntity)) { + returnValue = false; + } else { + + if (targetEntity == null) { + return false; + } else { + // Check for existence of relationship already + List relationships = targetEntity.getReferences(); + for (ERDAssociation currentRelationship : relationships) { + if (currentRelationship.getSourceEntity().equals(sourceEntity)) { + returnValue = false; + break; + } + } + } + + } + + return returnValue; + + } + + @Override + public void execute() { + if (sourceEntity instanceof ERDEntity && targetEntity instanceof ERDEntity) { + DBSEntity srcEntityObject = ((ERDEntity)sourceEntity).getObject(); + DBSEntity targetEntityObject = ((ERDEntity)targetEntity).getObject(); + + List srcAttrs = ERDUtils.getObjectsFromERD(sourceAttributes); + List refAttrs = ERDUtils.getObjectsFromERD(targetAttributes); + + DBVEntity vEntity = DBVUtils.getVirtualEntity(srcEntityObject, true); + DBVEntityForeignKey vfk = EditForeignKeyPage.createVirtualForeignKey( + vEntity, + targetEntityObject, + new EditForeignKeyPage.FKType[] { + EditForeignKeyPage.FK_TYPE_LOGICAL + }, + srcAttrs, + refAttrs); + if (vfk == null) { + return; + } + vEntity.persistConfiguration(); + association = new ERDAssociation(vfk, (ERDEntity)sourceEntity, (ERDEntity)targetEntity, true); + } else { + association = createAssociation(sourceEntity, targetEntity, true); + } + } + + public ERDElement getSourceEntity() { + return sourceEntity; + } + + public void setSourceEntity(ERDElement sourceEntity) { + this.sourceEntity = sourceEntity; + } + + public ERDElement getTargetEntity() { + return targetEntity; + } + + public void setTargetEntity(ERDElement targetEntity) { + this.targetEntity = targetEntity; + } + + public ERDAssociation getAssociation() { + return association; + } + + public void setAssociation(ERDAssociation association) { + this.association = association; + } + + @Override + public void redo() { + if (association != null) { + sourceEntity.addAssociation(association, true); + targetEntity.addReferenceAssociation(association, true); + } + } + + @Override + public void undo() { + if (association != null) { + sourceEntity.removeAssociation(association, true); + targetEntity.removeReferenceAssociation(association, true); + } + } + + protected ERDAssociation createAssociation(ERDElement sourceEntity, ERDElement targetEntity, boolean reflect) { + return new ERDAssociation(sourceEntity, targetEntity, true); + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java index aaaaf5ff8b..5575349fc9 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationDeleteCommand.java @@ -1,98 +1,98 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.SWT; -import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; -import org.jkiss.dbeaver.ext.erd.model.ERDElement; -import org.jkiss.dbeaver.ext.erd.part.AssociationPart; -import org.jkiss.dbeaver.model.struct.DBSEntityAssociation; -import org.jkiss.dbeaver.model.virtual.DBVEntity; -import org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey; -import org.jkiss.dbeaver.model.virtual.DBVUtils; -import org.jkiss.dbeaver.ui.UIUtils; - -/** - * Command to delete relationship - * - * @author Serge Rider - */ -public class AssociationDeleteCommand extends Command { - - protected final AssociationPart part; - protected final ERDElement sourceEntity; - protected final ERDElement targetEntity; - protected final ERDAssociation association; - - public AssociationDeleteCommand(AssociationPart part) { - super(); - this.part = part; - association = part.getAssociation(); - sourceEntity = association.getSourceEntity(); - targetEntity = association.getTargetEntity(); - } - - /** - * Removes the relationship - */ - @Override - public void execute() { - DBSEntityAssociation entityAssociation = association.getObject(); - if (entityAssociation instanceof DBVEntityForeignKey) { - if (!UIUtils.confirmAction("Delete logical key", "Are you sure you want to delete logical key '" + part.getAssociation().getName() + "'?")) { - return; - } - DBVEntity vEntity = DBVUtils.getVirtualEntity(entityAssociation.getParentObject(), false); - if (vEntity == null) { - UIUtils.showMessageBox(UIUtils.getActiveWorkbenchShell(), "No virtual entity", "Can't find association owner virtual entity", SWT.ICON_ERROR); - return; - } - vEntity.removeForeignKey((DBVEntityForeignKey) entityAssociation); - } - part.markAssociatedAttributes(EditPart.SELECTED_NONE); - - targetEntity.removeReferenceAssociation(association, true); - sourceEntity.removeAssociation(association, true); - association.setSourceEntity(null); - association.setTargetEntity(null); - } - - /** - * Restores the relationship - */ - @Override - public void undo() { - if (association.getSourceEntity() != null) { - return; - } - DBSEntityAssociation entityAssociation = association.getObject(); - if (entityAssociation instanceof DBVEntityForeignKey) { - DBVEntity vEntity = DBVUtils.getVirtualEntity(entityAssociation.getParentObject(), false); - if (vEntity != null) { - vEntity.addForeignKey((DBVEntityForeignKey) entityAssociation); - } - } - association.setSourceEntity(sourceEntity); - association.setTargetEntity(targetEntity); - sourceEntity.addAssociation(association, true); - targetEntity.addReferenceAssociation(association, true); - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.swt.SWT; +import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; +import org.jkiss.dbeaver.ext.erd.model.ERDElement; +import org.jkiss.dbeaver.ext.erd.part.AssociationPart; +import org.jkiss.dbeaver.model.struct.DBSEntityAssociation; +import org.jkiss.dbeaver.model.virtual.DBVEntity; +import org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey; +import org.jkiss.dbeaver.model.virtual.DBVUtils; +import org.jkiss.dbeaver.ui.UIUtils; + +/** + * Command to delete relationship + * + * @author Serge Rider + */ +public class AssociationDeleteCommand extends Command { + + protected final AssociationPart part; + protected final ERDElement sourceEntity; + protected final ERDElement targetEntity; + protected final ERDAssociation association; + + public AssociationDeleteCommand(AssociationPart part) { + super(); + this.part = part; + association = part.getAssociation(); + sourceEntity = association.getSourceEntity(); + targetEntity = association.getTargetEntity(); + } + + /** + * Removes the relationship + */ + @Override + public void execute() { + DBSEntityAssociation entityAssociation = association.getObject(); + if (entityAssociation instanceof DBVEntityForeignKey) { + if (!UIUtils.confirmAction("Delete logical key", "Are you sure you want to delete logical key '" + part.getAssociation().getName() + "'?")) { + return; + } + DBVEntity vEntity = DBVUtils.getVirtualEntity(entityAssociation.getParentObject(), false); + if (vEntity == null) { + UIUtils.showMessageBox(UIUtils.getActiveWorkbenchShell(), "No virtual entity", "Can't find association owner virtual entity", SWT.ICON_ERROR); + return; + } + vEntity.removeForeignKey((DBVEntityForeignKey) entityAssociation); + } + part.markAssociatedAttributes(EditPart.SELECTED_NONE); + + targetEntity.removeReferenceAssociation(association, true); + sourceEntity.removeAssociation(association, true); + association.setSourceEntity(null); + association.setTargetEntity(null); + } + + /** + * Restores the relationship + */ + @Override + public void undo() { + if (association.getSourceEntity() != null) { + return; + } + DBSEntityAssociation entityAssociation = association.getObject(); + if (entityAssociation instanceof DBVEntityForeignKey) { + DBVEntity vEntity = DBVUtils.getVirtualEntity(entityAssociation.getParentObject(), false); + if (vEntity != null) { + vEntity.addForeignKey((DBVEntityForeignKey) entityAssociation); + } + } + association.setSourceEntity(sourceEntity); + association.setTargetEntity(targetEntity); + sourceEntity.addAssociation(association, true); + targetEntity.addReferenceAssociation(association, true); + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java index 57f8e998a6..9b368b2d92 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectSourceCommand.java @@ -1,97 +1,97 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; -import org.jkiss.dbeaver.ext.erd.model.ERDElement; - -import java.util.List; - -/** - * Command to change the foreign key we are connecting to a particular primary - * key - * - * @author Serge Rider - */ -public class AssociationReconnectSourceCommand extends Command { - - protected ERDElement sourceEntity; - protected ERDElement targetEntity; - protected ERDAssociation association; - protected ERDElement oldSourceEntity; - - /** - * Makes sure that primary key doesn't reconnect to itself or try to create - * a relationship which already exists - */ - @Override - public boolean canExecute() { - - boolean returnVal = true; - - ERDElement primaryEntity = association.getTargetEntity(); - - //cannot connect to itself - if (primaryEntity.equals(sourceEntity)) { - returnVal = false; - } else { - - List relationships = sourceEntity.getAssociations(); - for (ERDAssociation relationship : relationships) { - if (relationship.getTargetEntity().equals(targetEntity) && - relationship.getSourceEntity().equals(sourceEntity)) { - returnVal = false; - break; - } - } - } - - return returnVal; - - } - - @Override - public void execute() { - if (sourceEntity != null) { - oldSourceEntity.removeAssociation(association, true); - association.setSourceEntity(sourceEntity); - sourceEntity.addAssociation(association, true); - } - } - - public void setSourceEntity(ERDElement sourceEntity) { - this.sourceEntity = sourceEntity; - } - - public ERDAssociation getAssociation() { - return association; - } - - public void setAssociation(ERDAssociation association) { - this.association = association; - targetEntity = association.getTargetEntity(); - oldSourceEntity = association.getSourceEntity(); - } - - @Override - public void undo() { - sourceEntity.removeAssociation(association, true); - association.setSourceEntity(oldSourceEntity); - oldSourceEntity.addAssociation(association, true); - } +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; +import org.jkiss.dbeaver.ext.erd.model.ERDElement; + +import java.util.List; + +/** + * Command to change the foreign key we are connecting to a particular primary + * key + * + * @author Serge Rider + */ +public class AssociationReconnectSourceCommand extends Command { + + protected ERDElement sourceEntity; + protected ERDElement targetEntity; + protected ERDAssociation association; + protected ERDElement oldSourceEntity; + + /** + * Makes sure that primary key doesn't reconnect to itself or try to create + * a relationship which already exists + */ + @Override + public boolean canExecute() { + + boolean returnVal = true; + + ERDElement primaryEntity = association.getTargetEntity(); + + //cannot connect to itself + if (primaryEntity.equals(sourceEntity)) { + returnVal = false; + } else { + + List relationships = sourceEntity.getAssociations(); + for (ERDAssociation relationship : relationships) { + if (relationship.getTargetEntity().equals(targetEntity) && + relationship.getSourceEntity().equals(sourceEntity)) { + returnVal = false; + break; + } + } + } + + return returnVal; + + } + + @Override + public void execute() { + if (sourceEntity != null) { + oldSourceEntity.removeAssociation(association, true); + association.setSourceEntity(sourceEntity); + sourceEntity.addAssociation(association, true); + } + } + + public void setSourceEntity(ERDElement sourceEntity) { + this.sourceEntity = sourceEntity; + } + + public ERDAssociation getAssociation() { + return association; + } + + public void setAssociation(ERDAssociation association) { + this.association = association; + targetEntity = association.getTargetEntity(); + oldSourceEntity = association.getSourceEntity(); + } + + @Override + public void undo() { + sourceEntity.removeAssociation(association, true); + association.setSourceEntity(oldSourceEntity); + oldSourceEntity.addAssociation(association, true); + } } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java index 687b72a235..4a955a88fe 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AssociationReconnectTargetCommand.java @@ -1,90 +1,90 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; -import org.jkiss.dbeaver.ext.erd.model.ERDElement; - -import java.util.List; - -/** - * Command to change the primary key we are connecting to a particular foreign key - * key - */ -public class AssociationReconnectTargetCommand extends Command { - - protected ERDElement sourceEntity; - protected ERDElement targetEntity; - protected ERDAssociation relationship; - protected ERDElement oldTargetEntity; - - /** - * Makes sure that foreign key doesn't reconnect to itself or try to create - * a relationship which already exists - */ - @Override - public boolean canExecute() { - - boolean returnVal = true; - - ERDElement foreignKeyEntity = relationship.getSourceEntity(); - - if (foreignKeyEntity.equals(targetEntity)) { - returnVal = false; - } else { - - List relationships = targetEntity.getReferences(); - for (ERDAssociation relationship : relationships) { - if (relationship.getSourceEntity().equals(sourceEntity) - && relationship.getTargetEntity().equals(targetEntity)) { - returnVal = false; - break; - } - } - } - - return returnVal; - - } - - @Override - public void execute() { - if (targetEntity != null) { - oldTargetEntity.removeReferenceAssociation(relationship, true); - relationship.setTargetEntity(targetEntity); - targetEntity.addReferenceAssociation(relationship, true); - } - } - - public void setTargetEntity(ERDElement targetEntity) { - this.targetEntity = targetEntity; - } - - public void setRelationship(ERDAssociation relationship) { - this.relationship = relationship; - oldTargetEntity = relationship.getTargetEntity(); - sourceEntity = relationship.getSourceEntity(); - } - - @Override - public void undo() { - targetEntity.removeReferenceAssociation(relationship, true); - relationship.setTargetEntity(oldTargetEntity); - oldTargetEntity.addReferenceAssociation(relationship, true); - } +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; +import org.jkiss.dbeaver.ext.erd.model.ERDElement; + +import java.util.List; + +/** + * Command to change the primary key we are connecting to a particular foreign key + * key + */ +public class AssociationReconnectTargetCommand extends Command { + + protected ERDElement sourceEntity; + protected ERDElement targetEntity; + protected ERDAssociation relationship; + protected ERDElement oldTargetEntity; + + /** + * Makes sure that foreign key doesn't reconnect to itself or try to create + * a relationship which already exists + */ + @Override + public boolean canExecute() { + + boolean returnVal = true; + + ERDElement foreignKeyEntity = relationship.getSourceEntity(); + + if (foreignKeyEntity.equals(targetEntity)) { + returnVal = false; + } else { + + List relationships = targetEntity.getReferences(); + for (ERDAssociation relationship : relationships) { + if (relationship.getSourceEntity().equals(sourceEntity) + && relationship.getTargetEntity().equals(targetEntity)) { + returnVal = false; + break; + } + } + } + + return returnVal; + + } + + @Override + public void execute() { + if (targetEntity != null) { + oldTargetEntity.removeReferenceAssociation(relationship, true); + relationship.setTargetEntity(targetEntity); + targetEntity.addReferenceAssociation(relationship, true); + } + } + + public void setTargetEntity(ERDElement targetEntity) { + this.targetEntity = targetEntity; + } + + public void setRelationship(ERDAssociation relationship) { + this.relationship = relationship; + oldTargetEntity = relationship.getTargetEntity(); + sourceEntity = relationship.getSourceEntity(); + } + + @Override + public void undo() { + targetEntity.removeReferenceAssociation(relationship, true); + relationship.setTargetEntity(oldTargetEntity); + oldTargetEntity.addReferenceAssociation(relationship, true); + } } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AttributeCheckCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AttributeCheckCommand.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/AttributeCheckCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/AttributeCheckCommand.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java index b927512ef8..4138dad5a4 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCommand.java @@ -1,32 +1,32 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.part.AssociationPart; - - -public abstract class BendpointCommand extends Command { - - protected final AssociationPart association; - - public BendpointCommand(AssociationPart association) { - this.association = association; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.part.AssociationPart; + + +public abstract class BendpointCommand extends Command { + + protected final AssociationPart association; + + public BendpointCommand(AssociationPart association) { + this.association = association; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java index ed8966e917..145d296956 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointCreateCommand.java @@ -1,46 +1,46 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.geometry.Point; -import org.jkiss.dbeaver.ext.erd.part.AssociationPart; - - -public class BendpointCreateCommand extends BendpointCommand { - - private Point location; - private int bendpointIndex; - - public BendpointCreateCommand(AssociationPart association, Point location, int bendpointIndex) { - super(association); - this.location = location; - this.bendpointIndex = bendpointIndex; - } - - @Override - public void execute() { - association.addBendpoint(bendpointIndex, location); - } - - @Override - public void undo() { - association.removeBendpoint(bendpointIndex); - } - -} - - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.geometry.Point; +import org.jkiss.dbeaver.ext.erd.part.AssociationPart; + + +public class BendpointCreateCommand extends BendpointCommand { + + private Point location; + private int bendpointIndex; + + public BendpointCreateCommand(AssociationPart association, Point location, int bendpointIndex) { + super(association); + this.location = location; + this.bendpointIndex = bendpointIndex; + } + + @Override + public void execute() { + association.addBendpoint(bendpointIndex, location); + } + + @Override + public void undo() { + association.removeBendpoint(bendpointIndex); + } + +} + + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java index 7830005236..be284e9258 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointDeleteCommand.java @@ -1,45 +1,45 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.jkiss.dbeaver.ext.erd.part.AssociationPart; - -public class BendpointDeleteCommand extends BendpointCommand { - - private int bendpointIndex; - - public BendpointDeleteCommand(AssociationPart association, int bendpointIndex) { - super(association); - this.bendpointIndex = bendpointIndex; - } - - @Override - public void execute() { - association.removeBendpoint(bendpointIndex); - } - - @Override - public void undo() { -/* - super.undo(); - getWire().insertBendpoint(getIndex(), bendpoint); -*/ - } - -} - - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.jkiss.dbeaver.ext.erd.part.AssociationPart; + +public class BendpointDeleteCommand extends BendpointCommand { + + private int bendpointIndex; + + public BendpointDeleteCommand(AssociationPart association, int bendpointIndex) { + super(association); + this.bendpointIndex = bendpointIndex; + } + + @Override + public void execute() { + association.removeBendpoint(bendpointIndex); + } + + @Override + public void undo() { +/* + super.undo(); + getWire().insertBendpoint(getIndex(), bendpoint); +*/ + } + +} + + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java index 33d7ca0afb..e85ca2f8dc 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/BendpointMoveCommand.java @@ -1,59 +1,59 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.Bendpoint; -import org.eclipse.draw2d.geometry.Point; -import org.jkiss.dbeaver.ext.erd.part.AssociationPart; - -public class BendpointMoveCommand extends BendpointCommand { - - private Point location; - private int bendpointIndex; - - private Bendpoint oldBendpoint; - - public BendpointMoveCommand(AssociationPart association, Point location, int bendpointIndex) { - super(association); - this.location = location; - this.bendpointIndex = bendpointIndex; - } - - @Override - public void execute() { - association.moveBendpoint(bendpointIndex, location); -/* - WireBendpoint bp = new WireBendpoint(); - bp.setRelativeDimensions(getFirstRelativeDimension(), - getSecondRelativeDimension()); - setOldBendpoint((Bendpoint) getWire().getBendpoints().get(getIndex())); - getWire().setBendpoint(getIndex(), bp); - super.execute(); -*/ - } - - @Override - public void undo() { -/* - super.undo(); - getWire().setBendpoint(getIndex(), getOldBendpoint()); -*/ - } - -} - - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.Bendpoint; +import org.eclipse.draw2d.geometry.Point; +import org.jkiss.dbeaver.ext.erd.part.AssociationPart; + +public class BendpointMoveCommand extends BendpointCommand { + + private Point location; + private int bendpointIndex; + + private Bendpoint oldBendpoint; + + public BendpointMoveCommand(AssociationPart association, Point location, int bendpointIndex) { + super(association); + this.location = location; + this.bendpointIndex = bendpointIndex; + } + + @Override + public void execute() { + association.moveBendpoint(bendpointIndex, location); +/* + WireBendpoint bp = new WireBendpoint(); + bp.setRelativeDimensions(getFirstRelativeDimension(), + getSecondRelativeDimension()); + setOldBendpoint((Bendpoint) getWire().getBendpoints().get(getIndex())); + getWire().setBendpoint(getIndex(), bp); + super.execute(); +*/ + } + + @Override + public void undo() { +/* + super.undo(); + getWire().setBendpoint(getIndex(), getOldBendpoint()); +*/ + } + +} + + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java index 61ce7580ba..a1830e3b7f 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityAddCommand.java @@ -1,141 +1,141 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDEntity; -import org.jkiss.dbeaver.ext.erd.model.ERDUtils; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.ext.erd.part.EntityPart; -import org.jkiss.dbeaver.model.DBUtils; -import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode; -import org.jkiss.dbeaver.model.navigator.DBNNode; -import org.jkiss.dbeaver.model.navigator.DBNUtils; -import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor; -import org.jkiss.dbeaver.model.struct.DBSEntity; -import org.jkiss.dbeaver.model.struct.DBSObject; -import org.jkiss.dbeaver.model.struct.rdb.DBSTable; -import org.jkiss.dbeaver.runtime.DBWorkbench; -import org.jkiss.dbeaver.ui.UIUtils; - -import java.util.Collections; -import java.util.List; - -/** - * Add entity to diagram - */ -public class EntityAddCommand extends Command -{ - - protected DiagramPart diagramPart; - protected List entities; - protected Point location; - - public EntityAddCommand(DiagramPart diagram, List entities, Point location) - { - this.diagramPart = diagram; - this.entities = entities; - this.location = location; - } - - public DiagramPart getDiagram() { - return diagramPart; - } - - @Override - public void execute() - { - VoidProgressMonitor monitor = new VoidProgressMonitor(); - - Point curLocation = location == null ? null : new Point(location); - for (ERDEntity entity : entities) { - boolean resolveRelations = false; - if (entity.getObject() == null) { - // Entity is not initialized - if (entity.getDataSource() != null) { - DBSObject selectedObject = DBUtils.getSelectedObject(DBUtils.getDefaultContext(entity.getDataSource(), false)); - DBNDatabaseNode dsNode = DBNUtils.getNodeByObject(selectedObject != null ? selectedObject : entity.getDataSource().getContainer()); - if (dsNode != null) { - DBNNode tableNode = DBWorkbench.getPlatformUI().selectObject( - UIUtils.getActiveWorkbenchShell(), - "Select a table", - dsNode, - null, - new Class[]{DBSTable.class}, - new Class[]{DBSTable.class}, - null); - if (tableNode instanceof DBNDatabaseNode && ((DBNDatabaseNode) tableNode).getObject() instanceof DBSEntity) { - entity = ERDUtils.makeEntityFromObject( - monitor, - diagramPart.getDiagram(), - Collections.emptyList(), - (DBSEntity)((DBNDatabaseNode) tableNode).getObject(), - null); - // This actually only loads unresolved relations. - // This happens only with entities added on diagram during editing - entity.addModelRelations(monitor, diagramPart.getDiagram(), false, false); - } - } - } - } - if (entity.getObject() == null) { - continue; - } - diagramPart.getDiagram().addEntity(entity, true); - - if (curLocation != null) { - // Put new entities in specified location - for (Object diagramChild : diagramPart.getChildren()) { - if (diagramChild instanceof EntityPart) { - EntityPart entityPart = (EntityPart) diagramChild; - if (entityPart.getEntity() == entity) { - final Rectangle newBounds = new Rectangle(); - final Dimension size = entityPart.getFigure().getPreferredSize(); - newBounds.x = curLocation.x; - newBounds.y = curLocation.y; - newBounds.width = size.width; - newBounds.height = size.height; - entityPart.modifyBounds(newBounds); - - curLocation.x += size.width + (size.width / 2); - break; - } - } - } - } - - handleEntityChange(entity, false); - } - } - - @Override - public void undo() - { - for (ERDEntity entity : entities) { - diagramPart.getDiagram().removeEntity(entity, true); - handleEntityChange(entity, true); - } - } - - protected void handleEntityChange(ERDEntity entity, boolean remove) { - // Nothing special - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDEntity; +import org.jkiss.dbeaver.ext.erd.model.ERDUtils; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.ext.erd.part.EntityPart; +import org.jkiss.dbeaver.model.DBUtils; +import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode; +import org.jkiss.dbeaver.model.navigator.DBNNode; +import org.jkiss.dbeaver.model.navigator.DBNUtils; +import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor; +import org.jkiss.dbeaver.model.struct.DBSEntity; +import org.jkiss.dbeaver.model.struct.DBSObject; +import org.jkiss.dbeaver.model.struct.rdb.DBSTable; +import org.jkiss.dbeaver.runtime.DBWorkbench; +import org.jkiss.dbeaver.ui.UIUtils; + +import java.util.Collections; +import java.util.List; + +/** + * Add entity to diagram + */ +public class EntityAddCommand extends Command +{ + + protected DiagramPart diagramPart; + protected List entities; + protected Point location; + + public EntityAddCommand(DiagramPart diagram, List entities, Point location) + { + this.diagramPart = diagram; + this.entities = entities; + this.location = location; + } + + public DiagramPart getDiagram() { + return diagramPart; + } + + @Override + public void execute() + { + VoidProgressMonitor monitor = new VoidProgressMonitor(); + + Point curLocation = location == null ? null : new Point(location); + for (ERDEntity entity : entities) { + boolean resolveRelations = false; + if (entity.getObject() == null) { + // Entity is not initialized + if (entity.getDataSource() != null) { + DBSObject selectedObject = DBUtils.getSelectedObject(DBUtils.getDefaultContext(entity.getDataSource(), false)); + DBNDatabaseNode dsNode = DBNUtils.getNodeByObject(selectedObject != null ? selectedObject : entity.getDataSource().getContainer()); + if (dsNode != null) { + DBNNode tableNode = DBWorkbench.getPlatformUI().selectObject( + UIUtils.getActiveWorkbenchShell(), + "Select a table", + dsNode, + null, + new Class[]{DBSTable.class}, + new Class[]{DBSTable.class}, + null); + if (tableNode instanceof DBNDatabaseNode && ((DBNDatabaseNode) tableNode).getObject() instanceof DBSEntity) { + entity = ERDUtils.makeEntityFromObject( + monitor, + diagramPart.getDiagram(), + Collections.emptyList(), + (DBSEntity)((DBNDatabaseNode) tableNode).getObject(), + null); + // This actually only loads unresolved relations. + // This happens only with entities added on diagram during editing + entity.addModelRelations(monitor, diagramPart.getDiagram(), false, false); + } + } + } + } + if (entity.getObject() == null) { + continue; + } + diagramPart.getDiagram().addEntity(entity, true); + + if (curLocation != null) { + // Put new entities in specified location + for (Object diagramChild : diagramPart.getChildren()) { + if (diagramChild instanceof EntityPart) { + EntityPart entityPart = (EntityPart) diagramChild; + if (entityPart.getEntity() == entity) { + final Rectangle newBounds = new Rectangle(); + final Dimension size = entityPart.getFigure().getPreferredSize(); + newBounds.x = curLocation.x; + newBounds.y = curLocation.y; + newBounds.width = size.width; + newBounds.height = size.height; + entityPart.modifyBounds(newBounds); + + curLocation.x += size.width + (size.width / 2); + break; + } + } + } + } + + handleEntityChange(entity, false); + } + } + + @Override + public void undo() + { + for (ERDEntity entity : entities) { + diagramPart.getDiagram().removeEntity(entity, true); + handleEntityChange(entity, true); + } + } + + protected void handleEntityChange(ERDEntity entity, boolean remove) { + // Nothing special + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java index f232ed5aaa..5f7fb7ccc1 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/EntityDeleteCommand.java @@ -1,128 +1,128 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; -import org.jkiss.dbeaver.ext.erd.model.ERDEntity; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.ext.erd.part.EntityPart; - -import java.util.ArrayList; -import java.util.List; - -/** - * Command to delete tables from the schema - * - * @author Serge Rider - */ -public class EntityDeleteCommand extends Command { - - private EntityPart entityPart; - private DiagramPart diagramPart; - private ERDEntity entity; - private int index = -1; - private List foreignKeyRelationships = new ArrayList<>(); - private List primaryKeyRelationships = new ArrayList<>(); - //private Rectangle bounds; - - public EntityDeleteCommand(EntityPart entityPart) { - this.entityPart = entityPart; - this.diagramPart = entityPart.getDiagramPart(); - this.entity = entityPart.getEntity(); - //this.bounds = entityPart.getFigure().getBounds().getCopy(); - } - - public EntityPart getEntityPart() { - return entityPart; - } - - public ERDEntity getEntity() { - return entity; - } - - private void deleteRelationships(ERDEntity t) { - - this.foreignKeyRelationships.addAll(t.getAssociations()); - - //for all relationships where current entity is foreign key - for (ERDAssociation association : foreignKeyRelationships) { - association.getTargetEntity().removeReferenceAssociation(association, true); - t.removeAssociation(association, true); - } - - //for all relationships where current entity is primary key - this.primaryKeyRelationships.addAll(t.getReferences()); - for (ERDAssociation r : primaryKeyRelationships) { - r.getSourceEntity().removeAssociation(r, true); - t.removeReferenceAssociation(r, true); - } - } - - /** - * @see org.eclipse.gef.commands.Command#execute() - */ - @Override - public void execute() { - primExecute(); - } - - /** - * Invokes the execution of this command. - */ - private void primExecute() { - // Put entity's bound in init map - it could be used by EntityPart on undo - diagramPart.getDiagram().getVisualInfo(entity.getObject(), true).initBounds = entityPart.getBounds(); - - // Zero bounds - to let modifyBounds reflect on undo - //entityPart.modifyBounds(new Rectangle(0, 0, 0, 0)); - - // Delete entity - deleteRelationships(entity); - index = diagramPart.getDiagram().getEntities().indexOf(entity); - diagramPart.getDiagram().removeEntity(entity, true); - } - - /** - * @see org.eclipse.gef.commands.Command#redo() - */ - @Override - public void redo() { - primExecute(); - } - - private void restoreRelationships() { - for (ERDAssociation r : foreignKeyRelationships) { - r.getSourceEntity().addAssociation(r, true); - r.getTargetEntity().addReferenceAssociation(r, true); - } - foreignKeyRelationships.clear(); - for (ERDAssociation r : primaryKeyRelationships) { - r.getSourceEntity().addAssociation(r, true); - r.getTargetEntity().addReferenceAssociation(r, true); - } - primaryKeyRelationships.clear(); - } - - @Override - public void undo() { - diagramPart.getDiagram().addEntity(entity, index, true); - restoreRelationships(); - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDAssociation; +import org.jkiss.dbeaver.ext.erd.model.ERDEntity; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.ext.erd.part.EntityPart; + +import java.util.ArrayList; +import java.util.List; + +/** + * Command to delete tables from the schema + * + * @author Serge Rider + */ +public class EntityDeleteCommand extends Command { + + private EntityPart entityPart; + private DiagramPart diagramPart; + private ERDEntity entity; + private int index = -1; + private List foreignKeyRelationships = new ArrayList<>(); + private List primaryKeyRelationships = new ArrayList<>(); + //private Rectangle bounds; + + public EntityDeleteCommand(EntityPart entityPart) { + this.entityPart = entityPart; + this.diagramPart = entityPart.getDiagramPart(); + this.entity = entityPart.getEntity(); + //this.bounds = entityPart.getFigure().getBounds().getCopy(); + } + + public EntityPart getEntityPart() { + return entityPart; + } + + public ERDEntity getEntity() { + return entity; + } + + private void deleteRelationships(ERDEntity t) { + + this.foreignKeyRelationships.addAll(t.getAssociations()); + + //for all relationships where current entity is foreign key + for (ERDAssociation association : foreignKeyRelationships) { + association.getTargetEntity().removeReferenceAssociation(association, true); + t.removeAssociation(association, true); + } + + //for all relationships where current entity is primary key + this.primaryKeyRelationships.addAll(t.getReferences()); + for (ERDAssociation r : primaryKeyRelationships) { + r.getSourceEntity().removeAssociation(r, true); + t.removeReferenceAssociation(r, true); + } + } + + /** + * @see org.eclipse.gef.commands.Command#execute() + */ + @Override + public void execute() { + primExecute(); + } + + /** + * Invokes the execution of this command. + */ + private void primExecute() { + // Put entity's bound in init map - it could be used by EntityPart on undo + diagramPart.getDiagram().getVisualInfo(entity.getObject(), true).initBounds = entityPart.getBounds(); + + // Zero bounds - to let modifyBounds reflect on undo + //entityPart.modifyBounds(new Rectangle(0, 0, 0, 0)); + + // Delete entity + deleteRelationships(entity); + index = diagramPart.getDiagram().getEntities().indexOf(entity); + diagramPart.getDiagram().removeEntity(entity, true); + } + + /** + * @see org.eclipse.gef.commands.Command#redo() + */ + @Override + public void redo() { + primExecute(); + } + + private void restoreRelationships() { + for (ERDAssociation r : foreignKeyRelationships) { + r.getSourceEntity().addAssociation(r, true); + r.getTargetEntity().addReferenceAssociation(r, true); + } + foreignKeyRelationships.clear(); + for (ERDAssociation r : primaryKeyRelationships) { + r.getSourceEntity().addAssociation(r, true); + r.getTargetEntity().addReferenceAssociation(r, true); + } + primaryKeyRelationships.clear(); + } + + @Override + public void undo() { + diagramPart.getDiagram().addEntity(entity, index, true); + restoreRelationships(); + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java index 3445ffd711..fb78dec406 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NodeMoveCommand.java @@ -1,64 +1,64 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.part.NodePart; - -/** - * Command to move the bounds of an existing table. Only used with - * XYLayoutEditPolicy (manual layout) - * - * @author Serge Rider - */ -public class NodeMoveCommand extends Command -{ - - private NodePart nodePart; - private Rectangle oldBounds; - private Rectangle newBounds; - - public NodeMoveCommand(NodePart nodePart, Rectangle oldBounds, Rectangle newBounds) - { - super(); - this.nodePart = nodePart; - this.oldBounds = oldBounds; - this.newBounds = newBounds; - } - - @Override - public void execute() - { -/* - List tcList = nodePart.getTargetConnections(); - for (Object tc : tcList) { - AssociationPart as = (AssociationPart)tc ; - PolylineConnection pc = (PolylineConnection) as.getFigure(); - pc.getConnectionRouter().route(pc); - } -*/ - nodePart.modifyBounds(newBounds); - } - - @Override - public void undo() - { - nodePart.modifyBounds(oldBounds); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.part.NodePart; + +/** + * Command to move the bounds of an existing table. Only used with + * XYLayoutEditPolicy (manual layout) + * + * @author Serge Rider + */ +public class NodeMoveCommand extends Command +{ + + private NodePart nodePart; + private Rectangle oldBounds; + private Rectangle newBounds; + + public NodeMoveCommand(NodePart nodePart, Rectangle oldBounds, Rectangle newBounds) + { + super(); + this.nodePart = nodePart; + this.oldBounds = oldBounds; + this.newBounds = newBounds; + } + + @Override + public void execute() + { +/* + List tcList = nodePart.getTargetConnections(); + for (Object tc : tcList) { + AssociationPart as = (AssociationPart)tc ; + PolylineConnection pc = (PolylineConnection) as.getFigure(); + pc.getConnectionRouter().route(pc); + } +*/ + nodePart.modifyBounds(newBounds); + } + + @Override + public void undo() + { + nodePart.modifyBounds(oldBounds); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java index 7995eeaa9c..d33e8bd19f 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteCreateCommand.java @@ -1,77 +1,77 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDNote; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.ext.erd.part.NotePart; - -/** - * Add entity to diagram - */ -public class NoteCreateCommand extends Command -{ - - private DiagramPart diagramPart; - private ERDNote note; - private Point location; - private Dimension size; - - public NoteCreateCommand(DiagramPart diagram, ERDNote note, Point location, Dimension size) - { - this.diagramPart = diagram; - this.note = note; - this.location = location; - this.size = size; - } - - @Override - public void execute() - { - diagramPart.getDiagram().addNote(note, true); - //diagramPart.getDiagram().addModelRelations(monitor, table, true); - - if (location != null) { - // Set new note location - for (Object diagramChild : diagramPart.getChildren()) { - if (diagramChild instanceof NotePart) { - NotePart notePart = (NotePart) diagramChild; - if (notePart.getNote() == note) { - Dimension size = this.size; - if (size == null || size.width <= 0 || size.height <= 0) { - size = notePart.getFigure().getPreferredSize(); - } - final Rectangle newBounds = new Rectangle(location.x, location.y, size.width, size.height); - notePart.modifyBounds(newBounds); - break; - } - } - } - } - } - - @Override - public void undo() - { - diagramPart.getDiagram().removeNote(note, true); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDNote; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.ext.erd.part.NotePart; + +/** + * Add entity to diagram + */ +public class NoteCreateCommand extends Command +{ + + private DiagramPart diagramPart; + private ERDNote note; + private Point location; + private Dimension size; + + public NoteCreateCommand(DiagramPart diagram, ERDNote note, Point location, Dimension size) + { + this.diagramPart = diagram; + this.note = note; + this.location = location; + this.size = size; + } + + @Override + public void execute() + { + diagramPart.getDiagram().addNote(note, true); + //diagramPart.getDiagram().addModelRelations(monitor, table, true); + + if (location != null) { + // Set new note location + for (Object diagramChild : diagramPart.getChildren()) { + if (diagramChild instanceof NotePart) { + NotePart notePart = (NotePart) diagramChild; + if (notePart.getNote() == note) { + Dimension size = this.size; + if (size == null || size.width <= 0 || size.height <= 0) { + size = notePart.getFigure().getPreferredSize(); + } + final Rectangle newBounds = new Rectangle(location.x, location.y, size.width, size.height); + notePart.modifyBounds(newBounds); + break; + } + } + } + } + } + + @Override + public void undo() + { + diagramPart.getDiagram().removeNote(note, true); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java index 7ff50285a9..8fe4951414 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteDeleteCommand.java @@ -1,69 +1,69 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.command; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.jkiss.dbeaver.ext.erd.model.ERDNote; -import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; -import org.jkiss.dbeaver.ext.erd.part.NotePart; - -/** - * Command to delete tables from the schema - * - * @author Serge Rider - */ -public class NoteDeleteCommand extends Command -{ - private NotePart notePart; - private ERDNote note; - private EntityDiagram entityDiagram; - private Rectangle bounds; - - public NoteDeleteCommand(EntityDiagram entityDiagram, NotePart notePart, Rectangle originalBounds) { - this.entityDiagram = entityDiagram; - this.notePart = notePart; - this.note = notePart.getNote(); - this.bounds = originalBounds; - } - - /** - * @see org.eclipse.gef.commands.Command#execute() - */ - @Override - public void execute() - { - entityDiagram.removeNote(note, true); - } - - /** - * @see org.eclipse.gef.commands.Command#redo() - */ - @Override - public void redo() - { - execute(); - } - - @Override - public void undo() - { - entityDiagram.addNote(note, true); - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.command; + +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.commands.Command; +import org.jkiss.dbeaver.ext.erd.model.ERDNote; +import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; +import org.jkiss.dbeaver.ext.erd.part.NotePart; + +/** + * Command to delete tables from the schema + * + * @author Serge Rider + */ +public class NoteDeleteCommand extends Command +{ + private NotePart notePart; + private ERDNote note; + private EntityDiagram entityDiagram; + private Rectangle bounds; + + public NoteDeleteCommand(EntityDiagram entityDiagram, NotePart notePart, Rectangle originalBounds) { + this.entityDiagram = entityDiagram; + this.notePart = notePart; + this.note = notePart.getNote(); + this.bounds = originalBounds; + } + + /** + * @see org.eclipse.gef.commands.Command#execute() + */ + @Override + public void execute() + { + entityDiagram.removeNote(note, true); + } + + /** + * @see org.eclipse.gef.commands.Command#redo() + */ + @Override + public void redo() + { + execute(); + } + + @Override + public void undo() + { + entityDiagram.addNote(note, true); + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteSetTextCommand.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteSetTextCommand.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/command/NoteSetTextCommand.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/command/NoteSetTextCommand.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java similarity index 95% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java index d86ce266cb..a7b445984e 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ColumnNameTypeCellEditorValidator.java @@ -1,97 +1,97 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 19, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -import org.eclipse.jface.viewers.ICellEditorValidator; - - -/** - * ICellValidator to validate direct edit values in the column label - * Collaborates with an instance of ValidationMessageHandler - * @author Serge Rider - */ -public class ColumnNameTypeCellEditorValidator implements ICellEditorValidator -{ - - private ValidationMessageHandler handler; - - /** - * @param validationMessageHandler the validation message handler to pass error information to - */ - public ColumnNameTypeCellEditorValidator(ValidationMessageHandler validationMessageHandler) - { - this.handler = validationMessageHandler; - } - - /** - * @return the error message if an error has occurred, otherwise null - */ - @Override - public String isValid(Object value) - { - String string = (String)value; - String name = null; - String type = null; - int colonIndex = string.indexOf(':'); - if (colonIndex >= 0) - { - name = string.substring(0, colonIndex); - if (string.length() > colonIndex+1) - { - type = string.substring(colonIndex+1); - } - } - if (name != null && type!= null) - { - - if (name.indexOf(" ")!= -1) - { - String text = "Column name should not include the space character"; - return setMessageText(text); - } else { - return unsetMessageText(); - } - } - else - { - String text = "Invalid format for text entry. Needs [name]:[type] format"; - return setMessageText(text); - } - } - - - private String unsetMessageText() - { - handler.reset(); - return null; - } - - - - - private String setMessageText(String text) - { - handler.setMessageText(text); - return text; - } - - - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 19, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +import org.eclipse.jface.viewers.ICellEditorValidator; + + +/** + * ICellValidator to validate direct edit values in the column label + * Collaborates with an instance of ValidationMessageHandler + * @author Serge Rider + */ +public class ColumnNameTypeCellEditorValidator implements ICellEditorValidator +{ + + private ValidationMessageHandler handler; + + /** + * @param validationMessageHandler the validation message handler to pass error information to + */ + public ColumnNameTypeCellEditorValidator(ValidationMessageHandler validationMessageHandler) + { + this.handler = validationMessageHandler; + } + + /** + * @return the error message if an error has occurred, otherwise null + */ + @Override + public String isValid(Object value) + { + String string = (String)value; + String name = null; + String type = null; + int colonIndex = string.indexOf(':'); + if (colonIndex >= 0) + { + name = string.substring(0, colonIndex); + if (string.length() > colonIndex+1) + { + type = string.substring(colonIndex+1); + } + } + if (name != null && type!= null) + { + + if (name.indexOf(" ")!= -1) + { + String text = "Column name should not include the space character"; + return setMessageText(text); + } else { + return unsetMessageText(); + } + } + else + { + String text = "Invalid format for text entry. Needs [name]:[type] format"; + return setMessageText(text); + } + } + + + private String unsetMessageText() + { + handler.reset(); + return null; + } + + + + + private String setMessageText(String text) + { + handler.setMessageText(text); + return text; + } + + + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java index bb5f7bbac2..0f93672599 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ExtendedDirectEditManager.java @@ -1,202 +1,202 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 13, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; -import org.jkiss.dbeaver.ext.erd.figures.NoteFigure; - -/** - * A generic DirectEdit manager to be used for labels which includes validation - * functionality by adding the ICellEditorValidator on startup - */ -public class ExtendedDirectEditManager extends DirectEditManager { - - protected Font figureFont; - protected VerifyListener verifyListener; - protected IFigure figure; - protected String originalValue; - private boolean committing = false; - private ICellEditorValidator validator = null; - - /** - * Creates a new ActivityDirectEditManager with the given attributes. - * - * @param source the source EditPart - * @param editorType type of editor - * @param locator the CellEditorLocator - */ - public ExtendedDirectEditManager(GraphicalEditPart source, Class editorType, CellEditorLocator locator, - IFigure figure, ICellEditorValidator validator) { - super(source, editorType, locator); - this.figure = figure; - this.originalValue = getFigureText(figure); - this.validator = validator; - } - - private static String getFigureText(IFigure figure) { - if (figure instanceof Label) { - return ((Label) figure).getText(); - } else if (figure instanceof NoteFigure) { - return ((NoteFigure) figure).getText(); - } else { - return "???"; - } - } - - /** - * @see org.eclipse.gef.tools.DirectEditManager#bringDown() - */ - @Override - protected void bringDown() { - Font disposeFont = figureFont; - figureFont = null; - super.bringDown(); - if (disposeFont != null) - disposeFont.dispose(); - } - - /** - * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor() - */ - @Override - protected void initCellEditor() { - - Text text = (Text) getCellEditor().getControl(); - - //add the verifyListener to apply changes to the control size - verifyListener = new VerifyListener() { - - /** - * Changes the size of the editor control to reflect the changed - * text - */ - @Override - public void verifyText(VerifyEvent event) { - Text text = (Text) getCellEditor().getControl(); - String oldText = text.getText(); - String leftText = oldText.substring(0, event.start); - String rightText = oldText.substring(event.end, oldText.length()); - GC gc = new GC(text); - - String s = leftText + event.text + rightText; - - Point size = gc.textExtent(leftText + event.text + rightText); - - gc.dispose(); - if (size.x != 0) - size = text.computeSize(size.x, SWT.DEFAULT); - else { - //just make it square - size.x = size.y; - } - getCellEditor().getControl().setSize(size.x, size.y); - } - - }; - text.addVerifyListener(verifyListener); - - //set the initial value of the - originalValue = getFigureText(this.figure); - getCellEditor().setValue(originalValue); - - //calculate the font size of the underlying - IFigure figure = getEditPart().getFigure(); - figureFont = figure.getFont(); - FontData data = figureFont.getFontData()[0]; - Dimension fontSize = new Dimension(0, data.getHeight()); - - //set the font to be used - this.figure.translateToAbsolute(fontSize); - data.setHeight(fontSize.height); - figureFont = new Font(null, data); - - //set the validator for the CellEditor - getCellEditor().setValidator(validator); - - text.setFont(figureFont); - text.selectAll(); - } - - /** - * Commits the current value of the cell editor by getting a {@link Command} - * from the source edit part and executing it via the {@link CommandStack}. - * Finally, {@link #bringDown()}is called to perform and necessary cleanup. - */ - @Override - protected void commit() { - - if (committing) - return; - - committing = true; - - try { - - //we set the cell editor control to invisible to remove any - // possible flicker - getCellEditor().getControl().setVisible(false); - if (isDirty()) { - CommandStack stack = getEditPart().getViewer().getEditDomain().getCommandStack(); - EditPolicy editPolicy = getEditPart().getEditPolicy(EditPolicy.DIRECT_EDIT_ROLE); - Command command; - if (editPolicy != null) { - command = editPolicy.getCommand(getDirectEditRequest()); - } else { - command = getEditPart().getCommand(getDirectEditRequest()); - } - if (command != null && command.canExecute()) { - stack.execute(command); - } - } - } finally { - bringDown(); - committing = false; - } - } - - /** - * Need to override so as to remove the verify listener - */ - @Override - protected void unhookListeners() { - super.unhookListeners(); - Text text = (Text) getCellEditor().getControl(); - text.removeVerifyListener(verifyListener); - verifyListener = null; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 13, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; +import org.jkiss.dbeaver.ext.erd.figures.NoteFigure; + +/** + * A generic DirectEdit manager to be used for labels which includes validation + * functionality by adding the ICellEditorValidator on startup + */ +public class ExtendedDirectEditManager extends DirectEditManager { + + protected Font figureFont; + protected VerifyListener verifyListener; + protected IFigure figure; + protected String originalValue; + private boolean committing = false; + private ICellEditorValidator validator = null; + + /** + * Creates a new ActivityDirectEditManager with the given attributes. + * + * @param source the source EditPart + * @param editorType type of editor + * @param locator the CellEditorLocator + */ + public ExtendedDirectEditManager(GraphicalEditPart source, Class editorType, CellEditorLocator locator, + IFigure figure, ICellEditorValidator validator) { + super(source, editorType, locator); + this.figure = figure; + this.originalValue = getFigureText(figure); + this.validator = validator; + } + + private static String getFigureText(IFigure figure) { + if (figure instanceof Label) { + return ((Label) figure).getText(); + } else if (figure instanceof NoteFigure) { + return ((NoteFigure) figure).getText(); + } else { + return "???"; + } + } + + /** + * @see org.eclipse.gef.tools.DirectEditManager#bringDown() + */ + @Override + protected void bringDown() { + Font disposeFont = figureFont; + figureFont = null; + super.bringDown(); + if (disposeFont != null) + disposeFont.dispose(); + } + + /** + * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor() + */ + @Override + protected void initCellEditor() { + + Text text = (Text) getCellEditor().getControl(); + + //add the verifyListener to apply changes to the control size + verifyListener = new VerifyListener() { + + /** + * Changes the size of the editor control to reflect the changed + * text + */ + @Override + public void verifyText(VerifyEvent event) { + Text text = (Text) getCellEditor().getControl(); + String oldText = text.getText(); + String leftText = oldText.substring(0, event.start); + String rightText = oldText.substring(event.end, oldText.length()); + GC gc = new GC(text); + + String s = leftText + event.text + rightText; + + Point size = gc.textExtent(leftText + event.text + rightText); + + gc.dispose(); + if (size.x != 0) + size = text.computeSize(size.x, SWT.DEFAULT); + else { + //just make it square + size.x = size.y; + } + getCellEditor().getControl().setSize(size.x, size.y); + } + + }; + text.addVerifyListener(verifyListener); + + //set the initial value of the + originalValue = getFigureText(this.figure); + getCellEditor().setValue(originalValue); + + //calculate the font size of the underlying + IFigure figure = getEditPart().getFigure(); + figureFont = figure.getFont(); + FontData data = figureFont.getFontData()[0]; + Dimension fontSize = new Dimension(0, data.getHeight()); + + //set the font to be used + this.figure.translateToAbsolute(fontSize); + data.setHeight(fontSize.height); + figureFont = new Font(null, data); + + //set the validator for the CellEditor + getCellEditor().setValidator(validator); + + text.setFont(figureFont); + text.selectAll(); + } + + /** + * Commits the current value of the cell editor by getting a {@link Command} + * from the source edit part and executing it via the {@link CommandStack}. + * Finally, {@link #bringDown()}is called to perform and necessary cleanup. + */ + @Override + protected void commit() { + + if (committing) + return; + + committing = true; + + try { + + //we set the cell editor control to invisible to remove any + // possible flicker + getCellEditor().getControl().setVisible(false); + if (isDirty()) { + CommandStack stack = getEditPart().getViewer().getEditDomain().getCommandStack(); + EditPolicy editPolicy = getEditPart().getEditPolicy(EditPolicy.DIRECT_EDIT_ROLE); + Command command; + if (editPolicy != null) { + command = editPolicy.getCommand(getDirectEditRequest()); + } else { + command = getEditPart().getCommand(getDirectEditRequest()); + } + if (command != null && command.canExecute()) { + stack.execute(command); + } + } + } finally { + bringDown(); + committing = false; + } + } + + /** + * Need to override so as to remove the verify listener + */ + @Override + protected void unhookListeners() { + super.unhookListeners(); + Text text = (Text) getCellEditor().getControl(); + text.removeVerifyListener(verifyListener); + verifyListener = null; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/FigureEditorLocator.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/FigureEditorLocator.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/FigureEditorLocator.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/FigureEditorLocator.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java similarity index 95% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java index 531f4b006a..bc80dd8dd3 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/LabelCellEditorLocator.java @@ -1,90 +1,90 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 13, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -/** - * A CellEditorLocator for a specified label - * - * @author Serge Rider - */ -public class LabelCellEditorLocator implements CellEditorLocator -{ - - private Label label; - - /** - * Creates a new CellEditorLocator for the given Label - * - * @param label - * the Label - */ - public LabelCellEditorLocator(Label label) - { - setLabel(label); - } - - /** - * expands the size of the control by 1 pixel in each direction - */ - @Override - public void relocate(CellEditor celleditor) - { - Text text = (Text) celleditor.getControl(); - - Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle rect = label.getTextBounds().getCopy(); - label.translateToAbsolute(rect); - if (text.getCharCount() > 1) - text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); - else - text.setBounds(rect.x - 1, rect.y - 1, pref.y + 1, pref.y + 1); - - } - - /** - * Returns the Label figure. - * - * @return the Label - */ - protected Label getLabel() - { - return label; - } - - /** - * Sets the label. - * - * @param label - * The label to set - */ - protected void setLabel(Label label) - { - this.label = label; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 13, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Text; + +/** + * A CellEditorLocator for a specified label + * + * @author Serge Rider + */ +public class LabelCellEditorLocator implements CellEditorLocator +{ + + private Label label; + + /** + * Creates a new CellEditorLocator for the given Label + * + * @param label + * the Label + */ + public LabelCellEditorLocator(Label label) + { + setLabel(label); + } + + /** + * expands the size of the control by 1 pixel in each direction + */ + @Override + public void relocate(CellEditor celleditor) + { + Text text = (Text) celleditor.getControl(); + + Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); + Rectangle rect = label.getTextBounds().getCopy(); + label.translateToAbsolute(rect); + if (text.getCharCount() > 1) + text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1); + else + text.setBounds(rect.x - 1, rect.y - 1, pref.y + 1, pref.y + 1); + + } + + /** + * Returns the Label figure. + * + * @return the Label + */ + protected Label getLabel() + { + return label; + } + + /** + * Sets the label. + * + * @param label + * The label to set + */ + protected void setLabel(Label label) + { + this.label = label; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java index 18801be4da..2bfdcc71fb 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/StatusLineValidationMessageHandler.java @@ -1,60 +1,60 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Aug 13, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -import org.eclipse.ui.IEditorSite; - - -/** - * Outputs validation messages to status line - * @author Serge Rider - */ -public class StatusLineValidationMessageHandler implements ValidationMessageHandler -{ - - private IEditorSite editorSite; - - public StatusLineValidationMessageHandler(IEditorSite editorSite) - { - this.editorSite = editorSite; - } - - /** - * Sets the status message - * - * @param text - * the message to display - */ - @Override - public void setMessageText(String text) - { - editorSite.getActionBars().getStatusLineManager().setErrorMessage(text); - } - - /** - * Sets clears the status line - */ - @Override - public void reset() - { - editorSite.getActionBars().getStatusLineManager().setErrorMessage(null); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Aug 13, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +import org.eclipse.ui.IEditorSite; + + +/** + * Outputs validation messages to status line + * @author Serge Rider + */ +public class StatusLineValidationMessageHandler implements ValidationMessageHandler +{ + + private IEditorSite editorSite; + + public StatusLineValidationMessageHandler(IEditorSite editorSite) + { + this.editorSite = editorSite; + } + + /** + * Sets the status message + * + * @param text + * the message to display + */ + @Override + public void setMessageText(String text) + { + editorSite.getActionBars().getStatusLineManager().setErrorMessage(text); + } + + /** + * Sets clears the status line + */ + @Override + public void reset() + { + editorSite.getActionBars().getStatusLineManager().setErrorMessage(null); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java index 6b28657973..977b8747d1 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/TableNameCellEditorValidator.java @@ -1,82 +1,82 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 19, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -import org.eclipse.jface.viewers.ICellEditorValidator; - -/** - * ICellValidator to validate direct edit values in the table label. Collaborates - * with an instance of ValidationMessageHandler - * @author Serge Rider - */ -public class TableNameCellEditorValidator implements ICellEditorValidator -{ - - private ValidationMessageHandler handler; - - /** - * @param validationMessageHandler - * the validation message handler to pass error information to - */ - public TableNameCellEditorValidator(ValidationMessageHandler validationMessageHandler) - { - this.handler = validationMessageHandler; - } - - /** - * @param validation - * of column type - * @return the error message if an error has occurred, otherwise null - */ - @Override - public String isValid(Object value) - { - String name = (String) value; - - if (name.indexOf(" ") != -1) - { - String text = "Table name should not include the space character"; - return setMessageText(text); - } - - if (name.length() == 0) - { - String text = "Table name should include at least one character"; - return setMessageText(text); - } - - unsetMessageText(); - return null; - - } - - private String unsetMessageText() - { - handler.reset(); - return null; - } - - private String setMessageText(String text) - { - handler.setMessageText(text); - return text; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 19, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +import org.eclipse.jface.viewers.ICellEditorValidator; + +/** + * ICellValidator to validate direct edit values in the table label. Collaborates + * with an instance of ValidationMessageHandler + * @author Serge Rider + */ +public class TableNameCellEditorValidator implements ICellEditorValidator +{ + + private ValidationMessageHandler handler; + + /** + * @param validationMessageHandler + * the validation message handler to pass error information to + */ + public TableNameCellEditorValidator(ValidationMessageHandler validationMessageHandler) + { + this.handler = validationMessageHandler; + } + + /** + * @param validation + * of column type + * @return the error message if an error has occurred, otherwise null + */ + @Override + public String isValid(Object value) + { + String name = (String) value; + + if (name.indexOf(" ") != -1) + { + String text = "Table name should not include the space character"; + return setMessageText(text); + } + + if (name.length() == 0) + { + String text = "Table name should include at least one character"; + return setMessageText(text); + } + + unsetMessageText(); + return null; + + } + + private String unsetMessageText() + { + handler.reset(); + return null; + } + + private String setMessageText(String text) + { + handler.setMessageText(text); + return text; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java index 645838759b..8c373da8ab 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/directedit/ValidationMessageHandler.java @@ -1,36 +1,36 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Created on Jul 25, 2004 - */ -package org.jkiss.dbeaver.ext.erd.directedit; - -/** - * Represents interface for outputting validation error messages to some widget - * @author Serge Rider - */ -public interface ValidationMessageHandler -{ - - public void setMessageText(String text); - - /** - * Resets so that the validation message is no longer shown - */ - public void reset(); +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Created on Jul 25, 2004 + */ +package org.jkiss.dbeaver.ext.erd.directedit; + +/** + * Represents interface for outputting validation error messages to some widget + * @author Serge Rider + */ +public interface ValidationMessageHandler +{ + + public void setMessageText(String text); + + /** + * Resets so that the validation message is no longer shown + */ + public void reset(); } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java index 048af84f8b..bc7c04a144 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataEditDropTargetListener.java @@ -1,44 +1,44 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 14, 2004 - */ -package org.jkiss.dbeaver.ext.erd.dnd; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; -import org.eclipse.gef.requests.CreationFactory; - -/** - * Provides a listener for dropping templates onto the editor drawing - */ -public class DataEditDropTargetListener extends TemplateTransferDropTargetListener -{ - - public DataEditDropTargetListener(EditPartViewer viewer) - { - super(viewer); - } - - @Override - protected CreationFactory getFactory(Object template) - { - return new DataElementFactory(template); - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 14, 2004 + */ +package org.jkiss.dbeaver.ext.erd.dnd; + +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; +import org.eclipse.gef.requests.CreationFactory; + +/** + * Provides a listener for dropping templates onto the editor drawing + */ +public class DataEditDropTargetListener extends TemplateTransferDropTargetListener +{ + + public DataEditDropTargetListener(EditPartViewer viewer) + { + super(viewer); + } + + @Override + protected CreationFactory getFactory(Object template) + { + return new DataElementFactory(template); + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java similarity index 95% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java index b967253597..6f1bfc22b9 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/DataElementFactory.java @@ -1,69 +1,69 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 14, 2004 - */ -package org.jkiss.dbeaver.ext.erd.dnd; - -import org.eclipse.gef.requests.CreationFactory; - -/** - * Factory for creating instances of new objects from a palette - * @author Serge Rider - */ -public class DataElementFactory implements CreationFactory -{ - - private Object template; - - /** - * Creates a new FlowElementFactory with the given template object - * - * @param o - * the template - */ - public DataElementFactory(Object o) - { - template = o; - } - - /** - * @see org.eclipse.gef.requests.CreationFactory#getNewObject() - */ - @Override - public Object getNewObject() - { - try - { - return ((Class) template).newInstance(); - } - catch (Exception e) - { - return null; - } - } - - /** - * @see org.eclipse.gef.requests.CreationFactory#getObjectType() - */ - @Override - public Object getObjectType() - { - return template; - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 14, 2004 + */ +package org.jkiss.dbeaver.ext.erd.dnd; + +import org.eclipse.gef.requests.CreationFactory; + +/** + * Factory for creating instances of new objects from a palette + * @author Serge Rider + */ +public class DataElementFactory implements CreationFactory +{ + + private Object template; + + /** + * Creates a new FlowElementFactory with the given template object + * + * @param o + * the template + */ + public DataElementFactory(Object o) + { + template = o; + } + + /** + * @see org.eclipse.gef.requests.CreationFactory#getNewObject() + */ + @Override + public Object getNewObject() + { + try + { + return ((Class) template).newInstance(); + } + catch (Exception e) + { + return null; + } + } + + /** + * @see org.eclipse.gef.requests.CreationFactory#getObjectType() + */ + @Override + public Object getObjectType() + { + return template; + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java index 0917d7decf..2909f8ebd9 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/NodeDropTargetListener.java @@ -1,81 +1,81 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 14, 2004 - */ -package org.jkiss.dbeaver.ext.erd.dnd; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.dnd.AbstractTransferDropTargetListener; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gef.requests.CreationFactory; -import org.jkiss.dbeaver.ext.erd.model.DiagramObjectCollector; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.model.DBPNamedObject; -import org.jkiss.dbeaver.ui.dnd.DatabaseObjectTransfer; - -import java.util.Collection; - -/** - * Provides a listener for dropping nodes onto the editor drawing - */ -public class NodeDropTargetListener extends AbstractTransferDropTargetListener { - - public NodeDropTargetListener(EditPartViewer viewer) - { - super(viewer, DatabaseObjectTransfer.getInstance()); - } - - @Override - protected void updateTargetRequest() - { - - } - - @Override - protected Request createTargetRequest() - { - CreateRequest request = new CreateRequest(); - request.setFactory(new CreationFactory() { - @Override - public Object getNewObject() - { - Collection objects = DatabaseObjectTransfer.getInstance().getObject(); - if (objects == null) { - return null; - } - - return DiagramObjectCollector.generateEntityList( - ((DiagramPart) getViewer().getRootEditPart().getContents()).getDiagram(), - objects, - true); - } - - @Override - public Object getObjectType() - { - return RequestConstants.REQ_CREATE; - } - }); - request.setLocation(getDropLocation()); - return request; - } - -} - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 14, 2004 + */ +package org.jkiss.dbeaver.ext.erd.dnd; + +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.dnd.AbstractTransferDropTargetListener; +import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gef.requests.CreationFactory; +import org.jkiss.dbeaver.ext.erd.model.DiagramObjectCollector; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.model.DBPNamedObject; +import org.jkiss.dbeaver.ui.dnd.DatabaseObjectTransfer; + +import java.util.Collection; + +/** + * Provides a listener for dropping nodes onto the editor drawing + */ +public class NodeDropTargetListener extends AbstractTransferDropTargetListener { + + public NodeDropTargetListener(EditPartViewer viewer) + { + super(viewer, DatabaseObjectTransfer.getInstance()); + } + + @Override + protected void updateTargetRequest() + { + + } + + @Override + protected Request createTargetRequest() + { + CreateRequest request = new CreateRequest(); + request.setFactory(new CreationFactory() { + @Override + public Object getNewObject() + { + Collection objects = DatabaseObjectTransfer.getInstance().getObject(); + if (objects == null) { + return null; + } + + return DiagramObjectCollector.generateEntityList( + ((DiagramPart) getViewer().getRootEditPart().getContents()).getDiagram(), + objects, + true); + } + + @Override + public Object getObjectType() + { + return RequestConstants.REQ_CREATE; + } + }); + request.setLocation(getDropLocation()); + return request; + } + +} + diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java index 3c126450b8..1933c85cf2 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/dnd/ObjectCreationFactory.java @@ -1,46 +1,46 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.dnd; - -import org.eclipse.gef.requests.CreationFactory; - -/** - * Simple object creation factory - */ -public class ObjectCreationFactory implements CreationFactory { - - private final Object newObject; - private final Object objectType; - - public ObjectCreationFactory(Object newObject, Object objectType) - { - this.newObject = newObject; - this.objectType = objectType; - } - - @Override - public Object getNewObject() - { - return newObject; - } - - @Override - public Object getObjectType() - { - return objectType; - } -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.dnd; + +import org.eclipse.gef.requests.CreationFactory; + +/** + * Simple object creation factory + */ +public class ObjectCreationFactory implements CreationFactory { + + private final Object newObject; + private final Object objectType; + + public ObjectCreationFactory(Object newObject, Object objectType) + { + this.newObject = newObject; + this.objectType = objectType; + } + + @Override + public Object getNewObject() + { + return newObject; + } + + @Override + public Object getObjectType() + { + return objectType; + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java index 89179bb20d..e7759efbd4 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDAttributeVisibility.java @@ -1,71 +1,71 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.jkiss.dbeaver.Log; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; -import org.jkiss.utils.CommonUtils; - -/** - * Entity attribute visibility - */ -public enum ERDAttributeVisibility -{ - - ALL(ERDMessages.erd_attribute_visibility_selection_item_all), - KEYS(ERDMessages.erd_attribute_visibility_selection_item_any_keys), - PRIMARY(ERDMessages.erd_attribute_visibility_selection_item_primary_key), - NONE(ERDMessages.erd_attribute_visibility_selection_item_none); - - private final String title; - - private static final Log log = Log.getLog(ERDAttributeVisibility.class); - - ERDAttributeVisibility(String title) - { - this.title = title; - } - - public String getTitle() - { - return title; - } - - public static ERDAttributeVisibility getDefaultVisibility(IPreferenceStore store) - { - String attrVisibilityString = store.getString(ERDConstants.PREF_ATTR_VISIBILITY); - if (!CommonUtils.isEmpty(attrVisibilityString)) { - try { - return ERDAttributeVisibility.valueOf(attrVisibilityString); - } catch (IllegalArgumentException e) { - log.warn(e); - } - } - return ALL; - } - - public static void setDefaultVisibility(DBPPreferenceStore store, ERDAttributeVisibility visibility) - { - store.setValue( - ERDConstants.PREF_ATTR_VISIBILITY, - visibility.name()); - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.jkiss.dbeaver.Log; +import org.jkiss.dbeaver.ext.erd.ERDConstants; +import org.jkiss.dbeaver.ext.erd.ERDMessages; +import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; +import org.jkiss.utils.CommonUtils; + +/** + * Entity attribute visibility + */ +public enum ERDAttributeVisibility +{ + + ALL(ERDMessages.erd_attribute_visibility_selection_item_all), + KEYS(ERDMessages.erd_attribute_visibility_selection_item_any_keys), + PRIMARY(ERDMessages.erd_attribute_visibility_selection_item_primary_key), + NONE(ERDMessages.erd_attribute_visibility_selection_item_none); + + private final String title; + + private static final Log log = Log.getLog(ERDAttributeVisibility.class); + + ERDAttributeVisibility(String title) + { + this.title = title; + } + + public String getTitle() + { + return title; + } + + public static ERDAttributeVisibility getDefaultVisibility(IPreferenceStore store) + { + String attrVisibilityString = store.getString(ERDConstants.PREF_ATTR_VISIBILITY); + if (!CommonUtils.isEmpty(attrVisibilityString)) { + try { + return ERDAttributeVisibility.valueOf(attrVisibilityString); + } catch (IllegalArgumentException e) { + log.warn(e); + } + } + return ALL; + } + + public static void setDefaultVisibility(DBPPreferenceStore store, ERDAttributeVisibility visibility) + { + store.setValue( + ERDConstants.PREF_ATTR_VISIBILITY, + visibility.name()); + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java index b88cc19bbf..ab83822b0e 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditPartFactory.java @@ -1,53 +1,53 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 13, 2004 - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.jkiss.dbeaver.ext.erd.model.*; -import org.jkiss.dbeaver.ext.erd.part.*; - -/** - * Edit part factory for creating EditPart instances as delegates for model objects - * - * @author Serge Rider - */ -public class ERDEditPartFactory implements EditPartFactory -{ - @Override - public EditPart createEditPart(EditPart context, Object model) { - EditPart part = null; - if (model instanceof EntityDiagram) { - part = new DiagramPart(); - } else if (model instanceof ERDEntity) { - part = new EntityPart(); - } else if (model instanceof ERDAssociation) { - part = new AssociationPart(); - } else if (model instanceof ERDEntityAttribute) { - part = new AttributePart(); - } else if (model instanceof ERDNote) { - part = new NotePart(); - } - if (part != null) { - part.setModel(model); - } - return part; - } +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 13, 2004 + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; +import org.jkiss.dbeaver.ext.erd.model.*; +import org.jkiss.dbeaver.ext.erd.part.*; + +/** + * Edit part factory for creating EditPart instances as delegates for model objects + * + * @author Serge Rider + */ +public class ERDEditPartFactory implements EditPartFactory +{ + @Override + public EditPart createEditPart(EditPart context, Object model) { + EditPart part = null; + if (model instanceof EntityDiagram) { + part = new DiagramPart(); + } else if (model instanceof ERDEntity) { + part = new EntityPart(); + } else if (model instanceof ERDAssociation) { + part = new AssociationPart(); + } else if (model instanceof ERDEntityAttribute) { + part = new AttributePart(); + } else if (model instanceof ERDNote) { + part = new NotePart(); + } + if (part != null) { + part.setModel(model); + } + return part; + } } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java index 8f6b233746..553e51c108 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorAdapter.java @@ -1,61 +1,61 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.swt.widgets.Control; - -import java.util.IdentityHashMap; -import java.util.Map; - -/** - * ERDEditorAdapter - */ -public class ERDEditorAdapter implements IAdapterFactory { - - private static Map editorsMap = new IdentityHashMap<>(); - - static synchronized void mapControl(Control control, ERDEditorPart editor) - { - editorsMap.put(control, editor); - } - - static synchronized void unmapControl(Control control) - { - editorsMap.remove(control); - } - - public static synchronized ERDEditorPart getEditor(Control control) - { - return editorsMap.get(control); - } - - @Override - public T getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType == ERDEditorPart.class) { - if (adaptableObject instanceof Control) { - return adapterType.cast(getEditor((Control) adaptableObject)); - } - } - return null; - } - - @Override - public Class[] getAdapterList() { - return new Class[] { ERDEditorPart.class }; - } -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.swt.widgets.Control; + +import java.util.IdentityHashMap; +import java.util.Map; + +/** + * ERDEditorAdapter + */ +public class ERDEditorAdapter implements IAdapterFactory { + + private static Map editorsMap = new IdentityHashMap<>(); + + static synchronized void mapControl(Control control, ERDEditorPart editor) + { + editorsMap.put(control, editor); + } + + static synchronized void unmapControl(Control control) + { + editorsMap.remove(control); + } + + public static synchronized ERDEditorPart getEditor(Control control) + { + return editorsMap.get(control); + } + + @Override + public T getAdapter(Object adaptableObject, Class adapterType) { + if (adapterType == ERDEditorPart.class) { + if (adaptableObject instanceof Control) { + return adapterType.cast(getEditor((Control) adaptableObject)); + } + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[] { ERDEditorPart.class }; + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java index c2705d0492..bdcc1ee8ed 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContextMenuProvider.java @@ -1,89 +1,89 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 22, 2004 - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.jkiss.dbeaver.ext.erd.action.DiagramLayoutAction; -import org.jkiss.dbeaver.ui.IActionConstants; -import org.jkiss.dbeaver.ui.navigator.NavigatorCommands; - -/** - * Provides a context menu for the schema diagram editor. A virtual cut and paste from the flow example - */ -public class ERDEditorContextMenuProvider extends ContextMenuProvider { - private ERDEditorPart editor; - - /** - * Creates a new FlowContextMenuProvider associated with the given viewer - * and action registry. - * - * @param editor the editor - */ - ERDEditorContextMenuProvider(ERDEditorPart editor) { - super(editor.getViewer()); - this.editor = editor; - } - - /** - * @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager) - */ - @Override - public void buildContextMenu(IMenuManager menu) { - if (editor.isLoaded()) { - ISelection selection = editor.getGraphicalViewer().getSelection(); - if (!selection.isEmpty() && selection instanceof IStructuredSelection) { - editor.fillPartContextMenu(menu, (IStructuredSelection) selection); - } - - menu.add(new Separator()); - editor.fillAttributeVisibilityMenu(menu); - menu.add(new DiagramLayoutAction(editor)); - - menu.add(new Separator()); - - menu.add(new Separator(GEFActionConstants.GROUP_UNDO)); - menu.add(new Separator(GEFActionConstants.GROUP_COPY)); - //menu.add(ActionUtils.makeCommandContribution(editor.getSite(), IWorkbenchCommandConstants.EDIT_COPY)); - - menu.add(new Separator(GEFActionConstants.GROUP_PRINT)); - menu.add(new Separator(GEFActionConstants.GROUP_EDIT)); - menu.add(new Separator(GEFActionConstants.GROUP_VIEW)); - menu.add(new Separator(GEFActionConstants.GROUP_FIND)); - menu.add(new Separator(GEFActionConstants.GROUP_REST)); - menu.add(new Separator(GEFActionConstants.GROUP_SAVE)); - - menu.add(new Separator()); - - menu.add(new GroupMarker(NavigatorCommands.GROUP_TOOLS)); - menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS)); - menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS_END)); - menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - menu.add(new GroupMarker(IActionConstants.MB_ADDITIONS_END)); - - } - } +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 22, 2004 + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.gef.ContextMenuProvider; +import org.eclipse.gef.ui.actions.GEFActionConstants; +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.jkiss.dbeaver.ext.erd.action.DiagramLayoutAction; +import org.jkiss.dbeaver.ui.IActionConstants; +import org.jkiss.dbeaver.ui.navigator.NavigatorCommands; + +/** + * Provides a context menu for the schema diagram editor. A virtual cut and paste from the flow example + */ +public class ERDEditorContextMenuProvider extends ContextMenuProvider { + private ERDEditorPart editor; + + /** + * Creates a new FlowContextMenuProvider associated with the given viewer + * and action registry. + * + * @param editor the editor + */ + ERDEditorContextMenuProvider(ERDEditorPart editor) { + super(editor.getViewer()); + this.editor = editor; + } + + /** + * @see ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager) + */ + @Override + public void buildContextMenu(IMenuManager menu) { + if (editor.isLoaded()) { + ISelection selection = editor.getGraphicalViewer().getSelection(); + if (!selection.isEmpty() && selection instanceof IStructuredSelection) { + editor.fillPartContextMenu(menu, (IStructuredSelection) selection); + } + + menu.add(new Separator()); + editor.fillAttributeVisibilityMenu(menu); + menu.add(new DiagramLayoutAction(editor)); + + menu.add(new Separator()); + + menu.add(new Separator(GEFActionConstants.GROUP_UNDO)); + menu.add(new Separator(GEFActionConstants.GROUP_COPY)); + //menu.add(ActionUtils.makeCommandContribution(editor.getSite(), IWorkbenchCommandConstants.EDIT_COPY)); + + menu.add(new Separator(GEFActionConstants.GROUP_PRINT)); + menu.add(new Separator(GEFActionConstants.GROUP_EDIT)); + menu.add(new Separator(GEFActionConstants.GROUP_VIEW)); + menu.add(new Separator(GEFActionConstants.GROUP_FIND)); + menu.add(new Separator(GEFActionConstants.GROUP_REST)); + menu.add(new Separator(GEFActionConstants.GROUP_SAVE)); + + menu.add(new Separator()); + + menu.add(new GroupMarker(NavigatorCommands.GROUP_TOOLS)); + menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS)); + menu.add(new GroupMarker(NavigatorCommands.GROUP_NAVIGATOR_ADDITIONS_END)); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(new GroupMarker(IActionConstants.MB_ADDITIONS_END)); + + } + } } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContributor.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContributor.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContributor.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorContributor.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java index 44fb88bc72..d54c8a58b6 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorEmbedded.java @@ -1,408 +1,408 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.action.IContributionManager; -import org.eclipse.swt.widgets.Composite; -import org.jkiss.code.Nullable; -import org.jkiss.dbeaver.DBException; -import org.jkiss.dbeaver.Log; -import org.jkiss.dbeaver.ext.erd.ERDActivator; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.action.DiagramTogglePersistAction; -import org.jkiss.dbeaver.ext.erd.model.DiagramLoader; -import org.jkiss.dbeaver.ext.erd.model.ERDEntity; -import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; -import org.jkiss.dbeaver.model.DBPDataSourceContainer; -import org.jkiss.dbeaver.model.DBUtils; -import org.jkiss.dbeaver.model.exec.DBCExecutionContext; -import org.jkiss.dbeaver.model.exec.DBExecUtils; -import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; -import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService; -import org.jkiss.dbeaver.model.struct.*; -import org.jkiss.dbeaver.model.struct.rdb.DBSTablePartition; -import org.jkiss.dbeaver.model.virtual.DBVObject; -import org.jkiss.dbeaver.model.virtual.DBVUtils; -import org.jkiss.dbeaver.runtime.DBWorkbench; -import org.jkiss.dbeaver.ui.ActionUtils; -import org.jkiss.dbeaver.ui.IActiveWorkbenchPart; -import org.jkiss.dbeaver.ui.LoadingJob; -import org.jkiss.dbeaver.ui.editors.IDatabaseEditor; -import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput; -import org.jkiss.dbeaver.ui.editors.entity.IEntityStructureEditor; -import org.jkiss.dbeaver.utils.RuntimeUtils; -import org.jkiss.utils.CommonUtils; -import org.jkiss.utils.xml.XMLUtils; -import org.w3c.dom.Document; - -import java.io.StringReader; -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -/** - * Embedded ERD editor - */ -public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor, IEntityStructureEditor, IActiveWorkbenchPart { - - private static final Log log = Log.getLog(ERDEditorEmbedded.class); - - private static final String PROP_DIAGRAM_STATE = "erd.diagram.state"; - private static final String PROPS_DIAGRAM_SERIALIZED = "serialized"; - - private Composite parent; - - /** - * No-arg constructor - */ - public ERDEditorEmbedded() - { - } - - @Override - public IDatabaseEditorInput getEditorInput() - { - return (IDatabaseEditorInput)super.getEditorInput(); - } - - @Override - public void recreateEditorControl() { - // Not implemented - } - - @Override - public boolean isReadOnly() - { - return false; - } - - @Override - protected void fillDefaultEditorContributions(IContributionManager toolBarManager) { - super.fillDefaultEditorContributions(toolBarManager); - - toolBarManager.add(ActionUtils.makeActionContribution(new DiagramTogglePersistAction(this), true)); - } - - @Override - public void activatePart() - { - if (progressControl == null) { - super.createPartControl(parent); - parent.layout(); - } - if (isLoaded()) { - return; - } - loadDiagram(false); - } - - @Override - public void deactivatePart() - { - } - - @Override - public void createPartControl(Composite parent) - { - // Do not create controls here - do it on part activation - this.parent = parent; - //super.createEditorControl(parent); - } - - @Override - public void setFocus() - { - if (progressControl != null) { - super.setFocus(); - } - } - - private DBSObject getRootObject() - { - DBSObject object = getEditorInput().getDatabaseObject(); - if (object == null) { - return null; - } - if (object instanceof DBPDataSourceContainer && object.getDataSource() != null) { - object = object.getDataSource(); - } - return object; - } - - @Override - protected synchronized void loadDiagram(final boolean refreshMetadata) - { - final DBSObject object = getRootObject(); - if (object == null) { - return; - } - if (diagramLoadingJob != null) { - // Do not start new one while old is running - return; - } - diagramLoadingJob = LoadingJob.createService( - new DatabaseLoadService("Load diagram '" + object.getName() + "'", object.getDataSource()) { - @Override - public EntityDiagram evaluate(DBRProgressMonitor monitor) { - try { - return loadFromDatabase(monitor); - } catch (DBException e) { - log.error("Error loading ER diagram", e); - } - - return null; - } - }, - progressControl.createLoadVisualizer()); - diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) - { - diagramLoadingJob = null; - } - }); - diagramLoadingJob.schedule(); - } - - @Override - public DBCExecutionContext getExecutionContext() - { - return getEditorInput().getExecutionContext(); - } - - private EntityDiagram loadFromDatabase(DBRProgressMonitor monitor) - throws DBException - { - DBSObject dbObject = getRootObject(); - if (dbObject == null) { - log.error("Database object must be entity container to render ERD diagram"); - return null; - } - EntityDiagram diagram; - if (!dbObject.isPersisted()) { - diagram = new EntityDiagram(getDecorator(), dbObject, "New Object"); - } else { - diagram = new EntityDiagram(getDecorator(), dbObject, dbObject.getName()); - - // Fill from database even if we loaded from state (something could change since last view) - diagram.fillEntities( - monitor, - collectDatabaseTables(monitor, dbObject, diagram), - dbObject); - - boolean hasPersistedState = false; - try { - // Load persisted state - DBVObject vObject = this.getVirtualObject(); - if (vObject != null) { - Map diagramState = vObject.getProperty(PROP_DIAGRAM_STATE); - if (diagramState != null) { - String serializedDiagram = (String) diagramState.get(PROPS_DIAGRAM_SERIALIZED); - if (!CommonUtils.isEmpty(serializedDiagram)) { - Document xmlDocument = XMLUtils.parseDocument(new StringReader(serializedDiagram)); - DiagramLoader.loadDiagram(monitor, xmlDocument, dbObject.getDataSource().getContainer().getProject(), diagram); - hasPersistedState = true; - } - } - } - } catch (Exception e) { - log.error("Error loading ER diagram from saved state", e); - } - diagram.setLayoutManualAllowed(true); - diagram.setNeedsAutoLayout(!hasPersistedState); - } - - return diagram; - } - - private Collection collectDatabaseTables(DBRProgressMonitor monitor, DBSObject root, EntityDiagram diagram) throws DBException - { - Set result = new LinkedHashSet<>(); - - // Cache structure - if (root instanceof DBSObjectContainer) { - monitor.beginTask("Load '" + root.getName() + "' content", 3); - DBSObjectContainer objectContainer = (DBSObjectContainer) root; - try { - DBExecUtils.tryExecuteRecover(monitor, objectContainer.getDataSource(), param -> { - try { - objectContainer.cacheStructure(monitor, DBSObjectContainer.STRUCT_ENTITIES | DBSObjectContainer.STRUCT_ASSOCIATIONS | DBSObjectContainer.STRUCT_ATTRIBUTES); - } catch (DBException e) { - throw new InvocationTargetException(e); - } - }); - } catch (DBException e) { - DBWorkbench.getPlatformUI().showError("Cache database model", "Error caching database model", e); - } - boolean showViews = ERDActivator.getDefault().getPreferenceStore().getBoolean(ERDConstants.PREF_DIAGRAM_SHOW_VIEWS); - Collection entities = objectContainer.getChildren(monitor); - if (entities != null) { - Class childType = objectContainer.getPrimaryChildType(monitor); - DBSObjectFilter objectFilter = objectContainer.getDataSource().getContainer().getObjectFilter(childType, objectContainer, true); - - for (DBSObject entity : entities) { - if (entity instanceof DBSEntity) { - if (objectFilter != null && objectFilter.isEnabled() && !objectFilter.matches(entity.getName())) { - continue; - } - - final DBSEntity entity1 = (DBSEntity) entity; - - if (entity1.getEntityType() == DBSEntityType.TABLE || - entity1.getEntityType() == DBSEntityType.CLASS || - entity1.getEntityType() == DBSEntityType.VIRTUAL_ENTITY || - (showViews && DBUtils.isView(entity1)) - ) - - { - result.add(entity1); - } - } - } - } - monitor.done(); - - } else if (root instanceof DBSEntity) { - monitor.beginTask("Load '" + root.getName() + "' relations", 3); - DBSEntity rootTable = (DBSEntity) root; - result.add(rootTable); - try { - monitor.subTask("Read foreign keys"); - Collection fks = DBVUtils.getAllAssociations(monitor, rootTable); - if (fks != null) { - for (DBSEntityAssociation fk : fks) { - DBSEntity associatedEntity = fk.getAssociatedEntity(); - if (associatedEntity != null) { - result.add(DBVUtils.getRealEntity(monitor, associatedEntity)); - } - } - } - monitor.worked(1); - } catch (DBException e) { - log.warn("Can't load table foreign keys", e); - } - if (monitor.isCanceled()) { - return result; - } - try { - monitor.subTask("Read references"); - Collection refs = DBVUtils.getAllReferences(monitor, rootTable); - if (refs != null) { - for (DBSEntityAssociation ref : refs) { - result.add(ref.getParentObject()); - } - } - monitor.worked(1); - } catch (DBException e) { - log.warn("Can't load table references", e); - } - if (monitor.isCanceled()) { - return result; - } - try { - monitor.subTask("Read associations"); - List secondLevelEntities = new ArrayList<>(); - for (DBSEntity entity : result) { - if (entity != rootTable && entity.getEntityType() == DBSEntityType.ASSOCIATION) { - // Read all association's associations - Collection fks = entity.getAssociations(monitor); - if (fks != null) { - for (DBSEntityAssociation association : fks) { - if (association.getConstraintType() != DBSEntityConstraintType.INHERITANCE) { - secondLevelEntities.add(association.getAssociatedEntity()); - } - } - } - } - } - result.addAll(secondLevelEntities); - monitor.worked(1); - } catch (DBException e) { - log.warn("Can't load table references", e); - } - - monitor.done(); - } - - // Remove entities already loaded in the diagram - for (ERDEntity diagramEntity : diagram.getEntities()) { - result.remove(diagramEntity.getObject()); - } - - if (!ERDActivator.getDefault().getPreferenceStore().getBoolean(ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS)) { - result.removeIf(entity -> entity instanceof DBSTablePartition); - } - - return result; - } - - @Override - public void doSave(IProgressMonitor monitor) { - try { - // Save in virtual model as entity property. - DBVObject vObject = this.getVirtualObject(); - if (vObject == null) { - return; - } - Map diagramStateMap = new LinkedHashMap<>(); - vObject.setProperty(PROP_DIAGRAM_STATE, diagramStateMap); - - String diagramState = DiagramLoader.serializeDiagram(RuntimeUtils.makeMonitor(monitor), getDiagramPart(), getDiagram(), false, true); - diagramStateMap.put(PROPS_DIAGRAM_SERIALIZED, diagramState); - - vObject.persistConfiguration(); - - getCommandStack().markSaveLocation(); - } catch (Exception e) { - log.error("Error saving diagram", e); - } - updateToolbarActions(); - } - - public boolean isStateSaved() { - DBVObject vObject = this.getVirtualObject(); - return (vObject != null && vObject.getProperty(PROP_DIAGRAM_STATE) != null); - } - - public void resetSavedState(boolean refreshDiagram) { - try { - DBVObject vObject = this.getVirtualObject(); - if (vObject != null && vObject.getProperty(PROP_DIAGRAM_STATE) != null) { - vObject.setProperty(PROP_DIAGRAM_STATE, null); - vObject.persistConfiguration(); - } - } catch (Exception e) { - log.error("Error resetting diagram state", e); - } - if (refreshDiagram) { - refreshDiagram(true, true); - } - } - - @Nullable - private DBVObject getVirtualObject() { - DBSObject rootObject = getRootObject(); - if (rootObject instanceof DBSEntity) { - return DBVUtils.getVirtualEntity((DBSEntity) rootObject, true); - } else { - return DBVUtils.getVirtualObject(rootObject, true); - } - } - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.jface.action.IContributionManager; +import org.eclipse.swt.widgets.Composite; +import org.jkiss.code.Nullable; +import org.jkiss.dbeaver.DBException; +import org.jkiss.dbeaver.Log; +import org.jkiss.dbeaver.ext.erd.ERDActivator; +import org.jkiss.dbeaver.ext.erd.ERDConstants; +import org.jkiss.dbeaver.ext.erd.action.DiagramTogglePersistAction; +import org.jkiss.dbeaver.ext.erd.model.DiagramLoader; +import org.jkiss.dbeaver.ext.erd.model.ERDEntity; +import org.jkiss.dbeaver.ext.erd.model.EntityDiagram; +import org.jkiss.dbeaver.model.DBPDataSourceContainer; +import org.jkiss.dbeaver.model.DBUtils; +import org.jkiss.dbeaver.model.exec.DBCExecutionContext; +import org.jkiss.dbeaver.model.exec.DBExecUtils; +import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; +import org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService; +import org.jkiss.dbeaver.model.struct.*; +import org.jkiss.dbeaver.model.struct.rdb.DBSTablePartition; +import org.jkiss.dbeaver.model.virtual.DBVObject; +import org.jkiss.dbeaver.model.virtual.DBVUtils; +import org.jkiss.dbeaver.runtime.DBWorkbench; +import org.jkiss.dbeaver.ui.ActionUtils; +import org.jkiss.dbeaver.ui.IActiveWorkbenchPart; +import org.jkiss.dbeaver.ui.LoadingJob; +import org.jkiss.dbeaver.ui.editors.IDatabaseEditor; +import org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput; +import org.jkiss.dbeaver.ui.editors.entity.IEntityStructureEditor; +import org.jkiss.dbeaver.utils.RuntimeUtils; +import org.jkiss.utils.CommonUtils; +import org.jkiss.utils.xml.XMLUtils; +import org.w3c.dom.Document; + +import java.io.StringReader; +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +/** + * Embedded ERD editor + */ +public class ERDEditorEmbedded extends ERDEditorPart implements IDatabaseEditor, IEntityStructureEditor, IActiveWorkbenchPart { + + private static final Log log = Log.getLog(ERDEditorEmbedded.class); + + private static final String PROP_DIAGRAM_STATE = "erd.diagram.state"; + private static final String PROPS_DIAGRAM_SERIALIZED = "serialized"; + + private Composite parent; + + /** + * No-arg constructor + */ + public ERDEditorEmbedded() + { + } + + @Override + public IDatabaseEditorInput getEditorInput() + { + return (IDatabaseEditorInput)super.getEditorInput(); + } + + @Override + public void recreateEditorControl() { + // Not implemented + } + + @Override + public boolean isReadOnly() + { + return false; + } + + @Override + protected void fillDefaultEditorContributions(IContributionManager toolBarManager) { + super.fillDefaultEditorContributions(toolBarManager); + + toolBarManager.add(ActionUtils.makeActionContribution(new DiagramTogglePersistAction(this), true)); + } + + @Override + public void activatePart() + { + if (progressControl == null) { + super.createPartControl(parent); + parent.layout(); + } + if (isLoaded()) { + return; + } + loadDiagram(false); + } + + @Override + public void deactivatePart() + { + } + + @Override + public void createPartControl(Composite parent) + { + // Do not create controls here - do it on part activation + this.parent = parent; + //super.createEditorControl(parent); + } + + @Override + public void setFocus() + { + if (progressControl != null) { + super.setFocus(); + } + } + + private DBSObject getRootObject() + { + DBSObject object = getEditorInput().getDatabaseObject(); + if (object == null) { + return null; + } + if (object instanceof DBPDataSourceContainer && object.getDataSource() != null) { + object = object.getDataSource(); + } + return object; + } + + @Override + protected synchronized void loadDiagram(final boolean refreshMetadata) + { + final DBSObject object = getRootObject(); + if (object == null) { + return; + } + if (diagramLoadingJob != null) { + // Do not start new one while old is running + return; + } + diagramLoadingJob = LoadingJob.createService( + new DatabaseLoadService("Load diagram '" + object.getName() + "'", object.getDataSource()) { + @Override + public EntityDiagram evaluate(DBRProgressMonitor monitor) { + try { + return loadFromDatabase(monitor); + } catch (DBException e) { + log.error("Error loading ER diagram", e); + } + + return null; + } + }, + progressControl.createLoadVisualizer()); + diagramLoadingJob.addJobChangeListener(new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) + { + diagramLoadingJob = null; + } + }); + diagramLoadingJob.schedule(); + } + + @Override + public DBCExecutionContext getExecutionContext() + { + return getEditorInput().getExecutionContext(); + } + + private EntityDiagram loadFromDatabase(DBRProgressMonitor monitor) + throws DBException + { + DBSObject dbObject = getRootObject(); + if (dbObject == null) { + log.error("Database object must be entity container to render ERD diagram"); + return null; + } + EntityDiagram diagram; + if (!dbObject.isPersisted()) { + diagram = new EntityDiagram(getDecorator(), dbObject, "New Object"); + } else { + diagram = new EntityDiagram(getDecorator(), dbObject, dbObject.getName()); + + // Fill from database even if we loaded from state (something could change since last view) + diagram.fillEntities( + monitor, + collectDatabaseTables(monitor, dbObject, diagram), + dbObject); + + boolean hasPersistedState = false; + try { + // Load persisted state + DBVObject vObject = this.getVirtualObject(); + if (vObject != null) { + Map diagramState = vObject.getProperty(PROP_DIAGRAM_STATE); + if (diagramState != null) { + String serializedDiagram = (String) diagramState.get(PROPS_DIAGRAM_SERIALIZED); + if (!CommonUtils.isEmpty(serializedDiagram)) { + Document xmlDocument = XMLUtils.parseDocument(new StringReader(serializedDiagram)); + DiagramLoader.loadDiagram(monitor, xmlDocument, dbObject.getDataSource().getContainer().getProject(), diagram); + hasPersistedState = true; + } + } + } + } catch (Exception e) { + log.error("Error loading ER diagram from saved state", e); + } + diagram.setLayoutManualAllowed(true); + diagram.setNeedsAutoLayout(!hasPersistedState); + } + + return diagram; + } + + private Collection collectDatabaseTables(DBRProgressMonitor monitor, DBSObject root, EntityDiagram diagram) throws DBException + { + Set result = new LinkedHashSet<>(); + + // Cache structure + if (root instanceof DBSObjectContainer) { + monitor.beginTask("Load '" + root.getName() + "' content", 3); + DBSObjectContainer objectContainer = (DBSObjectContainer) root; + try { + DBExecUtils.tryExecuteRecover(monitor, objectContainer.getDataSource(), param -> { + try { + objectContainer.cacheStructure(monitor, DBSObjectContainer.STRUCT_ENTITIES | DBSObjectContainer.STRUCT_ASSOCIATIONS | DBSObjectContainer.STRUCT_ATTRIBUTES); + } catch (DBException e) { + throw new InvocationTargetException(e); + } + }); + } catch (DBException e) { + DBWorkbench.getPlatformUI().showError("Cache database model", "Error caching database model", e); + } + boolean showViews = ERDActivator.getDefault().getPreferenceStore().getBoolean(ERDConstants.PREF_DIAGRAM_SHOW_VIEWS); + Collection entities = objectContainer.getChildren(monitor); + if (entities != null) { + Class childType = objectContainer.getPrimaryChildType(monitor); + DBSObjectFilter objectFilter = objectContainer.getDataSource().getContainer().getObjectFilter(childType, objectContainer, true); + + for (DBSObject entity : entities) { + if (entity instanceof DBSEntity) { + if (objectFilter != null && objectFilter.isEnabled() && !objectFilter.matches(entity.getName())) { + continue; + } + + final DBSEntity entity1 = (DBSEntity) entity; + + if (entity1.getEntityType() == DBSEntityType.TABLE || + entity1.getEntityType() == DBSEntityType.CLASS || + entity1.getEntityType() == DBSEntityType.VIRTUAL_ENTITY || + (showViews && DBUtils.isView(entity1)) + ) + + { + result.add(entity1); + } + } + } + } + monitor.done(); + + } else if (root instanceof DBSEntity) { + monitor.beginTask("Load '" + root.getName() + "' relations", 3); + DBSEntity rootTable = (DBSEntity) root; + result.add(rootTable); + try { + monitor.subTask("Read foreign keys"); + Collection fks = DBVUtils.getAllAssociations(monitor, rootTable); + if (fks != null) { + for (DBSEntityAssociation fk : fks) { + DBSEntity associatedEntity = fk.getAssociatedEntity(); + if (associatedEntity != null) { + result.add(DBVUtils.getRealEntity(monitor, associatedEntity)); + } + } + } + monitor.worked(1); + } catch (DBException e) { + log.warn("Can't load table foreign keys", e); + } + if (monitor.isCanceled()) { + return result; + } + try { + monitor.subTask("Read references"); + Collection refs = DBVUtils.getAllReferences(monitor, rootTable); + if (refs != null) { + for (DBSEntityAssociation ref : refs) { + result.add(ref.getParentObject()); + } + } + monitor.worked(1); + } catch (DBException e) { + log.warn("Can't load table references", e); + } + if (monitor.isCanceled()) { + return result; + } + try { + monitor.subTask("Read associations"); + List secondLevelEntities = new ArrayList<>(); + for (DBSEntity entity : result) { + if (entity != rootTable && entity.getEntityType() == DBSEntityType.ASSOCIATION) { + // Read all association's associations + Collection fks = entity.getAssociations(monitor); + if (fks != null) { + for (DBSEntityAssociation association : fks) { + if (association.getConstraintType() != DBSEntityConstraintType.INHERITANCE) { + secondLevelEntities.add(association.getAssociatedEntity()); + } + } + } + } + } + result.addAll(secondLevelEntities); + monitor.worked(1); + } catch (DBException e) { + log.warn("Can't load table references", e); + } + + monitor.done(); + } + + // Remove entities already loaded in the diagram + for (ERDEntity diagramEntity : diagram.getEntities()) { + result.remove(diagramEntity.getObject()); + } + + if (!ERDActivator.getDefault().getPreferenceStore().getBoolean(ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS)) { + result.removeIf(entity -> entity instanceof DBSTablePartition); + } + + return result; + } + + @Override + public void doSave(IProgressMonitor monitor) { + try { + // Save in virtual model as entity property. + DBVObject vObject = this.getVirtualObject(); + if (vObject == null) { + return; + } + Map diagramStateMap = new LinkedHashMap<>(); + vObject.setProperty(PROP_DIAGRAM_STATE, diagramStateMap); + + String diagramState = DiagramLoader.serializeDiagram(RuntimeUtils.makeMonitor(monitor), getDiagramPart(), getDiagram(), false, true); + diagramStateMap.put(PROPS_DIAGRAM_SERIALIZED, diagramState); + + vObject.persistConfiguration(); + + getCommandStack().markSaveLocation(); + } catch (Exception e) { + log.error("Error saving diagram", e); + } + updateToolbarActions(); + } + + public boolean isStateSaved() { + DBVObject vObject = this.getVirtualObject(); + return (vObject != null && vObject.getProperty(PROP_DIAGRAM_STATE) != null); + } + + public void resetSavedState(boolean refreshDiagram) { + try { + DBVObject vObject = this.getVirtualObject(); + if (vObject != null && vObject.getProperty(PROP_DIAGRAM_STATE) != null) { + vObject.setProperty(PROP_DIAGRAM_STATE, null); + vObject.persistConfiguration(); + } + } catch (Exception e) { + log.error("Error resetting diagram state", e); + } + if (refreshDiagram) { + refreshDiagram(true, true); + } + } + + @Nullable + private DBVObject getVirtualObject() { + DBSObject rootObject = getRootObject(); + if (rootObject instanceof DBSEntity) { + return DBVUtils.getVirtualEntity((DBSEntity) rootObject, true); + } else { + return DBVUtils.getVirtualObject(rootObject, true); + } + } + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java index 3c940de3c1..04c607d277 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorPart.java @@ -1,1225 +1,1225 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PrintFigureOperation; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.gef.*; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.ui.actions.*; -import org.eclipse.gef.ui.palette.FlyoutPaletteComposite; -import org.eclipse.gef.ui.palette.PaletteViewerProvider; -import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; -import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; -import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; -import org.eclipse.jface.action.*; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.printing.PrintDialog; -import org.eclipse.swt.printing.Printer; -import org.eclipse.swt.printing.PrinterData; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.model.WorkbenchAdapter; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheetPage; -import org.jkiss.code.Nullable; -import org.jkiss.dbeaver.DBException; -import org.jkiss.dbeaver.ext.erd.ERDActivator; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.ext.erd.action.DiagramLayoutAction; -import org.jkiss.dbeaver.ext.erd.action.DiagramRefreshAction; -import org.jkiss.dbeaver.ext.erd.action.DiagramToggleGridAction; -import org.jkiss.dbeaver.ext.erd.action.ERDEditorPropertyTester; -import org.jkiss.dbeaver.ext.erd.directedit.StatusLineValidationMessageHandler; -import org.jkiss.dbeaver.ext.erd.dnd.DataEditDropTargetListener; -import org.jkiss.dbeaver.ext.erd.dnd.NodeDropTargetListener; -import org.jkiss.dbeaver.ext.erd.editor.tools.ChangeZOrderAction; -import org.jkiss.dbeaver.ext.erd.editor.tools.ResetPartColorAction; -import org.jkiss.dbeaver.ext.erd.editor.tools.SetPartColorAction; -import org.jkiss.dbeaver.ext.erd.editor.tools.SetPartSettingsAction; -import org.jkiss.dbeaver.ext.erd.export.ERDExportFormatHandler; -import org.jkiss.dbeaver.ext.erd.export.ERDExportFormatRegistry; -import org.jkiss.dbeaver.ext.erd.model.*; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.ext.erd.part.EntityPart; -import org.jkiss.dbeaver.ext.erd.part.NodePart; -import org.jkiss.dbeaver.ext.erd.part.NotePart; -import org.jkiss.dbeaver.model.DBPDataSourceTask; -import org.jkiss.dbeaver.model.DBPNamedObject; -import org.jkiss.dbeaver.model.runtime.load.ILoadService; -import org.jkiss.dbeaver.runtime.DBWorkbench; -import org.jkiss.dbeaver.ui.*; -import org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer; -import org.jkiss.dbeaver.ui.controls.ProgressPageControl; -import org.jkiss.dbeaver.ui.dialogs.DialogUtils; -import org.jkiss.dbeaver.ui.navigator.itemlist.ObjectSearcher; -import org.jkiss.utils.ArrayUtils; -import org.jkiss.utils.CommonUtils; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.EventObject; -import java.util.List; - -/** - * Editor implementation based on the the example editor skeleton that is built in Building - * an editor in chapter Introduction to GEF - */ -public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette - implements DBPDataSourceTask, ISearchContextProvider, IRefreshablePart -{ - @Nullable - protected ProgressControl progressControl; - - /** - * the undoable IPropertySheetPage - */ - private PropertySheetPage undoablePropertySheetPage; - - /** - * the graphical viewer - */ - private ScalableFreeformRootEditPart rootPart; - - /** - * the list of action ids that are to EditPart actions - */ - private List editPartActionIDs = new ArrayList<>(); - - /** - * the overview outline page - */ - private ERDOutlinePage outlinePage; - - /** - * the EditDomain - */ - private DefaultEditDomain editDomain; - - /** - * the dirty state - */ - private boolean isDirty; - - private boolean isLoaded; - - protected LoadingJob diagramLoadingJob; - private IPropertyChangeListener configPropertyListener; - private PaletteRoot paletteRoot; - - private volatile String errorMessage; - private ERDDecorator decorator; - private ZoomComboContributionItem zoomCombo; - - /** - * No-arg constructor - */ - protected ERDEditorPart() - { - } - - public ERDDecorator getDecorator() { - if (decorator == null) { - decorator = createDecorator(); - } - return decorator; - } - - protected ERDDecorator createDecorator() { - return new ERDDecoratorDefault(); - } - - @Override - protected ERDGraphicalViewer getGraphicalViewer() { - return (ERDGraphicalViewer) super.getGraphicalViewer(); - } - - /** - * Initializes the editor. - */ - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException - { - rootPart = new ScalableFreeformRootEditPart(); - editDomain = new DefaultEditDomain(this); - setEditDomain(editDomain); - - super.init(site, input); - - // add selection change listener - //getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this); - - configPropertyListener = new ConfigPropertyListener(); - ERDActivator.getDefault().getPreferenceStore().addPropertyChangeListener(configPropertyListener); - } - - @Override - public void createPartControl(Composite parent) - { - Composite contentContainer = parent; - if (hasProgressControl()) { - progressControl = new ProgressControl(parent, SWT.SHEET); - progressControl.setShowDivider(true); - contentContainer = progressControl.createContentContainer(); - } else { - isLoaded = true; - } - - super.createPartControl(contentContainer); - - if (hasProgressControl()) { - progressControl.createProgressPanel(); - } - } - - protected void updateToolbarActions() { - if (progressControl != null) { - progressControl.updateActions(); - - } - } - - /** - * The CommandStackListener that listens for - * CommandStack changes. - */ - @Override - public void commandStackChanged(EventObject event) - { - // Reevaluate properties - ActionUtils.evaluatePropertyState(ERDEditorPropertyTester.NAMESPACE + "." + ERDEditorPropertyTester.PROP_CAN_UNDO); - ActionUtils.evaluatePropertyState(ERDEditorPropertyTester.NAMESPACE + "." + ERDEditorPropertyTester.PROP_CAN_REDO); - - // Update actions - setDirty(getCommandStack().isDirty()); - - super.commandStackChanged(event); - } - - @Override - public void dispose() - { - ERDActivator.getDefault().getPreferenceStore().removePropertyChangeListener(configPropertyListener); - - if (diagramLoadingJob != null) { - diagramLoadingJob.cancel(); - diagramLoadingJob = null; - } - // remove selection listener - //getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this); - // dispose the ActionRegistry (will dispose all actions) - getActionRegistry().dispose(); - // important: always call super implementation of dispose - super.dispose(); - } - - /** - * Adaptable implementation for Editor - */ - @Override - public Object getAdapter(Class adapter) - { - // we need to handle common GEF elements we created - if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class) { - return getGraphicalViewer(); - } else if (adapter == CommandStack.class) { - return getCommandStack(); - } else if (adapter == EditDomain.class) { - return getEditDomain(); - } else if (adapter == ActionRegistry.class) { - return getActionRegistry(); - } else if (adapter == IPropertySheetPage.class) { - return getPropertySheetPage(); - } else if (adapter == IContentOutlinePage.class) { - return getOverviewOutlinePage(); - } else if (adapter == ZoomManager.class) { - return getGraphicalViewer().getProperty(ZoomManager.class.toString()); - } else if (IWorkbenchAdapter.class.equals(adapter)) { - return new WorkbenchAdapter() { - @Override - public String getLabel(Object o) - { - return "ERD Editor"; - } - }; - } - // the super implementation handles the rest - return super.getAdapter(adapter); - } - - @Override - public abstract void doSave(IProgressMonitor monitor); - - /** - * Save as not allowed - */ - @Override - public void doSaveAs() - { - saveDiagramAs(); - } - - /** - * Save as not allowed - */ - @Override - public boolean isSaveAsAllowed() - { - return true; - } - - /** - * Indicates if the editor has unsaved changes. - * - * @see org.eclipse.ui.part.EditorPart#isDirty - */ - @Override - public boolean isDirty() - { - return !isReadOnly() && isDirty; - } - - public abstract boolean isReadOnly(); - - protected boolean hasProgressControl() { - return true; - } - - /** - * Returns the CommandStack of this editor's - * EditDomain. - * - * @return the CommandStack - */ - @Override - public CommandStack getCommandStack() - { - return getEditDomain().getCommandStack(); - } - - /** - * Returns the schema model associated with the editor - * - * @return an instance of Schema - */ - public EntityDiagram getDiagram() - { - return getDiagramPart().getDiagram(); - } - - public DiagramPart getDiagramPart() - { - return rootPart == null ? null : (DiagramPart) rootPart.getContents(); - } - - /** - * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) - */ - @Override - protected void setInput(IEditorInput input) - { - super.setInput(input); - } - - /** - * Creates a PaletteViewerProvider that will be used to create palettes for - * the view and the flyout. - * - * @return the palette provider - */ - @Override - protected PaletteViewerProvider createPaletteViewerProvider() - { - return new ERDPaletteViewerProvider(editDomain); - } - - public GraphicalViewer getViewer() - { - return super.getGraphicalViewer(); - } - - /** - * Creates a new GraphicalViewer, configures, registers and - * initializes it. - * - * @param parent the parent composite - */ - @Override - protected void createGraphicalViewer(Composite parent) - { - GraphicalViewer viewer = createViewer(parent); - - // hook the viewer into the EditDomain - setGraphicalViewer(viewer); - - configureGraphicalViewer(); - hookGraphicalViewer(); - initializeGraphicalViewer(); - - // Set initial (empty) contents - viewer.setContents(new EntityDiagram(getDecorator(), null, "empty")); - - // Set context menu - ContextMenuProvider provider = new ERDEditorContextMenuProvider(this); - viewer.setContextMenu(provider); - IWorkbenchPartSite site = getSite(); - if (site instanceof IEditorSite) { - ((IEditorSite)site).registerContextMenu(ERDEditorPart.class.getName() + ".EditorContext", provider, viewer, false); - } else { - site.registerContextMenu(ERDEditorPart.class.getName() + ".EditorContext", provider, viewer); - } - } - - private GraphicalViewer createViewer(Composite parent) - { - StatusLineValidationMessageHandler validationMessageHandler = new StatusLineValidationMessageHandler(getEditorSite()); - GraphicalViewer viewer = new ERDGraphicalViewer(this, validationMessageHandler); - viewer.createControl(parent); - - // configure the viewer - viewer.getControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); - viewer.setRootEditPart(rootPart); - viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)); - - registerDropTargetListeners(viewer); - - // initialize the viewer with input - viewer.setEditPartFactory(getDecorator().createPartFactory()); - - return viewer; - } - - protected void registerDropTargetListeners(GraphicalViewer viewer) { - viewer.addDropTargetListener(new DataEditDropTargetListener(viewer)); - viewer.addDropTargetListener(new NodeDropTargetListener(viewer)); - } - - @Override - protected void configureGraphicalViewer() - { - super.configureGraphicalViewer(); - this.getGraphicalViewer().getControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); - - GraphicalViewer graphicalViewer = getGraphicalViewer(); - -/* - MenuManager manager = new MenuManager(getClass().getName(), getClass().getName()); - manager.setRemoveAllWhenShown(true); - getEditorSite().registerContextMenu(getClass().getName() + ".EditorContext", manager, graphicalViewer, true); //$NON-NLS-1$ -*/ - - IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); - - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, store.getBoolean(ERDConstants.PREF_GRID_ENABLED)); - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, store.getBoolean(ERDConstants.PREF_GRID_ENABLED)); - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension( - store.getInt(ERDConstants.PREF_GRID_WIDTH), - store.getInt(ERDConstants.PREF_GRID_HEIGHT))); - - // initialize actions - createActions(); - - // Setup zoom manager - ZoomManager zoomManager = rootPart.getZoomManager(); - - List zoomLevels = new ArrayList<>(3); - zoomLevels.add(ZoomManager.FIT_ALL); - zoomLevels.add(ZoomManager.FIT_WIDTH); - zoomLevels.add(ZoomManager.FIT_HEIGHT); - zoomManager.setZoomLevelContributions(zoomLevels); - - zoomManager.setZoomLevels( - new double[]{.1, .1, .2, .3, .5, .6, .7, .8, .9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3, 4} - ); - - IAction zoomIn = new ZoomInAction(zoomManager); - IAction zoomOut = new ZoomOutAction(zoomManager); - addAction(zoomIn); - addAction(zoomOut); - - graphicalViewer.addSelectionChangedListener(event -> { - String status; - IStructuredSelection selection = (IStructuredSelection)event.getSelection(); - if (selection.isEmpty()) { - status = ""; - } else if (selection.size() == 1) { - status = CommonUtils.toString(selection.getFirstElement()); - } else { - status = selection.size() + " objects"; - } - if (progressControl != null) { - progressControl.setInfo(status); - } - - updateActions(editPartActionIDs); - }); - } - - /** - * Sets the dirty state of this editor. - *

- *

- * An event will be fired immediately if the new state is different than the - * current one. - * - * @param dirty the new dirty state to set - */ - protected void setDirty(boolean dirty) - { - if (isDirty != dirty) { - isDirty = dirty; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - } - - /** - * Adds an action to this editor's ActionRegistry. (This is - * a helper method.) - * - * @param action the action to add. - */ - protected void addAction(IAction action) - { - getActionRegistry().registerAction(action); - UIUtils.registerKeyBinding(getSite(), action); - } - - /** - * Updates the specified actions. - * - * @param actionIds the list of ids of actions to update - */ - @Override - protected void updateActions(List actionIds) - { - for (Object actionId : actionIds) { - IAction action = getActionRegistry().getAction(actionId); - if (null != action && action instanceof UpdateAction) { - ((UpdateAction) action).update(); - } - - } - } - - /** - * Returns the overview for the outline view. - * - * @return the overview - */ - protected ERDOutlinePage getOverviewOutlinePage() - { - if (null == outlinePage && null != getGraphicalViewer()) { - RootEditPart rootEditPart = getGraphicalViewer().getRootEditPart(); - if (rootEditPart instanceof ScalableFreeformRootEditPart) { - outlinePage = new ERDOutlinePage((ScalableFreeformRootEditPart) rootEditPart); - } - } - - return outlinePage; - } - - /** - * Returns the undoable PropertySheetPage for this editor. - * - * @return the undoable PropertySheetPage - */ - protected PropertySheetPage getPropertySheetPage() - { - if (null == undoablePropertySheetPage) { - undoablePropertySheetPage = new PropertySheetPage(); - undoablePropertySheetPage.setRootEntry(new UndoablePropertySheetEntry(getCommandStack())); - } - - return undoablePropertySheetPage; - } - - /** - * @return the preferences for the Palette Flyout - */ - @Override - protected ERDPalettePreferences getPalettePreferences() - { - return new ERDPalettePreferences(); - } - - /** - * @return the PaletteRoot to be used with the PaletteViewer - */ - @Override - protected PaletteRoot getPaletteRoot() - { - if (paletteRoot == null) { - paletteRoot = createPaletteRoot(); - } - return paletteRoot; - } - - public PaletteRoot createPaletteRoot() - { - // create root - PaletteRoot paletteRoot = new PaletteRoot(); - paletteRoot.setLabel("Entity Diagram"); - - getDecorator().fillPalette(paletteRoot, isReadOnly()); - - return paletteRoot; - - } - - protected FlyoutPaletteComposite createPaletteComposite(Composite parent) { - FlyoutPaletteComposite paletteComposite = new FlyoutPaletteComposite( - parent, - 0, - this.getSite().getPage(), - this.getPaletteViewerProvider(), - this.getPalettePreferences()); - paletteComposite.setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); - return paletteComposite; - } - - public boolean isLoaded() - { - return isLoaded; - } - - public void refreshDiagram(boolean force, boolean refreshMetadata) - { - if (isLoaded && force) { - loadDiagram(refreshMetadata); - } - } - - @Override - public void refreshPart(Object source, boolean force) - { - refreshDiagram(force, true); - } - - public void saveDiagramAs() - { - List allFormats = ERDExportFormatRegistry.getInstance().getFormats(); - String[] extensions = new String[allFormats.size()]; - String[] filterNames = new String[allFormats.size()]; - for (int i = 0; i < allFormats.size(); i++) { - extensions[i] = "*." + allFormats.get(i).getExtension(); - filterNames[i] = allFormats.get(i).getLabel() + " (" + extensions[i] + ")"; - } - final Shell shell = getSite().getShell(); - FileDialog saveDialog = new FileDialog(shell, SWT.SAVE); - saveDialog.setFilterExtensions(extensions); - saveDialog.setFilterNames(filterNames); - - String filePath = DialogUtils.openFileDialog(saveDialog); - if (filePath == null || filePath.trim().length() == 0) { - return; - } - - File outFile = new File(filePath); - if (outFile.exists()) { - if (!UIUtils.confirmAction(shell, "Overwrite file", "File '" + filePath + "' already exists.\nOverwrite?")) { - return; - } - } - - int divPos = filePath.lastIndexOf('.'); - if (divPos == -1) { - DBWorkbench.getPlatformUI().showError("ERD export", "No file extension was specified"); - return; - } - String ext = filePath.substring(divPos + 1); - ERDExportFormatRegistry.FormatDescriptor targetFormat = null; - for (ERDExportFormatRegistry.FormatDescriptor format : allFormats) { - if (format.getExtension().equals(ext)) { - targetFormat = format; - break; - } - } - if (targetFormat == null) { - DBWorkbench.getPlatformUI().showError("ERD export", "No export format correspond to file extension '" + ext + "'"); - return; - } - - try { - ERDExportFormatHandler formatHandler = targetFormat.getInstance(); - - IFigure figure = rootPart.getLayer(ScalableFreeformRootEditPart.PRINTABLE_LAYERS); - - formatHandler.exportDiagram(getDiagram(), figure, getDiagramPart(), outFile); - } catch (DBException e) { - DBWorkbench.getPlatformUI().showError("ERD export failed", null, e); - } - } - - public void fillAttributeVisibilityMenu(IMenuManager menu) - { - MenuManager asMenu = new MenuManager(ERDMessages.menu_view_style); - asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ICONS)); - asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.TYPES)); - asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.NULLABILITY)); - asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.COMMENTS)); - asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ENTITY_FQN)); - menu.add(asMenu); - - if (getDiagram().getDecorator().supportsAttributeVisibility()) { - MenuManager avMenu = new MenuManager(ERDMessages.menu_attribute_visibility); - avMenu.add(new EmptyAction(ERDMessages.menu_attribute_visibility_default)); - avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.ALL)); - avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.KEYS)); - avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.PRIMARY)); - avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.NONE)); - - ISelection selection = getGraphicalViewer().getSelection(); - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - int totalEntities = 0; - for (Object item : ((IStructuredSelection) selection).toArray()) { - if (item instanceof EntityPart) { - totalEntities++; - } - } - - if (totalEntities > 0) { - avMenu.add(new Separator()); - String avaTitle = ERDMessages.menu_attribute_visibility_entity; - if (((IStructuredSelection) selection).size() == 1) { - avaTitle += " (" + ((IStructuredSelection) selection).getFirstElement() + ")"; - } else { - avaTitle += " (" + totalEntities + ")"; - } - avMenu.add(new EmptyAction(avaTitle)); - avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.ALL)); - avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.KEYS)); - avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.PRIMARY)); - avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.NONE)); - } - } - menu.add(avMenu); - } - } - - public void fillPartContextMenu(IMenuManager menu, IStructuredSelection selection) { - if (selection.isEmpty()) { - return; - } - menu.add(new ChangeZOrderAction(this, selection, true)); - menu.add(new ChangeZOrderAction(this, selection, false)); - menu.add(new SetPartColorAction(this, selection)); - ResetPartColorAction resetPartColorAction = new ResetPartColorAction(this, selection); - if (resetPartColorAction.isEnabled()) { - menu.add(resetPartColorAction); - } - SetPartSettingsAction settingsAction = new SetPartSettingsAction(this, selection); - if (settingsAction.isEnabled()) { - menu.add(settingsAction); - } - -/* - Set actionSet = new HashSet<>(); - for (Object actionId : getSelectionActions()) { - IAction action = getActionRegistry().getAction(actionId); - if (!actionSet.contains(action)) { - menu.add(action); - actionSet.add(action); - } - } -*/ - } - - public void printDiagram() - { - GraphicalViewer viewer = getGraphicalViewer(); - - PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL); - PrinterData data = dialog.open(); - - if (data != null) { - IFigure rootFigure = rootPart.getLayer(ScalableFreeformRootEditPart.PRINTABLE_LAYERS); - //EntityDiagramFigure diagramFigure = findFigure(rootFigure, EntityDiagramFigure.class); - if (rootFigure != null) { - PrintFigureOperation printOp = new PrintFigureOperation(new Printer(data), rootFigure); - - // Set print preferences - IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); - printOp.setPrintMode(store.getInt(ERDConstants.PREF_PRINT_PAGE_MODE)); - printOp.setPrintMargin(new Insets( - store.getInt(ERDConstants.PREF_PRINT_MARGIN_TOP), - store.getInt(ERDConstants.PREF_PRINT_MARGIN_LEFT), - store.getInt(ERDConstants.PREF_PRINT_MARGIN_BOTTOM), - store.getInt(ERDConstants.PREF_PRINT_MARGIN_RIGHT) - )); - // Run print - printOp.run("Print ER diagram"); - } - } - //new PrintAction(this).run(); - } - - @Override - public boolean isSearchPossible() - { - return true; - } - - @Override - public boolean isSearchEnabled() - { - return progressControl != null && progressControl.isSearchEnabled(); - } - - @Override - public boolean performSearch(SearchType searchType) - { - return progressControl != null && progressControl.performSearch(searchType); - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - protected void fillDefaultEditorContributions(IContributionManager toolBarManager) { - ZoomManager zoomManager = rootPart.getZoomManager(); - - String[] zoomStrings = new String[]{ - ZoomManager.FIT_ALL, - ZoomManager.FIT_HEIGHT, - ZoomManager.FIT_WIDTH - }; - // Init zoom combo with dummy part service - // to prevent zoom disable on part change - as it is standalone zoom control, not global one - zoomCombo = new ZoomComboContributionItem( - new IPartService() { - @Override - public void addPartListener(IPartListener listener) - { - } - - @Override - public void addPartListener(IPartListener2 listener) - { - } - - @Override - public IWorkbenchPart getActivePart() - { - return ERDEditorPart.this; - } - - @Override - public IWorkbenchPartReference getActivePartReference() - { - return null; - } - - @Override - public void removePartListener(IPartListener listener) - { - } - - @Override - public void removePartListener(IPartListener2 listener) - { - } - }, - zoomStrings); - zoomCombo.setZoomManager(zoomManager); - - toolBarManager.add(zoomCombo); - - //toolBarManager.add(new UndoAction(ERDEditorPart.this)); - //toolBarManager.add(new RedoAction(ERDEditorPart.this)); - //toolBarManager.add(new PrintAction(ERDEditorPart.this)); - - ZoomInAction zoomInAction = new ZoomInAction(zoomManager); - zoomInAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_IN)); - ZoomOutAction zoomOutAction = new ZoomOutAction(zoomManager); - zoomOutAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_OUT)); - toolBarManager.add(zoomInAction); - toolBarManager.add(zoomOutAction); - - toolBarManager.add(new Separator()); - //toolBarManager.add(createAttributeVisibilityMenu()); - toolBarManager.add(new DiagramLayoutAction(ERDEditorPart.this)); - toolBarManager.add(new DiagramToggleGridAction()); - toolBarManager.add(new DiagramRefreshAction(ERDEditorPart.this)); - toolBarManager.add(new Separator()); - { - toolBarManager.add(ActionUtils.makeCommandContribution( - getSite(), - IWorkbenchCommandConstants.FILE_PRINT, - ERDMessages.erd_editor_control_action_print_diagram, - UIIcon.PRINT)); - - toolBarManager.add(ActionUtils.makeCommandContribution( - getSite(), - IWorkbenchCommandConstants.FILE_SAVE_AS, - ERDMessages.erd_editor_control_action_save_external_format, - UIIcon.PICTURE_SAVE)); - - toolBarManager.add(ActionUtils.makeCommandContribution( - getSite(), - IWorkbenchCommandConstants.FILE_SAVE, - null, - UIIcon.SAVE)); - } - toolBarManager.add(new Separator()); - { - Action configAction = new Action(ERDMessages.erd_editor_control_action_configuration) { - @Override - public void run() - { - UIUtils.showPreferencesFor( - getSite().getShell(), - ERDEditorPart.this, - ERDPreferencePage.PAGE_ID); - } - }; - configAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION)); - toolBarManager.add(configAction); - } - } - - protected abstract void loadDiagram(boolean refreshMetadata); - - @Override - public boolean isActiveTask() { - return diagramLoadingJob != null && diagramLoadingJob.getState() == Job.RUNNING; - } - - private class ChangeAttributePresentationAction extends Action { - private final ERDViewStyle style; - public ChangeAttributePresentationAction(ERDViewStyle style) { - super("Show " + style.getTitle(), AS_CHECK_BOX); - this.style = style; - } - @Override - public boolean isChecked() - { - return ArrayUtils.contains( - ERDViewStyle.getDefaultStyles(ERDActivator.getDefault().getPreferenceStore()), - style); - } - - @Override - public void run() - { - getDiagram().setAttributeStyle(style, !isChecked()); - refreshDiagram(true, false); - } - } - - private class ChangeAttributeVisibilityAction extends Action { - private final boolean defStyle; - private final ERDAttributeVisibility visibility; - - private ChangeAttributeVisibilityAction(boolean defStyle, ERDAttributeVisibility visibility) - { - super(visibility.getTitle() + "", IAction.AS_CHECK_BOX); - this.defStyle = defStyle; - this.visibility = visibility; - } - - @Override - public boolean isChecked() - { - if (defStyle) { - return visibility == getDiagram().getAttributeVisibility(); - } else { - for (Object object : ((IStructuredSelection)getGraphicalViewer().getSelection()).toArray()) { - if (object instanceof EntityPart) { - ERDAttributeVisibility entityAV = ((EntityPart) object).getEntity().getAttributeVisibility(); - if (entityAV == null) { - return visibility == getDiagram().getAttributeVisibility(); - } else if (entityAV == visibility) { - return true; - } - } - } - return false; - } - } - - @Override - public void runWithEvent(Event event) { - super.runWithEvent(event); - } - - @Override - public void run() - { - EntityDiagram diagram = getDiagram(); - if (defStyle) { - diagram.setAttributeVisibility(visibility); - for (ERDEntity entity : diagram.getEntities()) { - entity.reloadAttributes(diagram); - } - } else { - for (Object object : ((IStructuredSelection)getGraphicalViewer().getSelection()).toArray()) { - if (object instanceof EntityPart) { - ((EntityPart) object).getEntity().setAttributeVisibility(visibility); - UIUtils.asyncExec(() -> ((EntityPart) object).getEntity().reloadAttributes(diagram)); - } - } - } - diagram.setNeedsAutoLayout(true); - - UIUtils.asyncExec(() -> getGraphicalViewer().setContents(diagram)); - } - } - - private class ConfigPropertyListener implements IPropertyChangeListener { - @Override - public void propertyChange(PropertyChangeEvent event) - { - GraphicalViewer graphicalViewer = getGraphicalViewer(); - if (graphicalViewer == null) { - return; - } - if (ERDConstants.PREF_GRID_ENABLED.equals(event.getProperty())) { - Boolean enabled = Boolean.valueOf(event.getNewValue().toString()); - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, enabled); - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, enabled); - } else if (ERDConstants.PREF_GRID_WIDTH.equals(event.getProperty()) || ERDConstants.PREF_GRID_HEIGHT.equals(event.getProperty())) { - final IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); - graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension( - store.getInt(ERDConstants.PREF_GRID_WIDTH), - store.getInt(ERDConstants.PREF_GRID_HEIGHT))); - } else if (ERDConstants.PREF_ATTR_VISIBILITY.equals(event.getProperty())) { - EntityDiagram diagram = getDiagram(); - ERDAttributeVisibility attrVisibility = CommonUtils.valueOf(ERDAttributeVisibility.class, CommonUtils.toString(event.getNewValue())); - diagram.setAttributeVisibility(attrVisibility); - for (ERDEntity entity : diagram.getEntities()) { - entity.reloadAttributes(diagram); - } - diagram.setNeedsAutoLayout(true); - - UIUtils.asyncExec(() -> graphicalViewer.setContents(diagram)); - } else if (ERDConstants.PREF_ATTR_STYLES.equals(event.getProperty())) { - refreshDiagram(true, false); - } else if (ERDConstants.PREF_DIAGRAM_SHOW_VIEWS.equals(event.getProperty()) || ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS.equals(event.getProperty())) { - refreshDiagram(true, true); - } - } - } - - protected class ProgressControl extends ProgressPageControl { - - private Searcher searcher; - - private ProgressControl(Composite parent, int style) - { - super(parent, style); - searcher = new Searcher(); - } - - @Override - protected boolean cancelProgress() - { - if (diagramLoadingJob != null) { - diagramLoadingJob.cancel(); - return true; - } - return false; - } - - public ProgressVisualizer createLoadVisualizer() - { - getGraphicalControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); - return new LoadVisualizer(); - } - - @Override - public void fillCustomActions(IContributionManager toolBarManager) { - fillDefaultEditorContributions(toolBarManager); - } - - @Override - protected ISearchExecutor getSearchRunner() - { - return searcher; - } - - private class LoadVisualizer extends ProgressVisualizer { - @Override - public void visualizeLoading() - { - super.visualizeLoading(); - } - - @Override - public void completeLoading(EntityDiagram entityDiagram) - { - super.completeLoading(entityDiagram); - Control graphicalControl = getGraphicalControl(); - if (graphicalControl == null) { - return; - } - graphicalControl.setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); - isLoaded = true; - Control control = getGraphicalViewer().getControl(); - if (control == null || control.isDisposed()) { - return; - } - - if (entityDiagram != null) { - List errorMessages = entityDiagram.getErrorMessages(); - if (!errorMessages.isEmpty()) { - // log.debug(message); - List messageStatuses = new ArrayList<>(errorMessages.size()); - for (String error : errorMessages) { - messageStatuses.add(new Status(Status.ERROR, ERDActivator.PLUGIN_ID, error)); - } - MultiStatus status = new MultiStatus(ERDActivator.PLUGIN_ID, 0, messageStatuses.toArray(new IStatus[0]), null, null); - - DBWorkbench.getPlatformUI().showError( - "Diagram loading errors", - "Error(s) occurred during diagram loading. If these errors are recoverable then fix errors and then refresh/reopen diagram", - status); - } - setInfo(entityDiagram.getEntityCount() + " objects"); - } else { - setInfo("Empty diagram due to error (see error log)"); - } - getCommandStack().flush(); - if (entityDiagram != null) { - EditPart oldContents = getGraphicalViewer().getContents(); - if (oldContents instanceof DiagramPart) { - if (restoreVisualSettings((DiagramPart) oldContents, entityDiagram)) { - entityDiagram.setLayoutManualAllowed(true); - entityDiagram.setLayoutManualDesired(true); - } - } - getGraphicalViewer().setContents(entityDiagram); - } - // - if (zoomCombo != null) { - zoomCombo.setZoomManager(rootPart.getZoomManager()); - } - //toolBarManager.getControl().setEnabled(true); - } - } - - } - - private boolean restoreVisualSettings(DiagramPart oldDiagram, EntityDiagram newDiagram) { - boolean hasChanges = false; - // Collect visual settings from old diagram and apply them to the new one - for (ERDEntity newEntity : newDiagram.getEntities()) { - NodePart oldEntity = oldDiagram.getChildByObject(newEntity.getObject()); - if (oldEntity instanceof EntityPart) { - EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldEntity); - newDiagram.addVisualInfo(newEntity.getObject(), vi); - hasChanges = true; - } - } - - for (ERDNote newNote : newDiagram.getNotes()) { - NodePart oldNotePart = oldDiagram.getChildByObject(newNote.getObject()); - if (oldNotePart instanceof NotePart) { - EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldNotePart); - vi.initBounds = oldNotePart.getBounds(); - newDiagram.addVisualInfo(newNote, vi); - hasChanges = true; - } - } - return hasChanges; - } - - private class Searcher extends ObjectSearcher { - - @Override - protected void setInfo(String message) - { - progressControl.setInfo(message); - } - - @Override - protected Collection getContent() - { - return getDiagramPart().getChildren(); - } - - @Override - protected void selectObject(DBPNamedObject object) - { - if (object == null) { - getGraphicalViewer().deselectAll(); - } else { - getGraphicalViewer().select((EditPart)object); - } - } - - @Override - protected void updateObject(DBPNamedObject object) - { - } - - @Override - protected void revealObject(DBPNamedObject object) - { - getGraphicalViewer().reveal((EditPart)object); - } - } - - protected abstract class DiagramLoaderVisualizer extends ProgressLoaderVisualizer { - protected DiagramLoaderVisualizer(ILoadService loadingService, Composite control) { - super(loadingService, control); - } - - @Override - public void visualizeLoading() { - super.visualizeLoading(); - } - - @Override - public void completeLoading(EntityDiagram result) { - super.completeLoading(result); - super.visualizeLoading(); - if (result != null && !result.getEntities().isEmpty()) { - setErrorMessage(null); - } - getGraphicalViewer().setContents(result); - getDiagramPart().rearrangeDiagram(); - finishLoading(); - } - - protected abstract void finishLoading(); - } - - -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PrintFigureOperation; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Insets; +import org.eclipse.gef.*; +import org.eclipse.gef.commands.CommandStack; +import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; +import org.eclipse.gef.editparts.ZoomManager; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.ui.actions.*; +import org.eclipse.gef.ui.palette.FlyoutPaletteComposite; +import org.eclipse.gef.ui.palette.PaletteViewerProvider; +import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; +import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; +import org.eclipse.gef.ui.properties.UndoablePropertySheetEntry; +import org.eclipse.jface.action.*; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.printing.PrintDialog; +import org.eclipse.swt.printing.Printer; +import org.eclipse.swt.printing.PrinterData; +import org.eclipse.swt.widgets.*; +import org.eclipse.ui.*; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.model.WorkbenchAdapter; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.PropertySheetPage; +import org.jkiss.code.Nullable; +import org.jkiss.dbeaver.DBException; +import org.jkiss.dbeaver.ext.erd.ERDActivator; +import org.jkiss.dbeaver.ext.erd.ERDConstants; +import org.jkiss.dbeaver.ext.erd.ERDMessages; +import org.jkiss.dbeaver.ext.erd.action.DiagramLayoutAction; +import org.jkiss.dbeaver.ext.erd.action.DiagramRefreshAction; +import org.jkiss.dbeaver.ext.erd.action.DiagramToggleGridAction; +import org.jkiss.dbeaver.ext.erd.action.ERDEditorPropertyTester; +import org.jkiss.dbeaver.ext.erd.directedit.StatusLineValidationMessageHandler; +import org.jkiss.dbeaver.ext.erd.dnd.DataEditDropTargetListener; +import org.jkiss.dbeaver.ext.erd.dnd.NodeDropTargetListener; +import org.jkiss.dbeaver.ext.erd.editor.tools.ChangeZOrderAction; +import org.jkiss.dbeaver.ext.erd.editor.tools.ResetPartColorAction; +import org.jkiss.dbeaver.ext.erd.editor.tools.SetPartColorAction; +import org.jkiss.dbeaver.ext.erd.editor.tools.SetPartSettingsAction; +import org.jkiss.dbeaver.ext.erd.export.ERDExportFormatHandler; +import org.jkiss.dbeaver.ext.erd.export.ERDExportFormatRegistry; +import org.jkiss.dbeaver.ext.erd.model.*; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.ext.erd.part.EntityPart; +import org.jkiss.dbeaver.ext.erd.part.NodePart; +import org.jkiss.dbeaver.ext.erd.part.NotePart; +import org.jkiss.dbeaver.model.DBPDataSourceTask; +import org.jkiss.dbeaver.model.DBPNamedObject; +import org.jkiss.dbeaver.model.runtime.load.ILoadService; +import org.jkiss.dbeaver.runtime.DBWorkbench; +import org.jkiss.dbeaver.ui.*; +import org.jkiss.dbeaver.ui.controls.ProgressLoaderVisualizer; +import org.jkiss.dbeaver.ui.controls.ProgressPageControl; +import org.jkiss.dbeaver.ui.dialogs.DialogUtils; +import org.jkiss.dbeaver.ui.navigator.itemlist.ObjectSearcher; +import org.jkiss.utils.ArrayUtils; +import org.jkiss.utils.CommonUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EventObject; +import java.util.List; + +/** + * Editor implementation based on the the example editor skeleton that is built in Building + * an editor in chapter Introduction to GEF + */ +public abstract class ERDEditorPart extends GraphicalEditorWithFlyoutPalette + implements DBPDataSourceTask, ISearchContextProvider, IRefreshablePart +{ + @Nullable + protected ProgressControl progressControl; + + /** + * the undoable IPropertySheetPage + */ + private PropertySheetPage undoablePropertySheetPage; + + /** + * the graphical viewer + */ + private ScalableFreeformRootEditPart rootPart; + + /** + * the list of action ids that are to EditPart actions + */ + private List editPartActionIDs = new ArrayList<>(); + + /** + * the overview outline page + */ + private ERDOutlinePage outlinePage; + + /** + * the EditDomain + */ + private DefaultEditDomain editDomain; + + /** + * the dirty state + */ + private boolean isDirty; + + private boolean isLoaded; + + protected LoadingJob diagramLoadingJob; + private IPropertyChangeListener configPropertyListener; + private PaletteRoot paletteRoot; + + private volatile String errorMessage; + private ERDDecorator decorator; + private ZoomComboContributionItem zoomCombo; + + /** + * No-arg constructor + */ + protected ERDEditorPart() + { + } + + public ERDDecorator getDecorator() { + if (decorator == null) { + decorator = createDecorator(); + } + return decorator; + } + + protected ERDDecorator createDecorator() { + return new ERDDecoratorDefault(); + } + + @Override + protected ERDGraphicalViewer getGraphicalViewer() { + return (ERDGraphicalViewer) super.getGraphicalViewer(); + } + + /** + * Initializes the editor. + */ + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException + { + rootPart = new ScalableFreeformRootEditPart(); + editDomain = new DefaultEditDomain(this); + setEditDomain(editDomain); + + super.init(site, input); + + // add selection change listener + //getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this); + + configPropertyListener = new ConfigPropertyListener(); + ERDActivator.getDefault().getPreferenceStore().addPropertyChangeListener(configPropertyListener); + } + + @Override + public void createPartControl(Composite parent) + { + Composite contentContainer = parent; + if (hasProgressControl()) { + progressControl = new ProgressControl(parent, SWT.SHEET); + progressControl.setShowDivider(true); + contentContainer = progressControl.createContentContainer(); + } else { + isLoaded = true; + } + + super.createPartControl(contentContainer); + + if (hasProgressControl()) { + progressControl.createProgressPanel(); + } + } + + protected void updateToolbarActions() { + if (progressControl != null) { + progressControl.updateActions(); + + } + } + + /** + * The CommandStackListener that listens for + * CommandStack changes. + */ + @Override + public void commandStackChanged(EventObject event) + { + // Reevaluate properties + ActionUtils.evaluatePropertyState(ERDEditorPropertyTester.NAMESPACE + "." + ERDEditorPropertyTester.PROP_CAN_UNDO); + ActionUtils.evaluatePropertyState(ERDEditorPropertyTester.NAMESPACE + "." + ERDEditorPropertyTester.PROP_CAN_REDO); + + // Update actions + setDirty(getCommandStack().isDirty()); + + super.commandStackChanged(event); + } + + @Override + public void dispose() + { + ERDActivator.getDefault().getPreferenceStore().removePropertyChangeListener(configPropertyListener); + + if (diagramLoadingJob != null) { + diagramLoadingJob.cancel(); + diagramLoadingJob = null; + } + // remove selection listener + //getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this); + // dispose the ActionRegistry (will dispose all actions) + getActionRegistry().dispose(); + // important: always call super implementation of dispose + super.dispose(); + } + + /** + * Adaptable implementation for Editor + */ + @Override + public Object getAdapter(Class adapter) + { + // we need to handle common GEF elements we created + if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class) { + return getGraphicalViewer(); + } else if (adapter == CommandStack.class) { + return getCommandStack(); + } else if (adapter == EditDomain.class) { + return getEditDomain(); + } else if (adapter == ActionRegistry.class) { + return getActionRegistry(); + } else if (adapter == IPropertySheetPage.class) { + return getPropertySheetPage(); + } else if (adapter == IContentOutlinePage.class) { + return getOverviewOutlinePage(); + } else if (adapter == ZoomManager.class) { + return getGraphicalViewer().getProperty(ZoomManager.class.toString()); + } else if (IWorkbenchAdapter.class.equals(adapter)) { + return new WorkbenchAdapter() { + @Override + public String getLabel(Object o) + { + return "ERD Editor"; + } + }; + } + // the super implementation handles the rest + return super.getAdapter(adapter); + } + + @Override + public abstract void doSave(IProgressMonitor monitor); + + /** + * Save as not allowed + */ + @Override + public void doSaveAs() + { + saveDiagramAs(); + } + + /** + * Save as not allowed + */ + @Override + public boolean isSaveAsAllowed() + { + return true; + } + + /** + * Indicates if the editor has unsaved changes. + * + * @see org.eclipse.ui.part.EditorPart#isDirty + */ + @Override + public boolean isDirty() + { + return !isReadOnly() && isDirty; + } + + public abstract boolean isReadOnly(); + + protected boolean hasProgressControl() { + return true; + } + + /** + * Returns the CommandStack of this editor's + * EditDomain. + * + * @return the CommandStack + */ + @Override + public CommandStack getCommandStack() + { + return getEditDomain().getCommandStack(); + } + + /** + * Returns the schema model associated with the editor + * + * @return an instance of Schema + */ + public EntityDiagram getDiagram() + { + return getDiagramPart().getDiagram(); + } + + public DiagramPart getDiagramPart() + { + return rootPart == null ? null : (DiagramPart) rootPart.getContents(); + } + + /** + * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) + */ + @Override + protected void setInput(IEditorInput input) + { + super.setInput(input); + } + + /** + * Creates a PaletteViewerProvider that will be used to create palettes for + * the view and the flyout. + * + * @return the palette provider + */ + @Override + protected PaletteViewerProvider createPaletteViewerProvider() + { + return new ERDPaletteViewerProvider(editDomain); + } + + public GraphicalViewer getViewer() + { + return super.getGraphicalViewer(); + } + + /** + * Creates a new GraphicalViewer, configures, registers and + * initializes it. + * + * @param parent the parent composite + */ + @Override + protected void createGraphicalViewer(Composite parent) + { + GraphicalViewer viewer = createViewer(parent); + + // hook the viewer into the EditDomain + setGraphicalViewer(viewer); + + configureGraphicalViewer(); + hookGraphicalViewer(); + initializeGraphicalViewer(); + + // Set initial (empty) contents + viewer.setContents(new EntityDiagram(getDecorator(), null, "empty")); + + // Set context menu + ContextMenuProvider provider = new ERDEditorContextMenuProvider(this); + viewer.setContextMenu(provider); + IWorkbenchPartSite site = getSite(); + if (site instanceof IEditorSite) { + ((IEditorSite)site).registerContextMenu(ERDEditorPart.class.getName() + ".EditorContext", provider, viewer, false); + } else { + site.registerContextMenu(ERDEditorPart.class.getName() + ".EditorContext", provider, viewer); + } + } + + private GraphicalViewer createViewer(Composite parent) + { + StatusLineValidationMessageHandler validationMessageHandler = new StatusLineValidationMessageHandler(getEditorSite()); + GraphicalViewer viewer = new ERDGraphicalViewer(this, validationMessageHandler); + viewer.createControl(parent); + + // configure the viewer + viewer.getControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); + viewer.setRootEditPart(rootPart); + viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)); + + registerDropTargetListeners(viewer); + + // initialize the viewer with input + viewer.setEditPartFactory(getDecorator().createPartFactory()); + + return viewer; + } + + protected void registerDropTargetListeners(GraphicalViewer viewer) { + viewer.addDropTargetListener(new DataEditDropTargetListener(viewer)); + viewer.addDropTargetListener(new NodeDropTargetListener(viewer)); + } + + @Override + protected void configureGraphicalViewer() + { + super.configureGraphicalViewer(); + this.getGraphicalViewer().getControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); + + GraphicalViewer graphicalViewer = getGraphicalViewer(); + +/* + MenuManager manager = new MenuManager(getClass().getName(), getClass().getName()); + manager.setRemoveAllWhenShown(true); + getEditorSite().registerContextMenu(getClass().getName() + ".EditorContext", manager, graphicalViewer, true); //$NON-NLS-1$ +*/ + + IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); + + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, store.getBoolean(ERDConstants.PREF_GRID_ENABLED)); + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, store.getBoolean(ERDConstants.PREF_GRID_ENABLED)); + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension( + store.getInt(ERDConstants.PREF_GRID_WIDTH), + store.getInt(ERDConstants.PREF_GRID_HEIGHT))); + + // initialize actions + createActions(); + + // Setup zoom manager + ZoomManager zoomManager = rootPart.getZoomManager(); + + List zoomLevels = new ArrayList<>(3); + zoomLevels.add(ZoomManager.FIT_ALL); + zoomLevels.add(ZoomManager.FIT_WIDTH); + zoomLevels.add(ZoomManager.FIT_HEIGHT); + zoomManager.setZoomLevelContributions(zoomLevels); + + zoomManager.setZoomLevels( + new double[]{.1, .1, .2, .3, .5, .6, .7, .8, .9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3, 4} + ); + + IAction zoomIn = new ZoomInAction(zoomManager); + IAction zoomOut = new ZoomOutAction(zoomManager); + addAction(zoomIn); + addAction(zoomOut); + + graphicalViewer.addSelectionChangedListener(event -> { + String status; + IStructuredSelection selection = (IStructuredSelection)event.getSelection(); + if (selection.isEmpty()) { + status = ""; + } else if (selection.size() == 1) { + status = CommonUtils.toString(selection.getFirstElement()); + } else { + status = selection.size() + " objects"; + } + if (progressControl != null) { + progressControl.setInfo(status); + } + + updateActions(editPartActionIDs); + }); + } + + /** + * Sets the dirty state of this editor. + *

+ *

+ * An event will be fired immediately if the new state is different than the + * current one. + * + * @param dirty the new dirty state to set + */ + protected void setDirty(boolean dirty) + { + if (isDirty != dirty) { + isDirty = dirty; + firePropertyChange(IEditorPart.PROP_DIRTY); + } + } + + /** + * Adds an action to this editor's ActionRegistry. (This is + * a helper method.) + * + * @param action the action to add. + */ + protected void addAction(IAction action) + { + getActionRegistry().registerAction(action); + UIUtils.registerKeyBinding(getSite(), action); + } + + /** + * Updates the specified actions. + * + * @param actionIds the list of ids of actions to update + */ + @Override + protected void updateActions(List actionIds) + { + for (Object actionId : actionIds) { + IAction action = getActionRegistry().getAction(actionId); + if (null != action && action instanceof UpdateAction) { + ((UpdateAction) action).update(); + } + + } + } + + /** + * Returns the overview for the outline view. + * + * @return the overview + */ + protected ERDOutlinePage getOverviewOutlinePage() + { + if (null == outlinePage && null != getGraphicalViewer()) { + RootEditPart rootEditPart = getGraphicalViewer().getRootEditPart(); + if (rootEditPart instanceof ScalableFreeformRootEditPart) { + outlinePage = new ERDOutlinePage((ScalableFreeformRootEditPart) rootEditPart); + } + } + + return outlinePage; + } + + /** + * Returns the undoable PropertySheetPage for this editor. + * + * @return the undoable PropertySheetPage + */ + protected PropertySheetPage getPropertySheetPage() + { + if (null == undoablePropertySheetPage) { + undoablePropertySheetPage = new PropertySheetPage(); + undoablePropertySheetPage.setRootEntry(new UndoablePropertySheetEntry(getCommandStack())); + } + + return undoablePropertySheetPage; + } + + /** + * @return the preferences for the Palette Flyout + */ + @Override + protected ERDPalettePreferences getPalettePreferences() + { + return new ERDPalettePreferences(); + } + + /** + * @return the PaletteRoot to be used with the PaletteViewer + */ + @Override + protected PaletteRoot getPaletteRoot() + { + if (paletteRoot == null) { + paletteRoot = createPaletteRoot(); + } + return paletteRoot; + } + + public PaletteRoot createPaletteRoot() + { + // create root + PaletteRoot paletteRoot = new PaletteRoot(); + paletteRoot.setLabel("Entity Diagram"); + + getDecorator().fillPalette(paletteRoot, isReadOnly()); + + return paletteRoot; + + } + + protected FlyoutPaletteComposite createPaletteComposite(Composite parent) { + FlyoutPaletteComposite paletteComposite = new FlyoutPaletteComposite( + parent, + 0, + this.getSite().getPage(), + this.getPaletteViewerProvider(), + this.getPalettePreferences()); + paletteComposite.setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); + return paletteComposite; + } + + public boolean isLoaded() + { + return isLoaded; + } + + public void refreshDiagram(boolean force, boolean refreshMetadata) + { + if (isLoaded && force) { + loadDiagram(refreshMetadata); + } + } + + @Override + public void refreshPart(Object source, boolean force) + { + refreshDiagram(force, true); + } + + public void saveDiagramAs() + { + List allFormats = ERDExportFormatRegistry.getInstance().getFormats(); + String[] extensions = new String[allFormats.size()]; + String[] filterNames = new String[allFormats.size()]; + for (int i = 0; i < allFormats.size(); i++) { + extensions[i] = "*." + allFormats.get(i).getExtension(); + filterNames[i] = allFormats.get(i).getLabel() + " (" + extensions[i] + ")"; + } + final Shell shell = getSite().getShell(); + FileDialog saveDialog = new FileDialog(shell, SWT.SAVE); + saveDialog.setFilterExtensions(extensions); + saveDialog.setFilterNames(filterNames); + + String filePath = DialogUtils.openFileDialog(saveDialog); + if (filePath == null || filePath.trim().length() == 0) { + return; + } + + File outFile = new File(filePath); + if (outFile.exists()) { + if (!UIUtils.confirmAction(shell, "Overwrite file", "File '" + filePath + "' already exists.\nOverwrite?")) { + return; + } + } + + int divPos = filePath.lastIndexOf('.'); + if (divPos == -1) { + DBWorkbench.getPlatformUI().showError("ERD export", "No file extension was specified"); + return; + } + String ext = filePath.substring(divPos + 1); + ERDExportFormatRegistry.FormatDescriptor targetFormat = null; + for (ERDExportFormatRegistry.FormatDescriptor format : allFormats) { + if (format.getExtension().equals(ext)) { + targetFormat = format; + break; + } + } + if (targetFormat == null) { + DBWorkbench.getPlatformUI().showError("ERD export", "No export format correspond to file extension '" + ext + "'"); + return; + } + + try { + ERDExportFormatHandler formatHandler = targetFormat.getInstance(); + + IFigure figure = rootPart.getLayer(ScalableFreeformRootEditPart.PRINTABLE_LAYERS); + + formatHandler.exportDiagram(getDiagram(), figure, getDiagramPart(), outFile); + } catch (DBException e) { + DBWorkbench.getPlatformUI().showError("ERD export failed", null, e); + } + } + + public void fillAttributeVisibilityMenu(IMenuManager menu) + { + MenuManager asMenu = new MenuManager(ERDMessages.menu_view_style); + asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ICONS)); + asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.TYPES)); + asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.NULLABILITY)); + asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.COMMENTS)); + asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ENTITY_FQN)); + menu.add(asMenu); + + if (getDiagram().getDecorator().supportsAttributeVisibility()) { + MenuManager avMenu = new MenuManager(ERDMessages.menu_attribute_visibility); + avMenu.add(new EmptyAction(ERDMessages.menu_attribute_visibility_default)); + avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.ALL)); + avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.KEYS)); + avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.PRIMARY)); + avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.NONE)); + + ISelection selection = getGraphicalViewer().getSelection(); + if (selection instanceof IStructuredSelection && !selection.isEmpty()) { + int totalEntities = 0; + for (Object item : ((IStructuredSelection) selection).toArray()) { + if (item instanceof EntityPart) { + totalEntities++; + } + } + + if (totalEntities > 0) { + avMenu.add(new Separator()); + String avaTitle = ERDMessages.menu_attribute_visibility_entity; + if (((IStructuredSelection) selection).size() == 1) { + avaTitle += " (" + ((IStructuredSelection) selection).getFirstElement() + ")"; + } else { + avaTitle += " (" + totalEntities + ")"; + } + avMenu.add(new EmptyAction(avaTitle)); + avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.ALL)); + avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.KEYS)); + avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.PRIMARY)); + avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.NONE)); + } + } + menu.add(avMenu); + } + } + + public void fillPartContextMenu(IMenuManager menu, IStructuredSelection selection) { + if (selection.isEmpty()) { + return; + } + menu.add(new ChangeZOrderAction(this, selection, true)); + menu.add(new ChangeZOrderAction(this, selection, false)); + menu.add(new SetPartColorAction(this, selection)); + ResetPartColorAction resetPartColorAction = new ResetPartColorAction(this, selection); + if (resetPartColorAction.isEnabled()) { + menu.add(resetPartColorAction); + } + SetPartSettingsAction settingsAction = new SetPartSettingsAction(this, selection); + if (settingsAction.isEnabled()) { + menu.add(settingsAction); + } + +/* + Set actionSet = new HashSet<>(); + for (Object actionId : getSelectionActions()) { + IAction action = getActionRegistry().getAction(actionId); + if (!actionSet.contains(action)) { + menu.add(action); + actionSet.add(action); + } + } +*/ + } + + public void printDiagram() + { + GraphicalViewer viewer = getGraphicalViewer(); + + PrintDialog dialog = new PrintDialog(viewer.getControl().getShell(), SWT.NULL); + PrinterData data = dialog.open(); + + if (data != null) { + IFigure rootFigure = rootPart.getLayer(ScalableFreeformRootEditPart.PRINTABLE_LAYERS); + //EntityDiagramFigure diagramFigure = findFigure(rootFigure, EntityDiagramFigure.class); + if (rootFigure != null) { + PrintFigureOperation printOp = new PrintFigureOperation(new Printer(data), rootFigure); + + // Set print preferences + IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); + printOp.setPrintMode(store.getInt(ERDConstants.PREF_PRINT_PAGE_MODE)); + printOp.setPrintMargin(new Insets( + store.getInt(ERDConstants.PREF_PRINT_MARGIN_TOP), + store.getInt(ERDConstants.PREF_PRINT_MARGIN_LEFT), + store.getInt(ERDConstants.PREF_PRINT_MARGIN_BOTTOM), + store.getInt(ERDConstants.PREF_PRINT_MARGIN_RIGHT) + )); + // Run print + printOp.run("Print ER diagram"); + } + } + //new PrintAction(this).run(); + } + + @Override + public boolean isSearchPossible() + { + return true; + } + + @Override + public boolean isSearchEnabled() + { + return progressControl != null && progressControl.isSearchEnabled(); + } + + @Override + public boolean performSearch(SearchType searchType) + { + return progressControl != null && progressControl.performSearch(searchType); + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + protected void fillDefaultEditorContributions(IContributionManager toolBarManager) { + ZoomManager zoomManager = rootPart.getZoomManager(); + + String[] zoomStrings = new String[]{ + ZoomManager.FIT_ALL, + ZoomManager.FIT_HEIGHT, + ZoomManager.FIT_WIDTH + }; + // Init zoom combo with dummy part service + // to prevent zoom disable on part change - as it is standalone zoom control, not global one + zoomCombo = new ZoomComboContributionItem( + new IPartService() { + @Override + public void addPartListener(IPartListener listener) + { + } + + @Override + public void addPartListener(IPartListener2 listener) + { + } + + @Override + public IWorkbenchPart getActivePart() + { + return ERDEditorPart.this; + } + + @Override + public IWorkbenchPartReference getActivePartReference() + { + return null; + } + + @Override + public void removePartListener(IPartListener listener) + { + } + + @Override + public void removePartListener(IPartListener2 listener) + { + } + }, + zoomStrings); + zoomCombo.setZoomManager(zoomManager); + + toolBarManager.add(zoomCombo); + + //toolBarManager.add(new UndoAction(ERDEditorPart.this)); + //toolBarManager.add(new RedoAction(ERDEditorPart.this)); + //toolBarManager.add(new PrintAction(ERDEditorPart.this)); + + ZoomInAction zoomInAction = new ZoomInAction(zoomManager); + zoomInAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_IN)); + ZoomOutAction zoomOutAction = new ZoomOutAction(zoomManager); + zoomOutAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.ZOOM_OUT)); + toolBarManager.add(zoomInAction); + toolBarManager.add(zoomOutAction); + + toolBarManager.add(new Separator()); + //toolBarManager.add(createAttributeVisibilityMenu()); + toolBarManager.add(new DiagramLayoutAction(ERDEditorPart.this)); + toolBarManager.add(new DiagramToggleGridAction()); + toolBarManager.add(new DiagramRefreshAction(ERDEditorPart.this)); + toolBarManager.add(new Separator()); + { + toolBarManager.add(ActionUtils.makeCommandContribution( + getSite(), + IWorkbenchCommandConstants.FILE_PRINT, + ERDMessages.erd_editor_control_action_print_diagram, + UIIcon.PRINT)); + + toolBarManager.add(ActionUtils.makeCommandContribution( + getSite(), + IWorkbenchCommandConstants.FILE_SAVE_AS, + ERDMessages.erd_editor_control_action_save_external_format, + UIIcon.PICTURE_SAVE)); + + toolBarManager.add(ActionUtils.makeCommandContribution( + getSite(), + IWorkbenchCommandConstants.FILE_SAVE, + null, + UIIcon.SAVE)); + } + toolBarManager.add(new Separator()); + { + Action configAction = new Action(ERDMessages.erd_editor_control_action_configuration) { + @Override + public void run() + { + UIUtils.showPreferencesFor( + getSite().getShell(), + ERDEditorPart.this, + ERDPreferencePage.PAGE_ID); + } + }; + configAction.setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.CONFIGURATION)); + toolBarManager.add(configAction); + } + } + + protected abstract void loadDiagram(boolean refreshMetadata); + + @Override + public boolean isActiveTask() { + return diagramLoadingJob != null && diagramLoadingJob.getState() == Job.RUNNING; + } + + private class ChangeAttributePresentationAction extends Action { + private final ERDViewStyle style; + public ChangeAttributePresentationAction(ERDViewStyle style) { + super("Show " + style.getTitle(), AS_CHECK_BOX); + this.style = style; + } + @Override + public boolean isChecked() + { + return ArrayUtils.contains( + ERDViewStyle.getDefaultStyles(ERDActivator.getDefault().getPreferenceStore()), + style); + } + + @Override + public void run() + { + getDiagram().setAttributeStyle(style, !isChecked()); + refreshDiagram(true, false); + } + } + + private class ChangeAttributeVisibilityAction extends Action { + private final boolean defStyle; + private final ERDAttributeVisibility visibility; + + private ChangeAttributeVisibilityAction(boolean defStyle, ERDAttributeVisibility visibility) + { + super(visibility.getTitle() + "", IAction.AS_CHECK_BOX); + this.defStyle = defStyle; + this.visibility = visibility; + } + + @Override + public boolean isChecked() + { + if (defStyle) { + return visibility == getDiagram().getAttributeVisibility(); + } else { + for (Object object : ((IStructuredSelection)getGraphicalViewer().getSelection()).toArray()) { + if (object instanceof EntityPart) { + ERDAttributeVisibility entityAV = ((EntityPart) object).getEntity().getAttributeVisibility(); + if (entityAV == null) { + return visibility == getDiagram().getAttributeVisibility(); + } else if (entityAV == visibility) { + return true; + } + } + } + return false; + } + } + + @Override + public void runWithEvent(Event event) { + super.runWithEvent(event); + } + + @Override + public void run() + { + EntityDiagram diagram = getDiagram(); + if (defStyle) { + diagram.setAttributeVisibility(visibility); + for (ERDEntity entity : diagram.getEntities()) { + entity.reloadAttributes(diagram); + } + } else { + for (Object object : ((IStructuredSelection)getGraphicalViewer().getSelection()).toArray()) { + if (object instanceof EntityPart) { + ((EntityPart) object).getEntity().setAttributeVisibility(visibility); + UIUtils.asyncExec(() -> ((EntityPart) object).getEntity().reloadAttributes(diagram)); + } + } + } + diagram.setNeedsAutoLayout(true); + + UIUtils.asyncExec(() -> getGraphicalViewer().setContents(diagram)); + } + } + + private class ConfigPropertyListener implements IPropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent event) + { + GraphicalViewer graphicalViewer = getGraphicalViewer(); + if (graphicalViewer == null) { + return; + } + if (ERDConstants.PREF_GRID_ENABLED.equals(event.getProperty())) { + Boolean enabled = Boolean.valueOf(event.getNewValue().toString()); + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, enabled); + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, enabled); + } else if (ERDConstants.PREF_GRID_WIDTH.equals(event.getProperty()) || ERDConstants.PREF_GRID_HEIGHT.equals(event.getProperty())) { + final IPreferenceStore store = ERDActivator.getDefault().getPreferenceStore(); + graphicalViewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension( + store.getInt(ERDConstants.PREF_GRID_WIDTH), + store.getInt(ERDConstants.PREF_GRID_HEIGHT))); + } else if (ERDConstants.PREF_ATTR_VISIBILITY.equals(event.getProperty())) { + EntityDiagram diagram = getDiagram(); + ERDAttributeVisibility attrVisibility = CommonUtils.valueOf(ERDAttributeVisibility.class, CommonUtils.toString(event.getNewValue())); + diagram.setAttributeVisibility(attrVisibility); + for (ERDEntity entity : diagram.getEntities()) { + entity.reloadAttributes(diagram); + } + diagram.setNeedsAutoLayout(true); + + UIUtils.asyncExec(() -> graphicalViewer.setContents(diagram)); + } else if (ERDConstants.PREF_ATTR_STYLES.equals(event.getProperty())) { + refreshDiagram(true, false); + } else if (ERDConstants.PREF_DIAGRAM_SHOW_VIEWS.equals(event.getProperty()) || ERDConstants.PREF_DIAGRAM_SHOW_PARTITIONS.equals(event.getProperty())) { + refreshDiagram(true, true); + } + } + } + + protected class ProgressControl extends ProgressPageControl { + + private Searcher searcher; + + private ProgressControl(Composite parent, int style) + { + super(parent, style); + searcher = new Searcher(); + } + + @Override + protected boolean cancelProgress() + { + if (diagramLoadingJob != null) { + diagramLoadingJob.cancel(); + return true; + } + return false; + } + + public ProgressVisualizer createLoadVisualizer() + { + getGraphicalControl().setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); + return new LoadVisualizer(); + } + + @Override + public void fillCustomActions(IContributionManager toolBarManager) { + fillDefaultEditorContributions(toolBarManager); + } + + @Override + protected ISearchExecutor getSearchRunner() + { + return searcher; + } + + private class LoadVisualizer extends ProgressVisualizer { + @Override + public void visualizeLoading() + { + super.visualizeLoading(); + } + + @Override + public void completeLoading(EntityDiagram entityDiagram) + { + super.completeLoading(entityDiagram); + Control graphicalControl = getGraphicalControl(); + if (graphicalControl == null) { + return; + } + graphicalControl.setBackground(UIUtils.getColorRegistry().get(ERDConstants.COLOR_ERD_DIAGRAM_BACKGROUND)); + isLoaded = true; + Control control = getGraphicalViewer().getControl(); + if (control == null || control.isDisposed()) { + return; + } + + if (entityDiagram != null) { + List errorMessages = entityDiagram.getErrorMessages(); + if (!errorMessages.isEmpty()) { + // log.debug(message); + List messageStatuses = new ArrayList<>(errorMessages.size()); + for (String error : errorMessages) { + messageStatuses.add(new Status(Status.ERROR, ERDActivator.PLUGIN_ID, error)); + } + MultiStatus status = new MultiStatus(ERDActivator.PLUGIN_ID, 0, messageStatuses.toArray(new IStatus[0]), null, null); + + DBWorkbench.getPlatformUI().showError( + "Diagram loading errors", + "Error(s) occurred during diagram loading. If these errors are recoverable then fix errors and then refresh/reopen diagram", + status); + } + setInfo(entityDiagram.getEntityCount() + " objects"); + } else { + setInfo("Empty diagram due to error (see error log)"); + } + getCommandStack().flush(); + if (entityDiagram != null) { + EditPart oldContents = getGraphicalViewer().getContents(); + if (oldContents instanceof DiagramPart) { + if (restoreVisualSettings((DiagramPart) oldContents, entityDiagram)) { + entityDiagram.setLayoutManualAllowed(true); + entityDiagram.setLayoutManualDesired(true); + } + } + getGraphicalViewer().setContents(entityDiagram); + } + // + if (zoomCombo != null) { + zoomCombo.setZoomManager(rootPart.getZoomManager()); + } + //toolBarManager.getControl().setEnabled(true); + } + } + + } + + private boolean restoreVisualSettings(DiagramPart oldDiagram, EntityDiagram newDiagram) { + boolean hasChanges = false; + // Collect visual settings from old diagram and apply them to the new one + for (ERDEntity newEntity : newDiagram.getEntities()) { + NodePart oldEntity = oldDiagram.getChildByObject(newEntity.getObject()); + if (oldEntity instanceof EntityPart) { + EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldEntity); + newDiagram.addVisualInfo(newEntity.getObject(), vi); + hasChanges = true; + } + } + + for (ERDNote newNote : newDiagram.getNotes()) { + NodePart oldNotePart = oldDiagram.getChildByObject(newNote.getObject()); + if (oldNotePart instanceof NotePart) { + EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldNotePart); + vi.initBounds = oldNotePart.getBounds(); + newDiagram.addVisualInfo(newNote, vi); + hasChanges = true; + } + } + return hasChanges; + } + + private class Searcher extends ObjectSearcher { + + @Override + protected void setInfo(String message) + { + progressControl.setInfo(message); + } + + @Override + protected Collection getContent() + { + return getDiagramPart().getChildren(); + } + + @Override + protected void selectObject(DBPNamedObject object) + { + if (object == null) { + getGraphicalViewer().deselectAll(); + } else { + getGraphicalViewer().select((EditPart)object); + } + } + + @Override + protected void updateObject(DBPNamedObject object) + { + } + + @Override + protected void revealObject(DBPNamedObject object) + { + getGraphicalViewer().reveal((EditPart)object); + } + } + + protected abstract class DiagramLoaderVisualizer extends ProgressLoaderVisualizer { + protected DiagramLoaderVisualizer(ILoadService loadingService, Composite control) { + super(loadingService, control); + } + + @Override + public void visualizeLoading() { + super.visualizeLoading(); + } + + @Override + public void completeLoading(EntityDiagram result) { + super.completeLoading(result); + super.visualizeLoading(); + if (result != null && !result.getEntities().isEmpty()) { + setErrorMessage(null); + } + getGraphicalViewer().setContents(result); + getDiagramPart().rearrangeDiagram(); + finishLoading(); + } + + protected abstract void finishLoading(); + } + + +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorStandalone.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorStandalone.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorStandalone.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorStandalone.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorViewer.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorViewer.java similarity index 100% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorViewer.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDEditorViewer.java diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java index d91b7bb1f9..b2624a23d7 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDGraphicalViewer.java @@ -1,381 +1,381 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Jul 19, 2004 - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.gef.*; -import org.eclipse.gef.palette.PaletteContainer; -import org.eclipse.gef.palette.PaletteDrawer; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.palette.ToolEntry; -import org.eclipse.gef.tools.SelectionTool; -import org.eclipse.gef.ui.parts.AbstractEditPartViewer; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.themes.ITheme; -import org.eclipse.ui.themes.IThemeManager; -import org.jkiss.dbeaver.Log; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.directedit.ValidationMessageHandler; -import org.jkiss.dbeaver.ext.erd.part.DiagramPart; -import org.jkiss.dbeaver.ext.erd.part.EntityPart; -import org.jkiss.dbeaver.model.*; -import org.jkiss.dbeaver.model.struct.DBSEntity; -import org.jkiss.dbeaver.runtime.DBWorkbench; -import org.jkiss.dbeaver.ui.DBeaverIcons; -import org.jkiss.dbeaver.ui.UIUtils; - -import java.util.*; - -/** - * GraphicalViewer which also knows about ValidationMessageHandler to output - * error messages to - * @author Serge Rider - */ -public class ERDGraphicalViewer extends ScrollingGraphicalViewer implements IPropertyChangeListener, DBPEventListener { - private static final Log log = Log.getLog(ERDGraphicalViewer.class); - - private ERDEditorPart editor; - private ValidationMessageHandler messageHandler; - private IThemeManager themeManager; - private boolean loadContents = false; - - private static class DataSourceInfo { - int tableCount = 0; - } - - private final Map usedDataSources = new IdentityHashMap<>(); - - /** - * ValidationMessageHandler to receive messages - * @param messageHandler message handler - */ - public ERDGraphicalViewer(ERDEditorPart editor, ValidationMessageHandler messageHandler) - { - super(); - this.editor = editor; - this.messageHandler = messageHandler; - - themeManager = editor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); - themeManager.addPropertyChangeListener(this); - - setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON); - //setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD2), MouseWheelHorizontalScrollHandler.SINGLETON); - } - - public ERDEditorPart getEditor() - { - return editor; - } - - @Override - public void setControl(Control control) - { - super.setControl(control); - - if (control != null) { - ERDEditorAdapter.mapControl(control, editor); - UIUtils.addFocusTracker(editor.getSite(), ERDConstants.ERD_CONTROL_ID, control); - applyThemeSettings(); - } - } - - @Override - protected void handleDispose(DisposeEvent e) { - if (themeManager != null) { - themeManager.removePropertyChangeListener(this); - } - if (getControl() != null) { - ERDEditorAdapter.unmapControl(getControl()); - } - super.handleDispose(e); - } - - /** - * @return Returns the messageLabel. - */ - public ValidationMessageHandler getValidationHandler() - { - return messageHandler; - } - - /** - * This method is invoked when this viewer's control loses focus. It removes - * focus from the {@link AbstractEditPartViewer#focusPart focusPart}, if - * there is one. - * - * @param fe - * the focusEvent received by this viewer's control - */ - @Override - protected void handleFocusLost(FocusEvent fe) - { - //give the superclass a chance to handle this first - super.handleFocusLost(fe); - //call reset on the MessageHandler itself - messageHandler.reset(); - } - - @Override - public void propertyChange(PropertyChangeEvent event) - { - if (event.getProperty().equals(IThemeManager.CHANGE_CURRENT_THEME) - || event.getProperty().equals(ERDConstants.PROP_DIAGRAM_FONT)) - { - applyThemeSettings(); - } - } - - private void applyThemeSettings() - { - ITheme currentTheme = themeManager.getCurrentTheme(); - Font erdFont = currentTheme.getFontRegistry().get(ERDConstants.PROP_DIAGRAM_FONT); - if (erdFont != null) { - this.getControl().setFont(erdFont); - } - editor.refreshDiagram(true, false); -/* - DiagramPart diagramPart = editor.getDiagramPart(); - if (diagramPart != null) { - diagramPart.resetFonts(); - diagramPart.refresh(); - } -*/ - } - - @Override - public void setContents(EditPart editpart) - { - loadContents = true; - try { - super.setContents(editpart); - // Reset palette contents - if (editpart instanceof DiagramPart) { - List tables = new ArrayList<>(); - for (Object child : editpart.getChildren()) { - if (child instanceof EntityPart) { - tables.add(((EntityPart) child).getEntity().getObject()); - } - } - tables.sort(DBUtils.nameComparator()); - Map> toolMap = new LinkedHashMap<>(); - for (DBSEntity table : tables) { - DBPDataSourceContainer container = table.getDataSource().getContainer(); - PaletteDrawer drawer = getContainerPaletteDrawer(container); - if (drawer != null) { - List tools = toolMap.get(drawer); - if (tools == null) { - tools = new ArrayList<>(tables.size()); - toolMap.put(drawer, tools); - } - tools.add(new ToolEntryTable(table)); - } - } - for (Map.Entry> entry : toolMap.entrySet()) { - entry.getKey().setChildren(entry.getValue()); - } - //editor.getPaletteContents().setChildren(tools); - } - } - finally { - loadContents = false; - } - } - - public void handleTableActivate(DBSEntity table) - { - if (table.getDataSource() != null) { - DBPDataSourceContainer container = table.getDataSource().getContainer(); - if (container != null) { - synchronized (usedDataSources) { - DataSourceInfo dataSourceInfo = usedDataSources.get(container); - if (dataSourceInfo == null) { - dataSourceInfo = new DataSourceInfo(); - usedDataSources.put(container, dataSourceInfo); - acquireContainer(container); - } - dataSourceInfo.tableCount++; - } - } - } - - if (!loadContents) { - final PaletteContainer drawer = getContainerPaletteDrawer(table.getDataSource().getContainer()); - if (drawer != null) { - // Add entry (with right order) - List children = drawer.getChildren(); - int index = 0; - for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { - Object child = children.get(i); - if (child instanceof ToolEntryTable) { - if (((ToolEntryTable) child).table.getName().compareTo(table.getName()) > 0) { - index = i; - break; - } - } - } - drawer.add(index, new ToolEntryTable(table)); - } - } - } - - public void handleTableDeactivate(DBSEntity table) - { - final PaletteContainer drawer = getContainerPaletteDrawer(table.getDataSource().getContainer()); - if (drawer != null) { - for (Object entry : drawer.getChildren()) { - if (entry instanceof ToolEntryTable && ((ToolEntryTable)entry).table == table) { - drawer.remove((ToolEntryTable)entry); - break; - } - } - } - if (table.getDataSource() != null) { - DBPDataSourceContainer container = table.getDataSource().getContainer(); - if (container != null) { - synchronized (usedDataSources) { - DataSourceInfo dataSourceInfo = usedDataSources.get(container); - if (dataSourceInfo == null) { - log.warn("Datasource '" + container + "' not registered in ERD viewer"); - } else { - dataSourceInfo.tableCount--; - if (dataSourceInfo.tableCount <= 0) { - usedDataSources.remove(container); - releaseContainer(container); - } - } - } - } - } - } - - private void acquireContainer(DBPDataSourceContainer container) - { - container.acquire(editor); - container.getRegistry().addDataSourceListener(this); - - PaletteRoot paletteRoot = editor.getPaletteRoot(); - - PaletteDrawer dsDrawer = new PaletteDrawer( - container.getName(), - DBeaverIcons.getImageDescriptor(container.getDriver().getIcon())); - dsDrawer.setDescription(container.getDescription()); - dsDrawer.setId(container.getId()); - - paletteRoot.add(dsDrawer); - } - - private void releaseContainer(DBPDataSourceContainer container) - { - PaletteDrawer drawer = getContainerPaletteDrawer(container); - if (drawer != null) { - editor.getPaletteRoot().remove(drawer); - } - - container.getRegistry().removeDataSourceListener(this); - container.release(editor); - } - - PaletteDrawer getContainerPaletteDrawer(DBPDataSourceContainer container) - { - for (Object child : editor.getPaletteRoot().getChildren()) { - if (child instanceof PaletteDrawer && container.getId().equals(((PaletteDrawer) child).getId())) { - return (PaletteDrawer) child; - } - } - return null; - } - - @Override - public void handleDataSourceEvent(DBPEvent event) - { - if (!(event.getObject() instanceof DBPDataSourceContainer)) { - return; - } - DBPDataSourceContainer container = (DBPDataSourceContainer)event.getObject(); - if (usedDataSources.containsKey(container) && - event.getAction() == DBPEvent.Action.OBJECT_UPDATE && - Boolean.FALSE.equals(event.getEnabled()) && - !DBWorkbench.getPlatform().isShuttingDown()) - { - // Close editor only if it is simple disconnect - // Workbench shutdown doesn't close editor - UIUtils.asyncExec(() -> { - IWorkbenchPartSite site = editor.getSite(); - if (site != null && site.getWorkbenchWindow() != null) { - site.getWorkbenchWindow().getActivePage().closeEditor(editor, false); - } - }); - } - } - - private class ToolEntryTable extends ToolEntry { - private final DBSEntity table; - public ToolEntryTable(DBSEntity table) - { - super(table.getName(), table.getDescription(), - DBeaverIcons.getImageDescriptor(DBIcon.TREE_TABLE), - DBeaverIcons.getImageDescriptor(DBIcon.TREE_TABLE)); - this.setUserModificationPermission(PERMISSION_NO_MODIFICATION); - setDescription(DBUtils.getObjectFullName(table, DBPEvaluationContext.UI)); - this.table = table; - } - @Override - public Tool createTool() - { - return new ToolSelectTable(table); - } - } - - public static class ToolSelectTable extends SelectionTool { - private final DBSEntity table; - - public ToolSelectTable(DBSEntity table) - { - this.table = table; - } - - @Override - public void activate() - { - //ERDGraphicalViewer.this.reveal(part); - DefaultEditDomain editDomain = (DefaultEditDomain) getDomain(); - final ERDEditorPart editorPart = (ERDEditorPart)editDomain.getEditorPart(); - final GraphicalViewer viewer = editorPart.getViewer(); - for (Object child : editorPart.getDiagramPart().getChildren()) { - if (child instanceof EntityPart) { - if (((EntityPart)child).getEntity().getObject() == table) { - viewer.reveal((EditPart) child); - viewer.select((EditPart) child); - break; - } - } - } - super.activate(); - } - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Jul 19, 2004 + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.gef.*; +import org.eclipse.gef.palette.PaletteContainer; +import org.eclipse.gef.palette.PaletteDrawer; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.gef.tools.SelectionTool; +import org.eclipse.gef.ui.parts.AbstractEditPartViewer; +import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.themes.ITheme; +import org.eclipse.ui.themes.IThemeManager; +import org.jkiss.dbeaver.Log; +import org.jkiss.dbeaver.ext.erd.ERDConstants; +import org.jkiss.dbeaver.ext.erd.directedit.ValidationMessageHandler; +import org.jkiss.dbeaver.ext.erd.part.DiagramPart; +import org.jkiss.dbeaver.ext.erd.part.EntityPart; +import org.jkiss.dbeaver.model.*; +import org.jkiss.dbeaver.model.struct.DBSEntity; +import org.jkiss.dbeaver.runtime.DBWorkbench; +import org.jkiss.dbeaver.ui.DBeaverIcons; +import org.jkiss.dbeaver.ui.UIUtils; + +import java.util.*; + +/** + * GraphicalViewer which also knows about ValidationMessageHandler to output + * error messages to + * @author Serge Rider + */ +public class ERDGraphicalViewer extends ScrollingGraphicalViewer implements IPropertyChangeListener, DBPEventListener { + private static final Log log = Log.getLog(ERDGraphicalViewer.class); + + private ERDEditorPart editor; + private ValidationMessageHandler messageHandler; + private IThemeManager themeManager; + private boolean loadContents = false; + + private static class DataSourceInfo { + int tableCount = 0; + } + + private final Map usedDataSources = new IdentityHashMap<>(); + + /** + * ValidationMessageHandler to receive messages + * @param messageHandler message handler + */ + public ERDGraphicalViewer(ERDEditorPart editor, ValidationMessageHandler messageHandler) + { + super(); + this.editor = editor; + this.messageHandler = messageHandler; + + themeManager = editor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager(); + themeManager.addPropertyChangeListener(this); + + setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON); + //setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD2), MouseWheelHorizontalScrollHandler.SINGLETON); + } + + public ERDEditorPart getEditor() + { + return editor; + } + + @Override + public void setControl(Control control) + { + super.setControl(control); + + if (control != null) { + ERDEditorAdapter.mapControl(control, editor); + UIUtils.addFocusTracker(editor.getSite(), ERDConstants.ERD_CONTROL_ID, control); + applyThemeSettings(); + } + } + + @Override + protected void handleDispose(DisposeEvent e) { + if (themeManager != null) { + themeManager.removePropertyChangeListener(this); + } + if (getControl() != null) { + ERDEditorAdapter.unmapControl(getControl()); + } + super.handleDispose(e); + } + + /** + * @return Returns the messageLabel. + */ + public ValidationMessageHandler getValidationHandler() + { + return messageHandler; + } + + /** + * This method is invoked when this viewer's control loses focus. It removes + * focus from the {@link AbstractEditPartViewer#focusPart focusPart}, if + * there is one. + * + * @param fe + * the focusEvent received by this viewer's control + */ + @Override + protected void handleFocusLost(FocusEvent fe) + { + //give the superclass a chance to handle this first + super.handleFocusLost(fe); + //call reset on the MessageHandler itself + messageHandler.reset(); + } + + @Override + public void propertyChange(PropertyChangeEvent event) + { + if (event.getProperty().equals(IThemeManager.CHANGE_CURRENT_THEME) + || event.getProperty().equals(ERDConstants.PROP_DIAGRAM_FONT)) + { + applyThemeSettings(); + } + } + + private void applyThemeSettings() + { + ITheme currentTheme = themeManager.getCurrentTheme(); + Font erdFont = currentTheme.getFontRegistry().get(ERDConstants.PROP_DIAGRAM_FONT); + if (erdFont != null) { + this.getControl().setFont(erdFont); + } + editor.refreshDiagram(true, false); +/* + DiagramPart diagramPart = editor.getDiagramPart(); + if (diagramPart != null) { + diagramPart.resetFonts(); + diagramPart.refresh(); + } +*/ + } + + @Override + public void setContents(EditPart editpart) + { + loadContents = true; + try { + super.setContents(editpart); + // Reset palette contents + if (editpart instanceof DiagramPart) { + List tables = new ArrayList<>(); + for (Object child : editpart.getChildren()) { + if (child instanceof EntityPart) { + tables.add(((EntityPart) child).getEntity().getObject()); + } + } + tables.sort(DBUtils.nameComparator()); + Map> toolMap = new LinkedHashMap<>(); + for (DBSEntity table : tables) { + DBPDataSourceContainer container = table.getDataSource().getContainer(); + PaletteDrawer drawer = getContainerPaletteDrawer(container); + if (drawer != null) { + List tools = toolMap.get(drawer); + if (tools == null) { + tools = new ArrayList<>(tables.size()); + toolMap.put(drawer, tools); + } + tools.add(new ToolEntryTable(table)); + } + } + for (Map.Entry> entry : toolMap.entrySet()) { + entry.getKey().setChildren(entry.getValue()); + } + //editor.getPaletteContents().setChildren(tools); + } + } + finally { + loadContents = false; + } + } + + public void handleTableActivate(DBSEntity table) + { + if (table.getDataSource() != null) { + DBPDataSourceContainer container = table.getDataSource().getContainer(); + if (container != null) { + synchronized (usedDataSources) { + DataSourceInfo dataSourceInfo = usedDataSources.get(container); + if (dataSourceInfo == null) { + dataSourceInfo = new DataSourceInfo(); + usedDataSources.put(container, dataSourceInfo); + acquireContainer(container); + } + dataSourceInfo.tableCount++; + } + } + } + + if (!loadContents) { + final PaletteContainer drawer = getContainerPaletteDrawer(table.getDataSource().getContainer()); + if (drawer != null) { + // Add entry (with right order) + List children = drawer.getChildren(); + int index = 0; + for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) { + Object child = children.get(i); + if (child instanceof ToolEntryTable) { + if (((ToolEntryTable) child).table.getName().compareTo(table.getName()) > 0) { + index = i; + break; + } + } + } + drawer.add(index, new ToolEntryTable(table)); + } + } + } + + public void handleTableDeactivate(DBSEntity table) + { + final PaletteContainer drawer = getContainerPaletteDrawer(table.getDataSource().getContainer()); + if (drawer != null) { + for (Object entry : drawer.getChildren()) { + if (entry instanceof ToolEntryTable && ((ToolEntryTable)entry).table == table) { + drawer.remove((ToolEntryTable)entry); + break; + } + } + } + if (table.getDataSource() != null) { + DBPDataSourceContainer container = table.getDataSource().getContainer(); + if (container != null) { + synchronized (usedDataSources) { + DataSourceInfo dataSourceInfo = usedDataSources.get(container); + if (dataSourceInfo == null) { + log.warn("Datasource '" + container + "' not registered in ERD viewer"); + } else { + dataSourceInfo.tableCount--; + if (dataSourceInfo.tableCount <= 0) { + usedDataSources.remove(container); + releaseContainer(container); + } + } + } + } + } + } + + private void acquireContainer(DBPDataSourceContainer container) + { + container.acquire(editor); + container.getRegistry().addDataSourceListener(this); + + PaletteRoot paletteRoot = editor.getPaletteRoot(); + + PaletteDrawer dsDrawer = new PaletteDrawer( + container.getName(), + DBeaverIcons.getImageDescriptor(container.getDriver().getIcon())); + dsDrawer.setDescription(container.getDescription()); + dsDrawer.setId(container.getId()); + + paletteRoot.add(dsDrawer); + } + + private void releaseContainer(DBPDataSourceContainer container) + { + PaletteDrawer drawer = getContainerPaletteDrawer(container); + if (drawer != null) { + editor.getPaletteRoot().remove(drawer); + } + + container.getRegistry().removeDataSourceListener(this); + container.release(editor); + } + + PaletteDrawer getContainerPaletteDrawer(DBPDataSourceContainer container) + { + for (Object child : editor.getPaletteRoot().getChildren()) { + if (child instanceof PaletteDrawer && container.getId().equals(((PaletteDrawer) child).getId())) { + return (PaletteDrawer) child; + } + } + return null; + } + + @Override + public void handleDataSourceEvent(DBPEvent event) + { + if (!(event.getObject() instanceof DBPDataSourceContainer)) { + return; + } + DBPDataSourceContainer container = (DBPDataSourceContainer)event.getObject(); + if (usedDataSources.containsKey(container) && + event.getAction() == DBPEvent.Action.OBJECT_UPDATE && + Boolean.FALSE.equals(event.getEnabled()) && + !DBWorkbench.getPlatform().isShuttingDown()) + { + // Close editor only if it is simple disconnect + // Workbench shutdown doesn't close editor + UIUtils.asyncExec(() -> { + IWorkbenchPartSite site = editor.getSite(); + if (site != null && site.getWorkbenchWindow() != null) { + site.getWorkbenchWindow().getActivePage().closeEditor(editor, false); + } + }); + } + } + + private class ToolEntryTable extends ToolEntry { + private final DBSEntity table; + public ToolEntryTable(DBSEntity table) + { + super(table.getName(), table.getDescription(), + DBeaverIcons.getImageDescriptor(DBIcon.TREE_TABLE), + DBeaverIcons.getImageDescriptor(DBIcon.TREE_TABLE)); + this.setUserModificationPermission(PERMISSION_NO_MODIFICATION); + setDescription(DBUtils.getObjectFullName(table, DBPEvaluationContext.UI)); + this.table = table; + } + @Override + public Tool createTool() + { + return new ToolSelectTable(table); + } + } + + public static class ToolSelectTable extends SelectionTool { + private final DBSEntity table; + + public ToolSelectTable(DBSEntity table) + { + this.table = table; + } + + @Override + public void activate() + { + //ERDGraphicalViewer.this.reveal(part); + DefaultEditDomain editDomain = (DefaultEditDomain) getDomain(); + final ERDEditorPart editorPart = (ERDEditorPart)editDomain.getEditorPart(); + final GraphicalViewer viewer = editorPart.getViewer(); + for (Object child : editorPart.getDiagramPart().getChildren()) { + if (child instanceof EntityPart) { + if (((EntityPart)child).getEntity().getObject() == table) { + viewer.reveal((EditPart) child); + viewer.select((EditPart) child); + break; + } + } + } + super.activate(); + } + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java index 3ee81a6070..79326d5e5d 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDOutlinePage.java @@ -1,132 +1,132 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.draw2d.LightweightSystem; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.draw2d.parts.Thumbnail; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.Page; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * This is a sample implementation of an outline page showing an - * overview of a graphical editor. - * - * @author Gunnar Wagenknecht - */ -public class ERDOutlinePage extends Page implements IContentOutlinePage { - - /** - * the control of the overview - */ - private Canvas overview; - /** - * the root edit part - */ - private ScalableFreeformRootEditPart rootEditPart; - - /** - * the thumbnail - */ - private Thumbnail thumbnail; - - /** - * Creates a new ERDOutlinePage instance. - * - * @param rootEditPart the root edit part to show the overview from - */ - public ERDOutlinePage(ScalableFreeformRootEditPart rootEditPart) { - super(); - this.rootEditPart = rootEditPart; - } - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createControl(Composite parent) { - // create canvas and lws - overview = new Canvas(parent, SWT.NONE); - LightweightSystem lws = new LightweightSystem(overview); - - // create thumbnail - thumbnail = - new ScrollableThumbnail((Viewport) rootEditPart.getFigure()); - thumbnail.setBorder(new MarginBorder(3)); - thumbnail.setSource( - rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS)); - lws.setContents(thumbnail); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#dispose() - */ - @Override - public void dispose() { - if (null != thumbnail) - thumbnail.deactivate(); - - super.dispose(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - @Override - public Control getControl() { - return overview; - } - - @Override - public ISelection getSelection() { - return StructuredSelection.EMPTY; - } - - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - - } - - @Override - public void setFocus() { - if (getControl() != null) - getControl().setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - @Override - public void setSelection(ISelection selection) { - } -} +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.draw2d.LightweightSystem; +import org.eclipse.draw2d.MarginBorder; +import org.eclipse.draw2d.Viewport; +import org.eclipse.draw2d.parts.ScrollableThumbnail; +import org.eclipse.draw2d.parts.Thumbnail; +import org.eclipse.gef.LayerConstants; +import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.part.Page; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; + +/** + * This is a sample implementation of an outline page showing an + * overview of a graphical editor. + * + * @author Gunnar Wagenknecht + */ +public class ERDOutlinePage extends Page implements IContentOutlinePage { + + /** + * the control of the overview + */ + private Canvas overview; + /** + * the root edit part + */ + private ScalableFreeformRootEditPart rootEditPart; + + /** + * the thumbnail + */ + private Thumbnail thumbnail; + + /** + * Creates a new ERDOutlinePage instance. + * + * @param rootEditPart the root edit part to show the overview from + */ + public ERDOutlinePage(ScalableFreeformRootEditPart rootEditPart) { + super(); + this.rootEditPart = rootEditPart; + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createControl(Composite parent) { + // create canvas and lws + overview = new Canvas(parent, SWT.NONE); + LightweightSystem lws = new LightweightSystem(overview); + + // create thumbnail + thumbnail = + new ScrollableThumbnail((Viewport) rootEditPart.getFigure()); + thumbnail.setBorder(new MarginBorder(3)); + thumbnail.setSource( + rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS)); + lws.setContents(thumbnail); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#dispose() + */ + @Override + public void dispose() { + if (null != thumbnail) + thumbnail.deactivate(); + + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#getControl() + */ + @Override + public Control getControl() { + return overview; + } + + @Override + public ISelection getSelection() { + return StructuredSelection.EMPTY; + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + + } + + @Override + public void setFocus() { + if (getControl() != null) + getControl().setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + @Override + public void setSelection(ISelection selection) { + } +} diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java index 4c6c234f49..4e7231f4aa 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPalettePreferences.java @@ -1,84 +1,84 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Aug 12, 2004 - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; -import org.jkiss.dbeaver.ext.erd.ERDActivator; - - -/** - * Contains the preferences for the palette flyout - * @author Serge Rider - */ -public class ERDPalettePreferences implements FlyoutPreferences -{ - - public static final int DEFAULT_PALETTE_WIDTH = 150; - - protected static final String PALETTE_DOCK_LOCATION = "Dock location"; - protected static final String PALETTE_SIZE = "Palette Size"; - protected static final String PALETTE_STATE = "Palette state"; - - @Override - public int getDockLocation() - { - int location = ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_DOCK_LOCATION); - if (location == 0) - { - return PositionConstants.EAST; - } - return location; - } - - @Override - public int getPaletteState() - { - return ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_STATE); - } - - @Override - public int getPaletteWidth() - { - int width = ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_SIZE); - if (width == 0) - return DEFAULT_PALETTE_WIDTH; - return width; - } - - @Override - public void setDockLocation(int location) - { - ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_DOCK_LOCATION, location); - } - - @Override - public void setPaletteState(int state) - { - ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_STATE, state); - } - - @Override - public void setPaletteWidth(int width) - { - ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_SIZE, width); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Aug 12, 2004 + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences; +import org.jkiss.dbeaver.ext.erd.ERDActivator; + + +/** + * Contains the preferences for the palette flyout + * @author Serge Rider + */ +public class ERDPalettePreferences implements FlyoutPreferences +{ + + public static final int DEFAULT_PALETTE_WIDTH = 150; + + protected static final String PALETTE_DOCK_LOCATION = "Dock location"; + protected static final String PALETTE_SIZE = "Palette Size"; + protected static final String PALETTE_STATE = "Palette state"; + + @Override + public int getDockLocation() + { + int location = ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_DOCK_LOCATION); + if (location == 0) + { + return PositionConstants.EAST; + } + return location; + } + + @Override + public int getPaletteState() + { + return ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_STATE); + } + + @Override + public int getPaletteWidth() + { + int width = ERDActivator.getDefault().getPreferenceStore().getInt(PALETTE_SIZE); + if (width == 0) + return DEFAULT_PALETTE_WIDTH; + return width; + } + + @Override + public void setDockLocation(int location) + { + ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_DOCK_LOCATION, location); + } + + @Override + public void setPaletteState(int state) + { + ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_STATE, state); + } + + @Override + public void setPaletteWidth(int width) + { + ERDActivator.getDefault().getPreferenceStore().setValue(PALETTE_SIZE, width); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java similarity index 96% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java index 7c37b480b5..41a2a3ce11 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPaletteViewerProvider.java @@ -1,49 +1,49 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * Created on Aug 12, 2004 - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.gef.EditDomain; -import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; -import org.eclipse.gef.ui.palette.PaletteViewer; -import org.eclipse.gef.ui.palette.PaletteViewerProvider; - -/** - * PaletteViewerProvider subclass used for initialising drag and drop - * @author Serge Rider - */ -public class ERDPaletteViewerProvider extends PaletteViewerProvider -{ - - /** - * implicit constructor - */ - public ERDPaletteViewerProvider(EditDomain graphicalViewerDomain) - { - super(graphicalViewerDomain); - } - - @Override - protected void configurePaletteViewer(PaletteViewer viewer) - { - super.configurePaletteViewer(viewer); - viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer)); - } - +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2020 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * Created on Aug 12, 2004 + */ +package org.jkiss.dbeaver.ext.erd.editor; + +import org.eclipse.gef.EditDomain; +import org.eclipse.gef.dnd.TemplateTransferDragSourceListener; +import org.eclipse.gef.ui.palette.PaletteViewer; +import org.eclipse.gef.ui.palette.PaletteViewerProvider; + +/** + * PaletteViewerProvider subclass used for initialising drag and drop + * @author Serge Rider + */ +public class ERDPaletteViewerProvider extends PaletteViewerProvider +{ + + /** + * implicit constructor + */ + public ERDPaletteViewerProvider(EditDomain graphicalViewerDomain) + { + super(graphicalViewerDomain); + } + + @Override + protected void configurePaletteViewer(PaletteViewer viewer) + { + super.configurePaletteViewer(viewer); + viewer.addDragSourceListener(new TemplateTransferDragSourceListener(viewer)); + } + } \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java similarity index 97% rename from plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java rename to plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java index 9e09f26ac6..923bc2ff71 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java +++ b/plugins/org.jkiss.dbeaver.erd.ui/src/org/jkiss/dbeaver/ext/erd/editor/ERDPreferencePage.java @@ -1,235 +1,235 @@ -/* - * DBeaver - Universal Database Manager - * Copyright (C) 2010-2020 DBeaver Corp and others - * Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jkiss.dbeaver.ext.erd.editor; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.draw2d.PrintFigureOperation; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.IWorkbenchPropertyPage; -import org.jkiss.dbeaver.ext.erd.ERDActivator; -import org.jkiss.dbeaver.ext.erd.ERDConstants; -import org.jkiss.dbeaver.ext.erd.ERDMessages; -import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; -import org.jkiss.dbeaver.ui.UIUtils; -import org.jkiss.dbeaver.ui.preferences.AbstractPrefPage; -import org.jkiss.dbeaver.utils.PrefUtils; -import org.jkiss.utils.ArrayUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * ERDPreferencePage - */ -public class ERDPreferencePage extends AbstractPrefPage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage { - - public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.erd.general"; //$NON-NLS-1$ - private IAdaptable element; - - private Button contentsShowViews; - private Button contentsShowPartitions; - private Button changeBorderColors; - private Button changeHeaderColors; - - private Combo modeCombo; - private Spinner spinnerMarginTop; - private Spinner spinnerMarginBottom; - private Spinner spinnerMarginLeft; - private Spinner spinnerMarginRight; - private Button gridCheck; - private Button snapCheck; - private Spinner spinnerGridWidth; - private Spinner spinnerGridHeight; - - private List