提交 f156fe15 编写于 作者: M Mathieu Bastian

Make layout model workspace-specific

上级 c5ec6fee
......@@ -41,7 +41,6 @@ Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.layout;
import org.gephi.graph.api.GraphController;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.api.LayoutController;
import org.gephi.layout.api.LayoutModel;
......@@ -70,8 +69,8 @@ public class LayoutControllerImpl implements LayoutController {
@Override
public void initialize(Workspace workspace) {
if(workspace.getLookup().lookup(LayoutModelImpl.class) == null) {
workspace.add(new LayoutModelImpl());
if (workspace.getLookup().lookup(LayoutModelImpl.class) == null) {
workspace.add(new LayoutModelImpl(workspace));
}
}
......@@ -79,7 +78,7 @@ public class LayoutControllerImpl implements LayoutController {
public void select(Workspace workspace) {
model = workspace.getLookup().lookup(LayoutModelImpl.class);
if (model == null) {
model = new LayoutModelImpl();
model = new LayoutModelImpl(workspace);
}
workspace.add(model);
}
......@@ -109,7 +108,7 @@ public class LayoutControllerImpl implements LayoutController {
if (projectController.getCurrentWorkspace() != null) {
model = projectController.getCurrentWorkspace().getLookup().lookup(LayoutModelImpl.class);
if (model == null) {
model = new LayoutModelImpl();
model = new LayoutModelImpl(projectController.getCurrentWorkspace());
}
projectController.getCurrentWorkspace().add(model);
}
......
......@@ -55,10 +55,12 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.XMLEvent;
import org.gephi.graph.api.GraphController;
import org.gephi.graph.api.GraphModel;
import org.gephi.layout.api.LayoutModel;
import org.gephi.layout.spi.Layout;
import org.gephi.layout.spi.LayoutBuilder;
import org.gephi.layout.spi.LayoutProperty;
import org.gephi.project.api.Workspace;
import org.gephi.utils.Serialization;
import org.gephi.utils.longtask.api.LongTaskErrorHandler;
import org.gephi.utils.longtask.api.LongTaskExecutor;
......@@ -78,10 +80,12 @@ public class LayoutModelImpl implements LayoutModel {
private final Map<LayoutPropertyKey, Object> savedProperties;
private Layout selectedLayout;
private LayoutBuilder selectedBuilder;
private Workspace workspace;
//Util
private final LongTaskExecutor executor;
public LayoutModelImpl() {
public LayoutModelImpl(Workspace workspace) {
this.workspace = workspace;
listeners = new ArrayList<PropertyChangeListener>();
savedProperties = new HashMap<LayoutPropertyKey, Object>();
......@@ -135,8 +139,8 @@ public class LayoutModelImpl implements LayoutModel {
public void injectGraph() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
if (selectedLayout != null && graphController.getGraphModel() != null) {
selectedLayout.setGraphModel(graphController.getGraphModel());
if (selectedLayout != null && graphController.getGraphModel(workspace) != null) {
selectedLayout.setGraphModel(graphController.getGraphModel(workspace));
}
}
......
......@@ -72,7 +72,7 @@ public class LayoutModelPersistenceProvider implements WorkspaceXMLPersistencePr
public void readXML(XMLStreamReader reader, Workspace workspace) {
LayoutModelImpl model = workspace.getLookup().lookup(LayoutModelImpl.class);
if (model == null) {
model = new LayoutModelImpl();
model = new LayoutModelImpl(workspace);
workspace.add(model);
}
try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册