]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.platform/src/org/simantics/browsing/ui/platform/debug/BrowseDebuggerView.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.platform / src / org / simantics / browsing / ui / platform / debug / BrowseDebuggerView.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.browsing.ui.platform.debug;
13
14 import java.util.Collections;
15 import java.util.Map;
16 import java.util.Set;
17
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.IViewPart;
20 import org.eclipse.ui.IWorkbenchPart;
21 import org.simantics.browsing.ui.GraphExplorer;
22 import org.simantics.browsing.ui.common.EvaluatorData;
23 import org.simantics.browsing.ui.graph.impl.Evaluators;
24 import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;
25 import org.simantics.browsing.ui.platform.GraphExplorerView;
26 import org.simantics.browsing.ui.swt.DefaultSelectionDataResolver;
27 import org.simantics.browsing.ui.swt.GraphExplorerFactory;
28 import org.simantics.db.Session;
29 import org.simantics.db.management.ISessionContext;
30 import org.simantics.db.management.ISessionContextProvider;
31 import org.simantics.utils.ui.workbench.WorkbenchUtils;
32
33 public class BrowseDebuggerView extends GraphExplorerView {
34
35     final private Set<String> browseContexts = Collections.singleton("browseDebuggerView");
36
37     @Override
38     protected GraphExplorer createExplorerControl(Composite parent) {
39         return GraphExplorerFactory.getInstance()
40         .selectionDataResolver(new DefaultSelectionDataResolver())
41         .create(parent);
42     }
43
44     public BrowseDebuggerView() {
45
46         setInputSource(new SessionContextInputSource() {
47
48             @Override
49             public Object get(ISessionContext ctx) {
50
51                 Map<String, String> args = getViewArguments();
52                 System.out.println("args=" + args);
53
54                 IViewPart view = WorkbenchUtils.findView(args.get("view"));
55                 System.out.println("view=" + view);
56
57                 return view;
58
59             }
60             
61             @Override
62             public IWorkbenchPart getProvider() {
63                 Map<String, String> args = getViewArguments();
64                 IViewPart view = WorkbenchUtils.findView(args.get("view"));
65                 return view;
66             }
67
68         });
69
70     }
71
72     @Override
73     protected EvaluatorData createEvaluatorData(Session session) {
74
75         return Evaluators.load(session, browseContexts, resourceManager);
76
77     }
78
79     @SuppressWarnings({ "rawtypes" })
80     @Override
81     public Object getAdapter(Class adapter) {
82
83 //        if(adapter == IPropertyPage.class) {
84 //            return new UserPropertyPage(getSite(), this);
85 //        }
86         if(adapter == ISessionContextProvider.class) {
87             return getSessionContextProvider();
88         }
89
90         return super.getAdapter(adapter);
91
92     }
93
94 }