Bug #5812

Use Eclipse TextEditor implementation in procedural component type code editor

Added by Tuukka Lehtonen almost 2 years ago. Updated almost 2 years ago.

Status:ClosedStart date:2015-04-30
Priority:4Due date:2015-04-30
Assignee:Tuukka Lehtonen% Done:

100%

Category:User ComponentsSpent time:3.00 hours
Target version:1.18.1
Release notes:Better text editor for procedural user component code based on Eclipse TextEditor. Undo/Redo now works properly.
Tags: scl, structural, procedural
Story points-
Velocity based estimate-
ReleaseSimantics 1.18.1Release relationshipAuto

Description

Currently ProceduralComponentTypeCodeEditor is a custom implementation that has bad behavior and no undo/redo whatsoever.

We should use SCLModuleEditor as a foundation of this editor to provide basic text editing facilities out of the box.


Related issues

Copied to Platform - Bug #5857: Fix compilation problem annotations to work in procedural... On hold

Associated revisions

Revision 31222
Added by Tuukka Lehtonen almost 2 years ago

Inherited and customized ProceduralComponentTypeCodeEditor from SCLModuleEditor and SCLModuleEeditorDocumentProvider.

  • Proper text undo/redo is now supported for procedural UC code editor also
  • Title/tooltip for procedural UC code inputs is now calculated using a custom ProceduralComponentTypeEditorNamingService.
  • NewProceduralComponentType creates the UC code resource with a default value of [] which is a valid UC code instead of the previous empty string.

refs #5812

Revision 31224
Added by Tuukka Lehtonen almost 2 years ago

Merged trunk@31222 to branches/simantics-1.18 on 2015-04-30 for 1.18.1 release.

refs #5812

History

#1 Updated by Tuukka Lehtonen almost 2 years ago

  • Tags set to procedural, structural, scl
  • % Done changed from 0 to 80
  • Release set to 25

Otherwise the implementation is now fine but this code:

    protected void updateAnnotations() {
        Simantics.getSession().asyncRequest(new ResourceRead<TextAndErrors>(resource) {
            @Override
            public TextAndErrors perform(ReadGraph graph) throws DatabaseException {
                Layer0 L0 = Layer0.getInstance(graph);
                String text = graph.getValue(resource, Bindings.STRING);
                Resource componentType = graph.getPossibleObject(resource, L0.PropertyOf);
                CompilationError[] errors = CompilationError.EMPTY_ARRAY;
                if (componentType != null) {
                    try { 
                        graph.syncRequest(new CompileProceduralComponentTypeRequest(componentType));
                    } catch (SCLDatabaseException e) {
                        // Can't compile effectively empty code
                    } catch (ProceduralComponentTypeCompilationException e) {
                        errors = e.errors;
                    }
                }
                return new TextAndErrors(text, errors);
            }
        }, new Listener<TextAndErrors>() {
            @Override
            public void execute(final TextAndErrors textAndErrors) {
                if (editor.isDisposed())
                    return;
                SWTUtils.asyncExec(display, new Runnable() {
                    @Override
                    public void run() {
                        if (editor.isDisposed())
                            return;
                        if(textAndErrors.errors.length > 0) {
                            setAnnotations(Arrays.asList(textAndErrors.errors));
                        } else {
                            setAnnotations(Collections.<CompilationError>emptyList());
                        }
                    }
                });
            }
...

does not provide error annotations for the editor because CompileProceduralComponentTypeRequest does not seem to be thrown when compilation fails and that is the only way CompilationErrors[] are processed. Someone else can fix this, I know nothing about it.

#2 Updated by Tuukka Lehtonen almost 2 years ago

  • Target version changed from 1.19.0 to 1.18.1
  • Release changed from 25 to 17
  • Release notes set to Better text editor for procedural user component code based on Eclipse TextEditor. Undo/Redo now works properly.

#3 Updated by Tuukka Lehtonen almost 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 80 to 100

Also available in: Atom PDF