]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
chart component moved to jfreechart plug-in.
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jan 2013 10:57:37 +0000 (10:57 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jan 2013 10:57:37 +0000 (10:57 +0000)
refs #3988

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26621 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartDropTarget.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanel.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelElement.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelHeader.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelSeparator.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ElementContainer.java [deleted file]

diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartDropTarget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartDropTarget.java
deleted file mode 100644 (file)
index a1b8cd4..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.dnd.DND;\r
-import org.eclipse.swt.dnd.DropTargetAdapter;\r
-import org.eclipse.swt.dnd.DropTargetEvent;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.simantics.db.Resource;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
-\r
-/**\r
- * Drop target for dropping charts in chart panel\r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ChartDropTarget extends DropTargetAdapter {\r
-    \r
-    private Composite separator;\r
-    private ChartPanelElement element;\r
-    private Display display;\r
-    private ChartPanel panel;\r
-    \r
-    public ChartDropTarget(Composite separator, ChartPanelElement element, ChartPanel panel) {\r
-        this.separator = separator;\r
-        this.display = separator.getDisplay();\r
-        this.element = element;\r
-        this.panel = panel;\r
-    }\r
-    \r
-\r
-\r
-    /**\r
-     * Display effect on the composite when drag entered\r
-     */\r
-    @Override\r
-    public void dragEnter(DropTargetEvent event) {\r
-        if ((event.operations & DND.DROP_COPY) != 0) {\r
-            event.detail = DND.DROP_COPY;\r
-        } else if ((event.operations & DND.DROP_MOVE) != 0) {\r
-            event.detail = DND.DROP_MOVE;\r
-        } else {\r
-            event.detail = DND.DROP_NONE;\r
-        }\r
-        separator.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));\r
-    }\r
-\r
-    /**\r
-     * Revert effect when drag leaves\r
-     */\r
-    @Override\r
-    public void dragLeave(DropTargetEvent event) { \r
-        separator.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));\r
-    }\r
-\r
-    /**\r
-     * Drop the data to chart panel\r
-     */\r
-    @Override\r
-    public void drop(DropTargetEvent event) {\r
-        Resource chartResource = AdaptionUtils.adaptToSingle(event.data, Resource.class);\r
-        if(chartResource != null)\r
-            panel.addChart(chartResource, element);\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanel.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanel.java
deleted file mode 100644 (file)
index 1802127..0000000
+++ /dev/null
@@ -1,471 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import java.util.ArrayList;\r
-import java.util.LinkedHashMap;\r
-\r
-import org.eclipse.jface.dialogs.IDialogSettings;\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.dnd.DND;\r
-import org.eclipse.swt.dnd.DropTarget;\r
-import org.eclipse.swt.dnd.DropTargetAdapter;\r
-import org.eclipse.swt.dnd.DropTargetEvent;\r
-import org.eclipse.swt.dnd.Transfer;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.ui.IMemento;\r
-import org.eclipse.ui.IViewSite;\r
-import org.eclipse.ui.PartInitException;\r
-import org.eclipse.ui.part.ViewPart;\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ReadRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.procedure.AsyncListener;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.dnd.LocalObjectTransfer;\r
-import org.simantics.utils.RunnableWithObject;\r
-\r
-/**\r
- * Chart panel displays multiple charts in a single view. The view can be oriented \r
- * vertically or horizontally, the default is vertical. Charts can be added, removed \r
- * minimized or expanded. The order of the charts can be changed by dragging the charts.\r
- * \r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ChartPanel extends ViewPart {\r
-\r
-    private Composite body;\r
-    private ScrolledComposite sc;\r
-\r
-    private IDialogSettings settings;\r
-    private LinkedHashMap<Resource, ChartPanelElement> charts;\r
-    private ArrayList<Resource> minimizedResources;\r
-\r
-    private ArrayList<ChartPanelElement> chartElements;\r
-\r
-    public static final String CHART_PANEL_SETTINGS = "CHART_PANEL_SETTINGS";\r
-    public static final String CHARTS = "CHART_PANEL_CHARTS";\r
-    public static final String MINIMIZED_CHARTS = "CHART_PANEL_MINIMIZED_CHARTS";\r
-    public static final String CHART_PANEL_ORIENTATION = "CHART_PANEL_ORIENTATION";\r
-\r
-    public static final String CHART_PANEL_VERTICAL = "CHART_PANEL_ORIENTATION_VERTICAL";\r
-    public static final String CHART_PANEL_HORIZONTAL = "CHART_PANEL_ORIENTATION_HORIZONTAL";\r
-\r
-    private boolean vertical = true;\r
-\r
-    /**\r
-     * Initialize the view. Load charts that have previously been open (if there are any).\r
-     */\r
-    @Override\r
-    public void init(IViewSite site, IMemento memento) throws PartInitException {\r
-        super.init(site, memento);\r
-\r
-        minimizedResources = new ArrayList<Resource>();\r
-\r
-        settings = Activator.getDefault().getDialogSettings().getSection(CHART_PANEL_SETTINGS);\r
-\r
-        // Initialize settings if there are no settings\r
-        if (settings == null) {\r
-            settings = Activator.getDefault().getDialogSettings().addNewSection(CHART_PANEL_SETTINGS);\r
-        }\r
-\r
-        if(settings.getArray(CHARTS) == null) {\r
-            String[] chartUris = new String[] {};\r
-            settings.put(CHARTS, chartUris);\r
-        }\r
-\r
-        if(settings.getArray(MINIMIZED_CHARTS) == null) {\r
-            String[] minimizedChartUris = new String[] {};\r
-            settings.put(MINIMIZED_CHARTS, minimizedChartUris);\r
-        }\r
-\r
-        // initialize chart lists\r
-        charts = new LinkedHashMap<Resource, ChartPanelElement>();\r
-\r
-        // add chart resources to chart lists from settings\r
-        try {\r
-            SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
-\r
-                @Override\r
-                public void run(ReadGraph graph) throws DatabaseException {\r
-                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-                    Resource chart = null;\r
-                    String[] chartURIs = settings.getArray(CHARTS);\r
-                    for(String uri : chartURIs) {\r
-                        chart = graph.getPossibleResource(uri);\r
-                        if(chart != null && graph.isInstanceOf(chart, jfree.Chart)) {\r
-                            charts.put(chart, null);\r
-                            setChartExistingListener(chart);\r
-                        }\r
-                    }\r
-\r
-                    String[] minimizedUris = settings.getArray(MINIMIZED_CHARTS);\r
-                    for(String uri : minimizedUris) {\r
-                        chart = graph.getPossibleResource(uri);\r
-                        if(chart != null && graph.isInstanceOf(chart, jfree.Chart)) {\r
-                            minimizedResources.add(chart);\r
-                        } \r
-                    }\r
-                }\r
-            });\r
-        } catch (DatabaseException e1) {\r
-            e1.printStackTrace();\r
-        }\r
-\r
-        // set the orientation of the panel\r
-        String orientation = settings.get(CHART_PANEL_ORIENTATION);\r
-        if(CHART_PANEL_VERTICAL.equals(orientation))\r
-            this.vertical = true;\r
-        else if(CHART_PANEL_HORIZONTAL.equals(orientation))\r
-            this.vertical = false;\r
-\r
-    }\r
-\r
-    /**\r
-     * Create a scrolled composite that will contain all the charts, then call the actual \r
-     * content creator.\r
-     */\r
-    @Override\r
-    public void createPartControl(Composite parent) {\r
-        sc = new ScrolledComposite(parent, SWT.NONE | SWT.H_SCROLL | SWT.V_SCROLL);\r
-        GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(sc);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
-        sc.setExpandHorizontal(true);\r
-        sc.setExpandVertical(true);\r
-        sc.getVerticalBar().setIncrement(sc.getVerticalBar().getIncrement()*3);\r
-        sc.getHorizontalBar().setIncrement(sc.getHorizontalBar().getIncrement()*3);\r
-\r
-        body = new Composite(sc, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().margins(3, 0).spacing(0, 0).applyTo(body);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(body);\r
-\r
-        sc.setContent(body);\r
-        createContents();\r
-        \r
-        setupDropTarget();\r
-\r
-    }\r
-    \r
-    /**\r
-     * Creates the contents of this chart panel.\r
-     * Removes all old contents before creating new content\r
-     */\r
-    private void createContents() {\r
-        chartElements = new ArrayList<ChartPanelElement>();\r
-\r
-        for(Control child : body.getChildren()) {\r
-            child.dispose();\r
-        }\r
-        \r
-        // Set the initial layout\r
-        ElementContainer elementHolder;\r
-        for(Resource e : charts.keySet()) {\r
-            elementHolder = new ElementContainer(body, SWT.NONE);\r
-            elementHolder.setBackground(new Color(elementHolder.getDisplay(), 255, 0, 0));\r
-            ChartPanelElement element = new ChartPanelElement(elementHolder, this, e, SWT.NONE);\r
-            elementHolder.setLayout(GridLayoutFactory.copyLayout((GridLayout)element.getLayout()));\r
-            chartElements.add(element);\r
-            charts.put(e, element);\r
-            if(minimizedResources.contains(e)) {\r
-                element.toggleMinimize();\r
-            }\r
-        }\r
-\r
-        elementHolder = new ElementContainer(body, SWT.NONE);\r
-        elementHolder.setBackground(new Color(elementHolder.getDisplay(), 0, 255, 0));\r
-        ChartPanelElement element = new ChartPanelElement(elementHolder, this, null, SWT.NONE); // Last element is empty -> only the separator\r
-        elementHolder.setLayout(GridLayoutFactory.copyLayout((GridLayout)element.getLayout()));\r
-        chartElements.add(element);\r
-\r
-        layout();\r
-        saveState();\r
-\r
-    }\r
-\r
-    /**\r
-     * Lays out this panel (the body composite)\r
-     */\r
-    public void layout() {\r
-        if(vertical) {\r
-            GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(body);\r
-            GridDataFactory.fillDefaults().grab(true, true).applyTo(body);\r
-        } else {\r
-            // Need to calculate horizontal elements for gridLayout\r
-            int chartPanels = chartElements.size();\r
-            GridLayoutFactory.fillDefaults().spacing(0, 0).numColumns(chartPanels).applyTo(body);\r
-            GridDataFactory.fillDefaults().grab(true, true).applyTo(body);\r
-        }\r
-        body.layout();\r
-        sc.setMinSize(body.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
-    }\r
-\r
-    @Override\r
-    public void setFocus() {\r
-        if(!sc.isDisposed())\r
-            sc.setFocus();\r
-    }\r
-\r
-    @Override\r
-    public void saveState(IMemento memento) {\r
-        super.saveState(memento);\r
-        saveState();\r
-    }\r
-\r
-    /**\r
-     * Save the current state of the view to IDialogSettings \r
-     */\r
-    public void saveState() {\r
-        try {\r
-            SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
-\r
-                @Override\r
-                public void run(ReadGraph graph) throws DatabaseException {\r
-                    if (settings != null) {\r
-                        String[] uris = new String[chartElements.size() - 1];\r
-                        ArrayList<String> minimized = new ArrayList<String>();\r
-                        minimizedResources.clear();\r
-                        for(int i = 0; i < uris.length; i++) {\r
-                            ChartPanelElement e = chartElements.get(i);\r
-                            Resource r = e.getResource();\r
-                            if(r != null) {\r
-                                uris[i] = graph.getURI(r);\r
-                                if(e.isMinimized()) {\r
-                                    minimized.add(uris[i]);\r
-                                    minimizedResources.add(r);\r
-                                }\r
-                            } else {\r
-                                uris[i] = "";\r
-                            }\r
-                        }\r
-                        settings.put(CHARTS, uris);\r
-                        if(!minimized.isEmpty())\r
-                            settings.put(MINIMIZED_CHARTS, minimized.toArray(new String[minimized.size()]));\r
-                        else\r
-                            settings.put(MINIMIZED_CHARTS, new String[0]);\r
-\r
-                        if(vertical)\r
-                            settings.put(CHART_PANEL_ORIENTATION, CHART_PANEL_VERTICAL);\r
-                        else\r
-                            settings.put(CHART_PANEL_ORIENTATION, CHART_PANEL_HORIZONTAL);\r
-                    }\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Set the orientation for this chart panel.\r
-     * \r
-     * @param orientation Orientation (ChartPanel.CHART_PANEL_VERTICAL or ChartPanel.CHART_PANEL_HORIZONTAL)\r
-     */\r
-    public void setOrientation(String orientation) {\r
-        if(CHART_PANEL_VERTICAL.equals(orientation))\r
-            this.vertical = true;\r
-        else {\r
-            this.vertical = false;\r
-        }\r
-        createContents();\r
-    }\r
-\r
-    /**\r
-     * Removes a chart from this panel\r
-     * \r
-     * @param chart The chart to be removed\r
-     */\r
-    public void removeChart(Resource chart) {\r
-        ChartPanelElement element = charts.get(chart);\r
-        chartElements.remove(element);\r
-        element.getParent().dispose();\r
-        charts.remove(chart);\r
-        minimizedResources.remove(chart);\r
-        saveState();\r
-        layout();\r
-    }\r
-\r
-    /**\r
-     * Sets up drag-scrolling for a scrolled composite \r
-     * \r
-     * @param control\r
-     */\r
-    protected void setupDropTarget() {\r
-        DropTarget target = new DropTarget(sc, DND.DROP_MOVE);\r
-        target.setTransfer(new Transfer[] { LocalObjectTransfer.getTransfer() });\r
-\r
-        target.addDropListener(new DropTargetAdapter() {\r
-\r
-            private int activeMargin = 20;\r
-            private int moveAmount = 1;\r
-\r
-            @Override\r
-            public void dragOver(DropTargetEvent event) { \r
-                Point original = sc.getOrigin();\r
-                Point origin = sc.getOrigin();\r
-                Point pointer = sc.toControl(event.x, event.y);\r
-                Rectangle bounds = sc.getBounds();\r
-\r
-                if(pointer.y < activeMargin)\r
-                    origin.y = origin.y - moveAmount;\r
-                else if(bounds.height - pointer.y < activeMargin)\r
-                    origin.y = origin.y + moveAmount;\r
-                if(pointer.x < activeMargin)\r
-                    origin.x = origin.x - moveAmount;\r
-                else if(bounds.width - pointer.x < activeMargin)\r
-                    origin.x = origin.x + moveAmount;\r
-\r
-                if(origin != original) {\r
-                    sc.setOrigin (origin.x, origin.y);\r
-                    sc.redraw();\r
-                }\r
-            }\r
-\r
-        });\r
-        \r
-        DropTarget target2 = new DropTarget(body, DND.DROP_COPY | DND.DROP_MOVE);\r
-        target2.setTransfer(new Transfer[] {  LocalObjectTransfer.getTransfer() });\r
-        target2.addDropListener(new ChartDropTarget(body, null, this));\r
-\r
-    }\r
-\r
-    /**\r
-     * Is the panel vertically oriented\r
-     * @return Is the panel vertically oriented\r
-     */\r
-    public boolean isVertical() {\r
-        return vertical;\r
-    }\r
-    \r
-    /**\r
-     * Adds chart after given element. If element == null, adds chart to the top.\r
-     * \r
-     * @param element To which place the chart will be placed. (null allowed)\r
-     */\r
-    public void addChart(Resource chartResource, ChartPanelElement element) {\r
-        addChart(chartResource, element, true);\r
-    }\r
-\r
-    /**\r
-     * Adds chart after given element. If element == null, adds chart to the top.\r
-     * \r
-     * @param element To which place the chart will be placed. (null allowed)\r
-     * @param layout refresh layout. use with vertical layout. \r
-     */\r
-    public void addChart(Resource chartResource, ChartPanelElement element, boolean layout) {\r
-        if(element == null)\r
-            element = chartElements.get(chartElements.size() - 1);\r
-        int index = chartElements.indexOf(element);\r
-        if(index >= 0) {\r
-            ChartPanelElement e = chartElements.get(index);\r
-            ChartPanelElement newElement;\r
-\r
-            if(charts.containsKey(chartResource)) {\r
-                // Old element being moved to a new place\r
-                newElement = charts.get(chartResource);\r
-                int oldIndex = chartElements.indexOf(newElement);\r
-                if(newElement.equals(element) || oldIndex == index - 1)\r
-                    return; // Not moving anywhere, do nothing\r
-                Composite oldParent = newElement.getParent();\r
-                newElement.setParent(e.getParent());\r
-                oldParent.dispose();\r
-                if(oldIndex < index)\r
-                    index--;\r
-                chartElements.remove(newElement);\r
-            } else {\r
-                newElement = new ChartPanelElement(e.getParent(), this, chartResource, SWT.NONE);\r
-            }\r
-\r
-            // Add a new chart element to the location of the old element\r
-            chartElements.add(index, newElement);\r
-            charts.put(chartResource, newElement);\r
-\r
-            ElementContainer elementHolder;\r
-            // Move elements back after index\r
-            for(int i = index + 1 /*indexes after the new element*/; i < chartElements.size(); i++) {\r
-                e = chartElements.get(i);\r
-                if(i == chartElements.size() - 1) {\r
-                    // last element (the empty element) element to a new container\r
-                    elementHolder = new ElementContainer(body, SWT.NONE);\r
-                    elementHolder.setBackground(new Color(elementHolder.getDisplay(), 0, 0, 255));\r
-                    elementHolder.setLayout(GridLayoutFactory.copyLayout((GridLayout)e.getLayout()));\r
-                    e.setParent(elementHolder);\r
-                } else {\r
-                    // element to the next elements container\r
-                    elementHolder = (ElementContainer)chartElements.get(i + 1).getParent();\r
-                    e.setParent(elementHolder);\r
-                }\r
-            }\r
-            \r
-            layout();\r
-            saveState();\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Set a listener to listen if the chart resource has been removed.\r
-     * If the resource has been removed, close also the chart element in this panel.\r
-     * \r
-     * @param chart Listened chart resource\r
-     */\r
-    private void setChartExistingListener(final Resource chart) {\r
-        SimanticsUI.getSession().asyncRequest(new Read<Boolean>() {\r
-\r
-            @Override\r
-            public Boolean perform(ReadGraph graph) throws DatabaseException {\r
-                return graph.hasStatement(chart);\r
-            }\r
-        }, new AsyncListener<Boolean>() {\r
-\r
-            boolean disposed = false;\r
-\r
-            @Override\r
-            public void execute(AsyncReadGraph graph, Boolean result) {\r
-                if(result != null && result == false && body != null && !body.isDisposed()) {\r
-                    body.getDisplay().asyncExec(new RunnableWithObject(chart){\r
-                        public void run() {\r
-                            removeChart((Resource)getObject());\r
-                        }\r
-                    }) ;\r
-                    disposed = true;\r
-                }\r
-            }\r
-\r
-            @Override\r
-            public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-                throwable.printStackTrace();\r
-            }\r
-\r
-            @Override\r
-            public boolean isDisposed() {\r
-                return !disposed && !charts.containsKey(chart);\r
-            }\r
-        });\r
-    }\r
-\r
-    public ArrayList<ChartPanelElement> getElements() {\r
-        return chartElements;\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelElement.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelElement.java
deleted file mode 100644 (file)
index 405294a..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.dnd.DND;\r
-import org.eclipse.swt.dnd.DropTarget;\r
-import org.eclipse.swt.dnd.Transfer;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.db.Resource;\r
-import org.simantics.sysdyn.ui.trend.chart.ChartComposite;\r
-import org.simantics.ui.dnd.LocalObjectTransfer;\r
-\r
-/**\r
- * This class represents an expanded chart element in {@link ChartPanel}. It contains \r
- * a header {@link ChartPanelHeader} and the actual chart.\r
- * \r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ChartPanelElement extends Composite {\r
-\r
-    public static int CHART_MINIMUM_WIDTH = 300;\r
-    public static int CHART_MINIMUM_HEIGHT = 200;\r
-\r
-    private ChartPanel panel;\r
-    private ChartComposite chartComposite;\r
-    private Resource chartResource;\r
-    private boolean minimized = false;\r
-\r
-    public Resource getResource() {\r
-        return chartResource;\r
-    }\r
-\r
-    @Override\r
-    public Object getLayoutData () {\r
-        checkWidget();\r
-        Object oldData = super.getLayoutData();\r
-        if(oldData == null || !(oldData instanceof GridData)) {\r
-            oldData = GridDataFactory.fillDefaults().create();\r
-        }\r
-\r
-        int size = panel.getElements().size();\r
-        GridData data = (GridData) oldData;\r
-        // Horizontal data\r
-        data.widthHint = CHART_MINIMUM_WIDTH;\r
-        if(getResource() == null && size == 1) {\r
-            data.grabExcessHorizontalSpace = true;\r
-        } else if(getResource() == null && !panel.isVertical()){\r
-            data.grabExcessHorizontalSpace = false;\r
-            data.widthHint = SWT.DEFAULT;\r
-        } else if(minimized && !panel.isVertical()) {\r
-            data.grabExcessHorizontalSpace = false;\r
-            data.widthHint = SWT.DEFAULT;\r
-        } else {\r
-            data.grabExcessHorizontalSpace = true;\r
-        }\r
-\r
-        // Vertical data\r
-        if(getResource() == null && size == 1) {\r
-            data.grabExcessVerticalSpace = true;\r
-        } else if(!minimized && getResource() != null) {\r
-            data.grabExcessVerticalSpace = true;\r
-            data.heightHint = CHART_MINIMUM_HEIGHT;\r
-        } else if(!panel.isVertical()){\r
-            data.grabExcessVerticalSpace = true;\r
-        } else {\r
-            data.grabExcessVerticalSpace = false;\r
-            data.heightHint = SWT.DEFAULT;\r
-        }\r
-        return data;\r
-    }\r
-\r
-    /**\r
-     * Creates an expanded chart panel element into parent composite.\r
-     * \r
-     * @param parent The parent composite where the chart element is created\r
-     * @param panel The {@link ChartPanel} containing the chart element\r
-     * @param name The name of the chart\r
-     * @param style The Style of the created chart element\r
-     */\r
-    public ChartPanelElement(Composite parent, ChartPanel panel, Resource chartResource, int style) {\r
-        this(parent, panel, chartResource, false, style);\r
-    }\r
-\r
-    /**\r
-     *  Creates a chart panel element into parent composite.\r
-     * @param parent The parent composite where the chart element is created\r
-     * @param panel The {@link ChartPanel} containing the chart element\r
-     * @param name The name of the chart\r
-     * @param minimized Is the chart-section minimized\r
-     * @param style The Style of the created chart element\r
-     */\r
-    public ChartPanelElement(Composite parent, ChartPanel panel, Resource chartResource, boolean minimized, int style) {\r
-        super(parent, style | SWT.NONE );\r
-        \r
-        this.panel = panel;\r
-        this.chartResource = chartResource;\r
-        this.minimized = minimized;\r
-\r
-        if(panel.isVertical() || getResource() == null)\r
-            GridLayoutFactory.fillDefaults().spacing(0,0).applyTo(this);\r
-        else\r
-            GridLayoutFactory.fillDefaults().numColumns(2).spacing(0,0).applyTo(this);\r
-\r
-        GridDataFactory.fillDefaults().applyTo(this);\r
-\r
-        // Separator for dropping other elements\r
-        ChartPanelSeparator separator = new ChartPanelSeparator(this, panel, this, SWT.NONE);\r
-\r
-        if (chartResource != null) {\r
-            Composite c = new Composite(this, SWT.NONE);\r
-            GridDataFactory.fillDefaults().grab(true, true).applyTo(c);\r
-            GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(c);\r
-            // Header\r
-            new ChartPanelHeader(c, this, chartResource, SWT.BORDER);\r
-\r
-            // Chart\r
-            chartComposite = new ChartComposite(c, chartResource, SWT.BORDER);\r
-        }\r
-        \r
-        DropTarget target = new DropTarget(this, DND.DROP_COPY | DND.DROP_MOVE);\r
-        target.setTransfer(new Transfer[] {  LocalObjectTransfer.getTransfer() });\r
-        target.addDropListener(new ChartDropTarget(separator, this, panel));\r
-\r
-    }\r
-\r
-    /**\r
-     * Returns the chart resource associated with this element\r
-     * @return chart resource\r
-     */\r
-    public Resource getChartResource() {\r
-        return this.chartResource;\r
-    }\r
-\r
-    /**\r
-     * Returns the minimized state of this element\r
-     * @return is the element minimized\r
-     */\r
-    public boolean isMinimized() {\r
-        return minimized;\r
-    }\r
-\r
-    /**\r
-     * Change the minimized state of this element\r
-     */\r
-    public void toggleMinimize() {\r
-        toggleMinimize(false);\r
-    }\r
-    /**\r
-     * Change the minimized state of this element\r
-     */\r
-    public void toggleMinimize(boolean callSave) {\r
-        minimized = Boolean.FALSE.equals(minimized);\r
-        GridData data = (GridData) chartComposite.getLayoutData();\r
-        if(panel.isVertical())\r
-            data.exclude = minimized;\r
-        else\r
-            data.exclude = false;\r
-        chartComposite.setVisible(!minimized);\r
-\r
-        Composite parent = getParent();\r
-        data = (GridData) getLayoutData();\r
-        GridData parentData = (GridData)parent.getLayoutData();\r
-        parentData.grabExcessHorizontalSpace = data.grabExcessHorizontalSpace;\r
-        parentData.grabExcessVerticalSpace = data.grabExcessVerticalSpace;\r
-        parentData.heightHint = data.heightHint;\r
-\r
-        if(callSave) {\r
-            panel.saveState();\r
-        }\r
-        panel.layout();\r
-    }\r
-\r
-    /**\r
-     * Remove this chart panel element from its panel\r
-     */\r
-    public void remove() {\r
-        panel.removeChart(chartResource);\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelHeader.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelHeader.java
deleted file mode 100644 (file)
index 0395508..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.dnd.DND;\r
-import org.eclipse.swt.dnd.DragSource;\r
-import org.eclipse.swt.dnd.DragSourceEvent;\r
-import org.eclipse.swt.dnd.DragSourceListener;\r
-import org.eclipse.swt.dnd.Transfer;\r
-import org.eclipse.swt.events.DisposeEvent;\r
-import org.eclipse.swt.events.DisposeListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.ToolBar;\r
-import org.eclipse.swt.widgets.ToolItem;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.PossibleObjectWithType;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.procedure.Listener;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.sysdyn.JFreeChartResource;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.dnd.LocalObjectTransfer;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-/**\r
- * Header of a chart element in {@link ChartPanel}. Only this header is\r
- * shown if a chart is minimized. If a chart is expanded, this header is added\r
- * to the charts {@link ChartPanelElement}. \r
- * \r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ChartPanelHeader extends Composite {\r
-\r
-    public static int HEADER_MINIMUM_WIDTH = 250;\r
-    private ChartPanelElement element;\r
-    private Resource resource;\r
-    private Label name;\r
-    private Canvas iconCanvas;\r
-    private Image icon;\r
-    private ToolItem minimize, remove;\r
-    private Color defaultColor, darker, evenDarker;\r
-    private Image gradientBackgroundImage, borderImage;\r
-\r
-    private static ImageDescriptor closeDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/close.gif"));\r
-    private static Image closeImage = closeDescriptor.createImage();\r
-\r
-    private static ImageDescriptor minimizeDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/minimize.gif"));\r
-    private static Image minimizeImage = minimizeDescriptor.createImage();\r
-\r
-    private static ImageDescriptor maximizeDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/maximize.gif"));\r
-    private static Image maximizeImage = maximizeDescriptor.createImage();\r
-\r
-    private static ImageDescriptor lineChartDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_line_light.png"));\r
-    private static Image lineChartImage = lineChartDescriptor.createImage();\r
-\r
-    private static ImageDescriptor barChartDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar_light.png"));\r
-    private static Image barChartImage = barChartDescriptor.createImage();\r
-\r
-    private static ImageDescriptor pieChartDescriptor = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_pie_light.png"));\r
-    private static Image pieChartImage = pieChartDescriptor.createImage();\r
-\r
-\r
-    /**\r
-     * Chart panel header with minimize and close buttons.\r
-     * \r
-     * @param parent The composite where the header is added\r
-     * @param panel The {@link ChartPanel} containing the header\r
-     * @param name The name of the chart\r
-     * @param style he Style of the created chart element\r
-     */\r
-    public ChartPanelHeader(Composite c, ChartPanelElement element, Resource chartResource, int style) {\r
-        super(c, style);\r
-        this.resource = chartResource;\r
-        this.element = element;\r
-\r
-        GridLayoutFactory.fillDefaults().margins(3, 0).numColumns(3).applyTo(this);\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(this);\r
-\r
-        // Colors\r
-\r
-        // Chart icon\r
-        iconCanvas = new Canvas (this, SWT.NONE);\r
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).hint(16, 16).applyTo(iconCanvas);\r
-        iconCanvas.addPaintListener (new PaintListener() {\r
-\r
-            @Override\r
-            public void paintControl(PaintEvent e) {\r
-                if(icon != null)\r
-                    e.gc.drawImage (icon, 0, 0);                \r
-            }\r
-        });\r
-\r
-        // Label for the chart name (also minimize/expand)\r
-        name = new Label(this, SWT.NONE);\r
-\r
-        try {\r
-            // name updater\r
-            Pair<String, Image> result = SimanticsUI.getSession().syncRequest(new Read<Pair<String, Image>>() {\r
-\r
-                @Override\r
-                public Pair<String, Image> perform(ReadGraph graph) throws DatabaseException {\r
-                    JFreeChartResource jfree = JFreeChartResource.getInstance(graph);\r
-                    Layer0 l0 = Layer0.getInstance(graph);\r
-                    String label = graph.getPossibleRelatedValue(resource, l0.HasLabel);\r
-                    Image image = null;\r
-                    Resource plot = graph.syncRequest(new PossibleObjectWithType(resource, l0.ConsistsOf, jfree.Plot));\r
-                    if(plot != null) {\r
-                        if(graph.isInstanceOf(plot, jfree.CategoryPlot))\r
-                            image = barChartImage;\r
-                        else if(graph.isInstanceOf(plot, jfree.PiePlot))\r
-                            image = pieChartImage;\r
-                        else\r
-                            image = lineChartImage;\r
-                    }\r
-                    return new Pair<String, Image>(label, image);\r
-                }\r
-\r
-            }, new Listener<Pair<String, Image>>() {\r
-\r
-                @Override\r
-                public void execute(final Pair<String, Image> result) {\r
-                    if(result == null)\r
-                        return;\r
-\r
-                    name.getDisplay().asyncExec(new Runnable() {\r
-\r
-                        @Override\r
-                        public void run() {\r
-                            if(!name.isDisposed() && result.first != null)\r
-                                name.setText(result.first);\r
-\r
-                            if(!iconCanvas.isDisposed() && result.second != null) {\r
-                                icon = result.second;\r
-                                iconCanvas.redraw();\r
-                                ChartPanelHeader.this.layout();\r
-                            }\r
-                        }\r
-                    });\r
-                }\r
-\r
-                @Override\r
-                public void exception(Throwable t) {\r
-                    t.printStackTrace();\r
-                }\r
-\r
-                @Override\r
-                public boolean isDisposed() {\r
-                    return name.isDisposed();\r
-                }\r
-\r
-            });\r
-            name.setText(result.first);\r
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-            name.setText("No label");\r
-        }\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(name);\r
-\r
-        ToolBar toolbar = new ToolBar(this, SWT.FLAT);\r
-        // item for minimizing/expanding chart\r
-        minimize = new ToolItem(toolbar, SWT.PUSH);\r
-        minimize.addSelectionListener(new MinimizeListener());\r
-        if(isMinimized()) {\r
-            minimize.setToolTipText("Expand");\r
-            minimize.setImage(maximizeImage);\r
-        } else {\r
-            minimize.setToolTipText("Minimize");\r
-            minimize.setImage(minimizeImage);\r
-        }\r
-\r
-        // item for closing/removing the chart\r
-        remove = new ToolItem(toolbar, SWT.PUSH);\r
-        remove.setImage(closeImage);\r
-        remove.addSelectionListener(new RemoveChartListener());\r
-        remove.setToolTipText("Remove");\r
-\r
-\r
-        /* ********************************\r
-         * DnD \r
-         * ********************************/\r
-\r
-        // Allow data to be copied or moved from the drag source\r
-        int operations = DND.DROP_MOVE;\r
-        source = new DragSource(name, operations);\r
-\r
-        // Provide data in Text format\r
-        Transfer[] types = new Transfer[] {  LocalObjectTransfer.getTransfer() };\r
-        source.setTransfer(types);\r
-        dragSourceListener = new DragSourceListener() {\r
-\r
-            @Override\r
-            public void dragStart(DragSourceEvent event) {\r
-                if(name.isDisposed())\r
-                    event.doit = false;\r
-                event.detail = DND.DROP_LINK;\r
-\r
-            }\r
-\r
-            @Override\r
-            public void dragSetData(DragSourceEvent event) {\r
-                event.data = new StructuredSelection(resource);\r
-            }\r
-\r
-            @Override\r
-            public void dragFinished(DragSourceEvent event) {\r
-            }\r
-        };  \r
-        source.addDragListener(dragSourceListener);\r
-\r
-        name.addDisposeListener(new DisposeListener() {\r
-\r
-            @Override\r
-            public void widgetDisposed(DisposeEvent e) {\r
-                if(dragSourceListener != null && source != null && !source.isDisposed()) {\r
-                    source.removeDragListener(dragSourceListener);\r
-                }                \r
-            }\r
-        });\r
-        this.setBackgroundImage(getGradientBackgroundImage());\r
-        this.setBackgroundMode(SWT.INHERIT_FORCE);\r
-\r
-        this.addListener(SWT.MouseEnter, new EnterListener());\r
-        this.addListener(SWT.MouseExit, new ExitListener());\r
-\r
-        for(Control child : this.getChildren()) {\r
-            child.addListener(SWT.MouseEnter, new EnterListener());\r
-            child.addListener(SWT.MouseExit, new ExitListener());\r
-\r
-        }\r
-    }\r
-\r
-    private class EnterListener implements  org.eclipse.swt.widgets.Listener {\r
-        public void handleEvent(Event event) {\r
-            ChartPanelHeader.this.setBackgroundImage(getHighlightedGradientBackgroundImage());\r
-        }\r
-    }\r
-\r
-    private class ExitListener implements  org.eclipse.swt.widgets.Listener {\r
-        public void handleEvent(Event event) {\r
-            ChartPanelHeader.this.setBackgroundImage(getGradientBackgroundImage());\r
-        }\r
-    }\r
-\r
-    private void createColors() {\r
-        if(defaultColor == null) {\r
-            defaultColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);\r
-            try {\r
-                defaultColor = new Color(getDisplay(), defaultColor.getRed() + 500, defaultColor.getGreen() + 10, defaultColor.getBlue() + 10);\r
-            } catch (IllegalArgumentException e) {\r
-                // Do nothing, use the default color\r
-            }\r
-        }\r
-\r
-        if(darker == null) {\r
-            try {\r
-                darker = new Color(getDisplay(), defaultColor.getRed() - 30, defaultColor.getGreen() - 30, defaultColor.getBlue() - 30);\r
-            } catch (IllegalArgumentException e) {\r
-                // Do nothing, use the default color\r
-                darker = defaultColor;\r
-            }\r
-        }\r
-        \r
-        if(evenDarker == null) {\r
-            try {\r
-                evenDarker = new Color(getDisplay(), defaultColor.getRed() - 50, defaultColor.getGreen() - 50, defaultColor.getBlue() - 50);\r
-            } catch (IllegalArgumentException e) {\r
-                // Do nothing, use the default color\r
-                evenDarker = defaultColor;\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    private Image getHighlightedGradientBackgroundImage() {\r
-        createColors();\r
-        this.layout();\r
-        Point size = this.getSize();\r
-\r
-        borderImage = new Image(this.getDisplay(), 1, Math.max(1, size.y));\r
-        GC gc = new GC(borderImage);\r
-        gc.setForeground(defaultColor);\r
-        gc.setBackground(evenDarker);\r
-        gc.fillGradientRectangle(0, 0, 1, size.y, true);\r
-        gc.dispose();\r
-\r
-        return borderImage;\r
-    }\r
-\r
-    private Image getGradientBackgroundImage() {\r
-        createColors();\r
-        this.layout();\r
-        Point size = this.computeSize(SWT.DEFAULT, SWT.DEFAULT);\r
-        if(gradientBackgroundImage == null) {\r
-            gradientBackgroundImage = new Image(this.getDisplay(), 1, Math.max(1, size.y));\r
-            GC gc = new GC(gradientBackgroundImage);\r
-            gc.setForeground(defaultColor);\r
-            gc.setBackground(darker);\r
-            gc.fillGradientRectangle(0, 0, 1, size.y, true);\r
-            gc.dispose();\r
-        }\r
-\r
-        return gradientBackgroundImage;\r
-    }\r
-\r
-    private DragSourceListener dragSourceListener;\r
-    private DragSource source;\r
-\r
-    /**\r
-     * Return true if this element is minimized, false if expanded\r
-     * @return true if this element is minimized, false if expanded\r
-     */\r
-    private boolean isMinimized() {\r
-        return element.isMinimized();\r
-    }\r
-\r
-    /**\r
-     * Listener to minimize chart button. Expands and minimizes \r
-     * the chart of this header.\r
-     * \r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class MinimizeListener implements SelectionListener {\r
-        @Override\r
-        public void widgetSelected(SelectionEvent e) {\r
-            if(ChartPanelHeader.this.isDisposed())\r
-                return;\r
-\r
-            element.toggleMinimize(true);\r
-\r
-            if(!name.isDisposed() && !minimize.isDisposed()) {\r
-                if(isMinimized()) {\r
-                    minimize.setToolTipText("Expand");\r
-                } else {\r
-                    minimize.setToolTipText("Minimize");\r
-                }\r
-            }            \r
-        }\r
-\r
-        @Override\r
-        public void widgetDefaultSelected(SelectionEvent e) {\r
-            widgetSelected(e);\r
-        }\r
-\r
-    }\r
-\r
-    /**\r
-     * Listener for removing this chart from the chart panel.\r
-     * \r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class RemoveChartListener implements SelectionListener {\r
-        @Override\r
-        public void widgetSelected(SelectionEvent e) {\r
-            if(!ChartPanelHeader.this.isDisposed()) {\r
-                element.remove();\r
-            }\r
-        }\r
-\r
-        @Override\r
-        public void widgetDefaultSelected(SelectionEvent e) {\r
-            widgetSelected(e);\r
-        }\r
-\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelSeparator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ChartPanelSeparator.java
deleted file mode 100644 (file)
index e0bde1e..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.swt.events.MouseAdapter;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-/**\r
- * Class for separating charts in {@link ChartPanel}. Acts as a drop participant for adding\r
- * and moving charts in {@link ChartPanel}.\r
- * \r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ChartPanelSeparator extends Composite {\r
-\r
-    private ChartPanel panel;\r
-\r
-    @Override\r
-    public Object getLayoutData() {\r
-        checkWidget();\r
-        Object oldData = super.getLayoutData();\r
-        if(oldData == null || !(oldData instanceof GridData)) {\r
-            oldData = GridDataFactory.fillDefaults().create();\r
-        }\r
-        GridData data = (GridData) oldData;\r
-        // Empty panel -> drop area the size of the whole panel\r
-        if(panel.getElements().size() == 1 && panel.getElements().get(0).getResource() == null) {\r
-            data.grabExcessHorizontalSpace = true;\r
-            data.grabExcessVerticalSpace = true;\r
-        }\r
-        else {\r
-            if(panel.isVertical()) { \r
-                data.grabExcessHorizontalSpace = true;\r
-                data.grabExcessVerticalSpace = false;\r
-            } else {\r
-                data.grabExcessHorizontalSpace = false;\r
-                data.grabExcessVerticalSpace = true;\r
-            }\r
-        }\r
-        return data;\r
-    }\r
-\r
-    /**\r
-     * Set up a small horizontal or vertical separator depending on SWT style\r
-     * \r
-     * @param parent\r
-     * @param style\r
-     */\r
-    public ChartPanelSeparator(Composite parent, ChartPanel panel, ChartPanelElement element, int style) {\r
-        super(parent, style);\r
-        GridLayoutFactory.fillDefaults().margins(2, 2).applyTo(this);\r
-        GridDataFactory.fillDefaults().applyTo(this);\r
-        this.panel = panel;\r
-        addMouseListener(new SCFocusListener(panel));\r
-    }\r
-\r
-\r
-    /**\r
-     * Listener for directing focus to scrollableComposite\r
-     * @author Teemu Lempinen\r
-     *\r
-     */\r
-    private class SCFocusListener extends MouseAdapter {\r
-        ChartPanel panel;\r
-        public SCFocusListener(ChartPanel panel) {\r
-            this.panel = panel;\r
-        }\r
-        public void mouseDown(MouseEvent e) {\r
-            panel.setFocus();\r
-        }\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ElementContainer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/ElementContainer.java
deleted file mode 100644 (file)
index 56d9fa8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * 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.sysdyn.ui.trend;\r
-\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-\r
-/**\r
- * Container for a chart panel element. Needed for\r
- * moving chart panel elements around using setParent()\r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class ElementContainer extends Composite {\r
-\r
-    @Override\r
-    public Object getLayoutData () {\r
-        Control[] children = getChildren();\r
-        if(children.length == 1) {\r
-            if(children[0] instanceof ChartPanelElement) {\r
-                ChartPanelElement element = (ChartPanelElement)children[0];\r
-                return element.getLayoutData();\r
-            }\r
-        }\r
-        return super.getLayoutData();\r
-    }\r
-    \r
-    public ElementContainer(Composite parent, int style) {\r
-        super(parent, style);\r
-    }\r
-\r
-}\r