Skip to content

Commit

Permalink
Addresses #3091. Please test !
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Apr 20, 2021
1 parent 914ed37 commit c8f5833
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 54 deletions.
4 changes: 2 additions & 2 deletions msi.gama.core/src/msi/gama/runtime/ExecutionScope.java
Expand Up @@ -902,8 +902,8 @@ public RandomUtils getRandom() {
@Override
public IScope copy(final String additionalName) {
final ExecutionScope scope = new ExecutionScope(getRoot(), additionalName);
scope.executionContext = executionContext.createCopy();
scope.agentContext = agentContext.createCopy();
scope.executionContext = executionContext == null ? null : executionContext.createCopy();
scope.agentContext = agentContext == null ? null : agentContext.createCopy();
scope.additionalContext.copyFrom(additionalContext);
return scope;
}
Expand Down
2 changes: 1 addition & 1 deletion ummisco.gama.ui.shared/plugin.xml
Expand Up @@ -62,7 +62,7 @@
allowMultiple="false"
category="msi.gama.gui.category.gama"
class="ummisco.gama.ui.views.InteractiveConsoleView"
icon="platform:/plugin/ummisco.gama.ui.shared/icons/view.interactive2.png"
icon="/icons/view.interactive2.png"
id="msi.gama.application.view.InteractiveConsoleView"
name="Interactive console"
restorable="true">
Expand Down
75 changes: 24 additions & 51 deletions ummisco.gama.ui.shared/src/ummisco/gama/ui/views/GamaViewPart.java
@@ -1,8 +1,8 @@
/*********************************************************************************************
*
* 'GamaViewPart.java, in plugin ummisco.gama.ui.experiment, is part of the source code of the GAMA modeling and
* simulation platform. (v. 1.8.1)
*
* simulation platform. (v. 1.8.1)
*
* (c) 2007-2020 UMI 209 UMMISCO IRD/UPMC & Partners
*
* Visit https://github.com/gama-platform/gama for license information and developers contact.
Expand Down Expand Up @@ -106,9 +106,7 @@ public void addStateListener(final StateListener listener) {

@Override
public void updateToolbarState() {
if (toolbarUpdater != null) {
toolbarUpdater.updateToReflectState();
}
if (toolbarUpdater != null) { toolbarUpdater.updateToReflectState(); }
}

@Override
Expand All @@ -123,9 +121,7 @@ public void init(final IViewSite site) throws PartInitException {
String s_id = site.getSecondaryId();
if (s_id != null) {
final int i = s_id.indexOf("@@@");
if (i != -1) {
s_id = s_id.substring(0, i);
}
if (i != -1) { s_id = s_id.substring(0, i); }
}
final String id = site.getId() + (s_id == null ? "" : s_id);
IDisplayOutput out = null;
Expand All @@ -136,9 +132,7 @@ public void init(final IViewSite site) throws PartInitException {
for (final IOutputManager manager : concat(
transform(GAMA.getControllers(), each -> each.getExperiment().getActiveOutputManagers()))) {
out = (IDisplayOutput) manager.getOutputWithId(id);
if (out != null) {
break;
}
if (out != null) { break; }
}

// hqngh in case of micro-model
Expand All @@ -154,9 +148,7 @@ public void init(final IViewSite site) throws PartInitException {
final SimulationAgent spec = ((ExperimentAgent) expAgent).getSimulation();
if (spec != null) {
final IOutputManager manager = spec.getOutputManager();
if (manager != null) {
out = (IDisplayOutput) manager.getOutputWithId(s_id);
}
if (manager != null) { out = (IDisplayOutput) manager.getOutputWithId(s_id); }
}
}
}
Expand All @@ -166,9 +158,7 @@ public void init(final IViewSite site) throws PartInitException {
} else {
if (shouldBeClosedWhenNoExperiments()) {
WorkbenchHelper.asyncRun(() -> {
if (shouldBeClosedWhenNoExperiments()) {
close(GAMA.getRuntimeScope());
}
if (shouldBeClosedWhenNoExperiments()) { close(GAMA.getRuntimeScope()); }
});

}
Expand All @@ -195,7 +185,7 @@ public boolean containsPoint(final int x, final int y) {
public void createPartControl(final Composite composite) {
this.rootComposite = composite;
composite.addDisposeListener(this);
if (needsOutput() && getOutput() == null) { return; }
if (needsOutput() && getOutput() == null) return;
this.setParentComposite(GamaToolbarFactory.createToolbars(this, composite));
ownCreatePartControl(getParentComposite());
// activateContext();
Expand All @@ -209,9 +199,7 @@ protected boolean needsOutput() {
public abstract void ownCreatePartControl(Composite parent);

protected final GamaUIJob getUpdateJob() {
if (updateJob == null) {
updateJob = createUpdateJob();
}
if (updateJob == null) { updateJob = createUpdateJob(); }
return updateJob;
}

Expand All @@ -231,13 +219,13 @@ public void update(final IDisplayOutput output) {

@Override
public IDisplayOutput getOutput() {
if (outputs.isEmpty()) { return null; }
if (outputs.isEmpty()) return null;
return outputs.get(0);
}

@Override
public void addOutput(final IDisplayOutput out) {
if (out == null) { return; }
if (out == null) return;
if (!outputs.contains(out)) {
outputs.add(out);
} else {
Expand All @@ -264,7 +252,8 @@ public void widgetDisposed(final DisposeEvent e) {
public void dispose() {
DEBUG.OUT("+++ Part " + this.getPartName() + " is being disposed");
toolbarUpdater = null;
super.dispose();
WorkbenchHelper.run(() -> super.dispose());

}

/**
Expand All @@ -275,15 +264,13 @@ public void dispose() {
*/
@Override
public void stopDisplayingTooltips() {
if (toolbar == null || toolbar.isDisposed()) { return; }
if (toolbar.hasTooltip()) {
toolbar.wipe(SWT.LEFT, false);
}
if (toolbar == null || toolbar.isDisposed()) return;
if (toolbar.hasTooltip()) { toolbar.wipe(SWT.LEFT, false); }
}

@Override
public void displayTooltip(final String text, final GamaUIColor color) {
if (toolbar == null || toolbar.isDisposed()) { return; }
if (toolbar == null || toolbar.isDisposed()) return;
toolbar.tooltip(text, color, SWT.LEFT);
}

Expand All @@ -303,9 +290,7 @@ public void close(final IScope scope) {
@Override
public void removeOutput(final IDisplayOutput output) {
outputs.remove(output);
if (outputs.isEmpty()) {
close(output.getScope());
}
if (outputs.isEmpty()) { close(output.getScope()); }
}

@Override
Expand All @@ -314,9 +299,7 @@ public void changePartNameWithSimulation(final SimulationAgent agent) {
final int first = old.lastIndexOf('(');
final int second = old.lastIndexOf(')');
if (first == -1) {
if (agent.getPopulation().size() > 1) {
setPartName(old + " (" + agent.getName() + ")");
}
if (agent.getPopulation().size() > 1) { setPartName(old + " (" + agent.getName() + ")"); }
} else {

setPartName(overlay(old, agent.getName(), first + 1, second));
Expand All @@ -328,23 +311,13 @@ private String overlay(final String str, final String over, final int s, final i
String overlay = over;
int start = s;
int end = e;
if (str == null) { return null; }
if (overlay == null) {
overlay = "";
}
if (str == null) return null;
if (overlay == null) { overlay = ""; }
final int len = str.length();
if (start < 0) {
start = 0;
}
if (start > len) {
start = len;
}
if (end < 0) {
end = 0;
}
if (end > len) {
end = len;
}
if (start < 0) { start = 0; }
if (start > len) { start = len; }
if (end < 0) { end = 0; }
if (end > len) { end = len; }
if (start > end) {
final int temp = start;
start = end;
Expand Down

0 comments on commit c8f5833

Please sign in to comment.