use of org.eclipse.wst.sse.core.internal.provisional.IModelStateListener in project liferay-ide by liferay.
the class LayoutTplEditor method initSourceModel.
protected void initSourceModel() {
if (_sourceModel == null) {
if ((_sourcePage != null) && (_sourcePage.getDocumentProvider() != null)) {
IDocumentProvider documentProvider = _sourcePage.getDocumentProvider();
IDocument doc = documentProvider.getDocument(getEditorInput());
_sourceModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
_sourceModel.addModelStateListener(new IModelStateListener() {
public void modelAboutToBeChanged(IStructuredModel model) {
}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
}
public void modelChanged(IStructuredModel model) {
setSourceModelChanged(true);
}
public void modelDirtyStateChanged(IStructuredModel model, boolean dirty) {
}
public void modelReinitialized(IStructuredModel structuredModel) {
}
public void modelResourceDeleted(IStructuredModel model) {
}
public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
}
});
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelStateListener in project webtools.sourceediting by eclipse.
the class AbstractStructuredModel method fireModelAboutToBeReinitialized.
protected void fireModelAboutToBeReinitialized() {
// another thread
if (fModelStateListeners != null) {
if (Logger.DEBUG_MODELSTATE) {
// $NON-NLS-1$ //$NON-NLS-2$
Logger.log(Logger.INFO, "IModelStateListener event for " + getId() + " : modelAboutToBeReinitialized");
}
Object[] holdListeners = fModelStateListeners;
for (int i = 0; i < holdListeners.length; i++) {
// NOTE: trick for transition. We actual use the same
// listeners
// as modelState, but only send this to those that have
// implemented ModelStateExtended.
IModelStateListener listener = (IModelStateListener) holdListeners[i];
listener.modelAboutToBeReinitialized(this);
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelStateListener in project webtools.sourceediting by eclipse.
the class TestStructuredModel method testAddRemoveModelStateListener.
public void testAddRemoveModelStateListener() throws IOException, CoreException {
IStructuredModel model = getTestModel();
try {
IModelStateListener listener = new IModelStateListener() {
public void modelAboutToBeChanged(IStructuredModel model) {
//
}
public void modelChanged(IStructuredModel model) {
//
}
public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
//
}
public void modelResourceDeleted(IStructuredModel model) {
//
}
public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
//
}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
//
}
public void modelReinitialized(IStructuredModel structuredModel) {
//
}
};
model.aboutToChangeModel();
model.removeModelStateListener(listener);
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelStateListener in project webtools.sourceediting by eclipse.
the class AbstractStructuredModel method fireModelReinitialized.
protected void fireModelReinitialized() {
// another thread
if (fModelStateListeners != null) {
if (Logger.DEBUG_MODELSTATE) {
// $NON-NLS-1$ //$NON-NLS-2$
Logger.log(Logger.INFO, "IModelStateListener event for " + getId() + " : modelReinitialized");
}
Object[] holdListeners = fModelStateListeners;
for (int i = 0; i < holdListeners.length; i++) {
IModelStateListener listener = (IModelStateListener) holdListeners[i];
listener.modelReinitialized(this);
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelStateListener in project liferay-ide by liferay.
the class PortletsNode method _getPortletAppModelElement.
private PortletApp _getPortletAppModelElement() {
if (_modelElement == null) {
IFile portletXmlFile = ProjectUtil.getPortletXmlFile(this._parent.getProject());
if ((portletXmlFile != null) && portletXmlFile.exists()) {
try {
IStructuredModel portletXmlModel = StructuredModelManager.getModelManager().getModelForRead(portletXmlFile);
IModelStateListener listener = new IModelStateListener() {
public void modelAboutToBeChanged(IStructuredModel model) {
}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
}
public void modelChanged(IStructuredModel model) {
_refresh();
}
public void modelDirtyStateChanged(IStructuredModel model, boolean dirty) {
_refresh();
}
public void modelReinitialized(IStructuredModel structuredModel) {
_refresh();
}
public void modelResourceDeleted(IStructuredModel model) {
_refresh();
}
public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
_refresh();
}
private void _refresh() {
portletXmlModel.removeModelStateListener(this);
if (!PortletsNode.this._modelElement.disposed()) {
PortletsNode.this._modelElement.dispose();
}
PortletsNode.this._modelElement = null;
PortletsNode.this._parent.refresh();
}
};
portletXmlModel.addModelStateListener(listener);
_modelElement = PortletApp.TYPE.instantiate(new RootXmlResource(new XmlResourceStore(portletXmlFile.getContents())));
} catch (Exception e) {
PortletUIPlugin.logError(e);
}
}
}
return _modelElement;
}
Aggregations