Posts

Showing posts with the label decorate

Eclipse Editor: Partially editable/read-only editor Part 4

Image
Blocking drag & drop action to non-editable section It is an additional post to Eclipse Editor: Partially editable/read-only editor series . In all the previous pos ts I have explained making editor partially editable step by step to make functionality more robust. This post I am going to explain how to block drag & drop action to non-editable section of editor. Eclipse’s default implementation of text editor supports drag and drop of selection of text. When you have read-only as well as editable code section present, then such drag and drop may disturb read-only code section. To prevent the read-only code section from getting modified knowing or unknowingly , any drop action on read-on code section should be disabled. Eclipse TextEditor gives handle to DragAndDrop service , using it you can install your own implementation for DropTragetListener against the expected source viewer control. In your implementation any drop operation on the read-only code section can be ignore...

Eclipse Editor: Partially editable/read-only editor Part 2

Image
Decorating read-only section by line background The second part of this series I am going to explain changing line background color for particular section of editor, in this case read-only code section. We had reached till restricting editing in read-only code section in previous post . After previous post changes, user won’t able to edit in read-only code section, but user should get some kind of feedback about not able to edit the particular section of file. It would be very informative to color the background with grey color so that user understand that greyed out section is read-only. This can be achieved by providing Line background color listen over source viewer. LineBackgroundListener lineBackgroundListener = new LineBackgroundListener(){ @Override public void lineGetBackground(LineBackgroundEvent event) { int offset = event.lineOffset; if (editorSupport.isInsideReadOnlyBlock(offset, 0)){ event.lineBackground = colorManager.getColor...