I have a quick and dirty fix. Not for real use, but it shows a proof of concept. I am certainly cutting corners here.
Would like to know how to translate this into a better solution? Add a function to the Xcos class that returns a diagram based on cell that is passed? Started with this simple problem. Really like Xcos, but it is still very broken. Like to contribute if possible. Thanks. Op di 28 aug. 2018 om 17:40 schreef Johan Wesselink < johanwesselin...@gmail.com>: > Good day, > > I was having a look into some superblock problems. > In version 6.0.1. there are many problems with the super block. > > I have checkout the latest version of the GIT repository and can build and > debug it using eclipse. > > On this moment I am interested in Bug 14670 Super block can be opened more > then once. > I already discovered that the xcos/block/actian/BlockParametersAction.java > contains the method ActionPerformed on line 96 that actually generates the > diagram. > I am a little bit curious for the architecture. > I see that a XcosDiagram is created using the UID, Kind and Id of cell > that is the SUPER_f block. This is created diagram is then added to the > root diagram. > Maybe a very simplistic view, but is it possible to get the root diagram > and search for a sub diagram with the same UID, Kind and Id. And so, if > this is present does that mean that the diagram is already created and that > it only should be shown? > Or do not understand how it works. > > Sincerely > Johan > >
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/actions/BlockParametersAction.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/actions/BlockParametersAction.java index 0035c37c90f..5e25f775b15 100644 --- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/actions/BlockParametersAction.java +++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/actions/BlockParametersAction.java @@ -23,6 +23,7 @@ import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.util.Collection; import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; import org.scilab.modules.graph.ScilabGraph; @@ -110,23 +111,48 @@ public class BlockParametersAction extends VertexSelectionDependantAction { BlockInterFunction func = XcosCellFactory.lookForInterfunction(interfaceFunction[0]); if (func.equals(BlockInterFunction.SUPER_f)) { - // this is a super-block, open it - XcosDiagram sub = new XcosDiagram(controller, cell.getUID(), cell.getKind(), cell.getId()); - XcosCellFactory.insertChildren(controller, sub); - - ScicosObjectOwner root = Xcos.findRoot(graph); - Xcos.getInstance().addDiagram(root, sub); - - // propagate the modified status after discarding modification - // done on children insertion - sub.setModified(false); - sub.setModified(Xcos.getInstance().isModified(root)); - - // setup graphical interface - sub.getUndoManager().clear(); - sub.installListeners(); - - XcosTab.restore(sub, true); + ScicosObjectOwner root = Xcos.findRoot(graph); + + // Check if a diagram with the ID of the superblock already exists. + Collection<XcosDiagram> diagrams = Xcos.getInstance().getDiagrams(root); + + XcosDiagram sub = null; + + for (XcosDiagram item : diagrams) { + // Check if a diagram with the ID and of the BLOCK kind was already + // created. + if (item.getUID() == cell.getUID() && item.getKind() == cell.getKind()) + { + sub = item; + } + } + + if (sub != null) { + XcosTab tab = XcosTab.get(sub); + if (tab != null) { + tab.setCurrent(); + tab.requestFocus(); + } + }else + { + // this is a super-block, open it + sub = new XcosDiagram(controller, cell.getUID(), cell.getKind(), cell.getId()); + XcosCellFactory.insertChildren(controller, sub); + + Xcos.getInstance().addDiagram(root, sub); + + + // propagate the modified status after discarding modification + // done on children insertion + sub.setModified(false); + sub.setModified(Xcos.getInstance().isModified(root)); + + // setup graphical interface + sub.getUndoManager().clear(); + sub.installListeners(); + + XcosTab.restore(sub, true); + } } else { BasicBlock block = (BasicBlock) cell; // prevent to open twice
_______________________________________________ dev mailing list dev@lists.scilab.org http://lists.scilab.org/mailman/listinfo/dev