Search in sources :

Example 1 with IModelChangeProvider

use of com.liferay.ide.core.model.IModelChangeProvider in project liferay-ide by liferay.

the class InputContext method dispose.

public void dispose() {
    IAnnotationModel amodel = _fDocumentProvider.getAnnotationModel(_fEditorInput);
    if (amodel != null) {
        amodel.disconnect(_fDocumentProvider.getDocument(_fEditorInput));
    }
    _fDocumentProvider.removeElementStateListener(_fElementListener);
    _fDocumentProvider.disconnect(_fEditorInput);
    if ((_fModelListener != null) && _fModel instanceof IModelChangeProvider) {
        ((IModelChangeProvider) _fModel).removeModelChangedListener(_fModelListener);
    }
    if (_fModel != null) {
        _fModel.dispose();
    }
}
Also used : IModelChangeProvider(com.liferay.ide.core.model.IModelChangeProvider) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel)

Example 2 with IModelChangeProvider

use of com.liferay.ide.core.model.IModelChangeProvider in project liferay-ide by liferay.

the class InputContext method create.

protected void create() {
    _fDocumentProvider = createDocumentProvider(_fEditorInput);
    try {
        _fDocumentProvider.connect(_fEditorInput);
        _fModel = createModel(_fEditorInput);
        if (_fModel instanceof IModelChangeProvider) {
            _fModelListener = new IModelChangedListener() {

                public void modelChanged(IModelChangedEvent e) {
                    if (e.getChangeType() != IModelChangedEvent.WORLD_CHANGED) {
                        if (!_fEditor.getLastDirtyState()) {
                            _fEditor.fireSaveNeeded(_fEditorInput, true);
                        }
                        IModelChangeProvider provider = e.getChangeProvider();
                        if (provider instanceof IEditingModel) {
                            if (((IEditingModel) provider).isDirty()) {
                                addTextEditOperation(fEditOperations, e);
                            }
                        }
                    }
                }
            };
            ((IModelChangeProvider) _fModel).addModelChangedListener(_fModelListener);
        }
        IAnnotationModel amodel = _fDocumentProvider.getAnnotationModel(_fEditorInput);
        if (amodel != null) {
            amodel.connect(_fDocumentProvider.getDocument(_fEditorInput));
        }
        _fElementListener = new ElementListener();
        _fDocumentProvider.addElementStateListener(_fElementListener);
    } catch (CoreException ce) {
        LiferayUIPlugin.logError(ce);
    }
}
Also used : IModelChangedEvent(com.liferay.ide.core.model.IModelChangedEvent) CoreException(org.eclipse.core.runtime.CoreException) IModelChangeProvider(com.liferay.ide.core.model.IModelChangeProvider) IEditingModel(com.liferay.ide.core.model.IEditingModel) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) IModelChangedListener(com.liferay.ide.core.model.IModelChangedListener)

Aggregations

IModelChangeProvider (com.liferay.ide.core.model.IModelChangeProvider)2 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)2 IEditingModel (com.liferay.ide.core.model.IEditingModel)1 IModelChangedEvent (com.liferay.ide.core.model.IModelChangedEvent)1 IModelChangedListener (com.liferay.ide.core.model.IModelChangedListener)1 CoreException (org.eclipse.core.runtime.CoreException)1