From bd5abff68215e5636678b679bd1f324110b2be83 Mon Sep 17 00:00:00 2001 From: Pierre-Charles David Date: Thu, 30 Nov 2023 16:43:41 +0100 Subject: [PATCH] [206] Add support for disabling migration log messages Bug: https://github.com/eclipse-sirius/sirius-desktop/issues/206 Signed-off-by: Pierre-Charles David --- ...ltipleConnectorStyleMigrationParticipant.java | 3 +-- .../EdgesZOrderMigrationParticipant.java | 3 +-- .../LabelOnBorderMigrationParticipant.java | 3 +-- .../RepairGMFbendpointsMigrationParticipant.java | 3 +-- .../RepresentationLinkMigrationParticipant.java | 3 +-- .../SetChangeIdMigrationParticipant.java | 3 +-- ...napBackDistantLabelsMigrationParticipant.java | 3 +-- ...kspaceImageGMFBoundsMigrationParticipant.java | 3 +-- ...tivatedFilterSortingMigrationParticipant.java | 3 +-- ...ithoutSourceOrTargetMigrationParticipant.java | 3 +-- ...OriginalStyleFeatureMigrationParticipant.java | 3 +-- .../ViewWithNullElementMigrationParticipant.java | 3 +-- .../migration/AbstractMigrationParticipant.java | 16 ++++++++++++++++ 13 files changed, 28 insertions(+), 24 deletions(-) diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/DeleteMultipleConnectorStyleMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/DeleteMultipleConnectorStyleMigrationParticipant.java index 50e5c85085..5015879bf3 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/DeleteMultipleConnectorStyleMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/DeleteMultipleConnectorStyleMigrationParticipant.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DSemanticDiagram; import org.eclipse.sirius.diagram.business.api.refresh.DiagramCreationUtil; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.provider.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; @@ -80,7 +79,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } } if (migrationOccured) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); migrationOccured = false; } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/EdgesZOrderMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/EdgesZOrderMigrationParticipant.java index 8558cb6572..f20b18da26 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/EdgesZOrderMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/EdgesZOrderMigrationParticipant.java @@ -24,7 +24,6 @@ import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.DDiagramGraphicalQuery; import org.eclipse.sirius.diagram.ui.provider.Messages; import org.eclipse.sirius.ext.base.Option; @@ -92,7 +91,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } if (isModified) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/LabelOnBorderMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/LabelOnBorderMigrationParticipant.java index efd501209d..53636d2db1 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/LabelOnBorderMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/LabelOnBorderMigrationParticipant.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.diagram.DNode; import org.eclipse.sirius.diagram.LabelPosition; import org.eclipse.sirius.diagram.business.internal.migration.ActivatedFilterSortingMigrationParticipant; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.DDiagramGraphicalQuery; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNode2EditPart; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNode3EditPart; @@ -99,7 +98,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } }); if (migrationOccured) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); migrationOccured = false; } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java index 3c3d257eda..dd44328f3b 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepairGMFbendpointsMigrationParticipant.java @@ -37,7 +37,6 @@ import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.EdgeQuery; import org.eclipse.sirius.diagram.ui.internal.refresh.GMFHelper; import org.eclipse.sirius.diagram.ui.internal.refresh.edge.SlidableAnchor; @@ -100,7 +99,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } } if (isModified) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepresentationLinkMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepresentationLinkMigrationParticipant.java index 234bf81719..f9c9d23e41 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepresentationLinkMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/RepresentationLinkMigrationParticipant.java @@ -22,7 +22,6 @@ import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.DDiagramGraphicalQuery; import org.eclipse.sirius.diagram.ui.internal.view.factories.SiriusNoteViewFactory; import org.eclipse.sirius.diagram.ui.provider.Messages; @@ -80,7 +79,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { if (isModified) { builder.insert(0, System.lineSeparator()); builder.insert(0, Messages.RepresentationLinkMigrationParticipant_title); - DiagramPlugin.getDefault().logInfo(builder.toString()); + logMigrationInfo(builder.toString()); } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SetChangeIdMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SetChangeIdMigrationParticipant.java index 26160ce00f..e58b84e965 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SetChangeIdMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SetChangeIdMigrationParticipant.java @@ -17,7 +17,6 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.sirius.business.api.helper.RepresentationHelper; import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.provider.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; @@ -58,7 +57,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } } if (migrationOccured) { - DiagramPlugin.getDefault().logInfo(Messages.SetChangeIdMigrationParticipant_title); + logMigrationInfo(Messages.SetChangeIdMigrationParticipant_title); migrationOccured = false; } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SnapBackDistantLabelsMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SnapBackDistantLabelsMigrationParticipant.java index f41060b419..927e2a6956 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SnapBackDistantLabelsMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/SnapBackDistantLabelsMigrationParticipant.java @@ -42,7 +42,6 @@ import org.eclipse.sirius.business.api.migration.AbstractRepresentationsFileMigrationParticipant; import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.DDiagramGraphicalQuery; import org.eclipse.sirius.diagram.ui.business.api.query.NodeQuery; import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery; @@ -194,7 +193,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } if (isModified) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); } } } diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/WorkspaceImageGMFBoundsMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/WorkspaceImageGMFBoundsMigrationParticipant.java index e679fcab45..315e03ccf6 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/WorkspaceImageGMFBoundsMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/migration/WorkspaceImageGMFBoundsMigrationParticipant.java @@ -33,7 +33,6 @@ import org.eclipse.sirius.diagram.DNode; import org.eclipse.sirius.diagram.ResizeKind; import org.eclipse.sirius.diagram.description.style.WorkspaceImageDescription; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.ui.business.api.query.DDiagramGraphicalQuery; import org.eclipse.sirius.diagram.ui.business.api.query.NodeQuery; import org.eclipse.sirius.diagram.ui.business.internal.query.WorkspaceImageQuery; @@ -108,7 +107,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { } } if (migrationOccurred) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); migrationOccurred = false; } } diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ActivatedFilterSortingMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ActivatedFilterSortingMigrationParticipant.java index af4947d29b..e7d98a4d9a 100644 --- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ActivatedFilterSortingMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ActivatedFilterSortingMigrationParticipant.java @@ -23,7 +23,6 @@ import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.business.api.helper.filter.FilterService; import org.eclipse.sirius.diagram.description.filter.FilterDescription; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.tools.api.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; @@ -64,7 +63,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) { if (updateDiagrams > 0) { String migrationMessage = MessageFormat.format(Messages.ActivatedFilterSortingMigrationParticipant_updatedDiagrams, updateDiagrams); - DiagramPlugin.getDefault().logInfo(migrationMessage); + logMigrationInfo(migrationMessage); } } } diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/NoteAttachmentWithoutSourceOrTargetMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/NoteAttachmentWithoutSourceOrTargetMigrationParticipant.java index a13acfe643..cd2e88c2f1 100644 --- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/NoteAttachmentWithoutSourceOrTargetMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/NoteAttachmentWithoutSourceOrTargetMigrationParticipant.java @@ -26,7 +26,6 @@ import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.business.api.refresh.DiagramCreationUtil; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.tools.api.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; @@ -115,7 +114,7 @@ public void postLoad(XMLResource resource, String loadedVersion) { sb = new StringBuilder(MessageFormat.format(Messages.NoteAttachmentWithoutSourceOrTargetMigrationParticipant_title, resource.getURI().toPlatformString(true))); super.postLoad(resource, loadedVersion); if (deletionOccured) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); } } diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/UnsetOriginalStyleFeatureMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/UnsetOriginalStyleFeatureMigrationParticipant.java index 8f5ef9715b..8d5337bb84 100644 --- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/UnsetOriginalStyleFeatureMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/UnsetOriginalStyleFeatureMigrationParticipant.java @@ -33,7 +33,6 @@ import org.eclipse.sirius.diagram.DNodeListElement; import org.eclipse.sirius.diagram.DiagramPackage; import org.eclipse.sirius.diagram.business.api.query.DDiagramQuery; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.tools.api.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.osgi.framework.Version; @@ -127,7 +126,7 @@ public void postLoad(XMLResource resource, String loadedVersion) { if (numberOfOrignalStyeDanglingFeature > 0) { message.append(MessageFormat.format(Messages.UnsetOriginalStyleFeatureMigrationParticipant_danglingFeatures, numberOfOrignalStyeDanglingFeature)); } - DiagramPlugin.getDefault().logInfo(message.toString()); + logMigrationInfo(message.toString()); numberOfOrignalStyeFeatureUnset = 0; } diff --git a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ViewWithNullElementMigrationParticipant.java b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ViewWithNullElementMigrationParticipant.java index a30cb8b236..8e1a6c2cf2 100644 --- a/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ViewWithNullElementMigrationParticipant.java +++ b/plugins/org.eclipse.sirius.diagram/src/org/eclipse/sirius/diagram/business/internal/migration/ViewWithNullElementMigrationParticipant.java @@ -29,7 +29,6 @@ import org.eclipse.sirius.business.api.query.DViewQuery; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.business.api.refresh.DiagramCreationUtil; -import org.eclipse.sirius.diagram.tools.api.DiagramPlugin; import org.eclipse.sirius.diagram.tools.api.Messages; import org.eclipse.sirius.viewpoint.DAnalysis; import org.eclipse.sirius.viewpoint.DRepresentation; @@ -110,7 +109,7 @@ public void postLoad(XMLResource resource, String loadedVersion) { sb = new StringBuilder(Messages.ViewWithNullElementMigrationParticipant_title); super.postLoad(resource, loadedVersion); if (repairOccurred) { - DiagramPlugin.getDefault().logInfo(sb.toString()); + logMigrationInfo(sb.toString()); } } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/migration/AbstractMigrationParticipant.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/migration/AbstractMigrationParticipant.java index 654f127098..32971ad53f 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/migration/AbstractMigrationParticipant.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/migration/AbstractMigrationParticipant.java @@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.xml.type.AnyType; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.ext.base.Options; +import org.eclipse.sirius.tools.api.SiriusPlugin; import org.osgi.framework.Version; import org.xml.sax.Attributes; @@ -42,6 +43,7 @@ * @author fbarbin */ public abstract class AbstractMigrationParticipant implements IMigrationParticipant { + /** * Version number return when the representations file has never been loaded since the rewrite of migration * framework. @@ -53,6 +55,8 @@ public abstract class AbstractMigrationParticipant implements IMigrationParticip */ public static final Version VERSION_VP_6_5_0 = Version.parseVersion("6.5.0"); //$NON-NLS-1$ + private static final String DISABLE_LOG_MIGRATION_INFO = "org.eclipse.sirius.migration.disableLogMigrationInfo"; //$NON-NLS-1$ + @Override public EStructuralFeature getAttribute(EClass eClass, String name, String loadedVersion) { // Nothing to migrate by default. @@ -159,4 +163,16 @@ public void postXMLEndElement(Object doneObject, Attributes xmlAttributes, Strin // nothing to do by default. } + /** + * Log a migration message (unless disabled). + * + * @param message + * the migration message. + */ + protected void logMigrationInfo(String message) { + if (!Boolean.getBoolean(DISABLE_LOG_MIGRATION_INFO)) { + SiriusPlugin.getDefault().getLog().info(message); + } + } + }