ControlSystemStudio / cs-studio

Control System Studio is an Eclipse-based collections of tools to monitor and operate large scale control systems, such as the ones in the accelerator community.
https://controlsystemstudio.org/
Eclipse Public License 1.0
113 stars 97 forks source link

BOY Schema loading fails if triggered by Connector #1637

Open jbobnar opened 8 years ago

jbobnar commented 8 years ago

BOY schema loading fails if it is triggered by connector.

java.lang.IllegalArgumentException: Figure is not a child
    at org.eclipse.draw2d.Figure.remove(Figure.java:1267)
    at org.eclipse.draw2d.FreeformLayer.remove(FreeformLayer.java:76)
    at org.eclipse.gef.editpolicies.GraphicalEditPolicy.removeFeedback(GraphicalEditPolicy.java:79)
    at org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy.eraseCreationFeedback(GraphicalNodeEditPolicy.java:80)
    at org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy.eraseSourceFeedback(GraphicalNodeEditPolicy.java:94)
    at org.eclipse.gef.editparts.AbstractEditPart.eraseSourceFeedback(AbstractEditPart.java:353)
    ...

100% reproducible. These are the steps:

  1. Create an opi file with at least two widgets (any widgets will do).
  2. Save the file.
  3. Restart CSS, to make sure that schema is not loaded.
  4. Open the opi created in step 1.
  5. Click on the connector "widget"
  6. Add a connector to the existing widgets. Clicking on a widget triggers schema loading. An exception is thrown and the schema is not loaded.

This issue is present in CSS 3.x as well.

The workaround is to always add the widget to the OPI, which triggers loading of the schema. After the schema is loaded, you may delete the added widget and add as many connectors as you wish. It all works fine.

jbobnar commented 8 years ago

The problem occurs because in the connector case the schema is loaded after the connector drawing has already started. During the schema loading a progress dialog pops up, which changes the hierarchy of figures and causes the exception. It can actually be any dialog even the MessageDialog.

Two possible solutions:

  1. Load the schema when the opi editor opens.
  2. Do not show any progress dialog when the schema is being loaded. On average, loading of the schema takes 150-200 ms when no dialog is shown, and 300-350 ms when the dialog is shown.

I prefer the 2nd solution.