Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model loader crash and animation layer activation #199

Merged
merged 3 commits into from
Aug 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -304,76 +304,77 @@ protected void doExecute() {
for (DView view : session.getSelectedViews()) {
for (DRepresentationDescriptor repDescriptor : view.getOwnedRepresentationDescriptors()) {
DRepresentation representation = repDescriptor.getRepresentation();

final DSemanticDiagram diagram = (DSemanticDiagram) representation;
openEditorSubMonitor.subTask(diagram.getName());
final List<EObject> elements = new ArrayList<EObject>();
elements.add(diagram);

final IEditorPart editorPart = DialectUIManager.INSTANCE.openEditor(session, representation,
openEditorSubMonitor.newChild(1));
ToolManagement toolManagement = DiagramPlugin.getDefault().getToolManagement(diagram);
toolManagement.addToolFilter(new ToolFilter() {
if(representation instanceof DSemanticDiagram) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is in fact almost the only real change introduced in the PR, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right for item 1 of the description
for item 2 see my second comment

final DSemanticDiagram diagram = (DSemanticDiagram) representation;
openEditorSubMonitor.subTask(diagram.getName());
final List<EObject> elements = new ArrayList<EObject>();
elements.add(diagram);

final IEditorPart editorPart = DialectUIManager.INSTANCE.openEditor(session, representation,
openEditorSubMonitor.newChild(1));
ToolManagement toolManagement = DiagramPlugin.getDefault().getToolManagement(diagram);
toolManagement.addToolFilter(new ToolFilter() {
@Override
public boolean filter(DDiagram diagram, AbstractToolDescription tool) {
return true;
}
});
try {
RefreshDiagramOnOpeningCommand refresh = new RefreshDiagramOnOpeningCommand(editingDomain, diagram);
CommandExecution.execute(editingDomain, refresh);
} catch (Exception e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"Problem refreshing diagrams : " + diagram, e));
}

if (editorPart instanceof DiagramEditorWithFlyOutPalette) {
PaletteUtils.colapsePalette((DiagramEditorWithFlyOutPalette) editorPart);
}

RecordingCommand command = new RecordingCommand(editingDomain, "Activating animator and debug layers") {
@Override
public boolean filter(DDiagram diagram, AbstractToolDescription tool) {
return true;
}
});
try {
RefreshDiagramOnOpeningCommand refresh = new RefreshDiagramOnOpeningCommand(editingDomain, diagram);
CommandExecution.execute(editingDomain, refresh);
} catch (Exception e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"Problem refreshing diagrams : " + diagram, e));
}

if (editorPart instanceof DiagramEditorWithFlyOutPalette) {
PaletteUtils.colapsePalette((DiagramEditorWithFlyOutPalette) editorPart);
}

RecordingCommand command = new RecordingCommand(editingDomain, "Activating animator and debug layers") {
@Override
protected void doExecute() {
boolean hasADebugLayer = false;
Set<Layer> layers = new HashSet<Layer>();
layers.addAll(diagram.getDescription().getAdditionalLayers());
Collection<Viewpoint> selectedVp = session.getSelectedViewpoints(true);
for (Viewpoint vp : selectedVp) {
for (RepresentationExtensionDescription extension : vp.getOwnedRepresentationExtensions()) {
if (extension instanceof DiagramExtensionDescription) {
layers.addAll(((DiagramExtensionDescription) extension).getLayers());
protected void doExecute() {
boolean hasADebugLayer = false;
Set<Layer> layers = new HashSet<Layer>();
layers.addAll(diagram.getDescription().getAdditionalLayers());
Collection<Viewpoint> selectedVp = session.getSelectedViewpoints(true);
for (Viewpoint vp : selectedVp) {
for (RepresentationExtensionDescription extension : vp.getOwnedRepresentationExtensions()) {
if (extension instanceof DiagramExtensionDescription) {
layers.addAll(((DiagramExtensionDescription) extension).getLayers());
}
}
}
}
for (Layer l : layers) {
String descName = diagram.getDescription().getName();
String layerName = l.getName();
boolean mustBeActiveForDebug = AbstractDSLDebuggerServices.LISTENER
.isRepresentationToRefresh(context.getRunConfiguration().getDebugModelID(),
descName, layerName)
|| layerName.equalsIgnoreCase("Debug");
boolean mustBeActiveForAnimation = AbstractGemocAnimatorServices.ANIMATOR
.isRepresentationToRefresh(descName, layerName)
|| layerName.equalsIgnoreCase("Animation");
boolean mustBeActive = mustBeActiveForAnimation || mustBeActiveForDebug;
hasADebugLayer = hasADebugLayer || mustBeActiveForDebug;
if (mustBeActive && !diagram.getActivatedLayers().contains(l)) {
ChangeLayerActivationCommand c = new ChangeLayerActivationCommand(editingDomain,
diagram, l, openEditorSubMonitor.newChild(1));
c.execute();
for (Layer l : layers) {
String descName = diagram.getDescription().getName();
String layerName = l.getName();
boolean mustBeActiveForDebug = AbstractDSLDebuggerServices.LISTENER
.isRepresentationToRefresh(context.getRunConfiguration().getDebugModelID(),
descName, layerName)
|| layerName.equalsIgnoreCase("Debug");
boolean mustBeActiveForAnimation = AbstractGemocAnimatorServices.ANIMATOR
.isRepresentationToRefresh(descName, layerName)
|| layerName.equalsIgnoreCase("Animation");
boolean mustBeActive = mustBeActiveForAnimation || mustBeActiveForDebug;
hasADebugLayer = hasADebugLayer || mustBeActiveForDebug;
if (mustBeActive && !diagram.getActivatedLayers().contains(l) && !diagram.getActivatedTransientLayers().contains(l)) {
Copy link
Contributor Author

@dvojtise dvojtise Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the second line that has changed (most other changes are due to the new indentation)
(added && !diagram.getActivatedTransientLayers().contains(l))

ChangeLayerActivationCommand c = new ChangeLayerActivationCommand(editingDomain,
diagram, l, openEditorSubMonitor.newChild(1));
c.execute();
}
}
if (!hasADebugLayer) {
// no debug layer defined in the odesign for
// debugmodelID
Activator.getDefault().getLog()
.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID,
"No debug service defined in the odesign for the debug model id : "
+ context.getRunConfiguration().getDebugModelID()));
}
}
if (!hasADebugLayer) {
// no debug layer defined in the odesign for
// debugmodelID
Activator.getDefault().getLog()
.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID,
"No debug service defined in the odesign for the debug model id : "
+ context.getRunConfiguration().getDebugModelID()));
}
}
};
CommandExecution.execute(editingDomain, command);
};
CommandExecution.execute(editingDomain, command);
}
}
}

Expand Down