[Esbox-commits] r878 - in trunk: common/org.maemo.esbox.core/src/org/maemo/esbox/core/model linux/org.maemo.esbox.linux.autotools.core/src/org/maemo/esbox/linux/autotools/core
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Thu Oct 16 17:51:36 EEST 2008
Author: eswartz
Date: 2008-10-16 17:51:35 +0300 (Thu, 16 Oct 2008)
New Revision: 878
Removed:
trunk/linux/org.maemo.esbox.linux.autotools.core/src/org/maemo/esbox/linux/autotools/core/AutoconfModelProvider.java
Modified:
trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/IModelProvider.java
trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelBaseBase.java
trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelProviderBase.java
Log:
Merge some fixes from upstream (affected code is not used yet)
Modified: trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/IModelProvider.java
===================================================================
--- trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/IModelProvider.java 2008-10-15 19:30:29 UTC (rev 877)
+++ trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/IModelProvider.java 2008-10-16 14:51:35 UTC (rev 878)
@@ -12,7 +12,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import java.util.Map;
+
/**
* Interface managing shared access to models.
* <p>
@@ -60,8 +63,9 @@
* Save the contents of a model's document(s) to persistent storage.
* Only allowed on owned models.
* @param model
+ * @param documentMap the map of documents committed.
*/
- void save(Model model) throws CoreException;
+ void save(Model model, Map<IPath, IDocument> documentMap) throws CoreException;
/**
* Make a model visible to clients of the provider and manage its contents.
Modified: trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelBaseBase.java
===================================================================
--- trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelBaseBase.java 2008-10-15 19:30:29 UTC (rev 877)
+++ trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelBaseBase.java 2008-10-16 14:51:35 UTC (rev 878)
@@ -368,14 +368,50 @@
public void fireChanged() {
if (provider != null) {
try {
- provider.save(this);
+ Map<IPath, IDocument> documentMap;
+ synchronized (this) {
+ documentMap = copyDocumentMap(getDocumentMap());
+ }
+ provider.save(this, documentMap);
} catch (CoreException e) {
Activator.getErrorLogger().logError("Failed to save model", e);
}
}
}
+ /*
+ /*
+ * Notify that a view changed.
+ * @param base
+ * Mark other views out of sync due to operations that modify the model
+ * (such as a commit on a given view). The changedView itself might
+ * not actually be changed (firing listeners is in another method).
+
+ public void desyncOtherViews(IView changedView) {
+ // tell other views they're out-of-sync
+ IView[] viewsCopy;
+ synchronized (views) {
+ if (view != changedView)
+ view.markUnsynchronized();
+ }
+ }
+ */
+
/**
+ * Copy the document map
+ * @param documentMap
+ * @return
+ */
+ private Map<IPath, IDocument> copyDocumentMap(Map<IPath, IDocument> documentMap) {
+ Map<IPath, IDocument> copy = new HashMap<IPath, IDocument>();
+ for (Map.Entry<IPath, IDocument> entry : documentMap.entrySet()) {
+ copy.put(entry.getKey(), DocumentFactory.createDocument(entry.getValue().get()));
+ }
+ return copy;
+ }
+
+
+ /**
* Notify that a view changed.
* @param base
*/
Modified: trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelProviderBase.java
===================================================================
--- trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelProviderBase.java 2008-10-15 19:30:29 UTC (rev 877)
+++ trunk/common/org.maemo.esbox.core/src/org/maemo/esbox/core/model/ModelProviderBase.java 2008-10-16 14:51:35 UTC (rev 878)
@@ -217,19 +217,13 @@
/* (non-Javadoc)
* @see com.nokia.carbide.cpp.epoc.engine.model.IModelProvider#save(com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPOwnedModel)
*/
- public void save(Model model) throws CoreException {
+ public void save(Model model, Map<IPath, IDocument> documentMap) throws CoreException {
IPath path = model.getPath();
- Check.checkState(model.getDocument() != null);
- String text = model.getDocument().get();
-
if (models.containsKey(path)) {
stopTrackingModelStorage(model);
}
// check for changed documents and save modified files only
- saveStorage(path, text);
-
- Map<IPath, IDocument> documentMap = model.getDocumentMap();
for (Map.Entry<IPath, IDocument> entry : documentMap.entrySet()) {
saveStorage(entry.getKey(), entry.getValue().get());
}
@@ -272,7 +266,7 @@
synchronized (modelLock) {
if (model.getDocument() != null) {
// create from initial contents
- save(model);
+ save(model, model.getDocumentMap());
} else {
// try to load, or make empty if not existing
load(model);
Deleted: trunk/linux/org.maemo.esbox.linux.autotools.core/src/org/maemo/esbox/linux/autotools/core/AutoconfModelProvider.java
===================================================================
--- trunk/linux/org.maemo.esbox.linux.autotools.core/src/org/maemo/esbox/linux/autotools/core/AutoconfModelProvider.java 2008-10-15 19:30:29 UTC (rev 877)
+++ trunk/linux/org.maemo.esbox.linux.autotools.core/src/org/maemo/esbox/linux/autotools/core/AutoconfModelProvider.java 2008-10-16 14:51:35 UTC (rev 878)
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Nokia Corporation
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ed Swartz (Nokia) - initial API and implementation
- *******************************************************************************/
-
-package org.maemo.esbox.linux.autotools.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.maemo.esbox.core.model.IModelProvider;
-import org.maemo.esbox.linux.autotools.core.model.IAutoconfModel;
-import org.maemo.esbox.linux.autotools.core.model.IAutoconfOwnedModel;
-
-/**
- * @author eswartz
- *
- */
-public class AutoconfModelProvider implements
- IModelProvider<IAutoconfOwnedModel, IAutoconfModel> {
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#createModel(org.eclipse.core.runtime.IPath)
- */
- public IAutoconfOwnedModel createModel(IPath workspacePath) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#findSharedModel(org.eclipse.core.runtime.IPath)
- */
- public IAutoconfModel findSharedModel(IPath workspacePath) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#getSharedModel(org.eclipse.core.runtime.IPath)
- */
- public IAutoconfModel getSharedModel(IPath workspacePath)
- throws CoreException {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#load(org.maemo.esbox.core.model.IOwnedModel)
- */
- public void load(IAutoconfOwnedModel model) throws CoreException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#registerModel(org.maemo.esbox.core.model.IOwnedModel)
- */
- public void registerModel(IAutoconfOwnedModel model) throws CoreException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#releaseSharedModel(org.maemo.esbox.core.model.IModel)
- */
- public void releaseSharedModel(IAutoconfModel model)
- throws IllegalStateException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#save(org.maemo.esbox.core.model.IOwnedModel)
- */
- public void save(IAutoconfOwnedModel model) throws CoreException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#unregisterModel(org.maemo.esbox.core.model.IOwnedModel)
- */
- public void unregisterModel(IAutoconfOwnedModel model) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.core.model.IModelProvider#updateModelDocumentMappings(org.maemo.esbox.core.model.IOwnedModel)
- */
- public void updateModelDocumentMappings(IAutoconfOwnedModel model) {
- // TODO Auto-generated method stub
-
- }
-
-}
More information about the Esbox-commits
mailing list