Mercurial > hg > release > thermostat-0.9
changeset 790:b063c6afa2d7
Remove duplicate controller from Eclipse plugin
This commit removes the slightly modified RecentTimeSeriesChartController
used by the Eclipse plugins and instead uses the one provided by
client-core. I also had to make some slight modifications to the Eclipse
plugin code in order for it to work with the client-core version of the
controller.
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-November/004132.html
author | Elliott Baron <ebaron@redhat.com> |
---|---|
date | Mon, 19 Nov 2012 09:49:57 -0500 |
parents | a96af4716d10 |
children | 9fdbdf22d9d4 |
files | eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartComposite.java eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartController.java |
diffstat | 2 files changed, 12 insertions(+), 112 deletions(-) [+] |
line wrap: on
line diff
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartComposite.java Mon Nov 19 11:40:08 2012 +0100 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartComposite.java Mon Nov 19 09:49:57 2012 -0500 @@ -36,10 +36,12 @@ package com.redhat.thermostat.eclipse.chart.common; +import java.awt.Frame; import java.util.Arrays; import java.util.concurrent.TimeUnit; import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; @@ -59,6 +61,7 @@ import org.jfree.chart.JFreeChart; import com.redhat.thermostat.client.locale.LocaleResources; +import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.eclipse.ThermostatConstants; @@ -79,11 +82,18 @@ public RecentTimeSeriesChartComposite(Composite parent, int style, JFreeChart chart) { super(parent, style); this.setLayout(new GridLayout()); - this.controller = new RecentTimeSeriesChartController(this, chart); + + Composite top = new Composite(this, SWT.NONE | SWT.EMBEDDED); + top.setLayout(new GridLayout()); + top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + Frame frame = SWT_AWT.new_Frame(top); + this.controller = new RecentTimeSeriesChartController(chart); - final ChartPanel cp = controller.getChartComposite(); + ChartPanel cp = controller.getChartPanel(); + frame.add(cp); cp.setDisplayToolTips(false); + cp.setDoubleBuffered(true); cp.setMouseZoomable(false); cp.setPopupMenu(null);
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartController.java Mon Nov 19 11:40:08 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.Frame; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.awt.SWT_AWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; - -public class RecentTimeSeriesChartController { - - private static final int DEFAULT_VALUE = 10; - private static final TimeUnit DEFAULT_UNIT = TimeUnit.MINUTES; - - private JFreeChart chart; - private ChartPanel panel; - private int timeValue = DEFAULT_VALUE; - private TimeUnit timeUnit = DEFAULT_UNIT; - - public RecentTimeSeriesChartController(Composite parent, JFreeChart chart) { - this.chart = chart; - Composite top = new Composite(parent, SWT.NONE | SWT.EMBEDDED); - top.setLayout(new GridLayout()); - top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - Frame frame = SWT_AWT.new_Frame(top); - this.panel = new ChartPanel(chart, true); - frame.add(panel); - - // instead of just disabling display of tooltips, disable their generation too - if (chart.getPlot() instanceof XYPlot) { - chart.getXYPlot().getRenderer().setBaseToolTipGenerator(null); - } - - chart.getXYPlot().getDomainAxis().setAutoRange(true); - chart.getXYPlot().getDomainAxis().setFixedAutoRange(timeUnit.toMillis(timeValue)); - - chart.getXYPlot().getRangeAxis().setAutoRange(true); - - } - - public ChartPanel getChartComposite() { - return panel; - } - - public TimeUnit[] getTimeUnits() { - return new TimeUnit[] { TimeUnit.DAYS, TimeUnit.HOURS, TimeUnit.MINUTES }; - } - - public int getTimeValue() { - return timeValue; - } - - public TimeUnit getTimeUnit() { - return timeUnit; - } - - public void setTime(int value, TimeUnit unit) { - this.timeValue = value; - this.timeUnit = unit; - - updateChart(); - } - - private void updateChart() { - chart.getXYPlot().getDomainAxis().setAutoRange(true); - chart.getXYPlot().getDomainAxis().setFixedAutoRange(timeUnit.toMillis(timeValue)); - } - -}