]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/model/ChartNode.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / modelBrowser2 / model / ChartNode.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in 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.ui.modelBrowser2.model;
13
14 import java.util.List;
15
16 import org.eclipse.jface.viewers.ISelection;
17 import org.simantics.Simantics;
18 import org.simantics.browsing.ui.common.node.IDeletable;
19 import org.simantics.browsing.ui.common.node.IDropTargetNode;
20 import org.simantics.browsing.ui.common.node.IModifiableNode;
21 import org.simantics.browsing.ui.content.Labeler.Modifier;
22 import org.simantics.browsing.ui.graph.impl.LabelModifier;
23 import org.simantics.db.Resource;
24 import org.simantics.db.Session;
25 import org.simantics.modeling.PropertyVariables;
26 import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;
27 import org.simantics.utils.ui.ISelectionUtils;
28
29 /**
30  * @author Tuukka Lehtonen
31  */
32 public class ChartNode extends AbstractNode implements IDeletable, IDropTargetNode, IModifiableNode {
33
34     public ChartNode(Resource resource) {
35         super(resource);
36     }
37
38     @Override
39     public void drop(Object data) {
40         if (!(data instanceof ISelection))
41             return;
42
43         final List<PropertyVariables> vars = ISelectionUtils.filterSelection((ISelection) data, PropertyVariables.class);
44         if (!vars.isEmpty()) {
45 //            try {
46 //                List<VariableReference> references = Simantics.getSession().syncRequest(VariableReferences.toReferences(vars));
47 //                addPlots(references);
48 //            } catch (DatabaseException e) {
49 //                ErrorLogger.defaultLogError(e);
50 //            }
51         } else {
52             /*
53             final List<NodeReference> references = ISelectionUtils.filterSelection((ISelection) data, NodeReference.class);
54             if (!references.isEmpty()) {
55                 addPlots(references);
56             }
57             */
58         }
59     }
60
61 //    private void addPlots(List<VariableReference> references) {
62 //        Simantics.getSession().asyncRequest(new AddChartItem(resource, references), new Callback<DatabaseException>() {
63 //            @Override
64 //            public void run(DatabaseException e) {
65 //                if (e != null)
66 //                    ErrorLogger.defaultLogError(e);
67 //            }
68 //        });
69 //    }
70
71     @Override
72     public Modifier getModifier(String columnId) {
73         Session s = Simantics.getSession();
74         return new LabelModifier(s, resource);
75     }
76
77 }