]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/impl/WidgetSupportFactory.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / widgets / impl / WidgetSupportFactory.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 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.browsing.ui.swt.widgets.impl;
13
14 import java.util.concurrent.CopyOnWriteArrayList;
15
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.jface.viewers.StructuredSelection;
18 import org.simantics.Simantics;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.Resource;
21 import org.simantics.db.management.ISessionContext;
22
23 public class WidgetSupportFactory {
24
25         public static WidgetSupport projectSupport() {
26                 
27                 return new WidgetSupport() {
28
29                         final private CopyOnWriteArrayList<Widget> widgets = new CopyOnWriteArrayList<Widget>();
30
31                         @Override
32                         public synchronized void register(Widget widget) {
33                                 widgets.add(widget);
34                         }
35                         
36                         @Override
37                         public void update(Widget widget) {
38                                 throw new Error("Not implemented.");
39                         }
40
41                         @Override
42                         public void update() {
43                                 throw new Error("Not implemented.");
44                         }
45                         
46                         @Override
47                         public <T> T getInput() {
48                                 throw new Error("Not implemented.");
49                         }
50                         
51                         @Override
52                         public void finish() {
53                             Resource project = Simantics.peekProjectResource();
54                             if(project == null) return;
55                                 ISelection input = new StructuredSelection(project);
56                                 fireInput(Simantics.getSessionContext(), input);
57                         }
58                         
59                         public void fireInput(ISessionContext context, Object input) {
60                                 for(Widget widget : widgets) widget.setInput(context, input);
61                         }
62                         
63                         @Override
64                         public <T> T getParameter(String key) {
65                                 throw new Error("Not implemented.");
66                         }
67                         
68                         @Override
69                         public void setParameter(String key, Object value) {
70                                 throw new Error("Not implemented.");
71                         }
72
73                         @Override
74                         public <T> T getInput(ReadGraph graph) {
75                                 throw new Error("Not implemented.");
76                         }
77                         
78                 };
79                 
80         }
81         
82 }