Mercurial > hg > release > thermostat-0.5
changeset 870:b7125452697f
Merge
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Mon, 17 Dec 2012 15:52:20 -0500 |
parents | cf634ed45556 (current diff) 0926cdd87a6b (diff) |
children | 4ccae2248ed5 |
files | client/swing/src/main/java/com/redhat/thermostat/client/swing/components/models/LongRange.java client/swing/src/main/java/com/redhat/thermostat/client/swing/components/models/LongRangeNormalizer.java client/swing/src/test/java/com/redhat/thermostat/client/swing/components/models/LongRangeNormalizerTest.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadDetailsView.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadTableView.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadTimelineView.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadView.java thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/VMThreadCapabilitiesView.java |
diffstat | 43 files changed, 1138 insertions(+), 753 deletions(-) [+] |
line wrap: on
line diff
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/GradientPanel.java Mon Dec 17 15:26:45 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/GradientPanel.java Mon Dec 17 15:52:20 2012 -0500 @@ -41,6 +41,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Paint; +import java.awt.Rectangle; import javax.swing.JPanel; @@ -61,9 +62,11 @@ Graphics2D graphics = GraphicsUtils.getInstance().createAAGraphics(g); + Rectangle bounds = g.getClipBounds(); + Paint gradient = new GradientPaint(0, 0, top, 0, getHeight(), bottom); graphics.setPaint(gradient); - graphics.fillRect(0, 0, getWidth(), getHeight()); + graphics.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); graphics.dispose(); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/models/LongRange.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +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.client.swing.components.models; - -public class LongRange { - - long min; - long max; - - public void setMax(long max) { - this.max = max; - } - - public long getMax() { - return max; - } - - public void setMin(long min) { - this.min = min; - } - - - public long getMin() { - return min; - } -}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/components/models/LongRangeNormalizer.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +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.client.swing.components.models; - -public class LongRangeNormalizer { - - private long minNormalized; - - private long maxNormalized; - - private long value; - - private LongRange range; - - public LongRangeNormalizer(LongRange range) { - this.range = range; - } - - public void setMaxNormalized(long maxNormalized) { - this.maxNormalized = maxNormalized; - } - - public void setMinNormalized(long minNormalized) { - this.minNormalized = minNormalized; - } - - public long getValue() { - return value; - } - - public void setValue(long newValue) { - this.value = newValue; - } - - public long getMaxNormalized() { - return maxNormalized; - } - - public long getMinNormalized() { - return minNormalized; - } - - public long getValueNormalized() { - double normalized = ((value - range.min) * (double)(maxNormalized - minNormalized)/(range.max - range.min)) + minNormalized; - return Math.round(normalized); - } -}
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/components/models/LongRangeNormalizerTest.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +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.client.swing.components.models; - -import static org.junit.Assert.*; -import junit.framework.Assert; - -import org.junit.Test; - -public class LongRangeNormalizerTest { - - @Test - public void testSameRange() { - - LongRange range = new LongRange(); - range.setMax(10); - range.setMin(0); - - LongRangeNormalizer model = new LongRangeNormalizer(range); - - model.setValue(5); - - model.setMaxNormalized(10); - model.setMinNormalized(0); - - - Assert.assertEquals((int) model.getValue(), model.getValueNormalized()); - } - - @Test - public void testDoubleRange() { - - LongRange range = new LongRange(); - range.setMax(10); - range.setMin(0); - - LongRangeNormalizer model = new LongRangeNormalizer(range); - - model.setValue(5); - - model.setMaxNormalized(20); - model.setMinNormalized(0); - - - Assert.assertEquals(10, model.getValueNormalized()); - } - - @Test - public void testRanges() { - - LongRange range = new LongRange(); - range.setMax(10); - range.setMin(0); - - LongRangeNormalizer model = new LongRangeNormalizer(range); - - model.setValue(5); - - model.setMaxNormalized(40); - model.setMinNormalized(0); - - Assert.assertEquals(20, model.getValueNormalized()); - - model.setMaxNormalized(60); - model.setMinNormalized(0); - - Assert.assertEquals(30, model.getValueNormalized()); - - model.setMaxNormalized(200); - model.setMinNormalized(100); - - Assert.assertEquals(150, model.getValueNormalized()); - - range.setMax(100); - range.setMin(0); - model.setValue(50); - - model.setMaxNormalized(1); - model.setMinNormalized(0); - - Assert.assertEquals(1, model.getValueNormalized()); - - model.setValue(49); - Assert.assertEquals(0, model.getValueNormalized()); - } -}
--- a/common/core/pom.xml Mon Dec 17 15:26:45 2012 -0500 +++ b/common/core/pom.xml Mon Dec 17 15:52:20 2012 -0500 @@ -89,6 +89,7 @@ com.redhat.thermostat.common.heap, com.redhat.thermostat.common.locale, com.redhat.thermostat.common.ssl, + com.redhat.thermostat.common.model, </Export-Package> <Private-Package> com.redhat.thermostat.test,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/main/java/com/redhat/thermostat/common/model/LongRange.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,85 @@ +/* + * 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.common.model; + + +/** + * A class representing a span of units from min to max. <br /><br /> + * + * The units and the meaning of the range are left to the user, including the + * fact that the range are inclusive or exclusive of the extremes. + */ +public class LongRange { + + long min; + long max; + + /** + * Creates a new LongRange with a span of 0 units. + */ + public LongRange() { + } + + /** + * Creates a new Range that span from min to max. + */ + public LongRange(long min, long max) { + this.min = min; + this.max = max; + } + + public void setMax(long max) { + this.max = max; + } + + public long getMax() { + return max; + } + + public void setMin(long min) { + this.min = min; + } + + public long getMin() { + return min; + } + + @Override + public String toString() { + return "[" + min + " ->" + max + "("+ (max - min) + ")]"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/main/java/com/redhat/thermostat/common/model/LongRangeNormalizer.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,100 @@ +/* + * 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.common.model; + +/** + * A class that normalizes {@link LongRange} values to another given range. + * + * <br /><br /> + * + * The range of normalization is inclusive of the extremes. + */ +public class LongRangeNormalizer { + + private long minNormalized; + + private long maxNormalized; + + private long value; + + private LongRange range; + + public LongRangeNormalizer(LongRange range) { + this.range = range; + } + + public LongRangeNormalizer(LongRange range, long minNormalized, long maxNormalized) { + this.range = range; + this.maxNormalized = maxNormalized; + this.minNormalized = minNormalized; + } + + public LongRangeNormalizer(LongRange range, LongRange normilizedRange) { + this.range = range; + maxNormalized = normilizedRange.max; + minNormalized = normilizedRange.min; + } + + public void setMaxNormalized(long maxNormalized) { + this.maxNormalized = maxNormalized; + } + + public void setMinNormalized(long minNormalized) { + this.minNormalized = minNormalized; + } + + public long getValue() { + return value; + } + + public void setValue(long newValue) { + this.value = newValue; + } + + public long getMaxNormalized() { + return maxNormalized; + } + + public long getMinNormalized() { + return minNormalized; + } + + public long getValueNormalized() { + double normalized = ((value - range.min) * (double)(maxNormalized - minNormalized)/(range.max - range.min)) + minNormalized; + return Math.round(normalized); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/core/src/test/java/com/redhat/thermostat/common/model/LongRangeNormalizerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,123 @@ +/* + * 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.common.model; + +import static org.junit.Assert.*; +import junit.framework.Assert; + +import org.junit.Test; + +import com.redhat.thermostat.common.model.LongRange; +import com.redhat.thermostat.common.model.LongRangeNormalizer; + +public class LongRangeNormalizerTest { + + @Test + public void testSameRange() { + + LongRange range = new LongRange(); + range.setMax(10); + range.setMin(0); + + LongRangeNormalizer model = new LongRangeNormalizer(range); + + model.setValue(5); + + model.setMaxNormalized(10); + model.setMinNormalized(0); + + + Assert.assertEquals((int) model.getValue(), model.getValueNormalized()); + } + + @Test + public void testDoubleRange() { + + LongRange range = new LongRange(); + range.setMax(10); + range.setMin(0); + + LongRangeNormalizer model = new LongRangeNormalizer(range); + + model.setValue(5); + + model.setMaxNormalized(20); + model.setMinNormalized(0); + + + Assert.assertEquals(10, model.getValueNormalized()); + } + + @Test + public void testRanges() { + + LongRange range = new LongRange(); + range.setMax(10); + range.setMin(0); + + LongRangeNormalizer model = new LongRangeNormalizer(range); + + model.setValue(5); + + model.setMaxNormalized(40); + model.setMinNormalized(0); + + Assert.assertEquals(20, model.getValueNormalized()); + + model.setMaxNormalized(60); + model.setMinNormalized(0); + + Assert.assertEquals(30, model.getValueNormalized()); + + model.setMaxNormalized(200); + model.setMinNormalized(100); + + Assert.assertEquals(150, model.getValueNormalized()); + + range.setMax(100); + range.setMin(0); + model.setValue(50); + + model.setMaxNormalized(1); + model.setMinNormalized(0); + + Assert.assertEquals(1, model.getValueNormalized()); + + model.setValue(49); + Assert.assertEquals(0, model.getValueNormalized()); + } +}
--- a/thread/client-common/pom.xml Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-common/pom.xml Mon Dec 17 15:52:20 2012 -0500 @@ -62,6 +62,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>net.java.openjdk.cacio</groupId> + <artifactId>cacio-tta</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.redhat.thermostat</groupId> <artifactId>thermostat-common-core</artifactId> <version>${project.version}</version> @@ -105,6 +110,7 @@ <Bundle-Activator>com.redhat.thermostat.thread.client.common.osgi.Activator</Bundle-Activator> <Export-Package> com.redhat.thermostat.thread.client.common, + com.redhat.thermostat.thread.client.common.view, com.redhat.thermostat.thread.client.common.locale, com.redhat.thermostat.thread.client.common.chart, com.redhat.thermostat.thread.client.common.collector,
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadDetailsView.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +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.thread.client.common; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.client.ui.IconDescriptor; - -public abstract class ThreadDetailsView extends BasicView { - - public IconDescriptor getEmptyDetailsIcon() { - return IconResources.getMonitorIcon(); - } - - public abstract void setDetails(ThreadTableBean thread); -}
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadTableView.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +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.thread.client.common; - -import java.util.List; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ActionNotifier; - -public abstract class ThreadTableView extends BasicView { - - public static enum ThreadSelectionAction { - SHOW_THREAD_DETAILS - } - - protected final ActionNotifier<ThreadSelectionAction> threadTableNotifier; - public ThreadTableView() { - threadTableNotifier = new ActionNotifier<>(this); - } - - public void addThreadSelectionActionListener(ActionListener<ThreadSelectionAction> listener) { - threadTableNotifier.addActionListener(listener); - } - - public void removeThreadSelectionActionListener(ActionListener<ThreadSelectionAction> listener) { - threadTableNotifier.removeActionListener(listener); - } - - public abstract void display(List<ThreadTableBean> arrayList); -}
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadTimelineView.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +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.thread.client.common; - -import java.util.List; -import java.util.Map; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ActionNotifier; -import com.redhat.thermostat.thread.model.ThreadInfoData; - -public abstract class ThreadTimelineView extends BasicView { - - public static enum ThreadTimelineViewAction { - THREAD_TIMELINE_SELECTED - } - - protected final ActionNotifier<ThreadTimelineViewAction> threadTimelineNotifier; - public ThreadTimelineView() { - threadTimelineNotifier = new ActionNotifier<>(this); - } - - public void addThreadSelectionActionListener(ActionListener<ThreadTimelineViewAction> listener) { - threadTimelineNotifier.addActionListener(listener); - } - - public void removeThreadSelectionActionListener(ActionListener<ThreadTimelineViewAction> listener) { - threadTimelineNotifier.removeActionListener(listener); - } - - public abstract void displayStats(Map<ThreadInfoData, List<ThreadTimelineBean>> timelines, long start, long stop); - public abstract void setMarkersMessage(String left, String right); - public abstract void resetMarkerMessage(); -}
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadView.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +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.thread.client.common; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.common.ActionNotifier; -import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; - -public abstract class ThreadView extends BasicView implements UIComponent { - - public enum ThreadAction { - START_LIVE_RECORDING, - STOP_LIVE_RECORDING - }; - - protected ApplicationService appService; - protected String uniqueId; - - protected final ActionNotifier<ThreadAction> notifier; - public ThreadView() { - notifier = new ActionNotifier<>(this); - } - - public void addThreadActionListener(ActionListener<ThreadAction> listener) { - notifier.addActionListener(listener); - } - - public void removeThreadActionListener(ActionListener<ThreadAction> listener) { - notifier.removeActionListener(listener); - } - - public abstract void setRecording(boolean recording, boolean notify); - - public abstract void setDaemonThreads(String daemonThreads); - public abstract void setLiveThreads(String liveThreads); - public abstract void updateLivingDaemonTimeline(LivingDaemonThreadDifferenceChart model); - - public abstract VMThreadCapabilitiesView createVMThreadCapabilitiesView(); - public abstract ThreadTableView createThreadTableView(); - public abstract ThreadTimelineView createThreadTimelineView(); - - public abstract void displayWarning(String warning); - - public void setApplicationService(ApplicationService appService, String uniqueId) { - this.appService = appService; - this.uniqueId = uniqueId; - } - - public abstract void displayThreadDetails(ThreadTableBean thread); -}
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadViewProvider.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/ThreadViewProvider.java Mon Dec 17 15:52:20 2012 -0500 @@ -37,6 +37,7 @@ package com.redhat.thermostat.thread.client.common; import com.redhat.thermostat.client.core.views.ViewProvider; +import com.redhat.thermostat.thread.client.common.view.ThreadView; public interface ThreadViewProvider extends ViewProvider {
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/VMThreadCapabilitiesView.java Mon Dec 17 15:26:45 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +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.thread.client.common; - -import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.thread.model.VMThreadCapabilities; - -public abstract class VMThreadCapabilitiesView extends BasicView { - - public abstract void setVMThreadCapabilities(VMThreadCapabilities caps); -}
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java Mon Dec 17 15:52:20 2012 -0500 @@ -59,6 +59,7 @@ TABLE, DETAILS, TIMELINE, + THREAD_COUNT, LIVE_THREADS, DAEMON_THREADS,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadCountView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,46 @@ +/* + * 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.thread.client.common.view; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; + +public abstract class ThreadCountView extends BasicView { + public abstract void setDaemonThreads(String daemonThreads); + public abstract void setLiveThreads(String liveThreads); + public abstract void updateLivingDaemonTimeline(LivingDaemonThreadDifferenceChart model); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadDetailsView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,51 @@ +/* + * 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.thread.client.common.view; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.ui.IconDescriptor; +import com.redhat.thermostat.thread.client.common.IconResources; +import com.redhat.thermostat.thread.client.common.ThreadTableBean; + +public abstract class ThreadDetailsView extends BasicView { + + public IconDescriptor getEmptyDetailsIcon() { + return IconResources.getMonitorIcon(); + } + + public abstract void setDetails(ThreadTableBean thread); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadTableView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,66 @@ +/* + * 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.thread.client.common.view; + +import java.util.List; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.thread.client.common.ThreadTableBean; + +public abstract class ThreadTableView extends BasicView { + + public static enum ThreadSelectionAction { + SHOW_THREAD_DETAILS + } + + protected final ActionNotifier<ThreadSelectionAction> threadTableNotifier; + public ThreadTableView() { + threadTableNotifier = new ActionNotifier<>(this); + } + + public void addThreadSelectionActionListener(ActionListener<ThreadSelectionAction> listener) { + threadTableNotifier.addActionListener(listener); + } + + public void removeThreadSelectionActionListener(ActionListener<ThreadSelectionAction> listener) { + threadTableNotifier.removeActionListener(listener); + } + + public abstract void display(List<ThreadTableBean> arrayList); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadTimelineView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,70 @@ +/* + * 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.thread.client.common.view; + +import java.util.List; +import java.util.Map; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.thread.client.common.ThreadTimelineBean; +import com.redhat.thermostat.thread.model.ThreadInfoData; + +public abstract class ThreadTimelineView extends BasicView { + + public static enum ThreadTimelineViewAction { + THREAD_TIMELINE_SELECTED + } + + protected final ActionNotifier<ThreadTimelineViewAction> threadTimelineNotifier; + public ThreadTimelineView() { + threadTimelineNotifier = new ActionNotifier<>(this); + } + + public void addThreadSelectionActionListener(ActionListener<ThreadTimelineViewAction> listener) { + threadTimelineNotifier.addActionListener(listener); + } + + public void removeThreadSelectionActionListener(ActionListener<ThreadTimelineViewAction> listener) { + threadTimelineNotifier.removeActionListener(listener); + } + + public abstract void displayStats(Map<ThreadInfoData, List<ThreadTimelineBean>> timelines, long start, long stop); + public abstract void setMarkersMessage(String left, String right); + public abstract void resetMarkerMessage(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/ThreadView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,85 @@ +/* + * 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.thread.client.common.view; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.core.views.UIComponent; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.thread.client.common.ThreadTableBean; +import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; + +public abstract class ThreadView extends BasicView implements UIComponent { + + public enum ThreadAction { + START_LIVE_RECORDING, + STOP_LIVE_RECORDING + }; + + protected ApplicationService appService; + protected String uniqueId; + + protected final ActionNotifier<ThreadAction> notifier; + public ThreadView() { + notifier = new ActionNotifier<>(this); + } + + public void addThreadActionListener(ActionListener<ThreadAction> listener) { + notifier.addActionListener(listener); + } + + public void removeThreadActionListener(ActionListener<ThreadAction> listener) { + notifier.removeActionListener(listener); + } + + public abstract void setRecording(boolean recording, boolean notify); + + public abstract VMThreadCapabilitiesView createVMThreadCapabilitiesView(); + public abstract ThreadTableView createThreadTableView(); + public abstract ThreadTimelineView createThreadTimelineView(); + public abstract ThreadCountView createThreadCountView(); + + public abstract void displayWarning(String warning); + + public void setApplicationService(ApplicationService appService, String uniqueId) { + this.appService = appService; + this.uniqueId = uniqueId; + } + + public abstract void displayThreadDetails(ThreadTableBean thread); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/view/VMThreadCapabilitiesView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,45 @@ +/* + * 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.thread.client.common.view; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.thread.model.VMThreadCapabilities; + +public abstract class VMThreadCapabilitiesView extends BasicView { + + public abstract void setVMThreadCapabilities(VMThreadCapabilities caps); +}
--- a/thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties Mon Dec 17 15:52:20 2012 -0500 @@ -19,6 +19,7 @@ TABLE = Table DETAILS = Details TIMELINE = Timeline +THREAD_COUNT = Thread Count LIVE_THREADS = Live Threads DAEMON_THREADS = Daemon Threads
--- a/thread/client-controllers/pom.xml Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/pom.xml Mon Dec 17 15:52:20 2012 -0500 @@ -96,6 +96,17 @@ <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-swing</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>net.java.openjdk.cacio</groupId> + <artifactId>cacio-tta</artifactId> + <scope>test</scope> + </dependency> + </dependencies> <build>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadCountController.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,87 @@ +/* + * 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.thread.client.controller.impl; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import com.redhat.thermostat.common.Timer; +import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; +import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadCountView; +import com.redhat.thermostat.thread.model.ThreadSummary; + +class ThreadCountController extends CommonController { + + private LivingDaemonThreadDifferenceChart model; + private ThreadCollector collector; + + public ThreadCountController(ThreadCountView view, ThreadCollector collector, Timer timer) { + super(timer, view); + + this.collector = collector; + model = new LivingDaemonThreadDifferenceChart("Living Threads vs. Daemon Threads", "time", "threads", + "Living Threads", "Daemon Threads"); + model.setMaximumItemCount(3600); + + timer.setAction(new ThreadInformationDataCollector()); + } + + private class ThreadInformationDataCollector implements Runnable { + @Override + public void run() { + + ThreadCountView view = (ThreadCountView) ThreadCountController.this.view; + + // load the very latest thread summary + ThreadSummary latestSummary = collector.getLatestThreadSummary(); + if (latestSummary.getTimeStamp() != 0) { + view.setLiveThreads(Long.toString(latestSummary.getCurrentLiveThreads())); + view.setDaemonThreads(Long.toString(latestSummary.getCurrentDaemonThreads())); + } + + long lastHour = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1); + List<ThreadSummary> summaries = collector.getThreadSummary(lastHour); + if (summaries.size() != 0) { + for (ThreadSummary summary : summaries) { + model.addData(summary.getTimeStamp(), summary.getCurrentLiveThreads(), summary.getCurrentDaemonThreads()); + } + view.updateLivingDaemonTimeline(model); + } + } + } +}
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Mon Dec 17 15:52:20 2012 -0500 @@ -36,33 +36,25 @@ package com.redhat.thermostat.thread.client.controller.impl; -import java.util.List; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.NotImplementedException; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; import com.redhat.thermostat.common.TimerFactory; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.LoggingUtils; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; -import com.redhat.thermostat.thread.client.common.ThreadTableView.ThreadSelectionAction; -import com.redhat.thermostat.thread.client.common.ThreadView; -import com.redhat.thermostat.thread.client.common.ThreadView.ThreadAction; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; -import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; -import com.redhat.thermostat.thread.model.ThreadSummary; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; +import com.redhat.thermostat.thread.client.common.view.ThreadView; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView.ThreadSelectionAction; +import com.redhat.thermostat.thread.client.common.view.ThreadView.ThreadAction; public class ThreadInformationController implements InformationServiceController<VmRef> { @@ -72,10 +64,7 @@ private ThreadCollector collector; private ApplicationService appService; - private Timer timer; - - private LivingDaemonThreadDifferenceChart model; - + public ThreadInformationController(VmRef ref, ApplicationService appService, ThreadCollectorFactory collectorFactory, ThreadViewProvider viewFactory) @@ -88,38 +77,6 @@ initControllers(); - timer = appService.getTimerFactory().createTimer(); - - timer.setInitialDelay(0); - timer.setDelay(1000); - timer.setTimeUnit(TimeUnit.MILLISECONDS); - timer.setSchedulingType(SchedulingType.FIXED_RATE); - - timer.setAction(new ThreadInformationDataCollector()); - - model = new LivingDaemonThreadDifferenceChart("Living Threads vs. Daemon Threads", - "time", "threads", "Living Threads", - "Daemon Threads"); - model.setMaximumItemCount(3600); - - view.addActionListener(new ActionListener<Action>() { - @Override - public void actionPerformed(ActionEvent<Action> actionEvent) { - switch (actionEvent.getActionId()) { - case HIDDEN: - timer.stop(); - break; - - case VISIBLE: - timer.start(); - break; - - default: - throw new NotImplementedException("unknown event: " + actionEvent.getActionId()); - } - } - }); - view.setRecording(isRecording(), false); view.addThreadActionListener(new ThreadActionListener()); } @@ -139,28 +96,6 @@ return view; } - private class ThreadInformationDataCollector implements Runnable { - @Override - public void run() { - - // load the very latest thread summary - ThreadSummary latestSummary = collector.getLatestThreadSummary(); - if (latestSummary.getTimeStamp() != 0) { - view.setLiveThreads(Long.toString(latestSummary.getCurrentLiveThreads())); - view.setDaemonThreads(Long.toString(latestSummary.getCurrentDaemonThreads())); - } - - long lastHour = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1); - List<ThreadSummary> summaries = collector.getThreadSummary(lastHour); - if (summaries.size() != 0) { - for (ThreadSummary summary : summaries) { - model.addData(summary.getTimeStamp(), summary.getCurrentLiveThreads(), summary.getCurrentDaemonThreads()); - } - view.updateLivingDaemonTimeline(model); - } - } - } - private class ThreadActionListener implements ActionListener<ThreadAction> { @Override @@ -200,7 +135,7 @@ } private void initControllers() { - + VMThreadCapabilitiesController capsController = new VMThreadCapabilitiesController(view.createVMThreadCapabilitiesView(), collector); capsController.initialize(); @@ -208,6 +143,11 @@ ThreadTableView threadTableView = view.createThreadTableView(); threadTableView.addThreadSelectionActionListener(new ThreadSelectionActionListener()); TimerFactory tf = appService.getTimerFactory(); + + CommonController threadCountController = + new ThreadCountController(view.createThreadCountView(), collector, tf.createTimer()); + threadCountController.initialize(); + CommonController threadTableController = new ThreadTableController(threadTableView, collector, tf.createTimer()); threadTableController.initialize();
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableController.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableController.java Mon Dec 17 15:52:20 2012 -0500 @@ -44,8 +44,8 @@ import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; import com.redhat.thermostat.thread.model.ThreadInfoData; public class ThreadTableController extends CommonController {
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineController.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineController.java Mon Dec 17 15:52:20 2012 -0500 @@ -46,9 +46,9 @@ import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.Timer; import com.redhat.thermostat.thread.client.common.ThreadTimelineBean; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView.ThreadTimelineViewAction; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView.ThreadTimelineViewAction; import com.redhat.thermostat.thread.model.ThreadInfoData; public class ThreadTimelineController extends CommonController {
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesController.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesController.java Mon Dec 17 15:52:20 2012 -0500 @@ -39,8 +39,8 @@ import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.model.VMThreadCapabilities; public class VMThreadCapabilitiesController {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadCountControllerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,160 @@ +/* + * 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.thread.client.controller.impl; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.anyLong; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +import net.java.openjdk.cacio.ctc.junit.CacioFESTRunner; + +import org.jfree.chart.JFreeChart; +import org.jfree.data.xy.XYDataset; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; + +import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.common.ActionEvent; +import com.redhat.thermostat.common.ActionListener; +import com.redhat.thermostat.common.Timer; +import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; +import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadCountView; +import com.redhat.thermostat.thread.model.ThreadSummary; + +// this is not a GUI test, but testGetThreadInformation uses AWT under the hood +@RunWith(CacioFESTRunner.class) +public class ThreadCountControllerTest { + + private Timer timer; + private Runnable threadAction; + private ThreadCountView view; + private ThreadCollector collector; + + private ActionListener<ThreadCountView.Action> actionListener; + + @Before + public void setUp() { + timer = mock(Timer.class); + view = mock(ThreadCountView.class); + collector = mock(ThreadCollector.class); + } + + @Test + public void testGetThreadInformation() { + + ArgumentCaptor<LivingDaemonThreadDifferenceChart> modelCaptor = + ArgumentCaptor.forClass(LivingDaemonThreadDifferenceChart.class); + + + ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class); + doNothing().when(timer).setAction(captor.capture()); + + ThreadCountController controller = new ThreadCountController(view, collector, timer); + controller.initialize(); + + ThreadSummary summary = mock(ThreadSummary.class); + when(summary.getTimeStamp()).thenReturn(5l); + when(summary.getCurrentLiveThreads()).thenReturn(42l); + when(summary.getCurrentDaemonThreads()).thenReturn(2l); + + ThreadSummary summary0 = mock(ThreadSummary.class); + when(summary0.getTimeStamp()).thenReturn(2l); + when(summary0.getCurrentLiveThreads()).thenReturn(43l); + when(summary0.getCurrentDaemonThreads()).thenReturn(1l); + + List<ThreadSummary> summaries = new ArrayList<>(); + summaries.add(summary); + summaries.add(summary0); + + when(collector.getLatestThreadSummary()).thenReturn(summary); + when(collector.getThreadSummary(anyLong())).thenReturn(summaries); + + threadAction = captor.getValue(); + threadAction.run(); + + verify(view).setLiveThreads("42"); + verify(view).setDaemonThreads("2"); + + verify(view).updateLivingDaemonTimeline(modelCaptor.capture()); + LivingDaemonThreadDifferenceChart model = modelCaptor.getValue(); + + assertNotNull(model); + + JFreeChart chart = model.createChart(100, Color.BLACK); + XYDataset dataSet = chart.getXYPlot().getDataset(); + assertEquals(2, dataSet.getSeriesCount()); + + // total and living + assertEquals(2l, dataSet.getX(0, 0)); + assertEquals(5l, dataSet.getX(0, 1)); + + // the actual numbers + assertEquals(43.0, dataSet.getY(0, 0)); + assertEquals(42.0, dataSet.getY(0, 1)); + assertEquals(1.0, dataSet.getY(1, 0)); + assertEquals(2.0, dataSet.getY(1, 1)); + } + + @Test + public void testTimerStartAndStop() { + ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); + doNothing().when(view).addActionListener(viewArgumentCaptor.capture()); + + ThreadCountController controller = new ThreadCountController(view, collector, timer); + controller.initialize(); + + actionListener = viewArgumentCaptor.getValue(); + actionListener.actionPerformed(new ActionEvent<>(view, BasicView.Action.VISIBLE)); + + verify(timer).start(); + + actionListener.actionPerformed(new ActionEvent<>(view, BasicView.Action.HIDDEN)); + + verify(timer).stop(); + } +}
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationControllerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -41,6 +41,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.any; import org.junit.Before; import org.junit.Test; @@ -55,20 +56,20 @@ import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; -import com.redhat.thermostat.thread.client.common.ThreadTableView.ThreadSelectionAction; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView; -import com.redhat.thermostat.thread.client.common.ThreadView; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; -import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; +import com.redhat.thermostat.thread.client.common.view.ThreadCountView; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; +import com.redhat.thermostat.thread.client.common.view.ThreadView; +import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView.ThreadSelectionAction; public class ThreadInformationControllerTest { - private Timer timer; private ThreadView view; - private ActionListener<ThreadView.Action> actionListener; + private ActionListener<ThreadTableView.ThreadSelectionAction> threadTableActionListener; private ThreadViewProvider viewFactory; @@ -79,6 +80,7 @@ private ThreadTableView threadTableView; private VMThreadCapabilitiesView threadCapsView; private ThreadTimelineView threadTimelineView; + private ThreadCountView threadCountView; @Before public void setUp() { @@ -91,6 +93,7 @@ threadCapsView = mock(VMThreadCapabilitiesView.class); threadTableView = mock(ThreadTableView.class); threadTimelineView = mock(ThreadTimelineView.class); + threadCountView = mock(ThreadCountView.class); view = mock(ThreadView.class); viewFactory = mock(ThreadViewProvider.class); @@ -99,12 +102,12 @@ when(view.createVMThreadCapabilitiesView()).thenReturn(threadCapsView); when(view.createThreadTableView()).thenReturn(threadTableView); when(view.createThreadTimelineView()).thenReturn(threadTimelineView); + when(view.createThreadCountView()).thenReturn(threadCountView); + } private void setUpTimers() { - timer = mock(Timer.class); - ArgumentCaptor<Runnable> timerActionCaptor = ArgumentCaptor.forClass(Runnable.class); - doNothing().when(timer).setAction(timerActionCaptor.capture()); + Timer timer = mock(Timer.class); TimerFactory timerFactory = mock(TimerFactory.class); when(timerFactory.createTimer()).thenReturn(timer); @@ -112,15 +115,13 @@ } private void setUpListeners() { - ArgumentCaptor<ActionListener> viewArgumentCaptor = ArgumentCaptor.forClass(ActionListener.class); - doNothing().when(view).addActionListener(viewArgumentCaptor.capture()); + doNothing().when(view).addActionListener(any(ActionListener.class)); ArgumentCaptor<ActionListener> threadTableViewCaptor = ArgumentCaptor.forClass(ActionListener.class); doNothing().when(threadTableView).addThreadSelectionActionListener(threadTableViewCaptor.capture()); createController(); - actionListener = viewArgumentCaptor.getValue(); threadTableActionListener = threadTableViewCaptor.getValue(); } @@ -148,6 +149,7 @@ verify(view).createThreadTableView(); verify(view).createVMThreadCapabilitiesView(); verify(view).createThreadTimelineView(); + verify(view).createThreadCountView(); } @Test @@ -197,22 +199,6 @@ } @Test - public void testTimerStartOnViewVisible() { - setUpListeners(); - - actionListener.actionPerformed(new ActionEvent<>(view, ThreadView.Action.VISIBLE)); - verify(timer).start(); - } - - @Test - public void testTimerStopsOnViewHidden() { - setUpListeners(); - - actionListener.actionPerformed(new ActionEvent<>(view, ThreadView.Action.HIDDEN)); - verify(timer).stop(); - } - - @Test public void verifyTableViewLinksToDetailsView() { setUpListeners();
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableControllerTest.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTableControllerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -47,8 +47,8 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.thread.client.common.ThreadTableView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; public class ThreadTableControllerTest {
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineControllerTest.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/ThreadTimelineControllerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -55,10 +55,10 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.thread.client.common.ThreadTableView; import com.redhat.thermostat.thread.client.common.ThreadTimelineBean; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; import com.redhat.thermostat.thread.model.ThreadInfoData; public class ThreadTimelineControllerTest {
--- a/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-controllers/src/test/java/com/redhat/thermostat/thread/client/controller/impl/VMThreadCapabilitiesControllerTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -47,8 +47,8 @@ import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; -import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.collector.ThreadCollector; +import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.model.VMThreadCapabilities; public class VMThreadCapabilitiesControllerTest {
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/SwingThreadViewService.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/SwingThreadViewService.java Mon Dec 17 15:52:20 2012 -0500 @@ -36,8 +36,8 @@ package com.redhat.thermostat.thread.client.swing; -import com.redhat.thermostat.thread.client.common.ThreadView; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; +import com.redhat.thermostat.thread.client.common.view.ThreadView; import com.redhat.thermostat.thread.client.swing.impl.SwingThreadView; public class SwingThreadViewService implements ThreadViewProvider {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadCountView.java Mon Dec 17 15:52:20 2012 -0500 @@ -0,0 +1,110 @@ +/* + * 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.thread.client.swing.impl; + +import java.awt.Component; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; + +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import com.redhat.thermostat.client.swing.SwingComponent; +import com.redhat.thermostat.client.swing.components.ChartPanel; +import com.redhat.thermostat.client.ui.ComponentVisibleListener; +import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; +import com.redhat.thermostat.thread.client.common.view.ThreadCountView; + +public class SwingThreadCountView extends ThreadCountView implements SwingComponent { + + private ThreadAliveDaemonTimelinePanel timelinePanel; + + public SwingThreadCountView() { + timelinePanel = new ThreadAliveDaemonTimelinePanel(); + timelinePanel.addHierarchyListener(new ComponentVisibleListener() { + @Override + public void componentShown(Component component) { + SwingThreadCountView.this.notify(Action.VISIBLE); + } + @Override + public void componentHidden(Component component) { + SwingThreadCountView.this.notify(Action.HIDDEN); + } + }); + } + + public void setLiveThreads(final String liveThreads) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + timelinePanel.getLiveThreads().setText(liveThreads); + } + }); + }; + + @Override + public void updateLivingDaemonTimeline(final LivingDaemonThreadDifferenceChart model) + { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + JPanel pane = timelinePanel.getTimelinePanel(); + pane.removeAll(); + + ChartPanel charts = new ChartPanel(model.createChart(pane.getWidth(), pane.getBackground())); + pane.add(charts); + pane.revalidate(); + pane.repaint(); + } + }); + } + + @Override + public void setDaemonThreads(final String daemonThreads) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + timelinePanel.getDaemonThreads().setText(daemonThreads); + } + }); + } + + @Override + public Component getUiComponent() { + return timelinePanel; + } +}
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadDetailsView.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadDetailsView.java Mon Dec 17 15:52:20 2012 -0500 @@ -46,10 +46,10 @@ import com.redhat.thermostat.client.swing.SwingComponent; import com.redhat.thermostat.client.swing.components.ChartPanel; import com.redhat.thermostat.common.locale.Translate; -import com.redhat.thermostat.thread.client.common.ThreadDetailsView; import com.redhat.thermostat.thread.client.common.ThreadTableBean; import com.redhat.thermostat.thread.client.common.chart.ThreadDeatailsPieChart; import com.redhat.thermostat.thread.client.common.locale.LocaleResources; +import com.redhat.thermostat.thread.client.common.view.ThreadDetailsView; public class SwingThreadDetailsView extends ThreadDetailsView implements SwingComponent {
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTableView.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTableView.java Mon Dec 17 15:52:20 2012 -0500 @@ -53,9 +53,9 @@ import com.redhat.thermostat.client.swing.components.ThermostatTable; import com.redhat.thermostat.client.ui.ComponentVisibleListener; import com.redhat.thermostat.thread.client.common.locale.LocaleResources; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; public class SwingThreadTableView extends ThreadTableView implements SwingComponent {
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTimelineChart.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTimelineChart.java Mon Dec 17 15:52:20 2012 -0500 @@ -59,9 +59,9 @@ import com.redhat.thermostat.client.swing.components.GradientRoundBorder; import com.redhat.thermostat.client.swing.components.GraphicsUtils; -import com.redhat.thermostat.client.swing.components.models.LongRange; -import com.redhat.thermostat.client.swing.components.models.LongRangeNormalizer; import com.redhat.thermostat.client.ui.Palette; +import com.redhat.thermostat.common.model.LongRange; +import com.redhat.thermostat.common.model.LongRangeNormalizer; import com.redhat.thermostat.thread.client.common.ThreadTimelineBean; import com.redhat.thermostat.thread.client.common.chart.ChartColors;
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTimelineView.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadTimelineView.java Mon Dec 17 15:52:20 2012 -0500 @@ -59,7 +59,7 @@ import com.redhat.thermostat.client.swing.SwingComponent; import com.redhat.thermostat.client.ui.ComponentVisibleListener; import com.redhat.thermostat.thread.client.common.ThreadTimelineBean; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; import com.redhat.thermostat.thread.model.ThreadInfoData; public class SwingThreadTimelineView extends ThreadTimelineView implements SwingComponent {
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadView.java Mon Dec 17 15:52:20 2012 -0500 @@ -55,26 +55,28 @@ import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; -import com.redhat.thermostat.thread.client.common.ThreadTimelineView; -import com.redhat.thermostat.thread.client.common.ThreadView; -import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.client.common.chart.LivingDaemonThreadDifferenceChart; import com.redhat.thermostat.thread.client.common.locale.LocaleResources; +import com.redhat.thermostat.thread.client.common.view.ThreadCountView; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; +import com.redhat.thermostat.thread.client.common.view.ThreadTimelineView; +import com.redhat.thermostat.thread.client.common.view.ThreadView; +import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; public class SwingThreadView extends ThreadView implements SwingComponent { private String DIVIDER_LOCATION_KEY; private ThreadMainPanel panel; - private ThreadAliveDaemonTimelinePanel timelinePanel; + private SwingThreadCountView threadCountView; private SwingThreadTableView threadTableView; private SwingVMThreadCapabilitiesView vmCapsView; private SwingThreadTimelineView threadTimelineView; private SwingThreadDetailsView threadDetailsView; - private JTabbedPane pane; + private JTabbedPane topPane; + private JTabbedPane bottomPane; private static final Translate<LocaleResources> t = LocaleResources.createLocalizer(); @@ -109,7 +111,6 @@ } }); - timelinePanel = new ThreadAliveDaemonTimelinePanel(); panel.getToggleButton().setToolTipText(t.localize(LocaleResources.START_RECORDING)); panel.getToggleButton().setText(t.localize(LocaleResources.THREAD_MONITOR_SWITCH)); panel.getToggleButton().addItemListener(new ItemListener() @@ -140,25 +141,38 @@ } }); - panel.getSplitPane().setTopComponent(timelinePanel); + setupTopPane(); + setupBottomPane(); + } + + private void setupTopPane() { + topPane = new JTabbedPane(); + topPane.setName("topTabbedPane"); - vmCapsView = new SwingVMThreadCapabilitiesView(); - pane = new JTabbedPane(); - pane.setName("tabbedPane"); + threadTimelineView = new SwingThreadTimelineView(); + topPane.addTab(t.localize(LocaleResources.TIMELINE), threadTimelineView.getUiComponent()); + + threadCountView = new SwingThreadCountView(); + topPane.addTab(t.localize(LocaleResources.THREAD_COUNT), threadCountView.getUiComponent()); - pane.addTab(t.localize(LocaleResources.VM_CAPABILITIES), vmCapsView.getUiComponent()); + panel.getSplitPane().setTopComponent(topPane); + } + + private void setupBottomPane() { + bottomPane = new JTabbedPane(); + bottomPane.setName("bottomTabbedPane"); threadTableView = new SwingThreadTableView(); - pane.addTab(t.localize(LocaleResources.TABLE), threadTableView.getUiComponent()); + bottomPane.addTab(t.localize(LocaleResources.TABLE), threadTableView.getUiComponent()); threadDetailsView = new SwingThreadDetailsView(); - pane.addTab(t.localize(LocaleResources.DETAILS), threadDetailsView.getUiComponent()); - threadDetailsPaneID = 2; - - threadTimelineView = new SwingThreadTimelineView(); - pane.addTab(t.localize(LocaleResources.TIMELINE), threadTimelineView.getUiComponent()); - - panel.getSplitPane().setBottomComponent(pane); + bottomPane.addTab(t.localize(LocaleResources.DETAILS), threadDetailsView.getUiComponent()); + threadDetailsPaneID = 1; + + vmCapsView = new SwingVMThreadCapabilitiesView(); + bottomPane.addTab(t.localize(LocaleResources.VM_CAPABILITIES), vmCapsView.getUiComponent()); + + panel.getSplitPane().setBottomComponent(bottomPane); } @Override @@ -185,42 +199,6 @@ } @Override - public void setDaemonThreads(final String daemonThreads) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - timelinePanel.getDaemonThreads().setText(daemonThreads); - } - }); - } - - public void setLiveThreads(final String liveThreads) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - timelinePanel.getLiveThreads().setText(liveThreads); - } - }); - }; - - @Override - public void updateLivingDaemonTimeline(final LivingDaemonThreadDifferenceChart model) - { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - JPanel pane = timelinePanel.getTimelinePanel(); - pane.removeAll(); - - ChartPanel charts = new ChartPanel(model.createChart(pane.getWidth(), pane.getBackground())); - pane.add(charts); - pane.revalidate(); - pane.repaint(); - } - }); - } - - @Override public VMThreadCapabilitiesView createVMThreadCapabilitiesView() { return vmCapsView; } @@ -262,7 +240,7 @@ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - pane.setSelectedIndex(threadDetailsPaneID); + bottomPane.setSelectedIndex(threadDetailsPaneID); threadDetailsView.setDetails(thread); } }); @@ -272,4 +250,9 @@ public ThreadTimelineView createThreadTimelineView() { return threadTimelineView; } + + @Override + public ThreadCountView createThreadCountView() { + return threadCountView; + } }
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVMThreadCapabilitiesView.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVMThreadCapabilitiesView.java Mon Dec 17 15:52:20 2012 -0500 @@ -43,7 +43,7 @@ import com.redhat.thermostat.client.swing.SwingComponent; import com.redhat.thermostat.client.ui.ComponentVisibleListener; -import com.redhat.thermostat.thread.client.common.VMThreadCapabilitiesView; +import com.redhat.thermostat.thread.client.common.view.VMThreadCapabilitiesView; import com.redhat.thermostat.thread.model.VMThreadCapabilities; public class SwingVMThreadCapabilitiesView extends VMThreadCapabilitiesView implements SwingComponent {
--- a/thread/client-swing/src/test/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadViewTest.java Mon Dec 17 15:26:45 2012 -0500 +++ b/thread/client-swing/src/test/java/com/redhat/thermostat/thread/client/swing/impl/SwingThreadViewTest.java Mon Dec 17 15:52:20 2012 -0500 @@ -69,9 +69,9 @@ import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.thread.client.common.ThreadTableBean; -import com.redhat.thermostat.thread.client.common.ThreadTableView; -import com.redhat.thermostat.thread.client.common.ThreadTableView.ThreadSelectionAction; import com.redhat.thermostat.thread.client.common.locale.LocaleResources; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView; +import com.redhat.thermostat.thread.client.common.view.ThreadTableView.ThreadSelectionAction; @RunWith(CacioFESTRunner.class) public class SwingThreadViewTest { @@ -159,7 +159,7 @@ frameFixture.show(); frameFixture.splitPane("threadMainPanelSplitPane").moveDividerTo(0); - frameFixture.tabbedPane("tabbedPane").selectTab(1); + frameFixture.tabbedPane("bottomTabbedPane").selectTab(0); final Semaphore sem = new Semaphore(1); ThreadTableView tableView = view.createThreadTableView(); @@ -178,6 +178,6 @@ sem.acquire(); assertTrue(listenerCalled[0]); - assertEquals(2, frameFixture.tabbedPane("tabbedPane").target.getSelectedIndex()); + assertEquals(1, frameFixture.tabbedPane("bottomTabbedPane").target.getSelectedIndex()); } }