Skip to content

Commit

Permalink
[206] Add support for disabling migration log messages
Browse files Browse the repository at this point in the history
Bug: #206
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Dec 18, 2023
1 parent b058b58 commit bd5abff
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +79,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}
}
if (migrationOccured) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
migrationOccured = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +91,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}

if (isModified) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,7 +98,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}
});
if (migrationOccured) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
migrationOccured = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,7 +99,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}
}
if (isModified) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -194,7 +193,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}

if (isModified) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +107,7 @@ protected void postLoad(DAnalysis dAnalysis, Version loadedVersion) {
}
}
if (migrationOccurred) {
DiagramPlugin.getDefault().logInfo(sb.toString());
logMigrationInfo(sb.toString());
migrationOccurred = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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);
}
}

}

0 comments on commit bd5abff

Please sign in to comment.