]> gerrit.simantics Code Review - simantics/3d.git/blob
f0a6232400b4244fb8acfb12e5b423cb10801bb7
[simantics/3d.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.processeditor.adapters;\r
12 \r
13 import java.util.List;\r
14 \r
15 import org.simantics.proconf.g3d.base.ScenegraphAdapter;\r
16 import org.simantics.proconf.g3d.base.SelectionAdapter;\r
17 import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;\r
18 import org.simantics.proconf.g3d.scenegraph.ISelectableNode;\r
19 \r
20 public class ProcessEditorSelectionAdapter extends SelectionAdapter {\r
21         \r
22         \r
23          public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) {\r
24                 super(adapter);\r
25          }\r
26 \r
27             @Override\r
28             public void setEditorSelection() {\r
29                 List<IGraphicsNode> sel = getSelectedObjects();\r
30                 for (IGraphicsNode o : adapter.getNodes())\r
31                         if (o instanceof ISelectableNode) {\r
32                                 if (sel.contains(o)) {\r
33                                 ((ISelectableNode)o).setSelected(true);\r
34                         } else {\r
35                                 ((ISelectableNode)o).setSelected(false);\r
36                         }\r
37                         }\r
38             }\r
39 \r
40 \r
41             @Override\r
42             protected void setEditorHighlightSelection() {\r
43                 List<IGraphicsNode> sel = getInteractiveSelectedObjects();\r
44                 for (IGraphicsNode o : adapter.getNodes())\r
45                         if (o instanceof ISelectableNode) {\r
46                                 if (sel.contains(o)) {\r
47                                 ((ISelectableNode)o).setHighlighted(true);\r
48                         } else {\r
49                                 ((ISelectableNode)o).setHighlighted(false);\r
50                         }\r
51                         }\r
52             }\r
53 \r
54 }\r