Search in sources :

Example 1 with HasReadOnlyProperty

use of org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty in project che by eclipse.

the class EditorAgentImpl method finalizeInit.

private void finalizeInit(final VirtualFile file, final OpenEditorCallback callback, final EditorPartPresenter editor, EditorProvider editorProvider) {
    openedEditors.add(editor);
    openedEditorsToProviders.put(editor, editorProvider.getId());
    workspaceAgent.setActivePart(editor);
    editor.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            if (propId == EditorPartPresenter.PROP_INPUT) {
                if (editor instanceof HasReadOnlyProperty) {
                    ((HasReadOnlyProperty) editor).setReadOnly(file.isReadOnly());
                }
                if (editor instanceof TextEditor) {
                    editorContentSynchronizerProvider.get().trackEditor(editor);
                }
                callback.onEditorOpened(editor);
                eventBus.fireEvent(new EditorOpenedEvent(file, editor));
            }
        }
    });
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) HasReadOnlyProperty(org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

EditorOpenedEvent (org.eclipse.che.ide.api.editor.EditorOpenedEvent)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 HasReadOnlyProperty (org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)1 PropertyListener (org.eclipse.che.ide.api.parts.PropertyListener)1