# HG changeset patch # User Jon VanAlten # Date 1401734717 21600 # Node ID 58bb4fce5f5c147016d823de9ca4eb019e188c72 # Parent 60643e432434eb6ec46ce939d3bfbfd430fc206f Drop deprecated eclipse client reviewed-by: jerboaa, omajid, neugens review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-March/009443.html Backport bug: PR1817 diff -r 60643e432434 -r 58bb4fce5f5c Makefile --- a/Makefile Mon Jun 02 10:08:04 2014 -0600 +++ b/Makefile Mon Jun 02 12:45:17 2014 -0600 @@ -5,10 +5,6 @@ BUILD_DOCS ?= false REPO_LOC ?= $(HOME)/.thermostat-build/mvn_repository/ MAVEN_FLAGS ?= -USE_VNC ?= false -VNC ?= vncserver -VNC_DISPLAY ?= :10 -VNC_FLAGS ?= -SecurityTypes None XSLTPROC ?= xsltproc # @@ -27,54 +23,18 @@ MAVEN_JAVADOC = javadoc:aggregate endif -ifeq ($(USE_VNC),true) - DISPLAY = $(VNC_DISPLAY) -endif +all: core -# Default to cleaning the local repo and building core + eclipse -# Cleaning the repo prevents things like not seeing build failures -# after bundles have been renamed. -all: clean-repo eclipse eclipse-test - +# Default to just building core core: $(MAVEN) -f $(POM) $(MAVEN_FLAGS) $(MAVEN_SKIP_TEST) clean $(GOAL) $(MAVEN_JAVADOC) -core-install: create-repo-dir +# +# Cleaning the repo prevents things like not seeing build failures +# after bundles have been renamed. +core-install: clean-repo create-repo-dir $(MAVEN) -f $(POM) $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean install $(MAVEN_JAVADOC) -copy-core-natives: core-install - if [ "_$(ARCH)" = "_x86_64" ]; then \ - cp keyring/target/libGnomeKeyringWrapper.so eclipse/com.redhat.thermostat.client.feature/linux_x86_64; \ - else \ - cp keyring/target/libGnomeKeyringWrapper.so eclipse/com.redhat.thermostat.client.feature/linux_x86; \ - fi - -eclipse-test: eclipse eclipse-test-p2 -ifeq ($(USE_VNC),true) - $(VNC) $(VNC_DISPLAY) $(VNC_FLAGS) -endif - -$(MAVEN) -f eclipse/com.redhat.thermostat.eclipse.test/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean $(GOAL) - -$(MAVEN) -f eclipse/com.redhat.thermostat.eclipse.test.ui/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean $(GOAL) -ifeq ($(USE_VNC),true) - $(VNC) -kill $(VNC_DISPLAY) -endif - -eclipse-test-deps: copy-core-natives - $(MAVEN) -f eclipse/test-deps-bundle-wrapping/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean install - -eclipse-test-p2: eclipse-test-deps - $(MAVEN) -f eclipse/com.redhat.thermostat.eclipse.test.deps.feature/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean install - $(MAVEN) -f eclipse/test-deps-p2-repository/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean $(GOAL) - -jfreechart-deps: copy-core-natives - $(MAVEN) -f eclipse/jfreechart-bundle-wrapping/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean install - -jfreechart-p2: jfreechart-deps - $(MAVEN) -f eclipse/jfreechart-p2-repository/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean $(GOAL) - -eclipse: jfreechart-p2 - $(MAVEN) -f eclipse/pom.xml $(MAVEN_FLAGS) $(REPO_FLAG) $(MAVEN_SKIP_TEST) clean install - create-repo-dir: mkdir -p $(REPO_LOC) @@ -82,10 +42,6 @@ if [ -d $(REPO_LOC) ] ; then \ find $(REPO_LOC) -name '*thermostat*' -print0 | xargs -0 rm -rf ; \ fi - rm -rf $(REPO_LOC).cache/tycho/ - rm -rf eclipse/core-p2-repository/target - rm -rf eclipse/test-deps-p2-repository/target - rm -rf eclipse/jfreechart-p2-repository/target echo-repo: echo "Using private Maven repository: $(REPO_LOC)" @@ -98,4 +54,4 @@ $(XSLTPROC) distribution/tools/plugin-docs-html.xslt merged-plugin-docs.xml > $@ # We only have phony targets -.PHONY: all core core-install copy-core-natives eclipse-test eclipse-test-p2 eclipse-test-deps jfreechart-deps jfreechart-p2 eclipse create-repo-dir clean-repo echo-repo plugin-docs +.PHONY: all core core-install create-repo-dir clean-repo echo-repo plugin-docs diff -r 60643e432434 -r 58bb4fce5f5c README --- a/README Mon Jun 02 10:08:04 2014 -0600 +++ b/README Mon Jun 02 12:45:17 2014 -0600 @@ -7,12 +7,10 @@ 1. REQUIREMENTS 2. BUILDING THERMOSTAT 2.1 BUILDING THERMOSTAT CORE -2.2 BUILDING THERMOSTAT ECLIPSE (optional) 3. RUNNING THERMOSTAT 3.1 RUNNING THERMOSTAT CORE 3.1.1 PASSING JVM SPECIFIC OPTIONS 3.1.2 GNOME KEYRING -3.2 RUNNING THERMOSTAT ECLIPSE 4. EXTENDING THERMOSTAT 5. REFERENCES @@ -63,15 +61,17 @@ * The thermostat agent * The web service layer (plugged-in optionally) -Thermostat Eclipse is an Eclipse-based Thermostat client. At this point the -Eclipse-based client is experimental. - -------------------------------------------------------------------------------- 2.1. BUILDING THERMOSTAT CORE 2.1.1. Run "mvn clean install". All tests should pass and the build should succeed. It requires a graphical environment for the ui tests. + + Thermostat also includes a Makefile wrapping the maven build. In most + cases, simply running "make" will accomplish the same as "mvn clean + install". Please see environment variables near beginning of + Makefile for some options that can be customized. You can skip the tests phase by running: @@ -86,26 +86,6 @@ distribution/target/image. -------------------------------------------------------------------------------- -2.2. BUILDING THERMOSTAT ECLIPSE (optional) - -2.2.1. - Run "make". This will build both, Thermostat Core and Thermostat Eclipse, - since Eclipse bits depend on Thermostat Core. All tests should pass and the - build should succeed. Running Eclipse plug-in tests will open an Eclipse - instance during build. This requires a working graphical environment and - DISPLAY. - - You can skip the tests phase by running: - - make SKIP_TESTS=true - -2.2.2. - This produces a local "update-site" or p2 repository from which you can - install Thermostat Eclipse into your Eclipse. The repository is at: - - eclipse/composite-repo/target/composite-repo - --------------------------------------------------------------------------------- 3. RUNNING THERMOSTAT -------------------------------------------------------------------------------- @@ -151,31 +131,6 @@ will be stored. -------------------------------------------------------------------------------- -3.2. RUNNING THERMOSTAT ECLIPSE - - Note that the Thermostat Eclipse client is an experimental feature at this - point. - - The "eclipse/composite-repo/target/composite-repo" directory was - produced during step 2.2. In order to use this local repository - follow these steps: - - "Help" => "Install New Software..." - "Add..." - "Local..." - Select "eclipse/composite-repo/target/composite-repo" - Give it any name you like and click "OK". - Select "Thermostat Eclipse Plug-ins", then "Next >" - Click through dialog, accepting options. - - After this you should be able to open the Thermostat Eclipse perspective: - "Window" => "Open Perspective" => "Other..." => "Thermostat" - - Next, make sure you've got the thermostat service running (see above) and - click the "Connect" link/icon. Enjoy! - - --------------------------------------------------------------------------------- 4. EXTENDING THERMOSTAT The README.api file contains a list of public/support API of thermostat. diff -r 60643e432434 -r 58bb4fce5f5c eclipse/README.building --- a/eclipse/README.building Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -# perhaps set -Dmaven.repo.local=/desired/path -# for all of mvn commands below. -cd path/to/thermostat/home -# Build core Thermostat -mvn clean install -# Build Eclipse client -mvn -f eclipse/jfreechart-bundle-wrapping/pom.xml clean install -mvn -f eclipse/jfreechart-p2-repository/pom.xml clean package -mvn -f eclipse/pom.xml clean install -# Build and run Eclipse client tests -mvn -f eclipse/test-deps-bundle-wrapping/pom.xml clean install -mvn -f eclipse/com.redhat.thermostat.eclipse.test.deps.feature/pom.xml clean install -mvn -f eclipse/test-deps-p2-repository/pom.xml clean package -mvn -f eclipse/com.redhat.thermostat.eclipse.test/pom.xml clean package -mvn -f eclipse/com.redhat.thermostat.eclipse.test.ui/pom.xml clean package diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/.project --- a/eclipse/com.redhat.thermostat.client.feature/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - com.redhat.thermostat.client.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/build.properties --- a/eclipse/com.redhat.thermostat.client.feature/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -bin.includes = feature.xml - -root.linux.gtk.x86=linux_x86 -root.linux.gtk.x86_64=linux_x86_64 -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/feature.xml --- a/eclipse/com.redhat.thermostat.client.feature/feature.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,249 +0,0 @@ - - - - - Plug-ins necessary for a Thermostat client interface. - - - - Copyright 2012, 2013 Red Hat, Inc. - - - - Copyright 2012, 2013 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/linux_x86/.empty --- a/eclipse/com.redhat.thermostat.client.feature/linux_x86/.empty Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -File in order to trick hg into tracking the parent folder. diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/linux_x86_64/.empty --- a/eclipse/com.redhat.thermostat.client.feature/linux_x86_64/.empty Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -File in order to trick hg into tracking the parent folder. diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.client.feature/pom.xml --- a/eclipse/com.redhat.thermostat.client.feature/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - - Thermostat Client Feature - - - ${basedir}/.. - - - - - com.redhat.thermostat - thermostat-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-host-overview-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-host-cpu-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-host-memory-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-vm-cpu-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-vm-memory-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-vm-gc-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-vm-classstat-client-core - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-web-client - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-web-common - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-storage-mongodb - 1.0.3-SNAPSHOT - - - com.redhat.thermostat - thermostat-storage-core - 1.0.3-SNAPSHOT - - - - - - - - src - - **/*.java - - - - - - org.eclipse.tycho - tycho-source-plugin - - - org.eclipse.tycho - tycho-packaging-plugin - ${tycho-version} - - true - - - - - eclipse-feature - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/.classpath --- a/eclipse/com.redhat.thermostat.eclipse.boot/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/.project --- a/eclipse/com.redhat.thermostat.eclipse.boot/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse.boot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/.settings/org.eclipse.jdt.core.prefs --- a/eclipse/com.redhat.thermostat.eclipse.boot/.settings/org.eclipse.jdt.core.prefs Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/.settings/org.eclipse.pde.prefs --- a/eclipse/com.redhat.thermostat.eclipse.boot/.settings/org.eclipse.pde.prefs Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -compilers.f.unresolved-features=1 -compilers.f.unresolved-plugins=1 -compilers.incompatible-environment=1 -compilers.p.build=1 -compilers.p.build.bin.includes=1 -compilers.p.build.encodings=2 -compilers.p.build.java.compiler=2 -compilers.p.build.java.compliance=1 -compilers.p.build.missing.output=2 -compilers.p.build.output.library=1 -compilers.p.build.source.library=1 -compilers.p.build.src.includes=1 -compilers.p.deprecated=1 -compilers.p.discouraged-class=1 -compilers.p.internal=1 -compilers.p.missing-packages=2 -compilers.p.missing-version-export-package=2 -compilers.p.missing-version-import-package=2 -compilers.p.missing-version-require-bundle=2 -compilers.p.no-required-att=0 -compilers.p.not-externalized-att=2 -compilers.p.unknown-attribute=1 -compilers.p.unknown-class=1 -compilers.p.unknown-element=1 -compilers.p.unknown-identifier=1 -compilers.p.unknown-resource=1 -compilers.p.unresolved-ex-points=0 -compilers.p.unresolved-import=2 -compilers.s.create-docs=false -compilers.s.doc-folder=doc -compilers.s.open-tags=1 -eclipse.preferences.version=1 diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.boot/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Thermostat Eclipse client boot exports -Bundle-SymbolicName: com.redhat.thermostat.eclipse.boot -Bundle-Version: 1.0.3.qualifier -Bundle-Vendor: Redhat Inc. -Fragment-Host: system.bundle -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Export-Package: sun.swing, - sun.swing.table, - sun.misc, - sun.jvm.hotspot.tools, - com.sun.tools.hat.internal.model, - com.sun.tools.hat.internal.parser, - com.sun.tools.attach, - sun.jvmstat, - sun.jvmstat.monitor, - sun.jvmstat.monitor.event diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.boot/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.boot/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.boot - eclipse-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse Client Boot Package - - - ${basedir}/.. - - - - - - - src - - **/*.java - - - - - - org.eclipse.tycho - tycho-source-plugin - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.boot/src/.dummy.txt --- a/eclipse/com.redhat.thermostat.eclipse.boot/src/.dummy.txt Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -This file is simply there to make Eclipse happy and have some src folder. \ No newline at end of file diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/.classpath --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/.project --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse.chart.common - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Thermostat Eclipse Charting -Bundle-SymbolicName: com.redhat.thermostat.eclipse.chart.common;singleton:=true -Bundle-Version: 1.0.3.qualifier -Bundle-Activator: com.redhat.thermostat.eclipse.chart.common.Activator -Bundle-Vendor: Red Hat Inc. -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: com.redhat.thermostat.client.core.controllers, - com.redhat.thermostat.client.core.views, - com.redhat.thermostat.client.locale, - com.redhat.thermostat.client.ui, - com.redhat.thermostat.common, - com.redhat.thermostat.shared.locale, - com.redhat.thermostat.common.utils, - com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.views, - com.redhat.thermostat.host.cpu.client.core, - com.redhat.thermostat.host.cpu.client.locale, - com.redhat.thermostat.host.memory.client.core, - com.redhat.thermostat.host.memory.client.locale, - com.redhat.thermostat.storage.core, - com.redhat.thermostat.storage.dao, - com.redhat.thermostat.storage.model, - com.redhat.thermostat.vm.cpu.client.core, - com.redhat.thermostat.vm.cpu.client.locale, - com.redhat.thermostat.vm.gc.client.core, - com.redhat.thermostat.vm.gc.client.locale, - org.jfree.chart, - org.jfree.chart.axis, - org.jfree.chart.event, - org.jfree.chart.plot, - org.jfree.chart.renderer.xy, - org.jfree.data, - org.jfree.data.general, - org.jfree.data.time, - org.jfree.data.xy, - org.jfree.util, - org.osgi.framework;version="1.3.0" -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime;bundle-version="3.8.0", - com.redhat.thermostat.eclipse;bundle-version="0.8.0" -Export-Package: com.redhat.thermostat.eclipse.chart.common diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/plugin.xml --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/plugin.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.chart.common - eclipse-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse Charting - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/Activator.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/Activator.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; -import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; -import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; - -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.redhat.thermostat.eclipse.chart.common"; //$NON-NLS-1$ - - private static Activator plugin; - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - // Register our ViewProviders - context.registerService(HostCpuViewProvider.class, new SWTHostCpuViewProvider(), null); - context.registerService(HostMemoryViewProvider.class, new SWTHostMemoryViewProvider(), null); - context.registerService(VmCpuViewProvider.class, new SWTVmCpuViewProvider(), null); - context.registerService(VmGcViewProvider.class, new SWTVmGcViewProvider(), null); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - public static Activator getDefault() { - return plugin; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.views.HostRefViewPart; -import com.redhat.thermostat.host.cpu.client.core.HostCpuService; -import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; - -public class HostCpuViewPart extends HostRefViewPart { - - public HostCpuViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public HostCpuViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return HostCpuViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return HostCpuService.SERVICE_ID; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.views.HostRefViewPart; -import com.redhat.thermostat.host.memory.client.core.HostMemoryService; -import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; - -public class HostMemoryViewPart extends HostRefViewPart { - - public HostMemoryViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public HostMemoryViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return HostMemoryViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return HostMemoryService.SERVICE_ID; - } - -} \ No newline at end of file diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartComposite.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/RecentTimeSeriesChartComposite.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,240 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.Frame; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.awt.SWT_AWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowData; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; - -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.ThermostatConstants; - -public class RecentTimeSeriesChartComposite extends Composite { - public static final String TEST_ID_UNIT_COMBO = "RecentTimeSeriesChartComposite.timeUnit"; - public static final String TEST_ID_DURATION_TEXT = "RecentTimeSeriesChartComposite.timeDuration"; - - private static final int MINIMUM_DRAW_SIZE = 100; - private static final Translate translator = LocaleResources.createLocalizer(); - - private final RecentTimeSeriesChartController controller; - - private Composite labelContainer; - private Label label; - private Combo unitSelector; - private Text durationSelector; - - public RecentTimeSeriesChartComposite(Composite parent, int style, JFreeChart chart) { - super(parent, style); - this.setLayout(new GridLayout()); - - Composite top = new Composite(this, SWT.NONE | SWT.EMBEDDED); - top.setLayout(new GridLayout()); - top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - Frame frame = SWT_AWT.new_Frame(top); - this.controller = new RecentTimeSeriesChartController(chart); - - ChartPanel cp = controller.getChartPanel(); - frame.add(cp); - - cp.setDisplayToolTips(false); - cp.setDoubleBuffered(true); - cp.setMouseZoomable(false); - cp.setPopupMenu(null); - - /* - * By default, ChartPanel scales itself instead of redrawing things when - * it's resized. To have it resize automatically, we need to set minimum - * and maximum sizes. Lets constrain the minimum, but not the maximum - * size. - */ - cp.setMinimumDrawHeight(MINIMUM_DRAW_SIZE); - cp.setMaximumDrawHeight(Integer.MAX_VALUE); - cp.setMinimumDrawWidth(MINIMUM_DRAW_SIZE); - cp.setMaximumDrawWidth(Integer.MAX_VALUE); - - getControlsAndAdditionalDisplay(this); - } - - private Composite getControlsAndAdditionalDisplay(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - GridLayout containerLayout = new GridLayout(2, false); - containerLayout.marginHeight = 0; - container.setLayout(containerLayout); - - getChartControls(container); - getAdditionalDataDisplay(container); - - return container; - } - - private Composite getChartControls(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - RowLayout topLayout = new RowLayout(SWT.HORIZONTAL); - topLayout.center = true; - topLayout.marginHeight = 0; - container.setLayout(topLayout); - - Label prompt = new Label(container, SWT.NONE); - prompt.setText(translator.localize(LocaleResources.CHART_DURATION_SELECTOR_LABEL).getContents()); - - durationSelector = new Text(container, SWT.BORDER); - durationSelector.setData(ThermostatConstants.TEST_TAG, TEST_ID_DURATION_TEXT); - // Make 5 chars wide - GC gc = new GC(durationSelector); - FontMetrics metrics = gc.getFontMetrics(); - int width = metrics.getAverageCharWidth() * 5; - int height = metrics.getHeight(); - gc.dispose(); - durationSelector.setLayoutData(new RowData(computeSize(width, height))); - - unitSelector = new Combo(container, SWT.NONE); - unitSelector.setData(ThermostatConstants.TEST_TAG, TEST_ID_UNIT_COMBO); - TimeUnit[] units = controller.getTimeUnits(); - for (TimeUnit unit : units) { - unitSelector.add(unit.toString()); - } - - int defaultValue = controller.getTimeValue(); - TimeUnit defaultUnit = controller.getTimeUnit(); - - TimeUnitChangeListener timeUnitChangeListener = new TimeUnitChangeListener(controller, defaultValue, defaultUnit); - - durationSelector.addModifyListener(timeUnitChangeListener); - unitSelector.addSelectionListener(timeUnitChangeListener); - - durationSelector.setText(String.valueOf(defaultValue)); - int defaultPos = Arrays.asList(units).indexOf(defaultUnit); - unitSelector.select(defaultPos); - - return container; - } - - private Composite getAdditionalDataDisplay(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - GridLayout topLayout = new GridLayout(); - topLayout.marginHeight = 0; - top.setLayout(topLayout); - top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - labelContainer = new Composite(top, SWT.NONE); - return top; - } - - public void setDataInformationLabel(final String text) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (label == null) { - label = new Label(labelContainer, SWT.NONE); - } - - label.setText(text); - } - }); - } - - private class TimeUnitChangeListener implements SelectionListener, ModifyListener { - - private final RecentTimeSeriesChartController controller; - private int value; - private TimeUnit unit; - - public TimeUnitChangeListener(RecentTimeSeriesChartController controller, int defaultValue, TimeUnit defaultUnit) { - this.controller = controller; - this.value = defaultValue; - this.unit = defaultUnit; - } - - private void updateChartParameters() { - controller.setTime(value, unit); - } - - @Override - public void modifyText(ModifyEvent e) { - if (durationSelector.equals(e.widget)) { - try { - this.value = Integer.valueOf(durationSelector.getText()); - updateChartParameters(); - } catch (NumberFormatException nfe) { - // ignore - } - } - } - - @Override - public void widgetSelected(SelectionEvent e) { - if (unitSelector.equals(e.widget)) { - int idx = unitSelector.getSelectionIndex(); - if (idx >= 0) { - unit = controller.getTimeUnits()[idx]; - updateChartParameters(); - } - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - } - - public RecentTimeSeriesChartController getController() { - return controller; - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostCpuView.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostCpuView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,311 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.Color; -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.renderer.xy.XYItemRenderer; -import org.jfree.data.time.FixedMillisecond; -import org.jfree.data.time.RegularTimePeriod; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; - -import com.redhat.thermostat.host.cpu.client.core.HostCpuView; -import com.redhat.thermostat.host.cpu.client.locale.LocaleResources; -import com.redhat.thermostat.client.ui.ChartColors; -import com.redhat.thermostat.shared.locale.LocalizedString; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -public class SWTHostCpuView extends HostCpuView implements SWTComponent { - public static final String TEST_ID_CPU_MODEL = "SWTHostCpuView.cpuModel"; - public static final String TEST_ID_CPU_COUNT = "SWTHostCpuView.cpuCount"; - public static final String TEST_ID_LEGEND_ITEM = "SWTHostCpuView.legendItem"; - - private static final String LEGEND_COLOUR_BLOCK = "\u2588"; - private static final int H_INDENT = 20; - private static final int SPACER_WIDTH = 10; - private static final Translate translator = LocaleResources.createLocalizer(); - - private JFreeChart chart; - private TimeSeriesCollection datasetCollection; - private Label cpuModel; - private Label cpuCount; - - private final Map datasets; - private final Map colors; - private Composite chartTop; - private Composite legendTop; - private Composite parent; - - public SWTHostCpuView(Composite parent) { - this.parent = parent; - datasetCollection = new TimeSeriesCollection(); - datasets = new HashMap(); - colors = new HashMap(); - chart = createCpuChart(); - - Label summaryLabel = new Label(parent, SWT.LEAD); - Font stdFont = summaryLabel.getFont(); - Font boldFont = new Font(stdFont.getDevice(), - stdFont.getFontData()[0].getName(), - stdFont.getFontData()[0].getHeight(), SWT.BOLD); - - summaryLabel.setText(translator.localize(LocaleResources.HOST_CPU_SECTION_OVERVIEW).getContents()); - summaryLabel.setFont(boldFont); - - Composite detailsTop = new Composite(parent, SWT.NONE); - detailsTop.setLayout(new GridLayout(3, false)); - - Label cpuModelLabel = new Label(detailsTop, SWT.TRAIL); - cpuModelLabel.setText(translator.localize(LocaleResources.HOST_INFO_CPU_MODEL).getContents()); - GridData hIndentLayoutData = new GridData(); - hIndentLayoutData.horizontalIndent = H_INDENT; - cpuModelLabel.setLayoutData(hIndentLayoutData); - - Label cpuModelSpacer = new Label(detailsTop, SWT.NONE); - cpuModelSpacer.setLayoutData(new GridData(SPACER_WIDTH, SWT.DEFAULT)); - - cpuModel = new Label(detailsTop, SWT.LEAD); - cpuModel.setData(ThermostatConstants.TEST_TAG, TEST_ID_CPU_MODEL); - cpuModel.setText("Unknown"); - - Label cpuCountLabel = new Label(detailsTop, SWT.TRAIL); - cpuCountLabel.setText(translator.localize(LocaleResources.HOST_INFO_CPU_COUNT).getContents()); - cpuCountLabel.setLayoutData(hIndentLayoutData); - - Label cpuCountSpacer = new Label(detailsTop, SWT.NONE); - cpuCountSpacer.setLayoutData(new GridData(SPACER_WIDTH, SWT.DEFAULT)); - - cpuCount = new Label(detailsTop, SWT.LEAD); - cpuCount.setData(ThermostatConstants.TEST_TAG, TEST_ID_CPU_COUNT); - cpuCount.setText("Unknown"); - - chartTop = new RecentTimeSeriesChartComposite(parent, SWT.NONE, chart); - chartTop.setLayout(new GridLayout()); - chartTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - legendTop = new Composite(parent, SWT.NONE); - RowLayout legendLayout = new RowLayout(SWT.HORIZONTAL); - legendLayout.center = true; - legendLayout.wrap = false; - legendLayout.marginHeight = 0; - legendTop.setLayout(legendLayout); - } - - private JFreeChart createCpuChart() { - JFreeChart chart = ChartFactory.createTimeSeriesChart(null, - translator.localize(LocaleResources.HOST_CPU_USAGE_CHART_TIME_LABEL).getContents(), - translator.localize(LocaleResources.HOST_CPU_USAGE_CHART_VALUE_LABEL).getContents(), - datasetCollection, false, false, false); - - chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 0)); - chart.getPlot().setBackgroundImageAlpha(0.0f); - chart.getPlot().setOutlinePaint(new Color(0, 0, 0, 0)); - - return chart; - } - - public void setCpuCount(final String count) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!cpuCount.isDisposed()) { - cpuCount.setText(count); - } - } - }); - } - - public void setCpuModel(final String model) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!cpuModel.isDisposed()) { - cpuModel.setText(model); - } - } - }); - } - - @Override - public void addCpuUsageChart(final int cpuIndex, final LocalizedString name) { - EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - String theName = name.getContents(); - TimeSeries series = new TimeSeries(theName); - Color color = ChartColors.getColor(colors.size()); - colors.put(theName, color); - - datasets.put(cpuIndex, series); - datasetCollection.addSeries(series); - - updateColors(); - - addLegendItem(theName, color); - } - }); - } - - @Override - public void addCpuUsageData(final int cpuIndex, List> data) { - final ArrayList> copy = new ArrayList<>(data); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries dataset = datasets.get(cpuIndex); - for (DiscreteTimeData timeData: copy) { - RegularTimePeriod period = new FixedMillisecond(timeData.getTimeInMillis()); - if (dataset.getDataItem(period) == null) { - dataset.add(period, timeData.getData(), false); - } - } - dataset.fireSeriesChanged(); - } - }); - } - - @Override - public void clearCpuUsageData() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - for (Iterator> iter = datasets.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = iter.next(); - datasetCollection.removeSeries(entry.getValue()); - entry.getValue().clear(); - - iter.remove(); - - } - updateColors(); - } - }); - } - - /** - * Adding or removing series to the series collection may change the order - * of existing items. Plus the paint for the index is now out-of-date. So - * let's walk through all the series and set the right paint for those. - */ - private void updateColors() { - XYItemRenderer itemRenderer = chart.getXYPlot().getRenderer(); - for (int i = 0; i < datasetCollection.getSeriesCount(); i++) { - String tag = (String) datasetCollection.getSeriesKey(i); - Color color = colors.get(tag); - itemRenderer.setSeriesPaint(i, color); - } - } - - - private Composite createLabelWithLegend(Composite parent, String text, Color color) { - Composite top = new Composite(parent, SWT.NONE); - GridLayout topLayout = new GridLayout(2, false); - topLayout.marginHeight = 0; - top.setLayout(topLayout); - - Label colourBlock = new Label(top, SWT.NONE); - colourBlock.setText(LEGEND_COLOUR_BLOCK); - - // Convert to SWT colour - final org.eclipse.swt.graphics.Color swtColour = new org.eclipse.swt.graphics.Color( - PlatformUI.getWorkbench().getDisplay(), color.getRed(), - color.getGreen(), color.getBlue()); - colourBlock.addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - swtColour.dispose(); - } - }); - colourBlock.setForeground(swtColour); - - Label colourText = new Label(top, SWT.NONE); - colourText.setData(ThermostatConstants.TEST_TAG, TEST_ID_LEGEND_ITEM); - colourText.setText(text); - return top; - } - - private void addLegendItem(final String humanReadableName, final Color color) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - createLabelWithLegend(legendTop, humanReadableName, - color); - parent.layout(); - } - }); - } - - public JFreeChart getChart() { - return chart; - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostCpuViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostCpuViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.host.cpu.client.core.HostCpuView; -import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; - -public class SWTHostCpuViewProvider extends SWTViewProvider implements - HostCpuViewProvider { - - @Override - public HostCpuView createView() { - return new SWTHostCpuView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostMemoryView.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostMemoryView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,393 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.Color; -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.renderer.xy.XYItemRenderer; -import org.jfree.data.time.FixedMillisecond; -import org.jfree.data.time.RegularTimePeriod; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; - -import com.redhat.thermostat.host.memory.client.core.HostMemoryView; -import com.redhat.thermostat.host.memory.client.locale.LocaleResources; -import com.redhat.thermostat.client.ui.ChartColors; -import com.redhat.thermostat.common.Size; -import com.redhat.thermostat.shared.locale.LocalizedString; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -public class SWTHostMemoryView extends HostMemoryView implements SWTComponent { - public static final String TEST_ID_TOTAL_MEM = "SWTHostMemoryView.totalMemory"; - public static final String TEST_ID_LEGEND_ITEM_LABEL = "SWTHostMemoryView.legendItemLabel"; - public static final String TEST_ID_LEGEND_ITEM_CHECKBOX = "SWTHostMemoryView.legendItemCheckbox"; - - private static final String LEGEND_COLOUR_BLOCK = "\u2588"; - private static final int H_INDENT = 20; - private static final int SPACER_WIDTH = 10; - private static final Translate translator = LocaleResources.createLocalizer(); - - private final TimeSeriesCollection memoryCollection; - private final Map dataset; - private final Map colors; - private final CopyOnWriteArrayList listeners; - private final Map checkboxes; - - private Composite parent; - private Label totalMemory; - private JFreeChart chart; - private Composite legendTop; - - public SWTHostMemoryView(Composite parent) { - this.parent = parent; - this.memoryCollection = new TimeSeriesCollection(); - this.dataset = Collections.synchronizedMap(new HashMap()); - this.colors = new HashMap(); - this.listeners = new CopyOnWriteArrayList(); - this.checkboxes = new HashMap(); - this.chart = createMemoryChart(); - - Label summaryLabel = new Label(parent, SWT.LEAD); - Font stdFont = summaryLabel.getFont(); - Font boldFont = new Font(stdFont.getDevice(), - stdFont.getFontData()[0].getName(), - stdFont.getFontData()[0].getHeight(), SWT.BOLD); - - summaryLabel.setText(translator.localize(LocaleResources.HOST_MEMORY_SECTION_OVERVIEW).getContents()); - summaryLabel.setFont(boldFont); - - Composite detailsTop = new Composite(parent, SWT.NONE); - detailsTop.setLayout(new GridLayout(3, false)); - - Label cpuModelLabel = new Label(detailsTop, SWT.TRAIL); - cpuModelLabel.setText(translator.localize(LocaleResources.HOST_INFO_MEMORY_TOTAL).getContents()); - GridData hIndentLayoutData = new GridData(); - hIndentLayoutData.horizontalIndent = H_INDENT; - cpuModelLabel.setLayoutData(hIndentLayoutData); - - Label cpuModelSpacer = new Label(detailsTop, SWT.NONE); - cpuModelSpacer.setLayoutData(new GridData(SPACER_WIDTH, SWT.DEFAULT)); - - totalMemory = new Label(detailsTop, SWT.LEAD); - totalMemory.setData(ThermostatConstants.TEST_TAG, TEST_ID_TOTAL_MEM); - totalMemory.setText("Unknown"); - - Composite chartTop = new RecentTimeSeriesChartComposite(parent, SWT.NONE, chart); - chartTop.setLayout(new GridLayout()); - chartTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - legendTop = new Composite(parent, SWT.NONE); - RowLayout legendLayout = new RowLayout(SWT.HORIZONTAL); - legendLayout.center = true; - legendLayout.wrap = false; - legendLayout.marginHeight = 0; - legendTop.setLayout(legendLayout); - } - - @Override - public void setTotalMemory(final String newValue) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!totalMemory.isDisposed()) { - totalMemory.setText(newValue); - } - } - }); - } - - private JFreeChart createMemoryChart() { - // FIXME associate a fixed color with each type - - JFreeChart chart = ChartFactory.createTimeSeriesChart( - null, // Title - translator.localize(LocaleResources.HOST_MEMORY_CHART_TIME_LABEL).getContents(), // x-axis Label - translator.localize(LocaleResources.HOST_MEMORY_CHART_SIZE_LABEL, Size.Unit.MiB.name()).getContents(), // y-axis Label - memoryCollection, // Dataset - false, // Show Legend - false, // Use tooltips - false // Configure chart to generate URLs? - ); - - chart.getPlot().setBackgroundPaint( new Color(255,255,255,0) ); - chart.getPlot().setBackgroundImageAlpha(0.0f); - chart.getPlot().setOutlinePaint(new Color(0,0,0,0)); - - NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); - rangeAxis.setAutoRangeMinimumSize(100); - - return chart; - } - - private void fireShowHideHandlers(boolean show, String tag) { - for (GraphVisibilityChangeListener listener: listeners) { - if (show) { - listener.show(tag); - } else { - listener.hide(tag); - } - } - } - - @Override - public void addMemoryChart(final String tag, final LocalizedString name) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - int colorIndex = colors.size(); - colors.put(tag, ChartColors.getColor(colorIndex)); - TimeSeries series = new TimeSeries(tag); - dataset.put(tag, series); - - addLegendItem(tag, name.getContents()); - - updateColors(); - } - }); - } - - @Override - public void removeMemoryChart(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.remove(tag); - memoryCollection.removeSeries(series); - - removeLegendItem(tag); - - updateColors(); - } - }); - } - - @Override - public void showMemoryChart(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.get(tag); - memoryCollection.addSeries(series); - - updateColors(); - } - }); - } - - @Override - public void hideMemoryChart(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.get(tag); - memoryCollection.removeSeries(series); - - updateColors(); - } - }); - } - - @Override - public void addMemoryData(final String tag, List> data) { - final List> copy = new ArrayList<>(data); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - final TimeSeries series = dataset.get(tag); - for (DiscreteTimeData timeData: copy) { - RegularTimePeriod period = new FixedMillisecond(timeData.getTimeInMillis()); - if (series.getDataItem(period) == null) { - Long sizeInBytes = (Long) timeData.getData(); - Double sizeInMegaBytes = Size.bytes(sizeInBytes).convertTo(Size.Unit.MiB).getValue(); - series.add(new FixedMillisecond(timeData.getTimeInMillis()), sizeInMegaBytes, false); - } - } - series.fireSeriesChanged(); - } - }); - } - - @Override - public void clearMemoryData(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.get(tag); - series.clear(); - } - }); - } - - @Override - public void addGraphVisibilityListener(GraphVisibilityChangeListener listener) { - listeners.add(listener); - } - - @Override - public void removeGraphVisibilityListener(GraphVisibilityChangeListener listener) { - listeners.remove(listener); - } - - /** - * Adding or removing series to the series collection may change the order - * of existing items. Plus the paint for the index is now out-of-date. So - * let's walk through all the series and set the right paint for those. - */ - private void updateColors() { - XYItemRenderer itemRenderer = chart.getXYPlot().getRenderer(); - for (int i = 0; i < memoryCollection.getSeriesCount(); i++) { - String tag = (String) memoryCollection.getSeriesKey(i); - Color color = colors.get(tag); - itemRenderer.setSeriesPaint(i, color); - } - } - - private Composite createLabelWithLegend(Composite parent, String text, Color color, final String tag) { - Composite top = new Composite(parent, SWT.NONE); - RowLayout topLayout = new RowLayout(SWT.HORIZONTAL); - topLayout.marginHeight = 0; - topLayout.center = true; - top.setLayout(topLayout); - - final Button checkBox = new Button(top, SWT.CHECK); - checkBox.setData(ThermostatConstants.TEST_TAG, TEST_ID_LEGEND_ITEM_CHECKBOX); - checkBox.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - fireShowHideHandlers(checkBox.getSelection(), tag); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - } - }); - checkBox.setSelection(true); - checkBox.setAlignment(SWT.RIGHT); - - Label colourBlock = new Label(top, SWT.NONE); - colourBlock.setText(LEGEND_COLOUR_BLOCK); - - // Convert to SWT colour - final org.eclipse.swt.graphics.Color swtColour = new org.eclipse.swt.graphics.Color( - PlatformUI.getWorkbench().getDisplay(), color.getRed(), - color.getGreen(), color.getBlue()); - colourBlock.addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - swtColour.dispose(); - } - }); - colourBlock.setForeground(swtColour); - - Label colourText = new Label(top, SWT.NONE); - colourText.setData(ThermostatConstants.TEST_TAG, TEST_ID_LEGEND_ITEM_LABEL); - colourText.setText(text); - return top; - } - - private void addLegendItem(final String tag, final String humanReadableName) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - Composite checkbox = createLabelWithLegend(legendTop, - humanReadableName, colors.get(tag), tag); - checkboxes.put(tag, checkbox); - parent.layout(); - } - }); - } - - private void removeLegendItem(final String tag) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - Composite checkbox = checkboxes.remove(tag); - checkbox.dispose(); - parent.layout(); - } - }); - } - - public JFreeChart getChart() { - return chart; - } - - public TimeSeries getSeries(String tag) { - return dataset.get(tag); - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostMemoryViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTHostMemoryViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.host.memory.client.core.HostMemoryView; -import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; - -public class SWTHostMemoryViewProvider extends SWTViewProvider implements - HostMemoryViewProvider { - - @Override - public HostMemoryView createView() { - return new SWTHostMemoryView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmCpuView.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmCpuView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.data.time.FixedMillisecond; -import org.jfree.data.time.RegularTimePeriod; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; - -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.storage.model.DiscreteTimeData; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuView; -import com.redhat.thermostat.vm.cpu.client.locale.LocaleResources; - -public class SWTVmCpuView extends VmCpuView implements SWTComponent { - - private static final Translate translator = LocaleResources.createLocalizer(); - - private final TimeSeriesCollection data; - private final TimeSeries cpuTimeSeries; - - private JFreeChart chart; - - public SWTVmCpuView(Composite parent) { - data = new TimeSeriesCollection(); - cpuTimeSeries = new TimeSeries("cpu-stats"); - chart = createCpuChart(); - - data.addSeries(cpuTimeSeries); - - Composite chartTop = new RecentTimeSeriesChartComposite(parent, SWT.NONE, chart); - chartTop.setLayout(new GridLayout()); - chartTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - } - - private JFreeChart createCpuChart() { - JFreeChart chart = ChartFactory.createTimeSeriesChart( - null, - translator.localize(LocaleResources.VM_CPU_CHART_TIME_LABEL).getContents(), - translator.localize(LocaleResources.VM_CPU_CHART_LOAD_LABEL).getContents(), - data, - false, false, false); - - chart.getXYPlot().getRangeAxis().setLowerBound(0.0); - - return chart; - } - - @Override - public void addData(List> data) { - final List> copy = new ArrayList<>(data); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - for (DiscreteTimeData data: copy) { - RegularTimePeriod period = new FixedMillisecond(data.getTimeInMillis()); - if (cpuTimeSeries.getDataItem(period) == null) { - cpuTimeSeries.add(period, data.getData(), false); - } - } - cpuTimeSeries.fireSeriesChanged(); - } - }); - } - - @Override - public void clearData() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - cpuTimeSeries.clear(); - } - }); - } - - public JFreeChart getChart() { - return chart; - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmCpuViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmCpuViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuView; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; - -public class SWTVmCpuViewProvider extends SWTViewProvider implements - VmCpuViewProvider { - - @Override - public VmCpuView createView() { - return new SWTVmCpuView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcView.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,262 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.PlatformUI; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.DateAxis; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.event.ChartProgressEvent; -import org.jfree.chart.event.ChartProgressListener; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.renderer.xy.StandardXYBarPainter; -import org.jfree.chart.renderer.xy.XYBarRenderer; -import org.jfree.data.RangeType; -import org.jfree.data.xy.IntervalXYDataset; - -import com.redhat.thermostat.client.ui.SampledDataset; -import com.redhat.thermostat.shared.locale.LocalizedString; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.storage.model.IntervalTimeData; -import com.redhat.thermostat.vm.gc.client.core.VmGcView; -import com.redhat.thermostat.vm.gc.client.locale.LocaleResources; - -public class SWTVmGcView extends VmGcView implements SWTComponent { - - private static final Translate translator = LocaleResources.createLocalizer(); - - private final Map dataset; - private final Map subPanels; - private final Map charts; - - private Composite parent; - - public SWTVmGcView(Composite parent) { - this.parent = parent; - dataset = new HashMap(); - subPanels = Collections.synchronizedMap(new HashMap()); - charts = new HashMap(); - } - - @Override - public void addChart(final String tag, final LocalizedString title, final String units) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset newData = new SampledDataset(); - dataset.put(tag, newData); - Composite subPanel = createCollectorDetailsPanel(tag, newData, title.getContents(), units); - subPanels.put(tag, subPanel); - } - }); - } - - @Override - public void removeChart(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - dataset.remove(tag); - charts.remove(tag); - Composite subPanel = subPanels.remove(tag); - destroyChartComposite(subPanel); - } - }); - } - - @Override - public void addData(final String tag, List> data) { - final List> copy = new ArrayList<>(data); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset series = dataset.get(tag); - for (IntervalTimeData timeData: copy) { - series.add(timeData.getStartTimeInMillis(), timeData.getEndTimeInMillis(), timeData.getData()); - } - series.fireSeriesChanged(); - } - }); - } - - @Override - public void clearData(final String tag) { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - SampledDataset series = dataset.get(tag); - series.clear(); - } - }); - } - - private Composite createCollectorDetailsPanel(String tag, IntervalXYDataset collectorData, final String title, String units) { - // Create chart - final JFreeChart chart = ChartFactory.createHistogram( - null, - translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL).getContents(), - translator.localize(LocaleResources.VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, units).getContents(), - collectorData, - PlotOrientation.VERTICAL, - false, - false, - false); - - ((XYBarRenderer)(chart.getXYPlot().getRenderer())).setBarPainter(new StandardXYBarPainter()); - - setupPlotAxes(chart.getXYPlot()); - - chart.getXYPlot().setDomainCrosshairLockedOnData(true); - chart.getXYPlot().setDomainCrosshairVisible(true); - - // An array so we can modify it in the UI thread - final Composite detailsTop[] = new Composite[1]; - - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - detailsTop[0] = createChartComposite(title, chart); - parent.layout(); - } - }); - - charts.put(tag, chart); - - return detailsTop[0]; - } - - private void setupPlotAxes(XYPlot plot) { - setupDomainAxis(plot); - setupRangeAxis(plot); - } - - private void setupDomainAxis(XYPlot plot) { - plot.setDomainAxis(new DateAxis()); - } - - private void setupRangeAxis(XYPlot plot) { - NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); - - rangeAxis.setRangeType(RangeType.POSITIVE); - rangeAxis.setAutoRange(true); - rangeAxis.setAutoRangeMinimumSize(1); - } - - private Composite createChartComposite(final String title, - final JFreeChart chart) { - Composite detailsTop = new Composite(parent, SWT.NONE); - detailsTop.setLayout(new GridLayout()); - detailsTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - Label summaryLabel = new Label(detailsTop, SWT.LEAD); - Font stdFont = summaryLabel.getFont(); - Font boldFont = new Font(stdFont.getDevice(), - stdFont.getFontData()[0].getName(), - stdFont.getFontData()[0].getHeight(), SWT.BOLD); - - summaryLabel.setText(title); - summaryLabel.setFont(boldFont); - - final RecentTimeSeriesChartComposite chartTop = new RecentTimeSeriesChartComposite( - detailsTop, SWT.NONE, chart); - chartTop.setLayout(new GridLayout()); - chartTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - chart.addProgressListener(new ChartProgressListener() { - - @Override - public void chartProgress(ChartProgressEvent event) { - if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) { - return; - } - - double rangeCrossHairValue = event.getChart().getXYPlot() - .getRangeCrosshairValue(); - chartTop.setDataInformationLabel(String - .valueOf(rangeCrossHairValue)); - } - }); - - return detailsTop; - } - - private void destroyChartComposite(final Composite top) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if (top != null && !top.isDisposed()) { - top.dispose(); - parent.layout(); - } - } - }); - } - - public JFreeChart getChart(String tag) { - return charts.get(tag); - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/SWTVmGcViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.vm.gc.client.core.VmGcView; -import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; - -public class SWTVmGcViewProvider extends SWTViewProvider implements - VmGcViewProvider { - - @Override - public VmGcView createView() { - return new SWTVmGcView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.views.VmRefViewPart; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; - -public class VmCpuViewPart extends VmRefViewPart { - - public VmCpuViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public VmCpuViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return VmCpuViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return VmCpuService.SERVICE_ID; - } - -} diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.common; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.views.VmRefViewPart; -import com.redhat.thermostat.vm.gc.client.core.VmGcService; -import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; - -public class VmGcViewPart extends VmRefViewPart { - - public VmGcViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public VmGcViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return VmGcViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return VmGcService.SERVICE_ID; - } - -} diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/.classpath --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/.project --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse.chart.vmclassstat - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Thermostat VM Classes View -Bundle-SymbolicName: com.redhat.thermostat.eclipse.chart.vmclassstat;singleton:=true -Bundle-Version: 1.0.3.qualifier -Bundle-Activator: com.redhat.thermostat.eclipse.chart.vmclassstat.Activator -Bundle-Vendor: Red Hat Inc. -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Bundle-ActivationPolicy: lazy -Import-Package: com.redhat.thermostat.client.core.controllers, - com.redhat.thermostat.client.core.views, - com.redhat.thermostat.client.ui, - com.redhat.thermostat.common, - com.redhat.thermostat.storage.dao, - com.redhat.thermostat.shared.locale, - com.redhat.thermostat.common.utils, - com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.chart.common, - com.redhat.thermostat.eclipse.internal.views, - com.redhat.thermostat.eclipse.views, - com.redhat.thermostat.storage.core, - com.redhat.thermostat.storage.model, - com.redhat.thermostat.vm.classstat.client.core, - com.redhat.thermostat.vm.classstat.client.locale, - org.jfree.chart, - org.jfree.chart.axis, - org.jfree.chart.plot, - org.jfree.data, - org.jfree.data.general, - org.jfree.data.time, - org.jfree.data.xy -Export-Package: com.redhat.thermostat.eclipse.chart.vmclassstat diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/plugin.xml --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/plugin.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.chart.vmclassstat - eclipse-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse VmClassStat Plug-in - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/Activator.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/Activator.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.vmclassstat; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.redhat.thermostat.eclipse.chart.vmclassstat"; //$NON-NLS-1$ - - public static final String VIEW_ID_VM_CLASS_STAT = "com.redhat.thermostat.eclipse.chart.vmClassStatView"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - // Register view - context.registerService(VmClassStatViewProvider.class, - new SWTVmClassStatViewProvider(), null); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/SWTVmClassStatView.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/SWTVmClassStatView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.vmclassstat; - -import java.awt.EventQueue; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.axis.NumberTickUnit; -import org.jfree.chart.axis.TickUnits; -import org.jfree.data.RangeType; -import org.jfree.data.time.FixedMillisecond; -import org.jfree.data.time.RegularTimePeriod; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; - -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatView; -import com.redhat.thermostat.vm.classstat.client.locale.LocaleResources; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.chart.common.RecentTimeSeriesChartComposite; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -public class SWTVmClassStatView extends VmClassStatView implements SWTComponent { - - private static final Translate translator = LocaleResources.createLocalizer(); - - private final TimeSeriesCollection dataset; - - private JFreeChart chart; - - public SWTVmClassStatView(Composite parent) { - dataset = new TimeSeriesCollection(); - // any name works - dataset.addSeries(new TimeSeries("class-stat")); - - chart = ChartFactory.createTimeSeriesChart( - null, - translator.localize(LocaleResources.VM_CLASSES_CHART_REAL_TIME_LABEL).getContents(), - translator.localize(LocaleResources.VM_CLASSES_CHART_LOADED_CLASSES_LABEL).getContents(), - dataset, - false, false, false); - - TickUnits tickUnits = new TickUnits(); - tickUnits.add(new NumberTickUnit(1)); - tickUnits.add(new NumberTickUnit(10)); - tickUnits.add(new NumberTickUnit(100)); - tickUnits.add(new NumberTickUnit(1000)); - tickUnits.add(new NumberTickUnit(10000)); - tickUnits.add(new NumberTickUnit(100000)); - tickUnits.add(new NumberTickUnit(1000000)); - - NumberAxis axis = (NumberAxis) chart.getXYPlot().getRangeAxis(); - axis.setStandardTickUnits(tickUnits); - axis.setRangeType(RangeType.POSITIVE); - axis.setAutoRangeMinimumSize(10); - - Composite chartPanel = new RecentTimeSeriesChartComposite(parent, SWT.NONE, chart); - chartPanel.setLayout(new GridLayout()); - chartPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - } - - @Override - public void addClassCount(List> data) { - final List> copy = new ArrayList<>(data); - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.getSeries(0); - for (DiscreteTimeData data: copy) { - RegularTimePeriod period = new FixedMillisecond(data.getTimeInMillis()); - if (series.getDataItem(period) == null) { - series.add(period, data.getData(), false); - } - } - series.fireSeriesChanged(); - } - }); - } - - @Override - public void clearClassCount() { - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - TimeSeries series = dataset.getSeries(0); - series.clear(); - } - }); - } - - public JFreeChart getChart() { - return chart; - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/SWTVmClassStatViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/SWTVmClassStatViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.vmclassstat; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatView; -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; - -public class SWTVmClassStatViewProvider extends SWTViewProvider implements - VmClassStatViewProvider { - - @Override - public VmClassStatView createView() { - return new SWTVmClassStatView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.chart.vmclassstat; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.views.VmRefViewPart; -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; - -public class VmClassStatViewPart extends VmRefViewPart { - - public VmClassStatViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public VmClassStatViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return VmClassStatViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return VmClassStatService.SERVICE_ID; - } - -} diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.feature/.project --- a/eclipse/com.redhat.thermostat.eclipse.feature/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - com.redhat.thermostat.eclipse.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.feature/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.feature/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -bin.includes = feature.xml -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.feature/feature.xml --- a/eclipse/com.redhat.thermostat.eclipse.feature/feature.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ - - - - - Thermostat Eclipse Plug-ins. - - - - Copyright 2012, 2013 Red Hat, Inc. - - - - Copyright 2012, 2013 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. - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.feature/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.feature/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.feature - 1.0.3-SNAPSHOT - - Thermostat Eclipse Feature - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - eclipse-feature - - - - - - - - src - - **/*.java - - - - - - org.eclipse.tycho - tycho-source-plugin - - - - eclipse-feature - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.p2-repo/.project --- a/eclipse/com.redhat.thermostat.eclipse.p2-repo/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - com.redhat.thermostat.eclipse.p2-repo - - - - - - org.eclipse.pde.UpdateSiteBuilder - - - - - - org.eclipse.pde.UpdateSiteNature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.p2-repo/category.xml --- a/eclipse/com.redhat.thermostat.eclipse.p2-repo/category.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.p2-repo/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.p2-repo/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.p2-repo - 1.0.3-SNAPSHOT - - Thermostat Eclipse p2 Repository - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - eclipse-feature - - - - - - - org.eclipse.tycho - tycho-p2-publisher-plugin - ${tycho-version} - - true - - - - - - eclipse-repository - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.target_platform/.project --- a/eclipse/com.redhat.thermostat.eclipse.target_platform/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - com.redhat.thermostat.eclipse.target_platform - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.target_platform/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.target_platform/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.target_platform - 1.0.3-SNAPSHOT - pom - - Thermostat Eclipse Target Platform - - - ${basedir}/.. - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - package - - copy-resources - - - ${basedir}/target - - - src/main/resources - true - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.target_platform/src/main/resources/thermostat-juno.target --- a/eclipse/com.redhat.thermostat.eclipse.target_platform/src/main/resources/thermostat-juno.target Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.target_platform/src/main/resources/thermostat-kepler.target --- a/eclipse/com.redhat.thermostat.eclipse.target_platform/src/main/resources/thermostat-kepler.target Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.deps.feature/.project --- a/eclipse/com.redhat.thermostat.eclipse.test.deps.feature/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - - com.redhat.thermostat.eclipse.test.deps.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.deps.feature/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.test.deps.feature/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -bin.includes = feature.xml -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.deps.feature/feature.xml --- a/eclipse/com.redhat.thermostat.eclipse.test.deps.feature/feature.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ - - - - - Plug-ins necessary to run the Thermostat Eclipse client tests. - - - - Copyright 2012, 2013 Red Hat, Inc. - - - - Copyright 2012, 2013 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. - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.deps.feature/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.test.deps.feature/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.test.deps.feature - eclipse-feature - 1.0.3-SNAPSHOT - - Thermostat Eclipse Test Dependencies Feature - - - ${basedir}/.. - - - - - local_client - p2 - file://${eclipse-root}/core-p2-repository/target/repository/ - - - local_eclipse - p2 - file://${eclipse-root}/com.redhat.thermostat.eclipse.p2-repo/target/repository/ - - - - - - org.hamcrest - com.redhat.thermostat.bundles.org.hamcrest.core - 1.3 - - - org.mockito - com.redhat.thermostat.bundles.org.mockito.mockito-core - 1.9.0 - - - org.objenesis - com.redhat.thermostat.bundles.org.objenesis - 1.0 - - - - - - - - src - - **/*.java - - - - - - org.eclipse.tycho - tycho-source-plugin - - - org.eclipse.tycho - tycho-packaging-plugin - ${tycho-version} - - true - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/.classpath --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/.project --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse.test.ui - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Thermostat Eclipse UI Tests -Bundle-SymbolicName: com.redhat.thermostat.eclipse.test.ui -Bundle-Version: 1.0.3.qualifier -Bundle-Vendor: Red Hat Inc. -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.junit;bundle-version="4.10.0", - com.redhat.thermostat.bundles.org.hamcrest.core;resolution:=optional, - org.hamcrest;resolution:=optional -Import-Package: com.redhat.thermostat.client.core.views, - com.redhat.thermostat.client.ui, - com.redhat.thermostat.common, - com.redhat.thermostat.shared.locale, - com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.chart.common, - com.redhat.thermostat.eclipse.chart.vmclassstat, - com.redhat.thermostat.eclipse.internal.views, - com.redhat.thermostat.host.cpu.client.core, - com.redhat.thermostat.host.memory.client.core, - com.redhat.thermostat.host.overview.client.core, - com.redhat.thermostat.storage.model, - com.redhat.thermostat.vm.classstat.client.core, - com.redhat.thermostat.vm.cpu.client.core, - com.redhat.thermostat.vm.gc.client.core, - org.apache.log4j;version="1.2.13", - org.eclipse.swtbot.eclipse.finder, - org.eclipse.swtbot.eclipse.finder.matchers, - org.eclipse.swtbot.eclipse.finder.widgets, - org.eclipse.swtbot.swt.finder, - org.eclipse.swtbot.swt.finder.exceptions, - org.eclipse.swtbot.swt.finder.junit, - org.eclipse.swtbot.swt.finder.matchers, - org.eclipse.swtbot.swt.finder.utils, - org.eclipse.swtbot.swt.finder.waits, - org.eclipse.swtbot.swt.finder.widgets, - org.jfree.chart, - org.jfree.chart.axis, - org.jfree.chart.plot, - org.jfree.data.general, - org.jfree.data.time, - org.jfree.data.xy -Export-Package: com.redhat.thermostat.eclipse.test.ui diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.test.ui - eclipse-test-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse Client UI Tests - - - ${basedir}/.. - - - - - swtbot - p2 - http://download.eclipse.org/technology/swtbot/releases/2.1.0/ - - - local_client - p2 - file://${eclipse-root}/core-p2-repository/target/repository/ - - - local_eclipse - p2 - file://${eclipse-root}/com.redhat.thermostat.eclipse.p2-repo/target/repository/ - - - local_eclipse_test_deps - p2 - file://${eclipse-root}/test-deps-p2-repository/target/repository/ - - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - true - false - org.eclipse.platform.ide - org.eclipse.ui.ide.workbench - - - p2-installable-unit - org.eclipse.sdk.feature.group - ${sdk-version} - - - p2-installable-unit - com.redhat.thermostat.client.feature.feature.group - 1.0.3 - - - p2-installable-unit - com.redhat.thermostat.eclipse.feature.feature.group - 1.0.3 - - - p2-installable-unit - com.redhat.thermostat.eclipse.test.deps.feature.feature.group - 1.0.3 - - - - - com.redhat.thermostat.common.core - 4 - true - - - com.redhat.thermostat.web.common - 4 - true - - - com.redhat.thermostat.web.client - 4 - true - - - com.redhat.thermostat.launcher - 4 - true - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/RecentTimeSeriesChartCompositeTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/RecentTimeSeriesChartCompositeTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.swtbot.swt.finder.widgets.TimeoutException; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.data.time.TimeSeriesCollection; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.RecentTimeSeriesChartComposite; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class RecentTimeSeriesChartCompositeTest { - private SWTWorkbenchBot bot; - private Shell shell; - private JFreeChart chart; - private RecentTimeSeriesChartComposite composite; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - - chart = createChart(); - composite = new RecentTimeSeriesChartComposite(parent, - SWT.NONE, chart); - shell.open(); - } - }); - } - - private JFreeChart createChart() { - JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, - new TimeSeriesCollection(), false, false, false); - return chart; - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - } - } - }); - } - - @Test - public void testTimeUnitMinutes() throws Exception { - SWTBotCombo timeUnitCombo = bot.comboBoxWithId( - ThermostatConstants.TEST_TAG, - RecentTimeSeriesChartComposite.TEST_ID_UNIT_COMBO); - - List units = Arrays.asList(composite.getController().getTimeUnits()); - timeUnitCombo.setSelection(units.indexOf(TimeUnit.MINUTES)); - - checkTimeUnit(TimeUnit.MINUTES); - } - - @Test - public void testTimeUnitHours() throws Exception { - SWTBotCombo timeUnitCombo = bot.comboBoxWithId( - ThermostatConstants.TEST_TAG, - RecentTimeSeriesChartComposite.TEST_ID_UNIT_COMBO); - - List units = Arrays.asList(composite.getController().getTimeUnits()); - timeUnitCombo.setSelection(units.indexOf(TimeUnit.HOURS)); - - checkTimeUnit(TimeUnit.HOURS); - } - - @Test - public void testTimeUnitDays() throws Exception { - SWTBotCombo timeUnitCombo = bot.comboBoxWithId( - ThermostatConstants.TEST_TAG, - RecentTimeSeriesChartComposite.TEST_ID_UNIT_COMBO); - - List units = Arrays.asList(composite.getController().getTimeUnits()); - timeUnitCombo.setSelection(units.indexOf(TimeUnit.DAYS)); - - checkTimeUnit(TimeUnit.DAYS); - } - - @Test - public void testTimeDuration() throws Exception { - final int duration = 200; - SWTBotText durationText = bot.textWithId(ThermostatConstants.TEST_TAG, - RecentTimeSeriesChartComposite.TEST_ID_DURATION_TEXT); - - durationText.setText(String.valueOf(duration)); - - checkTimeDuration(duration); - } - - @Test(expected = TimeoutException.class) - public void testTimeDurationBad() throws Exception { - final int duration = 200; - - // Set a proper duration value, then try a bad one - SWTBotText durationText = bot.textWithId(ThermostatConstants.TEST_TAG, - RecentTimeSeriesChartComposite.TEST_ID_DURATION_TEXT); - - durationText.setText(String.valueOf(duration)); - - checkTimeDuration(duration); - - durationText.setText("Not an int"); - - // Ensure duration unchanged - bot.waitWhile(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return composite.getController().getTimeValue() == duration; - } - - @Override - public String getFailureMessage() { - return "Success"; - } - }); - } - - private void checkTimeDuration(final int duration) { - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return composite.getController().getTimeValue() == duration; - } - - @Override - public String getFailureMessage() { - return "Duration not set"; - } - }); - } - - private void checkTimeUnit(final TimeUnit unit) { - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return unit.equals(composite.getController().getTimeUnit()); - } - - @Override - public String getFailureMessage() { - return "Time unit not set to " + unit.toString(); - } - }); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostCpuViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostCpuViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,379 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; -import org.jfree.data.time.TimeSeriesCollection; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.redhat.thermostat.client.core.views.BasicView; -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.shared.locale.LocalizedString; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.SWTHostCpuView; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class SWTHostCpuViewTest { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTHostCpuView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTHostCpuView(parent); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testSetCpuModel() throws Exception { - String model = "Test CPU"; - - view.setCpuModel(model); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_CPU_MODEL); - return !label.getText().equals("Unknown"); // TODO Externalize - } - - @Override - public String getFailureMessage() { - return "CPU Model label unchanged after set"; - } - - }); - } - - @Test - public void testSetCpuCount() throws Exception { - String count = "8"; - - view.setCpuCount(count); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_CPU_COUNT); - return !label.getText().equals("Unknown"); // TODO Externalize - } - - @Override - public String getFailureMessage() { - return "CPU Model label unchanged after set"; - } - - }); - } - - @Test - public void testAddCpuUsageChart() throws Exception { - String humanReadableName = "Test"; - - // Test series added - addSeries(0, humanReadableName, 1); - - // Verify legend added - SWTBotLabel label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_LEGEND_ITEM); - assertEquals(humanReadableName, label.getText()); - } - - private void addSeries(int seriesIndex, String humanReadableName, - final int numSeries) { - view.addCpuUsageChart(seriesIndex, new LocalizedString(humanReadableName)); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - XYPlot plot = (XYPlot) chart.getPlot(); - int count = plot.getSeriesCount(); - return count == numSeries; - } - - @Override - public String getFailureMessage() { - return "Data series never added"; - } - }); - - // Wait until legend added - bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_LEGEND_ITEM); - } - - @Test - public void testAddCpuUsageChartMultiple() throws Exception { - String humanReadableName1 = "Test 1"; - String humanReadableName2 = "Test 2"; - - addSeries(0, humanReadableName1, 1); - addSeries(1, humanReadableName2, 2); - - // Verify legend added - SWTBotLabel label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_LEGEND_ITEM, 0); - assertEquals(humanReadableName1, label.getText()); - label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostCpuView.TEST_ID_LEGEND_ITEM, 1); - assertEquals(humanReadableName2, label.getText()); - } - - @Test - public void testAddCpuUsageData() throws Exception { - List> data = new ArrayList>(); - - data.add(new DiscreteTimeData(1000L, 50D)); - data.add(new DiscreteTimeData(2000L, 75D)); - data.add(new DiscreteTimeData(3000L, 25D)); - - addSeries(0, "Test", 1); - - addData(0, data); - - JFreeChart chart = view.getChart(); - TimeSeriesCollection dataset = (TimeSeriesCollection) chart.getXYPlot() - .getDataset(); - - assertEquals(1000L, dataset.getX(0, 0)); - assertEquals(2000L, dataset.getX(0, 1)); - assertEquals(3000L, dataset.getX(0, 2)); - - assertEquals(50D, dataset.getY(0, 0)); - assertEquals(75D, dataset.getY(0, 1)); - assertEquals(25D, dataset.getY(0, 2)); - } - - private void addData(final int seriesIndex, - final List> data) { - view.addCpuUsageData(seriesIndex, data); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - TimeSeriesCollection dataset = (TimeSeriesCollection) chart - .getXYPlot().getDataset(); - return dataset.getItemCount(seriesIndex) == data.size(); - } - - @Override - public String getFailureMessage() { - return "Data not added"; - } - }); - } - - @Test - public void testAddCpuUsageDataMultiple() throws Exception { - List> data1 = new ArrayList>(); - - data1.add(new DiscreteTimeData(1000L, 50D)); - data1.add(new DiscreteTimeData(2000L, 75D)); - data1.add(new DiscreteTimeData(3000L, 25D)); - - List> data2 = new ArrayList>(); - - data2.add(new DiscreteTimeData(1500L, 30D)); - data2.add(new DiscreteTimeData(2500L, 60D)); - data2.add(new DiscreteTimeData(3500L, 90D)); - - addSeries(0, "Test 1", 1); - addSeries(1, "Test 2", 2); - - addData(0, data1); - addData(1, data2); - - JFreeChart chart = view.getChart(); - TimeSeriesCollection dataset = (TimeSeriesCollection) chart.getXYPlot() - .getDataset(); - - assertEquals(1000L, dataset.getX(0, 0)); - assertEquals(2000L, dataset.getX(0, 1)); - assertEquals(3000L, dataset.getX(0, 2)); - - assertEquals(50D, dataset.getY(0, 0)); - assertEquals(75D, dataset.getY(0, 1)); - assertEquals(25D, dataset.getY(0, 2)); - - assertEquals(1500L, dataset.getX(1, 0)); - assertEquals(2500L, dataset.getX(1, 1)); - assertEquals(3500L, dataset.getX(1, 2)); - - assertEquals(30D, dataset.getY(1, 0)); - assertEquals(60D, dataset.getY(1, 1)); - assertEquals(90D, dataset.getY(1, 2)); - } - - @Test - public void testClearCpuUsageData() { - List> data1 = new ArrayList>(); - - data1.add(new DiscreteTimeData(1000L, 50D)); - data1.add(new DiscreteTimeData(2000L, 75D)); - data1.add(new DiscreteTimeData(3000L, 25D)); - - List> data2 = new ArrayList>(); - - data2.add(new DiscreteTimeData(1500L, 30D)); - data2.add(new DiscreteTimeData(2500L, 60D)); - data2.add(new DiscreteTimeData(3500L, 90D)); - - addSeries(0, "Test 1", 1); - addSeries(1, "Test 2", 2); - - addData(0, data1); - addData(1, data2); - - view.clearCpuUsageData(); - - // Wait until data cleared - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - int count = chart.getXYPlot().getSeriesCount(); - return count == 0; - } - - @Override - public String getFailureMessage() { - return "Data not cleared"; - } - }); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostMemoryViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostMemoryViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,585 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.matchers.WithId; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.redhat.thermostat.client.core.views.BasicView; -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.shared.locale.LocalizedString; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.SWTHostMemoryView; -import com.redhat.thermostat.host.memory.client.core.HostMemoryView.GraphVisibilityChangeListener; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class SWTHostMemoryViewTest implements GraphVisibilityChangeListener { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTHostMemoryView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTHostMemoryView(parent); - view.addGraphVisibilityListener(SWTHostMemoryViewTest.this); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testSetTotalMemory() throws Exception { - String totalMem = "8 GB"; - - view.setTotalMemory(totalMem); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_TOTAL_MEM); - return !label.getText().equals("Unknown"); // TODO Externalize - } - - @Override - public String getFailureMessage() { - return "Total memory label unchanged after set"; - } - - }); - } - - @Test - public void testAddMemoryChart() throws Exception { - final String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - - // Verify legend added - SWTBotLabel label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL); - assertEquals(humanReadableName, label.getText()); - } - - @Test - public void testAddMemoryChartMultiple() throws Exception { - final String tag1 = "TEST1"; - final String tag2 = "TEST2"; - String humanReadableName1 = "Test 1"; - String humanReadableName2 = "Test 2"; - - addSeries(tag1, humanReadableName1); - addSeries(tag2, humanReadableName2); - - // Verify legend added - SWTBotLabel label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL, 0); - assertEquals(humanReadableName1, label.getText()); - label = bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL, 1); - assertEquals(humanReadableName2, label.getText()); - } - - @Test - public void testRemoveMemoryChart() throws Exception { - final String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - - view.showMemoryChart(tag); - waitUntilSeriesShown(1); - - view.removeMemoryChart(tag); - - checkSeriesRemoved(tag, 0); - - // Verify legend removed - checkLegendRemoved(); - } - - @Test - public void testRemoveMemoryChartMultiple() throws Exception { - final String tag1 = "TEST1"; - final String tag2 = "TEST2"; - String humanReadableName1 = "Test 1"; - String humanReadableName2 = "Test 2"; - - addSeries(tag1, humanReadableName1); - addSeries(tag2, humanReadableName2); - - // Show both series - view.showMemoryChart(tag1); - waitUntilSeriesShown(1); - - view.showMemoryChart(tag2); - waitUntilSeriesShown(2); - - view.removeMemoryChart(tag2); - - checkSeriesRemoved(tag2, 1); - - // Verify legend removed - checkLegendItemRemoved(1); - } - - private void checkSeriesRemoved(final String tag, final int numSeries) { - // Wait until series removed from chart and dataset - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - XYPlot plot = chart.getXYPlot(); - int count = plot.getSeriesCount(); - return view.getSeries(tag) == null && count == numSeries; - } - - @Override - public String getFailureMessage() { - return "Data series never removed"; - } - }); - } - - private void checkLegendRemoved() { - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - boolean result = false; - - // Don't make this wait - long saveTimeout = SWTBotPreferences.TIMEOUT; - SWTBotPreferences.TIMEOUT = 0; - try { - bot.widget(WithId.withId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL)); - } catch (WidgetNotFoundException e) { - result = true; - } - SWTBotPreferences.TIMEOUT = saveTimeout; - - return result; - } - - @Override - public String getFailureMessage() { - return "Legend not removed"; - } - }); - } - - private void checkLegendItemRemoved(final int size) { - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - List widgets = bot.widgets(WithId.withId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL)); - return widgets.size() == size; - } - - @Override - public String getFailureMessage() { - return "Legend item not removed"; - } - }); - } - - @Test - public void testHideMemoryChart() throws Exception { - String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - view.showMemoryChart(tag); - - waitUntilSeriesShown(1); - - // Click checkbox to trigger hideMemoryChart - SWTBotCheckBox checkbox = bot.checkBoxWithId( - ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_CHECKBOX); - checkbox.click(); - - // Wait until series hidden - waitUntilSeriesShown(0); - } - - @Test - public void testShowMemoryChart() throws Exception { - String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - view.showMemoryChart(tag); - - waitUntilSeriesShown(1); - } - - @Test - public void testShowHiddenMemoryChart() throws Exception { - String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - view.showMemoryChart(tag); - - waitUntilSeriesShown(1); - - // Click checkbox to trigger hideMemoryChart - SWTBotCheckBox checkbox = bot.checkBoxWithId( - ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_CHECKBOX); - checkbox.click(); - - // Wait until series hidden - waitUntilSeriesShown(0); - - // Click checkbox to trigger showMemoryChart - checkbox.click(); - - waitUntilSeriesShown(1); - } - - @Test - public void testAddMemoryData() throws Exception { - String tag = "TEST"; - String humanReadableName = "Test"; - - addSeries(tag, humanReadableName); - view.showMemoryChart(tag); - - waitUntilSeriesShown(1); - - // Add some test data - List> data = new ArrayList>(); - data.add(new DiscreteTimeData(1000L, 134217728L)); // 128MiB - data.add(new DiscreteTimeData(2000L, 268435456L)); // 256MiB - data.add(new DiscreteTimeData(3000L, 536870912L)); // 512MiB - - final JFreeChart chart = view.getChart(); - final TimeSeries series = view.getSeries(tag); - - addData(tag, data, series); - - TimeSeriesCollection dataset = (TimeSeriesCollection) chart.getXYPlot().getDataset(); - int seriesIndex = chart.getXYPlot().getDataset().indexOf(series.getKey()); - - assertEquals(1000L, dataset.getX(seriesIndex, 0)); - assertEquals(2000L, dataset.getX(seriesIndex, 1)); - assertEquals(3000L, dataset.getX(seriesIndex, 2)); - - assertEquals(128D, dataset.getY(seriesIndex, 0)); - assertEquals(256D, dataset.getY(seriesIndex, 1)); - assertEquals(512D, dataset.getY(seriesIndex, 2)); - } - - private void addData(String tag, - final List> data, - final TimeSeries series) { - view.addMemoryData(tag, data); - - // Wait until data added to chart - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return series.getItemCount() == data.size(); - } - - @Override - public String getFailureMessage() { - return "Data never added"; - } - }); - } - - @Test - public void testAddMemoryDataMultiple() throws Exception { - String tag1 = "TEST1"; - String tag2 = "TEST2"; - String humanReadableName1 = "Test 1"; - String humanReadableName2 = "Test 2"; - - addSeries(tag1, humanReadableName1); - view.showMemoryChart(tag1); - - addSeries(tag2, humanReadableName2); - view.showMemoryChart(tag2); - - waitUntilSeriesShown(2); - - // Add some test data - List> data1 = new ArrayList>(); - data1.add(new DiscreteTimeData(1000L, 134217728L)); // 128MiB - data1.add(new DiscreteTimeData(2000L, 268435456L)); // 256MiB - data1.add(new DiscreteTimeData(3000L, 536870912L)); // 512MiB - - List> data2 = new ArrayList>(); - data2.add(new DiscreteTimeData(1500L, 536870912L)); // 512MiB - data2.add(new DiscreteTimeData(2500L, 134217728L)); // 128MiB - data2.add(new DiscreteTimeData(3500L, 268435456L)); // 256MiB - - final JFreeChart chart = view.getChart(); - final TimeSeries series1 = view.getSeries(tag1); - final TimeSeries series2 = view.getSeries(tag2); - - addData(tag1, data1, series1); - addData(tag2, data2, series2); - - TimeSeriesCollection dataset = (TimeSeriesCollection) chart.getXYPlot().getDataset(); - int series1Index = chart.getXYPlot().getDataset().indexOf(series1.getKey()); - int series2Index = chart.getXYPlot().getDataset().indexOf(series2.getKey()); - - assertEquals(1000L, dataset.getX(series1Index, 0)); - assertEquals(2000L, dataset.getX(series1Index, 1)); - assertEquals(3000L, dataset.getX(series1Index, 2)); - - assertEquals(128D, dataset.getY(series1Index, 0)); - assertEquals(256D, dataset.getY(series1Index, 1)); - assertEquals(512D, dataset.getY(series1Index, 2)); - - assertEquals(1500L, dataset.getX(series2Index, 0)); - assertEquals(2500L, dataset.getX(series2Index, 1)); - assertEquals(3500L, dataset.getX(series2Index, 2)); - - assertEquals(512D, dataset.getY(series2Index, 0)); - assertEquals(128D, dataset.getY(series2Index, 1)); - assertEquals(256D, dataset.getY(series2Index, 2)); - } - - @Test - public void testClearMemoryData() throws Exception { - String tag1 = "TEST1"; - String tag2 = "TEST2"; - String humanReadableName1 = "Test 1"; - String humanReadableName2 = "Test 2"; - - addSeries(tag1, humanReadableName1); - view.showMemoryChart(tag1); - - addSeries(tag2, humanReadableName2); - view.showMemoryChart(tag2); - - waitUntilSeriesShown(2); - - // Add some test data - List> data1 = new ArrayList>(); - data1.add(new DiscreteTimeData(1000L, 134217728L)); // 128MiB - data1.add(new DiscreteTimeData(2000L, 268435456L)); // 256MiB - data1.add(new DiscreteTimeData(3000L, 536870912L)); // 512MiB - - List> data2 = new ArrayList>(); - data2.add(new DiscreteTimeData(1500L, 536870912L)); // 512MiB - data2.add(new DiscreteTimeData(2500L, 134217728L)); // 128MiB - data2.add(new DiscreteTimeData(3500L, 268435456L)); // 256MiB - - final TimeSeries series1 = view.getSeries(tag1); - final TimeSeries series2 = view.getSeries(tag2); - - addData(tag1, data1, series1); - addData(tag2, data2, series2); - - // Remove data from series - view.clearMemoryData(tag1); - - // Wait until data removed to chart - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return series1.getItemCount() == 0; - } - - @Override - public String getFailureMessage() { - return "Data never added"; - } - }); - - // Check other series' size - assertEquals(data2.size(), series2.getItemCount()); - } - - private void waitUntilSeriesShown(final int numSeries) { - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - XYPlot plot = chart.getXYPlot(); - int count = plot.getSeriesCount(); - return count == numSeries; - } - - @Override - public String getFailureMessage() { - return "Data series never shown/hidden"; - } - }); - } - - private void addSeries(final String tag, String humanReadableName) { - view.addMemoryChart(tag, new LocalizedString(humanReadableName)); - - // Wait until series added - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return view.getSeries(tag) != null; - } - - @Override - public String getFailureMessage() { - return "Data series never added"; - } - }); - - // Wait for legend - bot.labelWithId(ThermostatConstants.TEST_TAG, - SWTHostMemoryView.TEST_ID_LEGEND_ITEM_LABEL); - } - - @Override - public void show(String tag) { - view.showMemoryChart(tag); - } - - @Override - public void hide(String tag) { - view.hideMemoryChart(tag); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostOverviewViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTHostOverviewViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,409 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; - -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.core.views.BasicView; -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.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewView; - -public class SWTHostOverviewViewTest { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTHostOverviewView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTHostOverviewView(parent); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testSetHostName() { - final String hostname = "Test Host"; - - view.setHostName(hostname); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_HOSTNAME); - return label.getText().equals(hostname); - } - - @Override - public String getFailureMessage() { - return "Hostname label not set"; - } - - }); - } - - @Test - public void testSetCpuModel() { - final String cpuModel = "Test CPU"; - - view.setCpuModel(cpuModel); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_PROC_MODEL); - return label.getText().equals(cpuModel); - } - - @Override - public String getFailureMessage() { - return "CPU Model label not set"; - } - - }); - } - - @Test - public void testSetCpuCount() { - final String cpuCount = "8"; - - view.setCpuCount(cpuCount); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_PROC_CORE_COUNT); - return label.getText().equals(cpuCount); - } - - @Override - public String getFailureMessage() { - return "CPU Count label not set"; - } - - }); - } - - @Test - public void testSetTotalMemory() { - final String totalMem = "100 TB"; - - view.setTotalMemory(totalMem); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_TOTAL_MEMORY); - return label.getText().equals(totalMem); - } - - @Override - public String getFailureMessage() { - return "Total Memory label not set"; - } - - }); - } - - @Test - public void testSetOsName() { - final String osName = "Test OS"; - - view.setOsName(osName); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_OS_NAME); - return label.getText().equals(osName); - } - - @Override - public String getFailureMessage() { - return "OS Name label not set"; - } - - }); - } - - @Test - public void testSetOsKernel() { - final String osKernel = "Test Kernel"; - - view.setOsKernel(osKernel); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotLabel label = bot.labelWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_OS_KERNEL); - return label.getText().equals(osKernel); - } - - @Override - public String getFailureMessage() { - return "OS Kernel label not set"; - } - - }); - } - - @Test - public void testSetNetworkTableColumns() { - final Object[] columns = { "Col 1", "Col 2", "Col 3" }; - addColumns(columns); - - SWTBotTable table = bot.tableWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_NETWORK_INTERFACES); - - List tableColumns = table.columns(); - assertEquals(columns[0], tableColumns.get(0)); - assertEquals(columns[1], tableColumns.get(1)); - assertEquals(columns[2], tableColumns.get(2)); - } - - protected void addColumns(final Object[] columns) { - view.setNetworkTableColumns(columns); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotTable table = bot.tableWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_NETWORK_INTERFACES); - - return table.columnCount() == 3; - } - - @Override - public String getFailureMessage() { - return "Network Interfaces columns not set"; - } - - }); - } - - @Test - public void testSetInitialNetworkTableData() { - final Object[] columns = { "Col 1", "Col 2", "Col 3" }; - final Object[][] data = { { "Iface 1", "IPv4 Addr 1", "IPv6 Addr 1" }, - { "Iface 2", "IPv4 Addr 2", "IPv6 Addr 2" }, - { "Iface 3", "IPv4 Addr 3", "IPv6 Addr 3" } }; - - addColumns(columns); - addInitialData(data); - - SWTBotTable table = bot.tableWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_NETWORK_INTERFACES); - - assertEquals(data[0][0], table.cell(0, 0)); - assertEquals(data[0][1], table.cell(0, 1)); - assertEquals(data[0][2], table.cell(0, 2)); - - assertEquals(data[1][0], table.cell(1, 0)); - assertEquals(data[1][1], table.cell(1, 1)); - assertEquals(data[1][2], table.cell(1, 2)); - - assertEquals(data[2][0], table.cell(2, 0)); - assertEquals(data[2][1], table.cell(2, 1)); - assertEquals(data[2][2], table.cell(2, 2)); - } - - protected void addInitialData(final Object[][] data) { - view.setInitialNetworkTableData(data); - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotTable table = bot.tableWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_NETWORK_INTERFACES); - - return table.rowCount() == 3; - } - - @Override - public String getFailureMessage() { - return "Network Interfaces inital data not set"; - } - - }); - } - - @Test - public void testUpdateNetworkTableData() { - final Object[] columns = { "Col 1", "Col 2", "Col 3" }; - final Object[][] data = { { "Iface 1", "IPv4 Addr 1", "IPv6 Addr 1" }, - { "Iface 2", "IPv4 Addr 2", "IPv6 Addr 2" }, - { "Iface 3", "IPv4 Addr 3", "IPv6 Addr 3" } }; - - addColumns(columns); - addInitialData(data); - - changeItem(0, 0, "Change 1"); - changeItem(0, 1, "Change 2"); - changeItem(2, 1, "Change 3"); - changeItem(1, 2, "Change 4"); - changeItem(2, 2, "Change 5"); - } - - protected void changeItem(final int row, final int col, final String item) { - view.updateNetworkTableData(row, col, item); - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - SWTBotTable table = bot.tableWithId( - ThermostatConstants.TEST_TAG, - SWTHostOverviewView.TEST_ID_NETWORK_INTERFACES); - - return table.cell(row, col).equals(item); - } - - @Override - public String getFailureMessage() { - return "Network Interfaces inital data not set"; - } - - }); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmClassStatViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmClassStatViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,208 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.jfree.chart.JFreeChart; -import org.jfree.data.xy.XYDataset; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.core.views.BasicView; -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.eclipse.chart.vmclassstat.SWTVmClassStatView; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -public class SWTVmClassStatViewTest { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTVmClassStatView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTVmClassStatView(parent); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testClearClassCount() { - List> data = new ArrayList>(); - data.add(new DiscreteTimeData(1000L, 0L)); - data.add(new DiscreteTimeData(2000L, 7L)); - data.add(new DiscreteTimeData(3000L, 50L)); - - addData(data); - - view.clearClassCount(); - - // Wait until data removed - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - return chart.getXYPlot().getDataset().getItemCount(0) == 0; - } - - @Override - public String getFailureMessage() { - return "Data not cleared"; - } - }); - } - - @Test - public void testAddClassCount() { - List> data = new ArrayList>(); - data.add(new DiscreteTimeData(1000L, 0L)); - data.add(new DiscreteTimeData(2000L, 7L)); - data.add(new DiscreteTimeData(3000L, 50L)); - - addData(data); - - // Verify data - XYDataset dataset = view.getChart().getXYPlot().getDataset(); - assertEquals(1000L, dataset.getX(0, 0)); - assertEquals(2000L, dataset.getX(0, 1)); - assertEquals(3000L, dataset.getX(0, 2)); - - assertEquals(0L, dataset.getY(0, 0)); - assertEquals(7L, dataset.getY(0, 1)); - assertEquals(50L, dataset.getY(0, 2)); - } - - public void addData(final List> data) { - view.addClassCount(data); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - return chart.getXYPlot().getDataset().getItemCount(0) == data.size(); - } - - @Override - public String getFailureMessage() { - return "Data not added"; - } - }); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmCpuViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmCpuViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.jfree.chart.JFreeChart; -import org.jfree.data.xy.XYDataset; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.core.views.BasicView; -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.eclipse.chart.common.SWTVmCpuView; -import com.redhat.thermostat.storage.model.DiscreteTimeData; - -public class SWTVmCpuViewTest { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTVmCpuView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTVmCpuView(parent); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testAddData() { - List> data = new ArrayList>(); - - data.add(new DiscreteTimeData(1000L, 20)); - data.add(new DiscreteTimeData(2000L, 80)); - data.add(new DiscreteTimeData(3000L, 50)); - - addSeries(data); - - JFreeChart chart = view.getChart(); - XYDataset dataset = chart.getXYPlot().getDataset(); - assertEquals(1000L, dataset.getX(0, 0)); - assertEquals(2000L, dataset.getX(0, 1)); - assertEquals(3000L, dataset.getX(0, 2)); - - assertEquals(20, dataset.getY(0, 0)); - assertEquals(80, dataset.getY(0, 1)); - assertEquals(50, dataset.getY(0, 2)); - } - - private void addSeries(List> data) { - view.addData(data); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - return chart.getXYPlot().getDataset().getItemCount(0) == 3; - } - - @Override - public String getFailureMessage() { - return "Data never added"; - } - }); - } - - @Test - public void testClearData() { - List> data = new ArrayList>(); - - data.add(new DiscreteTimeData(1000L, 20)); - data.add(new DiscreteTimeData(2000L, 80)); - data.add(new DiscreteTimeData(3000L, 50)); - - addSeries(data); - - view.clearData(); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(); - return chart.getXYPlot().getDataset().getItemCount(0) == 0; - } - - @Override - public String getFailureMessage() { - return "Data never cleared"; - } - }); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmGcViewTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test.ui/src/com/redhat/thermostat/eclipse/test/ui/SWTVmGcViewTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,344 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.ui; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -import org.jfree.chart.JFreeChart; -import org.jfree.data.xy.IntervalXYDataset; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.core.views.BasicView; -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.shared.locale.LocalizedString; -import com.redhat.thermostat.eclipse.chart.common.SWTVmGcView; -import com.redhat.thermostat.storage.model.IntervalTimeData; - -public class SWTVmGcViewTest { - private static final long TIMEOUT = 5000L; - private SWTWorkbenchBot bot; - private SWTVmGcView view; - private Shell shell; - - @Before - public void beforeTest() throws Exception { - bot = new SWTWorkbenchBot(); - - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - shell = new Shell(Display.getCurrent()); - Composite parent = new Composite(shell, SWT.NONE); - parent.setLayout(new GridLayout()); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - view = new SWTVmGcView(parent); - shell.open(); - } - }); - } - - @After - public void afterTest() throws Exception { - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - if (shell != null) { - shell.close(); - view = null; - } - } - }); - } - - @Test - public void testAddChart() { - addChart("TESTGC", "Test GC"); - } - - private void addChart(final String tag, String name) { - view.addChart(tag, new LocalizedString(name), "ms"); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return view.getChart(tag) != null; - } - - @Override - public String getFailureMessage() { - return "Chart not added"; - } - }); - } - - @Test - public void testAddChartMultiple() { - String tag = "TESTGC1"; - addChart(tag, "Test GC 1"); - addChart("TESTGC2", "Test GC 2"); - - // Ensure first is still there - assertNotNull(view.getChart(tag)); - } - - @Test - public void testRemoveChart() { - final String tag1 = "TESTGC1"; - addChart(tag1, "Test GC 1"); - String tag2 = "TESTGC2"; - addChart(tag2, "Test GC 2"); - - view.removeChart(tag1); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - return view.getChart(tag1) == null; - } - - @Override - public String getFailureMessage() { - return "Chart not removed"; - } - }); - - // Ensure other chart still there - assertNotNull(view.getChart(tag2)); - } - - @Test - public void testAddData() { - final String tag = "TESTGC"; - addChart(tag, "Test GC"); - - List> data = new ArrayList>(); - data.add(new IntervalTimeData(1000L, 1500L, 100D)); - data.add(new IntervalTimeData(1500L, 2000L, 120D)); - data.add(new IntervalTimeData(2000L, 2500L, 170D)); - - addData(tag, data); - - JFreeChart chart = view.getChart(tag); - IntervalXYDataset dataset = (IntervalXYDataset) chart.getXYPlot().getDataset(); - - assertEquals(1000L, dataset.getStartX(0, 0)); - assertEquals(1500L, dataset.getEndX(0, 0)); - assertEquals(100D, dataset.getY(0, 0)); - - assertEquals(1500L, dataset.getStartX(0, 1)); - assertEquals(2000L, dataset.getEndX(0, 1)); - assertEquals(120D, dataset.getY(0, 1)); - - assertEquals(2000L, dataset.getStartX(0, 2)); - assertEquals(2500L, dataset.getEndX(0, 2)); - assertEquals(170D, dataset.getY(0, 2)); - } - - @Test - public void testAddDataMultiple() { - final String tag1 = "TESTGC1"; - addChart(tag1, "Test GC1"); - final String tag2 = "TESTGC2"; - addChart(tag2, "Test GC2"); - - List> data1 = new ArrayList>(); - data1.add(new IntervalTimeData(1000L, 1500L, 100D)); - data1.add(new IntervalTimeData(1500L, 2000L, 120D)); - data1.add(new IntervalTimeData(2000L, 2500L, 170D)); - - addData(tag1, data1); - - List> data2 = new ArrayList>(); - data2.add(new IntervalTimeData(1200L, 1700L, 140D)); - data2.add(new IntervalTimeData(1700L, 2200L, 130D)); - data2.add(new IntervalTimeData(2200L, 2700L, 190D)); - - addData(tag2, data2); - - JFreeChart chart1 = view.getChart(tag1); - IntervalXYDataset dataset1 = (IntervalXYDataset) chart1.getXYPlot().getDataset(); - - assertEquals(1000L, dataset1.getStartX(0, 0)); - assertEquals(1500L, dataset1.getEndX(0, 0)); - assertEquals(100D, dataset1.getY(0, 0)); - - assertEquals(1500L, dataset1.getStartX(0, 1)); - assertEquals(2000L, dataset1.getEndX(0, 1)); - assertEquals(120D, dataset1.getY(0, 1)); - - assertEquals(2000L, dataset1.getStartX(0, 2)); - assertEquals(2500L, dataset1.getEndX(0, 2)); - assertEquals(170D, dataset1.getY(0, 2)); - - JFreeChart chart2 = view.getChart(tag2); - IntervalXYDataset dataset2 = (IntervalXYDataset) chart2.getXYPlot().getDataset(); - - assertEquals(1200L, dataset2.getStartX(0, 0)); - assertEquals(1700L, dataset2.getEndX(0, 0)); - assertEquals(140D, dataset2.getY(0, 0)); - - assertEquals(1700L, dataset2.getStartX(0, 1)); - assertEquals(2200L, dataset2.getEndX(0, 1)); - assertEquals(130D, dataset2.getY(0, 1)); - - assertEquals(2200L, dataset2.getStartX(0, 2)); - assertEquals(2700L, dataset2.getEndX(0, 2)); - assertEquals(190D, dataset2.getY(0, 2)); - } - - private void addData(final String tag, - List> data) { - view.addData(tag, data); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(tag); - return chart.getXYPlot().getDataset().getItemCount(0) == 3; - } - - @Override - public String getFailureMessage() { - return "Data not added"; - } - }); - } - - @Test - public void testClearData() { - final String tag1 = "TESTGC1"; - addChart(tag1, "Test GC1"); - final String tag2 = "TESTGC2"; - addChart(tag2, "Test GC2"); - - List> data1 = new ArrayList>(); - data1.add(new IntervalTimeData(1000L, 1500L, 100D)); - data1.add(new IntervalTimeData(1500L, 2000L, 120D)); - data1.add(new IntervalTimeData(2000L, 2500L, 170D)); - - addData(tag1, data1); - - List> data2 = new ArrayList>(); - data2.add(new IntervalTimeData(1200L, 1700L, 140D)); - data2.add(new IntervalTimeData(1700L, 2200L, 130D)); - data2.add(new IntervalTimeData(2200L, 2700L, 190D)); - - addData(tag2, data2); - - // Remove data from the first chart - view.clearData(tag1); - - bot.waitUntil(new DefaultCondition() { - - @Override - public boolean test() throws Exception { - JFreeChart chart = view.getChart(tag1); - return chart.getXYPlot().getDataset().getItemCount(0) == 0; - } - - @Override - public String getFailureMessage() { - return "Data not removed"; - } - }); - - // Ensure other chart unchanged - assertEquals(3, view.getChart(tag2).getXYPlot().getDataset().getItemCount(0)); - } - - @Test - public void testShowView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.show(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.VISIBLE, action[0]); - } - - @Test - public void testHideView() throws Exception { - final Action[] action = new Action[1]; - final CountDownLatch latch = new CountDownLatch(1); - view.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent actionEvent) { - action[0] = actionEvent.getActionId(); - latch.countDown(); - } - }); - - view.hide(); - latch.await(TIMEOUT, TimeUnit.MILLISECONDS); - assertEquals(Action.HIDDEN, action[0]); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/.classpath --- a/eclipse/com.redhat.thermostat.eclipse.test/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/.project --- a/eclipse/com.redhat.thermostat.eclipse.test/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/.settings/org.eclipse.jdt.core.prefs --- a/eclipse/com.redhat.thermostat.eclipse.test/.settings/org.eclipse.jdt.core.prefs Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse.test/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Version: 1.0.3.qualifier -Bundle-Name: Eclipse client tests -Bundle-Activator: com.redhat.thermostat.eclipse.test.Activator -Bundle-SymbolicName: com.redhat.thermostat.eclipse.test;singleton:=true -Bundle-Vendor: Redhat Inc. -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.junit;bundle-version="4.10.0", - com.redhat.thermostat.bundles.org.hamcrest.core;resolution:=optional, - com.redhat.thermostat.bundles.org.objenesis;resolution:=optional, - com.redhat.thermostat.bundles.org.mockito.mockito-core;resolution:=optional, - com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.chart.common, - com.redhat.thermostat.eclipse.chart.vmclassstat -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: com.redhat.thermostat.client.core, - com.redhat.thermostat.client.core.controllers, - com.redhat.thermostat.client.core.views, - com.redhat.thermostat.client.ui, - com.redhat.thermostat.common, - com.redhat.thermostat.storage.core, - com.redhat.thermostat.common.utils, - com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.chart.common, - com.redhat.thermostat.eclipse.chart.vmclassstat, - com.redhat.thermostat.eclipse.internal.model, - com.redhat.thermostat.eclipse.internal.views, - com.redhat.thermostat.eclipse.views, - com.redhat.thermostat.host.cpu.client.core, - com.redhat.thermostat.host.memory.client.core, - com.redhat.thermostat.host.overview.client.core, - com.redhat.thermostat.vm.classstat.client.core, - com.redhat.thermostat.vm.cpu.client.core, - com.redhat.thermostat.vm.gc.client.core, - org.mockito, - org.mockito.stubbing -Export-Package: com.redhat.thermostat.eclipse.test.model, - com.redhat.thermostat.eclipse.test.views diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/build.properties --- a/eclipse/com.redhat.thermostat.eclipse.test/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/fedora-packages.txt --- a/eclipse/com.redhat.thermostat.eclipse.test/fedora-packages.txt Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -The following Fedora packages required updates (OSGi metadata) in order -for this fragment to work: -- mockito -- hamcrest -- cglib \ No newline at end of file diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse.test/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.test - eclipse-test-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse Client Tests - - - ${basedir}/.. - - - - - local_client - p2 - file://${eclipse-root}/core-p2-repository/target/repository/ - - - local_eclipse - p2 - file://${eclipse-root}/com.redhat.thermostat.eclipse.p2-repo/target/repository/ - - - local_eclipse_test_deps - p2 - file://${eclipse-root}/test-deps-p2-repository/target/repository/ - - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - true - true - org.eclipse.platform.ide - - - p2-installable-unit - org.eclipse.sdk.feature.group - ${sdk-version} - - - p2-installable-unit - com.redhat.thermostat.client.feature.feature.group - 1.0.3-SNAPSHOT - - - p2-installable-unit - com.redhat.thermostat.eclipse.feature.feature.group - 1.0.3-SNAPSHOT - - - p2-installable-unit - com.redhat.thermostat.eclipse.test.deps.feature.feature.group - 1.0.3-SNAPSHOT - - - - - com.redhat.thermostat.common.core - 4 - true - - - com.redhat.thermostat.web.common - 4 - true - - - com.redhat.thermostat.web.client - 4 - true - - - com.redhat.thermostat.launcher - 4 - true - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/Activator.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/Activator.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.redhat.thermostat.eclipse.test"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostVmsTreeContentProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostVmsTreeContentProviderTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeContentProvider; -import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.HostsVMsLoader; -import com.redhat.thermostat.storage.core.VmRef; - -public class HostVmsTreeContentProviderTest { - - private HostsVmsTreeContentProvider treeProvider; - private HostRef hostRef; - HostsVMsLoader loader; - - @Before - public void setUp() throws Exception { - loader = mock(HostsVMsLoader.class); - hostRef = mock(HostRef.class); - treeProvider = new HostsVmsTreeContentProvider(loader); - } - - @After - public void tearDown() throws Exception { - hostRef = null; - treeProvider = null; - loader = null; - } - - @Test - public void canGetHosts() { - List expectedHosts = new ArrayList<>(); - HostRef hostRef1 = mock(HostRef.class); - HostRef hostRef2 = mock(HostRef.class); - expectedHosts.add(hostRef1); - expectedHosts.add(hostRef2); - - when(loader.getHosts()).thenReturn(expectedHosts); - Object[] children = treeProvider.getChildren(new HostsVmsTreeRoot()); - verifySameHosts(children, expectedHosts); - - children = treeProvider.getChildren(new String("ignored")); - assertTrue(children.length == 0); - } - - @Test - public void canGetVms() { - List expectedVms = new ArrayList<>(); - expectedVms.add(mock(VmRef.class)); - expectedVms.add(mock(VmRef.class)); - when(loader.getVMs(hostRef)).thenReturn(expectedVms); - Object[] children = treeProvider.getChildren(hostRef); - verifySameVms(children, expectedVms); - } - - @Test - public void canGetElements() { - List expectedHosts = new ArrayList<>(); - HostRef hostRef1 = mock(HostRef.class); - HostRef hostRef2 = mock(HostRef.class); - expectedHosts.add(hostRef1); - expectedHosts.add(hostRef2); - - when(loader.getHosts()).thenReturn(expectedHosts); - Object[] children = treeProvider.getElements(new HostsVmsTreeRoot()); - verifySameHosts(children, expectedHosts); - } - - @Test - public void canGetRoot() { - assertNull(treeProvider.getParent(new HostsVmsTreeRoot())); - } - - @Test - public void canGetVmParent() { - List expectedHosts = new ArrayList<>(); - HostRef hostRef1 = mock(HostRef.class); - HostRef hostRef2 = mock(HostRef.class); - expectedHosts.add(hostRef1); - expectedHosts.add(hostRef2); - List expectedVms = new ArrayList<>(); - VmRef vm = mock(VmRef.class); - expectedVms.add(mock(VmRef.class)); - expectedVms.add(vm); - expectedVms.add(mock(VmRef.class)); - when(loader.getHosts()).thenReturn(expectedHosts); - when(loader.getVMs(hostRef1)).thenReturn(expectedVms); - treeProvider = new HostsVmsTreeContentProvider(loader); - assertEquals(hostRef1, treeProvider.getParent(vm)); - } - - /** - * Implicitly tests inputChanged() as well - */ - @Test - public void canGetHostParent() { - List expectedHosts = new ArrayList<>(); - HostRef hostRef1 = mock(HostRef.class); - HostRef hostRef2 = mock(HostRef.class); - expectedHosts.add(hostRef1); - expectedHosts.add(hostRef2); - - // need this for reverse look-up map building - // which is triggered when inputChanged() is called - List expectedVms = new ArrayList<>(); - VmRef vm = mock(VmRef.class); - expectedVms.add(mock(VmRef.class)); - expectedVms.add(vm); - expectedVms.add(mock(VmRef.class)); - when(loader.getVMs(hostRef)).thenReturn(expectedVms); - when(loader.getHosts()).thenReturn(expectedHosts); - - // need to call inputChanged in order to set root - // this is safe to do since treeViewer's setInput() method - // triggers the same action. - HostsVmsTreeRoot root = new HostsVmsTreeRoot(); - treeProvider.inputChanged(null, null, root); - assertEquals(root, treeProvider.getParent(hostRef1)); - } - - @Test - public void hasChildren() { - List expectedHosts = new ArrayList<>(); - HostRef hostRef1 = mock(HostRef.class); - HostRef hostRef2 = mock(HostRef.class); - expectedHosts.add(hostRef1); - expectedHosts.add(hostRef2); - when(loader.getHosts()).thenReturn(expectedHosts); - assertTrue(treeProvider.hasChildren(new HostsVmsTreeRoot())); - expectedHosts = new ArrayList<>(); - when(loader.getHosts()).thenReturn(expectedHosts); - assertFalse(treeProvider.hasChildren(new HostsVmsTreeRoot())); - - List expectedVms = new ArrayList<>(); - VmRef vm = mock(VmRef.class); - expectedVms.add(mock(VmRef.class)); - expectedVms.add(vm); - expectedVms.add(mock(VmRef.class)); - when(loader.getVMs(hostRef)).thenReturn(expectedVms); - assertTrue(treeProvider.hasChildren(hostRef)); - expectedVms = new ArrayList<>(); - when(loader.getVMs(hostRef)).thenReturn(expectedVms); - assertFalse(treeProvider.hasChildren(hostRef)); - - // VMs don't have children - assertFalse(treeProvider.hasChildren(mock(VmRef.class))); - } - - private void verifySameHosts(Object[] children, List expectedHosts) { - assertEquals(children.length, expectedHosts.size()); - for (int i = 0; i < children.length; i++) { - assertTrue(children[i] instanceof HostRef); - assertEquals(children[i], expectedHosts.get(i)); - } - } - - private void verifySameVms(Object[] children, List expectedHosts) { - assertEquals(children.length, expectedHosts.size()); - for (int i = 0; i < children.length; i++) { - assertTrue(children[i] instanceof VmRef); - assertEquals(children[i], expectedHosts.get(i)); - } - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostsVmsLabelProviderTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/model/HostsVmsLabelProviderTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.model; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.redhat.thermostat.eclipse.internal.model.HostsVmsLabelProvider; -import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; - -public class HostsVmsLabelProviderTest { - - private HostsVmsLabelProvider labelProvider; - - @Before - public void setUp() { - labelProvider = new HostsVmsLabelProvider(); - } - - @After - public void tearDown() { - labelProvider = null; - } - - @Test - public void canGetLabels() { - String hostName = "host1"; - HostRef host = mock(HostRef.class); - when(host.getHostName()).thenReturn(hostName); - assertEquals(hostName, labelProvider.getText(host)); - String vmName = "vm1"; - VmRef vm = mock(VmRef.class); - when(vm.getName()).thenReturn(vmName); - } - - @Test(expected = RuntimeException.class) - public void getLabelthrowsException() { - labelProvider.getText(new HostsVmsTreeRoot()); - } - - @Test - public void canGetImage() { - assertNull(labelProvider.getImage(mock(HostRef.class))); - assertNull(labelProvider.getImage(mock(VmRef.class))); - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/AbstractRefViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/AbstractRefViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.isNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.junit.Before; -import org.osgi.framework.BundleContext; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.client.core.InformationService; -import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.internal.views.HostsVmsTreeViewPart; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.Ref; - -public abstract class AbstractRefViewPartTest { - - protected Composite parent; - protected RefViewPart view; - protected SWTComponent thermoView; - protected HostsVmsTreeViewPart hostVMView; - protected BundleContext context; - protected InformationServiceController controller; - private ISelectionProvider provider; - - public AbstractRefViewPartTest() { - super(); - } - - @SuppressWarnings("unchecked") - @Before - public void before() throws InvalidSyntaxException, PartInitException { - parent = spy(new Shell(Display.getCurrent())); - - context = mock(BundleContext.class); - view = spy(createViewPart(context)); - hostVMView = mock(HostsVmsTreeViewPart.class); - ServiceReference> ref = (ServiceReference>) mock(ServiceReference.class); - InformationService infoService = (InformationService) mock(InformationService.class); - controller = (InformationServiceController) mock(InformationServiceController.class); - when(infoService.getInformationServiceController((T) any(Ref.class))).thenReturn(controller); - when(context.getService(ref)).thenReturn(infoService); - when(context.getServiceReferences((String) isNull(), anyString())).thenReturn(new ServiceReference[] { ref }); - - // Workbench mocks - IWorkbenchWindow window = mock(IWorkbenchWindow.class); - IWorkbenchPage page = mock(IWorkbenchPage.class); - ISelectionService service = mock(ISelectionService.class); - IViewSite site = mock(IViewSite.class); - - when(page.findView(ThermostatConstants.VIEW_ID_HOST_VM)).thenReturn(hostVMView); - when(window.getSelectionService()).thenReturn(service); - when(window.getActivePage()).thenReturn(page); - when(view.getWorkbenchWindow()).thenReturn(window); - when(site.getId()).thenReturn(getViewID()); - when(view.getSite()).thenReturn(site); - - // ViewProvider mock - mockViewProvider(); - - // Selection mocks - IWorkbenchPartSite hostVMSite = mock(IWorkbenchPartSite.class); - provider = mock(ISelectionProvider.class); - - when(hostVMSite.getId()).thenReturn(ThermostatConstants.VIEW_ID_HOST_VM); - when(hostVMSite.getSelectionProvider()).thenReturn(provider); - when(hostVMView.getSite()).thenReturn(hostVMSite); - - view.init(site); - } - - protected abstract void mockViewProvider(); - - protected abstract RefViewPart createViewPart(BundleContext context); - - protected abstract String getViewID(); - - protected IStructuredSelection mockSelection(Ref ref) { - IStructuredSelection selection = mock(IStructuredSelection.class);; - when(provider.getSelection()).thenReturn(selection); - when(selection.getFirstElement()).thenReturn(ref); - - return selection; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.HostCpuViewPart; -import com.redhat.thermostat.eclipse.chart.common.SWTHostCpuViewProvider; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; - -public class HostCpuViewPartTest extends AbstractRefViewPartTest { - - private SWTHostCpuViewProvider viewProvider; - - @Test - public void testSetFocus() throws Exception { - view.createPartControl(parent); - view.setFocus(); - - verify(parent).setFocus(); - } - - @Test - public void testNoSelection() throws Exception { - view.createPartControl(parent); - verify(view).createNoSelectionLabel(); - } - - @Test - public void testBadSelection() throws Exception { - mockSelection(null); - view.createPartControl(parent); - verify(view).createNoSelectionLabel(); - } - - @Test - public void testSelectionBefore() throws Exception { - HostRef hostRef = new HostRef("TEST", "Test"); - mockSelection(hostRef); - view.createPartControl(parent); - - verify(view, never()).createNoSelectionLabel(); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - IStructuredSelection selection = mockSelection(hostRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - @Test - public void testSelectionVmRef() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - VmRef vmRef = new VmRef(hostRef, "vmId", 0, "Test"); - IStructuredSelection selection = mockSelection(vmRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new HostCpuViewPart(context); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTHostCpuViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(HostCpuViewProvider.class)).thenReturn( - ref); - } - - @Override - protected String getViewID() { - return ThermostatConstants.VIEW_ID_HOST_CPU; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.HostMemoryViewPart; -import com.redhat.thermostat.eclipse.chart.common.SWTHostMemoryViewProvider; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; -import com.redhat.thermostat.storage.core.HostRef; - -public class HostMemoryViewPartTest extends AbstractRefViewPartTest { - - private SWTHostMemoryViewProvider viewProvider; - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - IStructuredSelection selection = mockSelection(hostRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTHostMemoryViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(HostMemoryViewProvider.class)).thenReturn(ref); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new HostMemoryViewPart(context); - } - - @Override - protected String getViewID() { - return ThermostatConstants.VIEW_ID_HOST_MEMORY; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.internal.views.HostOverviewViewPart; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewViewProvider; -import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; -import com.redhat.thermostat.storage.core.HostRef; - -public class HostOverviewViewPartTest extends AbstractRefViewPartTest { - - private SWTHostOverviewViewProvider viewProvider; - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - IStructuredSelection selection = mockSelection(hostRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTHostOverviewViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(HostOverviewViewProvider.class)).thenReturn( - ref); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new HostOverviewViewPart(context); - } - - @Override - protected String getViewID() { - return ThermostatConstants.VIEW_ID_HOST_OVERVIEW; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/ThermostatPerspectiveTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/ThermostatPerspectiveTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.internal.views.ThermostatPerspectiveFactory; - -public class ThermostatPerspectiveTest { - - private IFolderLayout leftFolder; - private IFolderLayout rightFolder; - private IPageLayout layout; - - @Before - public void createLayout() { - ThermostatPerspectiveFactory factory = new ThermostatPerspectiveFactory(); - layout = mock(IPageLayout.class); - leftFolder = mock(IFolderLayout.class); - rightFolder = mock(IFolderLayout.class); - when(layout.createFolder(eq(ThermostatPerspectiveFactory.FOLDER_LEFT), anyInt(), anyFloat(), anyString())).thenReturn(leftFolder); - when(layout.createFolder(eq(ThermostatPerspectiveFactory.FOLDER_RIGHT), anyInt(), anyFloat(), anyString())).thenReturn(rightFolder); - factory.createInitialLayout(layout); - } - - @Test - public void testHostVMViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_HOST_VM, leftFolder); - } - - @Test - public void testHostVMShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_HOST_VM); - } - - @Test - public void testHostOverviewViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_HOST_OVERVIEW, rightFolder); - } - - @Test - public void testHostOverviewShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_HOST_OVERVIEW); - } - - @Test - public void testHostCPUViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_HOST_CPU, rightFolder); - } - - @Test - public void testHostCPUShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_HOST_CPU); - } - - @Test - public void testHostMemoryViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_HOST_MEMORY, rightFolder); - } - - @Test - public void testHostMemoryShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_HOST_MEMORY); - } - - @Test - public void testVMCPUViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_VM_CPU, rightFolder); - } - - @Test - public void testVMCPUShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_VM_CPU); - } - - @Test - public void testVMGCViewAdded() { - verifyViewAdded(ThermostatConstants.VIEW_ID_VM_GC, rightFolder); - } - - @Test - public void testVMGCShortcutAdded() { - verifyShortcutAdded(ThermostatConstants.VIEW_ID_VM_GC); - } - - private void verifyViewAdded(String viewID, IFolderLayout folder) { - verify(folder).addView(viewID); - } - - private void verifyShortcutAdded(String viewID) { - verify(layout).addShowViewShortcut(viewID); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/ViewVisibilityWatcherTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/ViewVisibilityWatcherTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.core.views.BasicView.Action; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.internal.views.ViewVisibilityWatcher; - -public class ViewVisibilityWatcherTest { - private static final Long TIME_OUT_MILLIS = 5000L; - private static final String VIEW_ID = IPageLayout.ID_PROBLEM_VIEW; - private IViewPart view; - private Shell shell; - private CountDownLatch latch; - private Action action; - private ViewVisibilityWatcher watcher; - - @Before - public void beforeTest() throws Exception { - shell = new Shell(Display.getCurrent()); - - latch = new CountDownLatch(1); - action = null; - - SWTComponent component = new SWTComponent() { - - @Override - public void show() { - action = Action.VISIBLE; - latch.countDown(); - } - - @Override - public void hide() { - action = Action.HIDDEN; - latch.countDown(); - } - }; - - watcher = new ViewVisibilityWatcher(component); - } - - @After - public void afterTest() throws Exception { - shell = null; - } - - @Test - public void testVisibleBeforeAttach() throws Exception { - showView(); - - // Attach - watcher.watch(shell, VIEW_ID); - - waitForAction(); - - assertEquals(Action.VISIBLE, action); - } - - @Test - public void testVisibleAfterAttach() throws Exception { - // Attach - watcher.watch(shell, VIEW_ID); - - showView(); - - waitForAction(); - - assertEquals(Action.VISIBLE, action); - } - - @Test - public void testVisibleBeforeAttachHiddenAfter() throws Exception { - showView(); - - // Attach - watcher.watch(shell, VIEW_ID); - - waitForAction(); - - assertEquals(Action.VISIBLE, action); - - // Hide view - latch = new CountDownLatch(1); - action = null; - - hideView(); - - waitForAction(); - - assertEquals(Action.HIDDEN, action); - } - - private void waitForAction() - throws InterruptedException { - if (!latch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS)) { - fail("Timeout while waiting for action"); - } - } - - private void showView() throws PartInitException { - view = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().showView(VIEW_ID); - } - - private void hideView() { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .hideView(view); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.chart.vmclassstat.Activator; -import com.redhat.thermostat.eclipse.chart.vmclassstat.SWTVmClassStatViewProvider; -import com.redhat.thermostat.eclipse.chart.vmclassstat.VmClassStatViewPart; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; -import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; - -public class VmClassStatViewPartTest extends AbstractRefViewPartTest { - - private SWTVmClassStatViewProvider viewProvider; - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - VmRef vmRef = new VmRef(hostRef, "vmId", 0, "Test"); - IStructuredSelection selection = mockSelection(vmRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTVmClassStatViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(VmClassStatViewProvider.class)).thenReturn( - ref); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new VmClassStatViewPart(context); - } - - @Override - protected String getViewID() { - return Activator.VIEW_ID_VM_CLASS_STAT; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.SWTVmCpuViewProvider; -import com.redhat.thermostat.eclipse.chart.common.VmCpuViewPart; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; -import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; - -public class VmCpuViewPartTest extends AbstractRefViewPartTest { - - private SWTVmCpuViewProvider viewProvider; - - @Test - public void testSelectionHostRef() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - IStructuredSelection selection = mockSelection(hostRef); - view.selectionChanged(hostVMView, selection); - - // Ensure not created - verify(viewProvider, never()).createView(); - } - - @Test - public void testSelectionHostRefAfterVmRef() throws Exception { - HostRef hostRef = new HostRef("TEST", "Test"); - VmRef vmRef = new VmRef(hostRef, "vmId", 0, "Test"); - mockSelection(vmRef); - view.createPartControl(parent); - - IStructuredSelection selection = mockSelection(hostRef); - view.selectionChanged(hostVMView, selection); - - // Ensure selection prompt shown - verify(view).createNoSelectionLabel(); - } - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - VmRef vmRef = new VmRef(hostRef, "vmId", 0, "Test"); - IStructuredSelection selection = mockSelection(vmRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTVmCpuViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(VmCpuViewProvider.class)).thenReturn( - ref); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new VmCpuViewPart(context); - } - - @Override - protected String getViewID() { - return ThermostatConstants.VIEW_ID_VM_CPU; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java --- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.test.views; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.junit.Test; -import org.mockito.InOrder; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.chart.common.SWTVmGcViewProvider; -import com.redhat.thermostat.eclipse.chart.common.VmGcViewPart; -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; -import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; - -public class VmGcViewPartTest extends AbstractRefViewPartTest { - - private SWTVmGcViewProvider viewProvider; - - @Test - public void testSelectionAfter() throws Exception { - view.createPartControl(parent); - - HostRef hostRef = new HostRef("TEST", "Test"); - VmRef vmRef = new VmRef(hostRef, "vmId", 0, "Test"); - IStructuredSelection selection = mockSelection(vmRef); - view.selectionChanged(hostVMView, selection); - - verifyViewProvider(); - } - - private void verifyViewProvider() { - InOrder order = inOrder(viewProvider, controller); - order.verify(viewProvider).setParent(any(Composite.class)); - order.verify(controller).getView(); - } - - @Override - protected void mockViewProvider() { - viewProvider = mock(SWTVmGcViewProvider.class); - @SuppressWarnings("unchecked") - ServiceReference ref = (ServiceReference) mock(ServiceReference.class); - when(context.getService(ref)).thenReturn(viewProvider); - when(context.getServiceReference(VmGcViewProvider.class)).thenReturn( - ref); - } - - @Override - protected RefViewPart createViewPart(BundleContext context) { - return new VmGcViewPart(context); - } - - @Override - protected String getViewID() { - return ThermostatConstants.VIEW_ID_VM_GC; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/.classpath --- a/eclipse/com.redhat.thermostat.eclipse/.classpath Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/.project --- a/eclipse/com.redhat.thermostat.eclipse/.project Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - - com.redhat.thermostat.eclipse - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF --- a/eclipse/com.redhat.thermostat.eclipse/META-INF/MANIFEST.MF Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Thermostat Eclipse Client -Bundle-Activator: com.redhat.thermostat.eclipse.internal.Activator -Bundle-SymbolicName: com.redhat.thermostat.eclipse;singleton:=true -Bundle-Version: 1.0.3.qualifier -Bundle-Vendor: Red Hat Inc. -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ui, - org.eclipse.ui.workbench -Import-Package: com.redhat.thermostat.client.core, - com.redhat.thermostat.client.core.controllers, - com.redhat.thermostat.client.core.views, - com.redhat.thermostat.client.locale, - com.redhat.thermostat.client.ui, - com.redhat.thermostat.common, - com.redhat.thermostat.shared.config, - com.redhat.thermostat.shared.locale, - com.redhat.thermostat.common.utils, - com.redhat.thermostat.host.overview.client.core, - com.redhat.thermostat.host.overview.client.locale, - com.redhat.thermostat.storage.config, - com.redhat.thermostat.storage.core, - com.redhat.thermostat.storage.model, - com.redhat.thermostat.storage.dao, - com.redhat.thermostat.utils.keyring, - com.redhat.thermostat.common.config, - org.eclipse.equinox.security.storage -Export-Package: com.redhat.thermostat.eclipse, - com.redhat.thermostat.eclipse.internal;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", - com.redhat.thermostat.eclipse.internal.controllers;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", - com.redhat.thermostat.eclipse.internal.jobs;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", - com.redhat.thermostat.eclipse.internal.model;x-friends:="com.redhat.thermostat.eclipse.test,com.redhat.thermostat.eclipse.test.ui", - com.redhat.thermostat.eclipse.internal.views, - com.redhat.thermostat.eclipse.views diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/build.properties --- a/eclipse/com.redhat.thermostat.eclipse/build.properties Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/ -forceContextQualifier = SNAPSHOT diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/icons/offline.png Binary file eclipse/com.redhat.thermostat.eclipse/icons/offline.png has changed diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/icons/online.png Binary file eclipse/com.redhat.thermostat.eclipse/icons/online.png has changed diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/plugin.xml --- a/eclipse/com.redhat.thermostat.eclipse/plugin.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/pom.xml --- a/eclipse/com.redhat.thermostat.eclipse/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse - eclipse-plugin - 1.0.3-SNAPSHOT - - Thermostat Eclipse Client - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - eclipse-feature - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/LoggerFacility.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/LoggerFacility.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import com.redhat.thermostat.eclipse.internal.Activator; - -public class LoggerFacility { - - private ILog log; - private static LoggerFacility instance; - private static boolean isLoggingEnabled; // want default of false - - private LoggerFacility() { - log = Activator.getDefault().getLog(); - isLoggingEnabled = Activator.inDebugMode(); - } - - /** - * Get a LoggerFacility singleton. - * - * @return The singleton instance. - */ - public static LoggerFacility getInstance() { - if (instance == null) { - instance = new LoggerFacility(); - } - return instance; - } - - /** - * Logs messages with the given severity. - * - * @param message - * The human readable localized message. - * @param throwable - * The exception which occurred. - */ - public void log(int severity, String message, Throwable throwable) { - if (isLoggingEnabled) { - log.log(new Status(severity, Activator.PLUGIN_ID, message, - throwable)); - } - } - - /** - * Logs messages with the given severity. - * - * @param message - * A human readable localized message. - * @param severity - * A suitable severity. See {@link IStatus}. - */ - public void log(int severity, String message) { - if (isLoggingEnabled) { - log.log(new Status(severity, Activator.PLUGIN_ID, message)); - } - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/SWTComponent.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/SWTComponent.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse; - -import com.redhat.thermostat.client.core.views.UIComponent; - -public interface SWTComponent extends UIComponent { - - public void show(); - - public void hide(); - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/SWTViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/SWTViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse; - -import org.eclipse.swt.widgets.Composite; - -import com.redhat.thermostat.client.core.views.ViewProvider; - -public abstract class SWTViewProvider implements ViewProvider { - - private Composite parent; - - public Composite getParent() { - return parent; - } - - public void setParent(Composite parent) { - this.parent = parent; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/ThermostatConstants.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/ThermostatConstants.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse; - -public interface ThermostatConstants { - - public static final String PERSPECTIVE_ID = "com.redhat.thermostat.eclipse.perspective"; - - public static final String VIEW_ID_HOST_VM = "com.redhat.thermostat.eclipse.vmtree"; - public static final String VIEW_ID_HOST_OVERVIEW = "com.redhat.thermostat.eclipse.mainContainer"; - public static final String VIEW_ID_HOST_CPU = "com.redhat.thermostat.eclipse.chart.hostCpuView"; - public static final String VIEW_ID_HOST_MEMORY = "com.redhat.thermostat.eclipse.chart.hostMemoryView"; - public static final String VIEW_ID_VM_CPU = "com.redhat.thermostat.eclipse.chart.vmCpuView"; - public static final String VIEW_ID_VM_GC = "com.redhat.thermostat.eclipse.chart.vmGcView"; - - public static final String TEST_TAG = "com.redhat.thermostat.eclipse.test.swtTag"; - - public static final String CONNECTION_URL_PREF_NAME = "com.redhat.thermostat.eclipse.prefs.connectionURL"; - public static final String USERNAME_PREF_NAME = "com.redhat.thermostat.eclipse.prefs.username"; - public static final String PASSWORD_PREF_NAME = "com.redhat.thermostat.eclipse.prefs.password"; - public static final String SAVE_ENTITLEMENTS_PREF_NAME = "com.redhat.thermostat.eclipse.prefs.saveEntitlements"; -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/Activator.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,225 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -import com.redhat.thermostat.eclipse.LoggerFacility; -import com.redhat.thermostat.eclipse.internal.views.SWTHostOverviewViewProvider; -import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; -import com.redhat.thermostat.shared.config.CommonPaths; -import com.redhat.thermostat.storage.core.ConnectionException; -import com.redhat.thermostat.storage.core.DbService; -import com.redhat.thermostat.utils.keyring.Keyring; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.redhat.thermostat.eclipse"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - private Keyring keyring; - @SuppressWarnings({ "rawtypes" }) - private ServiceTracker keyringTracker; - - private CommonPaths paths; - @SuppressWarnings({ "rawtypes" }) - private ServiceTracker pathsTracker; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext - * ) - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - - // Register ViewProvider - context.registerService(HostOverviewViewProvider.class, - new SWTHostOverviewViewProvider(), null); - - keyringTracker = new ServiceTracker(context, Keyring.class, null) { - @Override - public Object addingService(ServiceReference reference) { - Keyring keyring = (Keyring) context.getService(reference); - Activator.this.keyring = keyring; - return keyring; - } - - @Override - public void removedService(ServiceReference reference, Object service) { - Activator.this.keyring = null; - context.ungetService(reference); - } - - }; - pathsTracker = new ServiceTracker(context, CommonPaths.class, null) { - @Override - public Object addingService(ServiceReference reference) { - CommonPaths paths = (CommonPaths) context.getService(reference); - Activator.this.paths = paths; - return keyring; - } - - @Override - public void removedService(ServiceReference reference, Object service) { - Activator.this.paths = null; - context.ungetService(reference); - } - - }; - // Track Keyring and CommonPaths services. - keyringTracker.open(); - pathsTracker.open(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext - * ) - */ - public void stop(BundleContext context) throws Exception { - ServiceReference dbServiceRef = context.getServiceReference(DbService.class); - if (dbServiceRef != null) { - DbService dbService = context.getService(dbServiceRef); - if (dbService != null) { - try { - dbService.disconnect(); - context.ungetService(dbServiceRef); - } catch (ConnectionException e) { - LoggerFacility.getInstance().log(IStatus.ERROR, - "Error disconnecting from database", e); - } - } - } - plugin = null; - keyringTracker.close(); - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * - * @return {@code true} when platform was started in debug mode ( - * {@code -debug} switch) and - * {@code com.redhat.thermostat.eclipse/debug=true} is set in some - * .options file either in $HOME/.options or $(pwd)/.options. - */ - public static boolean inDebugMode() { - if (Platform.inDebugMode()) { - String debugOption = Platform.getDebugOption(PLUGIN_ID + "/debug"); //$NON-NLS-1$ - if (debugOption != null && debugOption.equals("true")) { //$NON-NLS-1$ - return true; - } - } - return false; - } - - public IWorkbenchPage getActivePage() { - return internalGetActivePage(); - } - - private IWorkbenchPage internalGetActivePage() { - IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); - if (window == null) - return null; - return window.getActivePage(); - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path - * - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - public boolean isDbConnected() { - boolean result = false; - BundleContext context = getBundle().getBundleContext(); - if (context.getServiceReference(DbService.class) != null) { - result = true; - } - return result; - } - - public Keyring getKeyring() { - return keyring; - } - - public CommonPaths getCommonPaths() { - return paths; - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/controllers/ConnectDBAction.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/controllers/ConnectDBAction.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.controllers; - -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.Action; - -public class ConnectDBAction extends Action { - - private Job connectJob; - - public ConnectDBAction(Job job) { - this.connectJob = job; - } - - @Override - public void run() { - connectJob.schedule(); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/controllers/ConnectionJobListener.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/controllers/ConnectionJobListener.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.controllers; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.action.Action; - -import com.redhat.thermostat.eclipse.internal.Activator; - -public class ConnectionJobListener extends JobChangeAdapter { - - private Action connectAction; - - public ConnectionJobListener(Action connectAction) { - this.connectAction = connectAction; - } - - @Override - public void done(IJobChangeEvent event) { - IStatus result = event.getResult(); - if (result.isOK()) { - connectAction.setImageDescriptor(Activator - .getImageDescriptor("icons/online.png")); - connectAction.setEnabled(!Activator.getDefault().isDbConnected()); - connectAction.setToolTipText("Online"); - } - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/jobs/ConnectDbJob.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/jobs/ConnectDbJob.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.jobs; - -import java.util.Arrays; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; - -import com.redhat.thermostat.common.config.ClientPreferences; -import com.redhat.thermostat.eclipse.LoggerFacility; -import com.redhat.thermostat.eclipse.internal.Activator; -import com.redhat.thermostat.storage.core.ConnectionException; -import com.redhat.thermostat.storage.core.DbService; -import com.redhat.thermostat.storage.core.DbServiceFactory; - -public class ConnectDbJob extends Job { - - private ClientPreferences configuration; - - public ConnectDbJob(String name, ClientPreferences configuration) { - super(name); - this.configuration = configuration; - } - - @Override - protected IStatus run(IProgressMonitor monitor) { - monitor.beginTask( - "Connecting to " + configuration.getConnectionUrl(), - IProgressMonitor.UNKNOWN); - try { - connectToBackEnd(); - return Status.OK_STATUS; - } catch (ConnectionException e) { - LoggerFacility.getInstance().log(IStatus.ERROR, - "Could not connect to DB", e); - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not connect to DB", e); - } - } - - /* - * Establish a DB connection. - */ - private void connectToBackEnd() throws ConnectionException { - DbServiceFactory dbServiceFactory = new DbServiceFactory(); - DbService dbService = dbServiceFactory.createDbService(configuration.getConnectionUrl()); - dbService.connect(); - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsLabelProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsLabelProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.model; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; - -public class HostsVmsLabelProvider extends LabelProvider { - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) - */ - @Override - public Image getImage(Object element) { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) - */ - @Override - public String getText(Object element) { - if (element instanceof HostRef) { - return ((HostRef) element).getHostName(); - } else if (element instanceof VmRef) { - return ((VmRef) element).getName(); - } else { - throw unknownElement(element); - } - } - - private RuntimeException unknownElement(Object element) { - return new RuntimeException("Unknown type of element in tree of type " - + element.getClass().getName()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeContentProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeContentProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.model; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.HostsVMsLoader; -import com.redhat.thermostat.storage.core.VmRef; - -public class HostsVmsTreeContentProvider implements ITreeContentProvider { - - private static final Object[] EMPTY_LIST = new Object[0]; - - private HostsVMsLoader loader; - private Map reverseLookupMap; - private HostsVmsTreeRoot root; - - public HostsVmsTreeContentProvider(HostsVMsLoader loader) { - this.loader = loader; - this.reverseLookupMap = buildReverseLookupMap(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - @Override - public void dispose() { - // nothing - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput instanceof HostsVmsTreeRoot) { - root = (HostsVmsTreeRoot) newInput; - } - // refresh reverse look-up - this.reverseLookupMap = buildReverseLookupMap(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang. - * Object) - */ - @Override - public Object[] getElements(Object root) { - return getChildren(root); - } - - @Override - public Object[] getChildren(Object parentElement) { - if (parentElement instanceof HostsVmsTreeRoot) { - return loader.getHosts().toArray(); - } else if (parentElement instanceof HostRef) { - HostRef hostRef = (HostRef) parentElement; - return loader.getVMs(hostRef).toArray(); - } else { - return EMPTY_LIST; - } - } - - @Override - public Object getParent(Object element) { - if (element instanceof HostsVmsTreeRoot) { - return null; - } else if (element instanceof HostRef) { - return root; - } else if (element instanceof VmRef) { - return this.reverseLookupMap.get(element); - } - return null; - } - - @Override - public boolean hasChildren(Object element) { - if (element instanceof HostsVmsTreeRoot) { - return loader.getHosts().size() > 0; - } else if (element instanceof HostRef) { - HostRef host = (HostRef) element; - return loader.getVMs(host).size() > 0; - } else { - // VM refs don't have children - return false; - } - } - - private Map buildReverseLookupMap() { - Map lookupMap = new HashMap<>(); - for (HostRef ref : loader.getHosts()) { - for (VmRef vmRef : loader.getVMs(ref)) { - lookupMap.put(vmRef, ref); - } - } - return lookupMap; - } -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeRoot.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/model/HostsVmsTreeRoot.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.model; - -/** - * A dummy root object, since the Hosts don't have a real root. - */ -public class HostsVmsTreeRoot { - // nothing -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/preferences/MainPreferencePage.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/preferences/MainPreferencePage.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.preferences; - -import java.io.IOException; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.redhat.thermostat.client.ui.ClientPreferencesModel; -import com.redhat.thermostat.common.config.ClientPreferences; -import com.redhat.thermostat.eclipse.LoggerFacility; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.eclipse.internal.Activator; - -/** - * Main preferences page for the Thermostat Eclipse client. - * - */ -public class MainPreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - - private static final int GROUP_SPAN = 2; - private static final String HTTP_PREFIX = "http"; - private static final String MONGODB_PREFIX = "mongodb"; - - private StringFieldEditor connectionUrlEditor; - private StringFieldEditor usernameEditor; - private StringFieldEditor passwordEditor; - private BooleanFieldEditor saveEntitlementsEditor; - private ClientPreferencesModel clientPrefs; - - /** - * Default no-arg constructor. - */ - public MainPreferencePage() { - super(GRID); - // TODO: Externalize string. - setDescription("Thermostat Client Preferences"); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); - } - - /** - * Validate fields for sane values. - */ - @Override - public void checkState() { - super.checkState(); - // connection URL has to be http(s) or mongodb - if (connectionUrlEditor.getStringValue() != null - && !(connectionUrlEditor.getStringValue().startsWith(HTTP_PREFIX) - || connectionUrlEditor.getStringValue().startsWith(MONGODB_PREFIX))) { - setErrorMessage("Connection URL must start with either 'http' or 'mongodb'"); - setValid(false); - } else { - // erase error message and mark things valid - setErrorMessage(null); - setValid(true); - } - } - - @Override - public boolean performOk() { - clientPrefs.setConnectionUrl(connectionUrlEditor.getStringValue()); - clientPrefs.setSaveEntitlements(saveEntitlementsEditor.getBooleanValue()); - if (saveEntitlementsEditor.getBooleanValue()) { - // FIXME Eclipse "Text" doesn't have a widget to return a char[] password, yet. - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=297412 - clientPrefs.setCredentials(usernameEditor.getStringValue(), passwordEditor.getTextControl(getFieldEditorParent()).getText().toCharArray()); - try { - clientPrefs.flush(); - } catch (IOException e) { - LoggerFacility.getInstance().log(IStatus.ERROR, "Failed to save preferences", e); - } - } - return true; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - @Override - public void init(IWorkbench arg0) { - // nothing - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - @Override - public void propertyChange(PropertyChangeEvent event) { - /* - * Validate input on change events. - */ - if (event.getProperty().equals(FieldEditor.VALUE)) { - checkState(); - } - } - - @Override - protected void createFieldEditors() { - Composite composite = getFieldEditorParent(); - - // General prefs - Group generalGroup = new Group(composite, SWT.SHADOW_ETCHED_IN); - generalGroup.setText("General"); - - GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1) - .applyTo(generalGroup); - connectionUrlEditor = new StringFieldEditor( - ThermostatConstants.CONNECTION_URL_PREF_NAME, - "Connection URL", - generalGroup); - usernameEditor = new StringFieldEditor( - ThermostatConstants.USERNAME_PREF_NAME, - "Username", - generalGroup); - passwordEditor = new StringFieldEditor(ThermostatConstants.PASSWORD_PREF_NAME, - "Password", generalGroup); - passwordEditor.getTextControl(generalGroup).setEchoChar('*'); - saveEntitlementsEditor = new BooleanFieldEditor( - ThermostatConstants.SAVE_ENTITLEMENTS_PREF_NAME, - "Save Entitlements", generalGroup); - // register change listener - connectionUrlEditor.setPropertyChangeListener(this); - addField(connectionUrlEditor); - addField(usernameEditor); - addField(passwordEditor); - addField(saveEntitlementsEditor); - updateMargins(generalGroup); - this.clientPrefs = new ClientPreferencesModel(Activator.getDefault().getKeyring(), new ClientPreferences(Activator.getDefault().getCommonPaths())); - synchronizeValues(); - } - - private void updateMargins(Group group) { - // make sure there is some room between the group border - // and the controls in the group - GridLayout layout = (GridLayout) group.getLayout(); - layout.marginWidth = 5; - layout.marginHeight = 5; - } - - private void synchronizeValues() { - IEclipsePreferences node = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID); - if (clientPrefs.getSaveEntitlements()) { - node.put(ThermostatConstants.USERNAME_PREF_NAME, clientPrefs.getUserName()); - // FIXME Need Eclipse prefs and widgets that supports char[] - String passString = new String(clientPrefs.getPassword()); - node.put(ThermostatConstants.PASSWORD_PREF_NAME, passString); - passwordEditor.setStringValue(passString); - usernameEditor.setStringValue(clientPrefs.getUserName()); - } else { - try { - node.clear(); - } catch (org.osgi.service.prefs.BackingStoreException e) { - LoggerFacility.getInstance().log(IStatus.ERROR, "Failed to clear preferences", e); - } - } - node.put(ThermostatConstants.CONNECTION_URL_PREF_NAME, - clientPrefs.getConnectionUrl()); - connectionUrlEditor.setStringValue(clientPrefs.getConnectionUrl()); - node.putBoolean(ThermostatConstants.SAVE_ENTITLEMENTS_PREF_NAME, clientPrefs.getSaveEntitlements()); - } - -} diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.internal.Activator; -import com.redhat.thermostat.eclipse.views.HostRefViewPart; -import com.redhat.thermostat.host.overview.client.core.HostOverviewService; -import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; - -public class HostOverviewViewPart extends HostRefViewPart { - - public HostOverviewViewPart() { - this(Activator.getDefault().getBundle().getBundleContext()); - } - - public HostOverviewViewPart(BundleContext context) { - super(context); - } - - @Override - protected Class getViewProviderClass() { - return HostOverviewViewProvider.class; - } - - @Override - protected String getInformationServiceID() { - return HostOverviewService.SERVICE_ID; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostsVmsTreeViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostsVmsTreeViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.common.ApplicationService; -import com.redhat.thermostat.common.MultipleServiceTracker; -import com.redhat.thermostat.common.Timer; -import com.redhat.thermostat.common.Timer.SchedulingType; -import com.redhat.thermostat.common.config.ClientPreferences; -import com.redhat.thermostat.eclipse.internal.Activator; -import com.redhat.thermostat.eclipse.internal.controllers.ConnectDBAction; -import com.redhat.thermostat.eclipse.internal.controllers.ConnectionJobListener; -import com.redhat.thermostat.eclipse.internal.jobs.ConnectDbJob; -import com.redhat.thermostat.eclipse.internal.model.HostsVmsLabelProvider; -import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeContentProvider; -import com.redhat.thermostat.eclipse.internal.model.HostsVmsTreeRoot; -import com.redhat.thermostat.storage.core.DefaultHostsVMsLoader; -import com.redhat.thermostat.storage.core.HostsVMsLoader; -import com.redhat.thermostat.storage.dao.HostInfoDAO; -import com.redhat.thermostat.storage.dao.VmInfoDAO; - -/** - * - * The main class for the VM tree view of the Thermostat Eclipse client. - * - */ -public class HostsVmsTreeViewPart extends ViewPart { - - private Action connectAction; - // Hosts and VMs viewer - private TreeViewer treeViewer; - // viewer for the connect viewing. - private Composite connectPage; - // Container for tree and connect - private PageBook pageBook; - private MultipleServiceTracker tracker; - private ApplicationService appSvc; - private HostInfoDAO hostInfoDAO; - private VmInfoDAO vmInfoDAO; - private boolean closing; - private Timer timer; - - public HostsVmsTreeViewPart() { - ClientPreferences clientPrefs = new ClientPreferences(Activator.getDefault().getCommonPaths()); - Job connectJob = new ConnectDbJob( - "Connecting to Thermostat storage...", clientPrefs); - connectJob.setSystem(true); - connectAction = new ConnectDBAction(connectJob); - connectAction.setImageDescriptor(Activator - .getImageDescriptor("icons/offline.png")); - connectJob.addJobChangeListener(new ConnectionJobListener(connectAction)); - - BundleContext context = Activator.getDefault().getBundle().getBundleContext(); - Class[] deps = new Class[] { - ApplicationService.class, - HostInfoDAO.class, - VmInfoDAO.class - }; - tracker = new MultipleServiceTracker(context, deps, new MultipleServiceTracker.Action() { - - @Override - public void dependenciesAvailable(Map services) { - appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - hostInfoDAO = (HostInfoDAO) services.get(HostInfoDAO.class.getName()); - Objects.requireNonNull(hostInfoDAO); - vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - - // Switch to Hosts/VMs page - showHostVmsPage(); - } - - @Override - public void dependenciesUnavailable() { - if (!closing) { - // Show the user an error - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - - @Override - public void run() { - MessageDialog.openError(null, "Connection Error", "Unable to connect to storage"); - } - }); - // Switch to the connection page - showConnectionPage(); - } - } - }); - } - - @Override - public void dispose() { - closing = true; - tracker.close(); - super.dispose(); - } - - public void showConnectionPage() { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - // Stop background updates - if (timer != null) { - timer.stop(); - } - pageBook.showPage(connectPage); - } - }); - } - - private void showHostVmsPage() { - final HostsVMsLoader loader = new DefaultHostsVMsLoader(hostInfoDAO, - vmInfoDAO, true /* TODO Make configurable */); - final HostsVmsTreeRoot root = new HostsVmsTreeRoot(); - - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - initializeTimer(root); - - treeViewer.setContentProvider(new HostsVmsTreeContentProvider(loader)); - treeViewer.setLabelProvider(new HostsVmsLabelProvider()); - treeViewer.setUseHashlookup(true); - treeViewer.setInput(root); - - // Start background updates - timer.start(); - - pageBook.showPage(treeViewer.getControl()); - } - - }); - } - - @Override - public void createPartControl(final Composite parent) { - IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - mgr.add(connectAction); - - pageBook = new PageBook(parent, SWT.NONE); - - // Prepare Hosts/VMs tree - treeViewer = new TreeViewer(pageBook, SWT.NONE); - // register the tree as selection provider - getSite().setSelectionProvider(treeViewer); - - // Prepare connect page - RowLayout layout = new RowLayout(); - layout.wrap = true; - connectPage = new Composite(pageBook, SWT.NONE); - connectPage.setLayout(layout); - Label test = new Label(connectPage, SWT.NONE); - test.setText("Not connected... "); - Link link = new Link(connectPage, SWT.NONE); - // FIXME: Externalize - link.setText("Connect"); - link.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event event) { - connectAction.run(); - } - }); - - showConnectionPage(); - tracker.open(); - } - - @Override - public void setFocus() { - pageBook.setFocus(); - } - - private void initializeTimer(final HostsVmsTreeRoot root) { - timer = appSvc.getTimerFactory().createTimer(); - timer.setAction(new Runnable() { - - @Override - public void run() { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if (!treeViewer.getTree().isDisposed()) { - // Turn off redrawing while we update to prevent flickering - treeViewer.getTree().setRedraw(false); - - // Preserve expanded elements - Object[] expandedElements = treeViewer.getExpandedElements(); - - // Force update to tree - treeViewer.setInput(root); - - // Restore expanded elements - treeViewer.setExpandedElements(expandedElements); - - treeViewer.getTree().setRedraw(true); - } - } - }); - } - }); - timer.setInitialDelay(0); - timer.setDelay(3); - timer.setTimeUnit(TimeUnit.SECONDS); - timer.setSchedulingType(SchedulingType.FIXED_RATE); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/RefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/RefViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,266 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -import com.redhat.thermostat.client.core.InformationService; -import com.redhat.thermostat.client.core.controllers.InformationServiceController; -import com.redhat.thermostat.client.core.views.View; -import com.redhat.thermostat.client.core.views.ViewProvider; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.eclipse.ThermostatConstants; -import com.redhat.thermostat.storage.core.Ref; - -public abstract class RefViewPart extends ViewPart implements - ISelectionListener { - - protected Composite top; - - private Composite parent; - private IStructuredSelection currentSelection; - - private ServiceTracker, InformationService> tracker; - private InformationService infoService; - private BundleContext context; - - public RefViewPart(BundleContext context) { - super(); - this.context = context; - } - - @Override - public void init(IViewSite site) throws PartInitException { - super.init(site); - - try { - tracker = new ServiceTracker, InformationService>(context, createFilter(), null) { - @Override - public InformationService addingService( - ServiceReference> reference) { - infoService = super.addingService(reference); - return infoService; - } - @Override - public void removedService( - ServiceReference> reference, - InformationService service) { - infoService = null; - super.removedService(reference, service); - } - }; - } catch (InvalidSyntaxException e) { - throw new PartInitException("Bad OSGi filter", e); - } - tracker.open(); - } - - @Override - public void createPartControl(Composite parent) { - this.parent = parent; - - createComposite(); - - getWorkbenchWindow().getSelectionService().addSelectionListener(this); - - // Check for an existing selection - boolean selected = false; - IViewPart part = getWorkbenchWindow().getActivePage().findView( - ThermostatConstants.VIEW_ID_HOST_VM); - if (part != null) { - ISelection selection = part.getSite().getSelectionProvider() - .getSelection(); - if (selection instanceof IStructuredSelection - && !selection.isEmpty()) { - currentSelection = (IStructuredSelection) selection; - T ref = handleSelection(selection); - if (ref != null) { - createView(ref); - selected = true; - } - } - } - if (!selected) { - createNoSelectionLabel(); - } - } - - @Override - public void dispose() { - tracker.close(); - super.dispose(); - } - - public void createNoSelectionLabel() { - Label noHost = new Label(top, SWT.NONE); - noHost.setText(getNoSelectionMessage()); - } - - public IWorkbenchWindow getWorkbenchWindow() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - } - - @Override - public void setFocus() { - parent.setFocus(); - } - - /** - * Returns the {@link ViewProvider} class for the root {@link View} - * whose controls will be placed in this ViewPart. - * @return the {@link ViewProvider} class - */ - protected abstract Class getViewProviderClass(); - - /** - * Parses the given selection and returns a {@link Ref} suitable as input for - * this view, if one can be found. - * @param selection a selected element from the Hosts/VMs view - * @return a {@link Ref} parsed from selection - */ - protected abstract T getRefFromSelection(Object selection); - - /** - * Returns a helpful message when the current selection in the Hosts/VMs - * view does not contain a {@link Ref} that this view can provide - * information for. This message should inform the user what they should - * select to receive data in this view. - * @return a message prompting the user to make a selection in the - * Hosts/VMs view - */ - protected abstract String getNoSelectionMessage(); - - /** - * Returns the identifier for the {@link InformationService} that this - * ViewPart corresponds to. This identifier must have been set as a - * property with key {@link InformationService#KEY_SERVICE_ID} when the - * service was registered. - * @return the unique service ID for a specific implementation of - * {@link InformationService} - */ - protected abstract String getInformationServiceID(); - - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - // We must have received createPartControl - if (parent != null && !parent.isDisposed()) { - // Check if a HostRef has been selected - if (part.getSite().getId() - .equals(ThermostatConstants.VIEW_ID_HOST_VM)) { - if (selection instanceof IStructuredSelection - && !selection.isEmpty() - && !selection.equals(currentSelection)) { - currentSelection = (IStructuredSelection) selection; - T ref = handleSelection(selection); - // Replace the existing view - top.dispose(); - createComposite(); - - if (ref != null) { - createView(ref); - } else { - // Prompt the user to select a valid ref - createNoSelectionLabel(); - } - parent.layout(); - } - } - } - } - - private T handleSelection(ISelection selection) { - Object selectedElement = ((IStructuredSelection) selection) - .getFirstElement(); - return getRefFromSelection(selectedElement); - } - - private void createComposite() { - top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - } - - private void createView(T ref) { - if (infoService != null) { - // Get the ViewProvider and set its parent Composite - Class viewProviderClazz = getViewProviderClass(); - ServiceReference serviceRef = context.getServiceReference(viewProviderClazz); - SWTViewProvider viewProvider = (SWTViewProvider) context.getService(serviceRef); - viewProvider.setParent(top); - - // Instantiate the service's controller and view - InformationServiceController controller = infoService.getInformationServiceController(ref); - SWTComponent view = (SWTComponent) controller.getView(); - - // Register for view visibility updates - ViewVisibilityWatcher watcher = new ViewVisibilityWatcher(view); - watcher.watch(top, getSite().getId()); - - context.ungetService(serviceRef); - } - } - - private Filter createFilter() throws InvalidSyntaxException { - String filter = "(&(" + Constants.OBJECTCLASS + "=" - + InformationService.class.getName() + ")(" - + InformationService.KEY_SERVICE_ID + "=" + getInformationServiceID() + "))"; - return FrameworkUtil.createFilter(filter); - } - -} diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/SWTHostOverviewView.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/SWTHostOverviewView.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,384 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CellLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.PlatformUI; - -import com.redhat.thermostat.host.overview.client.core.HostOverviewView; -import com.redhat.thermostat.host.overview.client.locale.LocaleResources; -import com.redhat.thermostat.shared.locale.Translate; -import com.redhat.thermostat.eclipse.SWTComponent; -import com.redhat.thermostat.eclipse.ThermostatConstants; - -public class SWTHostOverviewView extends HostOverviewView implements - SWTComponent { - private static final String CLASS_NAME = SWTHostOverviewView.class.getSimpleName(); - public static final String TEST_ID_HOSTNAME = CLASS_NAME + ".hostname"; - public static final String TEST_ID_PROC_MODEL = CLASS_NAME + ".procModel"; - public static final String TEST_ID_PROC_CORE_COUNT = CLASS_NAME + ".procCoreCount"; - public static final String TEST_ID_TOTAL_MEMORY = CLASS_NAME + ".totalMemory"; - public static final String TEST_ID_NETWORK_INTERFACES = CLASS_NAME + ".networkInterfaces"; - public static final String TEST_ID_OS_NAME = CLASS_NAME + ".osName"; - public static final String TEST_ID_OS_KERNEL = CLASS_NAME + ".osKernel"; - - private static final Translate translator = LocaleResources - .createLocalizer(); - private static final int FIRST_COLUMN_WIDTH = 150; - private static final String STR_UNKNOWN = "UNKNOWN"; - private static final int NUM_TABLE_ROWS = 5; - private static int[] TABLE_COLUMN_WIDTHS = { 80, 150, 300 }; - - private Label hostname; - private Label procModel; - private Label procCoreCount; - private Label totalMemory; - private TableViewer networkInterfaces; - private Label osName; - private Label osKernel; - - public SWTHostOverviewView(Composite parent) { - Composite top = new Composite(parent, SWT.NONE); - top.setLayout(new GridLayout()); - top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - // Basics - Label lblBasics = new Label(top, SWT.NONE); - lblBasics.setText(translator - .localize(LocaleResources.HOST_OVERVIEW_SECTION_BASICS).getContents()); - Font stdFont = lblBasics.getFont(); - Font boldFont = new Font(stdFont.getDevice(), - stdFont.getFontData()[0].getName(), - stdFont.getFontData()[0].getHeight(), SWT.BOLD); - lblBasics.setFont(boldFont); - Composite basicsComps = new Composite(top, SWT.NONE); - GridLayout gridlayout = new GridLayout(2, false); - basicsComps.setLayout(gridlayout); - basicsComps.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, - false)); - Label lblHostName = new Label(basicsComps, SWT.NONE); - lblHostName.setText(translator - .localize(LocaleResources.HOST_INFO_HOSTNAME).getContents()); - GridData hostNameGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - hostNameGridData.widthHint = FIRST_COLUMN_WIDTH; - lblHostName.setLayoutData(hostNameGridData); - hostname = new Label(basicsComps, SWT.NONE); - hostname.setData(ThermostatConstants.TEST_TAG, TEST_ID_HOSTNAME); - hostname.setText(STR_UNKNOWN); - hostname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - - // Hardware - Label lblHardware = new Label(top, SWT.NONE); - lblHardware.setText(translator - .localize(LocaleResources.HOST_OVERVIEW_SECTION_HARDWARE).getContents()); - lblHardware.setFont(boldFont); - Composite hardwareComps = new Composite(top, SWT.NONE); - hardwareComps.setLayout(gridlayout); - hardwareComps.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, - false)); - Label lblProcModel = new Label(hardwareComps, SWT.NONE); - lblProcModel.setText(translator - .localize(LocaleResources.HOST_INFO_CPU_MODEL).getContents()); - GridData procModelGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - procModelGridData.widthHint = FIRST_COLUMN_WIDTH; - lblProcModel.setLayoutData(procModelGridData); - procModel = new Label(hardwareComps, SWT.NONE); - procModel.setData(ThermostatConstants.TEST_TAG, TEST_ID_PROC_MODEL); - procModel.setText(STR_UNKNOWN); - procModel - .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - Label lblProcCount = new Label(hardwareComps, SWT.NONE); - lblProcCount.setText(translator - .localize(LocaleResources.HOST_INFO_CPU_COUNT).getContents()); - GridData procCountGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - procCountGridData.widthHint = FIRST_COLUMN_WIDTH; - lblProcCount.setLayoutData(procCountGridData); - procCoreCount = new Label(hardwareComps, SWT.NONE); - procCoreCount.setData(ThermostatConstants.TEST_TAG, TEST_ID_PROC_CORE_COUNT); - procCoreCount.setText(STR_UNKNOWN); - procCoreCount.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - Label lblTotalMemory = new Label(hardwareComps, SWT.NONE); - lblTotalMemory.setText(translator - .localize(LocaleResources.HOST_INFO_MEMORY_TOTAL).getContents()); - GridData totalMemGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - totalMemGridData.widthHint = FIRST_COLUMN_WIDTH; - lblTotalMemory.setLayoutData(totalMemGridData); - totalMemory = new Label(hardwareComps, SWT.NONE); - totalMemory.setData(ThermostatConstants.TEST_TAG, TEST_ID_TOTAL_MEMORY); - totalMemory.setText(STR_UNKNOWN); - totalMemory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - Label lblNetwork = new Label(hardwareComps, SWT.NONE); - lblNetwork.setText(translator - .localize(LocaleResources.HOST_INFO_NETWORK).getContents()); - GridData networkLayout = new GridData(SWT.FILL, SWT.TOP, false, false); - networkLayout.widthHint = FIRST_COLUMN_WIDTH; - lblNetwork.setLayoutData(networkLayout); - networkInterfaces = new TableViewer(hardwareComps, SWT.BORDER); - networkInterfaces.getTable().setData(ThermostatConstants.TEST_TAG, TEST_ID_NETWORK_INTERFACES); - createNetworkTableViewer(); - - // Software - Label lblSoftware = new Label(top, SWT.NONE); - lblSoftware.setText(translator - .localize(LocaleResources.HOST_OVERVIEW_SECTION_SOFTWARE).getContents()); - lblSoftware.setFont(boldFont); - Composite softwareComps = new Composite(top, SWT.NONE); - softwareComps.setLayout(gridlayout); - softwareComps.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, - false)); - Label lblOsName = new Label(softwareComps, SWT.NONE); - lblOsName.setText(translator - .localize(LocaleResources.HOST_INFO_OS_NAME).getContents()); - GridData osNameGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - osNameGridData.widthHint = FIRST_COLUMN_WIDTH; - lblOsName.setLayoutData(osNameGridData); - osName = new Label(softwareComps, SWT.NONE); - osName.setData(ThermostatConstants.TEST_TAG, TEST_ID_OS_NAME); - osName.setText(STR_UNKNOWN); - osName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - Label lblKernel = new Label(softwareComps, SWT.NONE); - lblKernel.setText(translator - .localize(LocaleResources.HOST_INFO_OS_KERNEL).getContents()); - GridData osKernelGridData = new GridData(SWT.FILL, SWT.CENTER, false, - false); - osKernelGridData.widthHint = FIRST_COLUMN_WIDTH; - lblKernel.setLayoutData(osKernelGridData); - osKernel = new Label(softwareComps, SWT.NONE); - osKernel.setData(ThermostatConstants.TEST_TAG, TEST_ID_OS_KERNEL); - osKernel.setText(STR_UNKNOWN); - osKernel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - } - - @Override - public void setHostName(final String newHostName) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!hostname.isDisposed()) { - hostname.setText(newHostName); - } - } - }); - } - - @Override - public void setCpuModel(final String newCpuModel) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!procModel.isDisposed()) { - procModel.setText(newCpuModel); - } - } - }); - } - - @Override - public void setCpuCount(final String newCpuCount) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!procCoreCount.isDisposed()) { - procCoreCount.setText(newCpuCount); - } - } - }); - } - - @Override - public void setTotalMemory(final String newTotalMemory) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!totalMemory.isDisposed()) { - totalMemory.setText(newTotalMemory); - } - } - }); - } - - @Override - public void setOsName(final String newOsName) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!osName.isDisposed()) { - osName.setText(newOsName); - } - } - }); - } - - @Override - public void setOsKernel(final String newOsKernel) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!osKernel.isDisposed()) { - osKernel.setText(newOsKernel); - } - } - }); - } - - @Override - public void setNetworkTableColumns(final Object[] columns) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!networkInterfaces.getTable().isDisposed()) { - for (int i = 0; i < columns.length; i++) { - Object column = columns[i]; - createTableViewerColumn(column.toString(), - TABLE_COLUMN_WIDTHS[i]); - networkInterfaces.getTable().getParent().layout(); - } - } - } - }); - } - - @Override - public void setInitialNetworkTableData(final Object[][] table) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!networkInterfaces.getTable().isDisposed()) { - networkInterfaces.setInput(table); - } - } - }); - } - - @Override - public void updateNetworkTableData(final int row, final int column, - final String data) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!networkInterfaces.getTable().isDisposed()) { - Object[][] input = (Object[][]) networkInterfaces - .getInput(); - input[row][column] = data; - networkInterfaces.refresh(); - } - } - }); - } - - private void createNetworkTableViewer() { - final Table table = networkInterfaces.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - table.setLayout(new GridLayout()); - GridData tableGridData = new GridData(); - int height = NUM_TABLE_ROWS - * networkInterfaces.getTable().getItemHeight(); - tableGridData.heightHint = height; - table.setLayoutData(tableGridData); - - networkInterfaces.setContentProvider(new ArrayContentProvider()); - - // create empty table - networkInterfaces.setInput(new Object[0]); - } - - private TableViewerColumn createTableViewerColumn(String title, int bound) { - final TableViewerColumn viewerColumn = new TableViewerColumn( - networkInterfaces, SWT.NONE); - final TableColumn column = viewerColumn.getColumn(); - column.setText(title); - column.setWidth(bound); - column.setResizable(true); - column.setMoveable(false); - - viewerColumn.setLabelProvider(new CellLabelProvider() { - - @Override - public void update(ViewerCell cell) { - int idx = cell.getColumnIndex(); - Object[] array = (Object[]) cell.getElement(); - Object element = array[idx]; - if (element != null) { - cell.setText(element.toString()); - } - } - }); - return viewerColumn; - } - - @Override - public void setMemoryPercentage(float percent) { - // TODO implement this - } - - @Override - public void setCPUPercentage(float percent) { - // TODO implement this - } - - @Override - public void show() { - notifier.fireAction(Action.VISIBLE); - } - - @Override - public void hide() { - notifier.fireAction(Action.HIDDEN); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/SWTHostOverviewViewProvider.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/SWTHostOverviewViewProvider.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import com.redhat.thermostat.eclipse.SWTViewProvider; -import com.redhat.thermostat.host.overview.client.core.HostOverviewView; -import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; - -public class SWTHostOverviewViewProvider extends SWTViewProvider implements HostOverviewViewProvider { - - @Override - public HostOverviewView createView() { - return new SWTHostOverviewView(getParent()); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/ThermostatPerspectiveFactory.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/ThermostatPerspectiveFactory.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import org.eclipse.ui.IFolderLayout; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -import com.redhat.thermostat.eclipse.ThermostatConstants; - -public class ThermostatPerspectiveFactory implements IPerspectiveFactory { - - public static final String FOLDER_LEFT = "left"; - public static final String FOLDER_RIGHT = "right"; - - @Override - public void createInitialLayout(IPageLayout layout) { - defineActions(layout); - defineLayout(layout); - } - - private void defineLayout(IPageLayout layout) { - IFolderLayout left = layout.createFolder(FOLDER_LEFT, IPageLayout.LEFT, 0.25f, layout.getEditorArea()); - left.addView(ThermostatConstants.VIEW_ID_HOST_VM); - - IFolderLayout right = layout.createFolder(FOLDER_RIGHT, IPageLayout.RIGHT, 0.5f, layout.getEditorArea()); - right.addView(ThermostatConstants.VIEW_ID_HOST_OVERVIEW); - right.addView(ThermostatConstants.VIEW_ID_HOST_CPU); - right.addView(ThermostatConstants.VIEW_ID_HOST_MEMORY); - right.addView(ThermostatConstants.VIEW_ID_VM_CPU); - right.addView(ThermostatConstants.VIEW_ID_VM_GC); - - layout.setEditorAreaVisible(false); - } - - private void defineActions(IPageLayout layout) { - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_HOST_VM); - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_HOST_OVERVIEW); - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_HOST_CPU); - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_HOST_MEMORY); - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_VM_CPU); - layout.addShowViewShortcut(ThermostatConstants.VIEW_ID_VM_GC); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/ViewVisibilityWatcher.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/ViewVisibilityWatcher.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.internal.views; - -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -import com.redhat.thermostat.eclipse.SWTComponent; - -public class ViewVisibilityWatcher { - - private SWTComponent component; - private boolean visible; - - public ViewVisibilityWatcher(SWTComponent component) { - this.component = component; - this.visible = false; - } - - public void watch(Composite parent, final String viewID) { - // Check if the view is currently visible - IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IViewPart view = activePage.findView(viewID); - if (activePage.isPartVisible(view)) { - visible = true; - component.show(); - } - - // Register listener for visibility updates on the Eclipse view - final IPartListener2 partListener = new IPartListener2() { - - @Override - public void partVisible(IWorkbenchPartReference partRef) { - // The workbench fires a visible event when the view first takes - // focus, even if it was already on top - if (!visible && viewID.equals(partRef.getId())) { - component.show(); - visible = true; - } - } - - @Override - public void partHidden(IWorkbenchPartReference partRef) { - if (visible && viewID.equals(partRef.getId())) { - component.hide(); - visible = false; - } - } - - @Override - public void partOpened(IWorkbenchPartReference partRef) { - } - - @Override - public void partInputChanged(IWorkbenchPartReference partRef) { - } - - @Override - public void partDeactivated(IWorkbenchPartReference partRef) { - } - - @Override - public void partClosed(IWorkbenchPartReference partRef) { - } - - @Override - public void partBroughtToTop(IWorkbenchPartReference partRef) { - } - - @Override - public void partActivated(IWorkbenchPartReference partRef) { - } - }; - - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(partListener); - - parent.addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - - @Override - public void run() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - window.getPartService().removePartListener(partListener); - } - } - }); - } - }); - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/HostRefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/HostRefViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.views; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.HostRef; -import com.redhat.thermostat.storage.core.VmRef; - -public abstract class HostRefViewPart extends RefViewPart { - - public HostRefViewPart(BundleContext context) { - super(context); - } - - @Override - protected HostRef getRefFromSelection(Object selection) { - HostRef ref = null; - if (selection instanceof HostRef) { - ref = (HostRef) selection; - } - else if (selection instanceof VmRef) { - ref = ((VmRef) selection).getHostRef(); - } - return ref; - } - - @Override - protected String getNoSelectionMessage() { - return "No host selected"; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/VmRefViewPart.java --- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/views/VmRefViewPart.java Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright 2012, 2013 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 - * . - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.eclipse.views; - -import org.osgi.framework.BundleContext; - -import com.redhat.thermostat.eclipse.internal.views.RefViewPart; -import com.redhat.thermostat.storage.core.VmRef; - -public abstract class VmRefViewPart extends RefViewPart { - - public VmRefViewPart(BundleContext context) { - super(context); - } - - @Override - protected VmRef getRefFromSelection(Object selection) { - VmRef ref = null; - if (selection instanceof VmRef) { - ref = (VmRef) selection; - } - return ref; - } - - @Override - protected String getNoSelectionMessage() { - return "No VM selected"; - } - -} - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/composite-repo/compositeArtifacts.xml --- a/eclipse/composite-repo/compositeArtifacts.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/composite-repo/compositeContent.xml --- a/eclipse/composite-repo/compositeContent.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/composite-repo/pom.xml --- a/eclipse/composite-repo/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ - - - - 4.0.0 - - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.composite-repo - pom - - - ${basedir}/.. - - - Thermostat Eclipse :: Composite p2 Repo - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.6 - - - build-repo - prepare-package - - - - - - - - - - - - - - - run - - - - - - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.p2-repo - ${project.version} - eclipse-repository - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.core-p2-repo - ${project.version} - eclipse-repository - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/core-p2-repository/category.xml --- a/eclipse/core-p2-repository/category.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/core-p2-repository/pom.xml --- a/eclipse/core-p2-repository/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.core-p2-repo - - Thermostat Client p2 Repository - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.client.feature - 1.0.3-SNAPSHOT - eclipse-feature - - - - - - - org.eclipse.tycho - tycho-p2-publisher-plugin - ${tycho-version} - - true - - - - - - eclipse-repository - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/jfreechart-bundle-wrapping/org.jfree.chart/pom.xml --- a/eclipse/jfreechart-bundle-wrapping/org.jfree.chart/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ - - - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-jfreechart - 1.0.3-SNAPSHOT - - - org.jfree.chart - com.redhat.thermostat.bundles.org.jfree.chart - bundle - 1.0.14 - Thermostat Eclipse :: Bundles :: ${pkgArtifactId} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - org.jfree - jfreechart - 1.0.14 - ${basedir}/../.. - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - - org.jfree.chart, - org.jfree.chart.annotations, - org.jfree.chart.axis, - org.jfree.chart.block, - org.jfree.chart.demo, - org.jfree.chart.editor, - org.jfree.chart.encoders, - org.jfree.chart.entity, - org.jfree.chart.event, - org.jfree.chart.imagemap, - org.jfree.chart.labels, - org.jfree.chart.needle, - org.jfree.chart.panel, - org.jfree.chart.plot, - org.jfree.chart.plot.dial, - org.jfree.chart.renderer, - org.jfree.chart.renderer.category, - org.jfree.chart.renderer.xy, - org.jfree.chart.resources, - org.jfree.chart.servlet, - org.jfree.chart.title, - org.jfree.chart.urls, - org.jfree.chart.util, - org.jfree.data, - org.jfree.data.category, - org.jfree.data.contour, - org.jfree.data.function, - org.jfree.data.gantt, - org.jfree.data.general, - org.jfree.data.io, - org.jfree.data.jdbc, - org.jfree.data.resources, - org.jfree.data.statistics, - org.jfree.data.time, - org.jfree.data.time.ohlc, - org.jfree.data.xml, - org.jfree.data.xy - - - com.keypoint;resolution:=optional, - javax.imageio;resolution:=optional, - javax.imageio.metadata;resolution:=optional, - javax.imageio.stream;resolution:=optional, - javax.servlet;resolution:=optional, - javax.servlet.http;resolution:=optional, - javax.swing;resolution:=optional, - javax.swing.border;resolution:=optional, - javax.swing.event;resolution:=optional, - javax.swing.filechooser;resolution:=optional, - javax.swing.table;resolution:=optional, - javax.xml.parsers;resolution:=optional, - org.jfree;resolution:=optional, - org.jfree.base;resolution:=optional, - org.jfree.chart;resolution:=optional, - org.jfree.chart.annotations;resolution:=optional, - org.jfree.chart.axis;resolution:=optional, - org.jfree.chart.block;resolution:=optional, - org.jfree.chart.demo;resolution:=optional, - org.jfree.chart.editor;resolution:=optional, - org.jfree.chart.encoders;resolution:=optional, - org.jfree.chart.entity;resolution:=optional, - org.jfree.chart.event;resolution:=optional, - org.jfree.chart.imagemap;resolution:=optional, - org.jfree.chart.labels;resolution:=optional, - org.jfree.chart.needle;resolution:=optional, - org.jfree.chart.panel;resolution:=optional, - org.jfree.chart.plot;resolution:=optional, - org.jfree.chart.plot.dial;resolution:=optional, - org.jfree.chart.renderer;resolution:=optional, - org.jfree.chart.renderer.category;resolution:=optional, - org.jfree.chart.renderer.xy;resolution:=optional, - org.jfree.chart.resources;resolution:=optional, - org.jfree.chart.servlet;resolution:=optional, - org.jfree.chart.title;resolution:=optional, - org.jfree.chart.urls;resolution:=optional, - org.jfree.chart.util;resolution:=optional, - org.jfree.data;resolution:=optional, - org.jfree.data.category;resolution:=optional, - org.jfree.data.contour;resolution:=optional, - org.jfree.data.function;resolution:=optional, - org.jfree.data.gantt;resolution:=optional, - org.jfree.data.general;resolution:=optional, - org.jfree.data.io;resolution:=optional, - org.jfree.data.jdbc;resolution:=optional, - org.jfree.data.resources;resolution:=optional, - org.jfree.data.statistics;resolution:=optional, - org.jfree.data.time;resolution:=optional, - org.jfree.data.time.ohlc;resolution:=optional, - org.jfree.data.xml;resolution:=optional, - org.jfree.data.xy;resolution:=optional, - org.jfree.date;resolution:=optional, - org.jfree.io;resolution:=optional, - org.jfree.layout;resolution:=optional, - org.jfree.text;resolution:=optional, - org.jfree.ui;resolution:=optional, - org.jfree.ui.about;resolution:=optional, - org.jfree.util;resolution:=optional, - org.xml.sax;resolution:=optional, - org.xml.sax.helpers;resolution:=optional - - <_nouses>true - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/jfreechart-bundle-wrapping/org.jfree/pom.xml --- a/eclipse/jfreechart-bundle-wrapping/org.jfree/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,138 +0,0 @@ - - - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-jfreechart - 1.0.3-SNAPSHOT - - - org.jfree - com.redhat.thermostat.bundles.org.jfree - bundle - 1.0.17 - Thermostat Eclipse :: Bundles :: ${pkgArtifactId} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - org.jfree - jcommon - 1.0.17 - ${basedir}/../.. - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - - com.keypoint, - org.jfree, - org.jfree.base, - org.jfree.base.config, - org.jfree.base.log, - org.jfree.base.modules, - org.jfree.date, - org.jfree.io, - org.jfree.layout, - org.jfree.resources, - org.jfree.text, - org.jfree.threads, - org.jfree.ui, - org.jfree.ui.about, - org.jfree.ui.about.resources, - org.jfree.ui.action, - org.jfree.ui.tabbedui, - org.jfree.util - - - com.keypoint;resolution:=optional, - javax.accessibility;resolution:=optional, - javax.swing;resolution:=optional, - javax.swing.border;resolution:=optional, - javax.swing.event;resolution:=optional, - javax.swing.filechooser;resolution:=optional, - javax.swing.plaf;resolution:=optional, - javax.swing.table;resolution:=optional, - javax.swing.text;resolution:=optional, - org.jfree;resolution:=optional, - org.jfree.base;resolution:=optional, - org.jfree.base.config;resolution:=optional, - org.jfree.base.log;resolution:=optional, - org.jfree.base.modules;resolution:=optional, - org.jfree.date;resolution:=optional, - org.jfree.io;resolution:=optional, - org.jfree.layout;resolution:=optional, - org.jfree.resources;resolution:=optional, - org.jfree.text;resolution:=optional, - org.jfree.threads;resolution:=optional, - org.jfree.ui;resolution:=optional, - org.jfree.ui.about;resolution:=optional, - org.jfree.ui.about.resources;resolution:=optional, - org.jfree.ui.action;resolution:=optional, - org.jfree.ui.tabbedui;resolution:=optional, - org.jfree.util;resolution:=optional - - <_nouses>true - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/jfreechart-bundle-wrapping/pom.xml --- a/eclipse/jfreechart-bundle-wrapping/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-parent - 1.0.3-SNAPSHOT - - - thermostat-eclipse-jfreechart - pom - - Thermostat Eclipse :: JFreeChart :: Bundles - - - org.jfree - org.jfree.chart - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/jfreechart-p2-repository/pom.xml --- a/eclipse/jfreechart-p2-repository/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ - - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.jfreechart-repo - 1.0.3-SNAPSHOT - - Thermostat Eclipse :: p2 repository for JFreeChart - - - ${basedir}/.. - - - - - - - org.eclipse.tycho.extras - tycho-p2-extras-plugin - ${tycho-version} - - - prepare-package - - publish-features-and-bundles - - - - - true - - - - maven-dependency-plugin - - - copy-bundles-for-publishing - process-resources - - copy - - - - - org.jfree - com.redhat.thermostat.bundles.org.jfree - 1.0.17 - - - org.jfree.chart - com.redhat.thermostat.bundles.org.jfree.chart - 1.0.14 - - - ${project.basedir}/target/source/plugins - - - - - - - - pom - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/pom.xml --- a/eclipse/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,288 +0,0 @@ - - - - 4.0.0 - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-parent - 1.0.3-SNAPSHOT - pom - - Thermostat Eclipse Client (Parent) - - - - GPL with Classpath Exception - - - - - 0.15.0 - 0.15.0 - kepler - http://download.eclipse.org/releases/${platform-version-name} - http://download.eclipse.org/tools/orbit/downloads/drops/R20120526062928/repository/ - ${basedir} - - - - - platform-helios - - - platform-version-name - helios - - - - http://download.eclipse.org/releases/helios - [3.6,3.7) - - - - platform-kepler - - true - - platform-version-name - kepler - - - - http://download.eclipse.org/releases/kepler - [3.8,4.4) - - - - - - com.redhat.thermostat.eclipse.boot - com.redhat.thermostat.eclipse - com.redhat.thermostat.eclipse.chart.common - com.redhat.thermostat.eclipse.chart.vmclassstat - com.redhat.thermostat.client.feature - com.redhat.thermostat.eclipse.feature - com.redhat.thermostat.eclipse.target_platform - com.redhat.thermostat.eclipse.p2-repo - core-p2-repository - composite-repo - - - - - platform - p2 - ${eclipse-site} - - - orbit - p2 - ${orbit-site} - - - local_jfreechart - p2 - file://${eclipse-root}/jfreechart-p2-repository/target/repository/ - - - eclipse.org - http://repo.eclipse.org/nexus/content/groups/public/ - - - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho-version} - true - - - org.eclipse.tycho - target-platform-configuration - ${tycho-version} - - p2 - - consider - - - - maven-assembly-plugin - - - src.xml - - - - - org.eclipse.tycho.extras - tycho-source-feature-plugin - ${tycho-extras-version} - - - source-feature - package - - source-feature - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - - run-tests-during-package - package - - test - - - - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - - - org.eclipse.tycho - tycho-compiler-plugin - ${tycho-version} - - UTF-8 - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho-version} - - true - flase - - - p2-installable-unit - org.eclipse.sdk.feature.group - ${sdk-version} - - - org.eclipse.sdk.ide - - - - - org.eclipse.tycho - tycho-source-plugin - ${tycho-version} - - - attach-source - process-classes - - plugin-source - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - ISO-8859-1 - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.3 - - gnu - - - - org.apache.maven.plugins - maven-site-plugin - 3.1 - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.eclipse.tycho - - tycho-source-plugin - - [0.15.0,) - - plugin-source - - - - - - - - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-bundle-wrapping/org.hamcrest/pom.xml --- a/eclipse/test-deps-bundle-wrapping/org.hamcrest/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ - - - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-test-deps - 1.0.3-SNAPSHOT - - - org.hamcrest - com.redhat.thermostat.bundles.org.hamcrest.core - bundle - 1.3 - Thermostat Eclipse :: Bundles :: ${pkgArtifactId} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - org.hamcrest - hamcrest-core - 1.3 - ${basedir}/../.. - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - 1.3.0 - - org.hamcrest.core;uses:="org.hamcrest";version="1.3", - org.hamcrest;uses:="org.hamcrest.internal, - org.hamcrest.core";version="1.3" - - org.hamcrest.internal - * - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-bundle-wrapping/org.mockito/pom.xml --- a/eclipse/test-deps-bundle-wrapping/org.mockito/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ - - - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-test-deps - 1.0.3-SNAPSHOT - - - org.mockito - com.redhat.thermostat.bundles.org.mockito.mockito-core - bundle - 1.9.0 - Thermostat Eclipse :: Bundles :: ${pkgArtifactId} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - org.mockito - mockito-core - 1.9.0 - ${basedir}/../.. - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - - org.mockito.internal*, - org.mockito.cglib*, - org.mockito.asm*, - org.objenesis*, - org.hamcrest*, - - - org.mockito.exceptions.base;version="1.9", - org.mockito.exceptions; - uses:="org.mockito.exceptions.verification.junit,org.mockito.exceptions.base, - org.mockito.listeners,org.mockito.exceptions.misusing, - org.mockito.exceptions.verification";version="1.9", - org.mockito.exceptions.verification; - uses:="org.mockito.exceptions.base";version="1.9", - org.mockito.stubbing.answers; - uses:="org.mockito.exceptions.base,org.mockito.invocation,org.mockito.stubbing"; - version="1.9", - org.mockito.configuration; - uses:="org.mockito,org.mockito.stubbing";version="1.9", - org.mockito.invocation;version="1.9", - org.mockito.exceptions.verification.junit; - uses:="junit.framework,org.mockito.exceptions.verification";version="1.9", - org.mockito.listeners;uses:="org.mockito.exceptions";version="1.9", - org.mockito; - uses:="org.hamcrest,org.mockito.stubbing,org.mockito.verification, - org.mockito.listeners,org.mockito.exceptions.base,org.mockito.exceptions, - org.mockito.configuration,org.mockito.invocation";version="1.9", - org.mockito.runners; - uses:="org.junit.runner,org.junit.runner.notification,org.junit.runner.manipulation"; - version="1.9", - org.mockito.exceptions.misusing;uses:="org.mockito.exceptions.base";version="1.9", - org.mockito.verification;uses:="org.mockito.exceptions";version="1.9", - org.mockito.stubbing;uses:="org.mockito.invocation";version="1.9" - - - junit.*;resolution:=optional, - org.junit.*;resolution:=optional, - org.hamcrest;version="[1.3,2.0)", - org.objenesis;version="[1.0,2.0)", - org.apache.tools.ant;resolution:=optional, - org.apache.tools.ant.types;resolution:=optional, - COM.jrockit.reflect;resolution:=optional, - jrockit.vm;resolution:=optional, - sun.reflect;resolution:=optional, - org.mockito* - - <_removeheaders>Private-Package - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-bundle-wrapping/org.objenesis/pom.xml --- a/eclipse/test-deps-bundle-wrapping/org.objenesis/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ - - - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-test-deps - 1.0.3-SNAPSHOT - - - org.objenesis - com.redhat.thermostat.bundles.org.objenesis - bundle - 1.0 - Thermostat Eclipse :: Bundles :: ${pkgArtifactId} - - This bundle simply wraps ${pkgArtifactId}-${pkgVersion}.jar. - - - - org.objenesis - objenesis - 1.0 - ${basedir}/../.. - - - - - ${pkgGroupId} - ${pkgArtifactId} - ${pkgVersion} - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - - org.objenesis.instantiator.jrockit;version="1.0", - org.objenesis;version="1.0", - org.objenesis.strategy;version="1.0", - org.objenesis.instantiator;version="1.0", - org.objenesis.instantiator.basic;version="1.0", - org.objenesis.instantiator.sun;version="1.0", - org.objenesis.instantiator.gcj;version="1.0" - - - !COM.jrockit*,!jrockit.vm*,!sun.reflect, - org.objenesis.instantiator.jrockit;version="1.0", - org.objenesis;version="1.0", - org.objenesis.strategy;version="1.0", - org.objenesis.instantiator;version="1.0", - org.objenesis.instantiator.basic;version="1.0", - org.objenesis.instantiator.sun;version="1.0", - org.objenesis.instantiator.gcj;version="1.0" - - <_nouses>true - - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-bundle-wrapping/pom.xml --- a/eclipse/test-deps-bundle-wrapping/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ - - - 4.0.0 - - - com.redhat.thermostat.eclipse.parent - thermostat-eclipse-parent - 1.0.3-SNAPSHOT - - - - thermostat-eclipse-test-deps - pom - - Thermostat Eclipse :: Test Deps :: Bundles - - - org.hamcrest - org.objenesis - org.mockito - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12 - - true - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-p2-repository/category.xml --- a/eclipse/test-deps-p2-repository/category.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r 60643e432434 -r 58bb4fce5f5c eclipse/test-deps-p2-repository/pom.xml --- a/eclipse/test-deps-p2-repository/pom.xml Mon Jun 02 10:08:04 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ - - - - 4.0.0 - - thermostat-eclipse-parent - com.redhat.thermostat.eclipse.parent - 1.0.3-SNAPSHOT - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.test-deps-repo - 1.0.3-SNAPSHOT - eclipse-repository - - Thermostat Eclipse :: p2 repository for plain Java test deps - - - ${basedir}/.. - - - - - com.redhat.thermostat.eclipse.parent - com.redhat.thermostat.eclipse.test.deps.feature - 1.0.3-SNAPSHOT - eclipse-feature - - - - - - - org.eclipse.tycho - tycho-p2-publisher-plugin - ${tycho-version} - - true - - - - - -