]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / GraphExplorerDialog.java
index 3d877212e4850031d84810d4eaf563db8710c29d..6945d06d3dc9d1cc6b85ce97aa80a22ff099819f 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.browsing.ui.swt;\r
-\r
-import java.util.Set;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Tree;\r
-import org.eclipse.swt.widgets.TreeItem;\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.Column;\r
-import org.simantics.browsing.ui.Column.Align;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.graph.impl.GraphInputSources;\r
-import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;\r
-import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
-import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.utils.DataContainer;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
-import org.simantics.utils.datastructures.UnaryFunction;\r
-\r
-\r
-/*\r
- * A dialog, which contains a single graph explorer composite\r
- *\r
- * Override getBrowseContexts() to specify the graph explorer contents.\r
- * \r
- */\r
-\r
-public abstract class GraphExplorerDialog implements UnaryFunction<SimanticsDialog, Shell> {\r
-\r
-       abstract public Set<String> getBrowseContexts();\r
-\r
-       Column[] getColumns() {\r
-               return new Column[] { new Column(ColumnKeys.SINGLE, Align.RIGHT, 180, "single", true, 1) };\r
-       }\r
-\r
-       protected SessionContextInputSource getInputSource() {\r
-               return GraphInputSources.projectSource();\r
-       }\r
-       \r
-       private final String title;\r
-       private final IWorkbenchSite site;\r
-       private final DataContainer<Object[]> result = new DataContainer<Object[]>();\r
-       \r
-       public GraphExplorerDialog(IWorkbenchSite site, String title) {\r
-               this.site = site;\r
-               this.title = title;\r
-       }\r
-       \r
-       class Dialog extends SimanticsDialog {\r
-\r
-               private GraphExplorerComposite outputExplorer;\r
-               \r
-               public Dialog(Shell shell, String title) {\r
-                       super(shell, title);\r
-               }\r
-               \r
-               @Override\r
-               protected boolean isResizable() {\r
-                       return true;\r
-               }\r
-               \r
-               @Override\r
-               protected SessionContextInputSource getInputSource() {\r
-                       return GraphExplorerDialog.this.getInputSource();\r
-               }\r
-\r
-               @Override\r
-               protected void createControls(Composite body, ISessionContext context, WidgetSupport support) {\r
-                       \r
-               outputExplorer = new GraphExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter").values(false, false), site, body, support, SWT.BORDER);          \r
-               outputExplorer.setBrowseContexts(getBrowseContexts());\r
-               outputExplorer.setColumnsVisible(false);\r
-               outputExplorer.setColumns(getColumns());\r
-               outputExplorer.finish();\r
-               \r
-               outputExplorer.setBackground(body.getDisplay().getSystemColor(SWT.COLOR_GREEN));\r
-               \r
-               GridDataFactory.fillDefaults().grab(true, true).span(2, 1).minSize(300, 400).applyTo(outputExplorer);\r
-                       \r
-               }\r
-               \r
-               @Override\r
-               protected void buttonPressed(int buttonId) {\r
-                       \r
-                       if(buttonId == Window.OK) {\r
-\r
-                               Tree tree = (Tree)outputExplorer.getExplorerControl();\r
-                               \r
-                               TreeItem[] selectedItems = tree.getSelection();\r
-                               Object[] res = new Object[selectedItems.length];\r
-                               for(int i=0;i<selectedItems.length;i++) {\r
-                                       res[i] = selectedItems[i].getData();\r
-                               }\r
-                               result.set(res);\r
-                               \r
-                       }\r
-                       \r
-                       super.buttonPressed(buttonId);\r
-                       \r
-               }\r
-               \r
-               @Override\r
-               protected Object getSelection() {\r
-                       return result.get();\r
-               }\r
-               \r
-       }\r
-       \r
-       @Override\r
-       public SimanticsDialog call(Shell shell) {\r
-               return new Dialog(shell, title);\r
-       }\r
-       \r
-       \r
-       public Object[] getSelection() {\r
-               return result.get(); \r
-       }\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.swt;
+
+import java.util.Set;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.browsing.ui.Column;
+import org.simantics.browsing.ui.Column.Align;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.graph.impl.GraphInputSources;
+import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.utils.DataContainer;
+import org.simantics.utils.datastructures.ArrayMap;
+import org.simantics.utils.datastructures.UnaryFunction;
+
+
+/*
+ * A dialog, which contains a single graph explorer composite
+ *
+ * Override getBrowseContexts() to specify the graph explorer contents.
+ * 
+ */
+
+public abstract class GraphExplorerDialog implements UnaryFunction<SimanticsDialog, Shell> {
+
+       abstract public Set<String> getBrowseContexts();
+
+       Column[] getColumns() {
+               return new Column[] { new Column(ColumnKeys.SINGLE, Align.RIGHT, 180, "single", true, 1) };
+       }
+
+       protected SessionContextInputSource getInputSource() {
+               return GraphInputSources.projectSource();
+       }
+       
+       private final String title;
+       private final IWorkbenchSite site;
+       private final DataContainer<Object[]> result = new DataContainer<Object[]>();
+       
+       public GraphExplorerDialog(IWorkbenchSite site, String title) {
+               this.site = site;
+               this.title = title;
+       }
+       
+       class Dialog extends SimanticsDialog {
+
+               private GraphExplorerComposite outputExplorer;
+               
+               public Dialog(Shell shell, String title) {
+                       super(shell, title);
+               }
+               
+               @Override
+               protected boolean isResizable() {
+                       return true;
+               }
+               
+               @Override
+               protected SessionContextInputSource getInputSource() {
+                       return GraphExplorerDialog.this.getInputSource();
+               }
+
+               @Override
+               protected void createControls(Composite body, ISessionContext context, WidgetSupport support) {
+                       
+               outputExplorer = new GraphExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter").values(false, false), site, body, support, SWT.BORDER);          
+               outputExplorer.setBrowseContexts(getBrowseContexts());
+               outputExplorer.setColumnsVisible(false);
+               outputExplorer.setColumns(getColumns());
+               outputExplorer.finish();
+               
+               outputExplorer.setBackground(body.getDisplay().getSystemColor(SWT.COLOR_GREEN));
+               
+               GridDataFactory.fillDefaults().grab(true, true).span(2, 1).minSize(300, 400).applyTo(outputExplorer);
+                       
+               }
+               
+               @Override
+               protected void buttonPressed(int buttonId) {
+                       
+                       if(buttonId == Window.OK) {
+
+                               Tree tree = (Tree)outputExplorer.getExplorerControl();
+                               
+                               TreeItem[] selectedItems = tree.getSelection();
+                               Object[] res = new Object[selectedItems.length];
+                               for(int i=0;i<selectedItems.length;i++) {
+                                       res[i] = selectedItems[i].getData();
+                               }
+                               result.set(res);
+                               
+                       }
+                       
+                       super.buttonPressed(buttonId);
+                       
+               }
+               
+               @Override
+               protected Object getSelection() {
+                       return result.get();
+               }
+               
+       }
+       
+       @Override
+       public SimanticsDialog call(Shell shell) {
+               return new Dialog(shell, title);
+       }
+       
+       
+       public Object[] getSelection() {
+               return result.get(); 
+       }
+       
+}