]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/DiagramSubgraphExtent.java
WIP: Some old-ish adapter registry initialization improvements
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / adapters / DiagramSubgraphExtent.java
1 /*******************************************************************************
2  * Copyright (c) 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.adapters;
13
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.Statement;
17 import org.simantics.db.layer0.adapter.impl.TypeSubgraphExtent;
18 import org.simantics.db.procedure.AsyncProcedure;
19 import org.simantics.diagram.stubs.DiagramResource;
20
21 public class DiagramSubgraphExtent extends TypeSubgraphExtent {
22
23         final private Classifier classifier = new Classifier() {
24
25                 @Override
26                 public void classify(AsyncReadGraph graph, Statement statement, ExtentStatus objectExtent,
27                                 Callback callback) {
28
29                         if(!ExtentStatus.INTERNAL.equals(objectExtent)) return;
30                         
31                         Resource predicate = statement.getPredicate();
32                         
33                         DiagramResource dr = graph.getService(DiagramResource.class);
34                         if(dr.JoinsFlag.equalsResource(predicate)) callback.statement(statement, true);
35                         else if(dr.FlagIsJoinedBy.equalsResource(predicate)) callback.statement(statement, true);
36                         
37                 }
38                 
39         };
40         
41         @Override
42         public void accept(AsyncReadGraph graph, Resource resource,
43                         AsyncProcedure<Classifier> procedure, Callback callback) {
44                 procedure.execute(graph, classifier);
45         }
46
47 }