diff options
| author | Aidan Skinner <aidan@apache.org> | 2008-04-23 23:50:34 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2008-04-23 23:50:34 +0000 |
| commit | d947dab3de62830cbfb41dc989ec7a5ff6af8f55 (patch) | |
| tree | 3116da8a78a41339f4eb584c71c1e50c13e5e6f1 /java/management/eclipse-plugin | |
| parent | 046e1e70a0bed4689040324eaa7e4da10b7a0508 (diff) | |
| download | qpid-python-d947dab3de62830cbfb41dc989ec7a5ff6af8f55.tar.gz | |
Delete stuff that's just going to get synced from M2.x
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@651111 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/eclipse-plugin')
92 files changed, 0 insertions, 12186 deletions
diff --git a/java/management/eclipse-plugin/META-INF/MANIFEST.MF b/java/management/eclipse-plugin/META-INF/MANIFEST.MF deleted file mode 100644 index 658fa2cb4c..0000000000 --- a/java/management/eclipse-plugin/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Qpid Management Console Plug-in -Bundle-SymbolicName: org.apache.qpid.management.ui; singleton:=true -Bundle-Version: 0.1.0 -Bundle-Activator: org.apache.qpid.management.ui.Activator -Bundle-Localization: plugin -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.ui.forms, - jmxremote.sasl, - org.apache.commons.codec -Eclipse-LazyStart: true -Bundle-Vendor: Apache Software Foundation diff --git a/java/management/eclipse-plugin/README.txt b/java/management/eclipse-plugin/README.txt deleted file mode 100644 index 5325bf27ec..0000000000 --- a/java/management/eclipse-plugin/README.txt +++ /dev/null @@ -1,21 +0,0 @@ - -Running the Qpid Management Console (eclipse-plugin) ----------------------------------------------------- - -To run the management console, set the QPIDMC_HOME environment variable to -qpid management console root directory (e.g. C:/qpidmc)and add $QPIDMC_HOME/bin to your PATH. -Then run the script to launch the management console- -For Windows: ------------- -qpidmc.bat -qpidmc.sh (using cygwin) - -Unix: ------ -qpidmc.sh <operating system> <windowing system> <platform achitecture> -eg. qpidms.sh linux motif x86 -qpidmc_motif.sh -qpidmc_gtk.sh - -Apache confluence page for latest information: -http://cwiki.apache.org/confluence/display/qpid/Qpid+Management+Console diff --git a/java/management/eclipse-plugin/bin/qpidmc.bat b/java/management/eclipse-plugin/bin/qpidmc.bat deleted file mode 100644 index 1f3207f043..0000000000 --- a/java/management/eclipse-plugin/bin/qpidmc.bat +++ /dev/null @@ -1,55 +0,0 @@ -@REM
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM
-
-@echo off
-REM Script to run the Qpid Management Console
-
-rem Guess QPIDMC_HOME if not defined
-set CURRENT_DIR=%cd%
-if not "%QPIDMC_HOME%" == "" goto gotHome
-set QPIDMC_HOME=%CURRENT_DIR%
-echo %QPIDMC_HOME%
-if exist "%QPIDMC_HOME%\bin\qpidmc.bat" goto okHome
-cd ..
-set QPIDMC_HOME=%cd%
-cd %CURRENT_DIR%
-:gotHome
-if exist "%QPIDMC_HOME%\bin\qpidmc.bat" goto okHome
-echo The QPIDMC_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program
-goto end
-:okHome
-
-if not "%JAVA_HOME%" == "" goto gotJavaHome
-echo The JAVA_HOME environment variable is not defined
-echo This environment variable is needed to run this program
-goto exit
-:gotJavaHome
-if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
-goto okJavaHome
-:noJavaHome
-echo The JAVA_HOME environment variable is not defined correctly
-echo This environment variable is needed to run this program.
-goto exit
-:okJavaHome
-
-rem Slurp the command line arguments. This loop allows for an unlimited number
-rem of agruments (up to the command line limit, anyway).
-
-"%JAVA_HOME%\bin\java" -Xms40m -Xmx256m -Declipse.consoleLog=false -jar %QPIDMC_HOME%\eclipse\startup.jar org.eclipse.core.launcher.Main -launcher %QPIDMC_HOME%\eclipse\eclipse -name "Qpid Management Console" -showsplash 600 -configuration "file:%QPIDMC_HOME%\configuration" -os win32 -ws win32 -arch x86
diff --git a/java/management/eclipse-plugin/bin/qpidmc.sh b/java/management/eclipse-plugin/bin/qpidmc.sh deleted file mode 100755 index 2472545a14..0000000000 --- a/java/management/eclipse-plugin/bin/qpidmc.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -if [ "$JAVA_HOME" == "" ]; then - echo "The JAVA_HOME environment variable is not defined"; - exit 0; -fi - -if [ "$QPIDMC_HOME" == "" ]; then - echo "The QPIDMC_HOME environment variable is not defined correctly"; - exit 0; -fi - -# Test if we're running on cygwin. -cygwin=false -if [[ "$(uname -a | fgrep Cygwin)" != "" ]]; then - cygwin=true -fi - -if $cygwin; then - QPIDMC_HOME=$(cygpath -w $QPIDMC_HOME) -fi - -os=win32 -ws=win32 -arch=x86 - -##echo $os -##echo $ws -##echo $arch - -## If this is to be run on different platform other than windows then following parameters should be passed -## qpidmc.sh <operating system> <windowing system> <platform achitecture> -## eg. qpidmc.sh linux motif x86 -if [ $# -eq 3 ]; then - os=$1 - ws=$2 - arch=$3 -fi - -if [ $os = "SunOS" ]; then - os="solaris" -elif [ $os = "Linux" ]; then - os="linux" -fi - -"$JAVA_HOME/bin/java" -Xms40m -Xmx256m -Declipse.consoleLog=false -jar $QPIDMC_HOME/eclipse/startup.jar org.eclipse.core.launcher.Main -launcher $QPIDMC_HOME/eclipse/eclipse -name "Qpid Management Console" -showsplash 600 -configuration "file:$QPIDMC_HOME/configuration" -os $os -ws $ws -arch $arch diff --git a/java/management/eclipse-plugin/bin/qpidmc_gtk.sh b/java/management/eclipse-plugin/bin/qpidmc_gtk.sh deleted file mode 100755 index 10b463d63b..0000000000 --- a/java/management/eclipse-plugin/bin/qpidmc_gtk.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -os=`uname | tr A-Z a-z` -arch=`uname -p` - -$QPIDMC_HOME/bin/qpidmc.sh $os gtk $arch diff --git a/java/management/eclipse-plugin/bin/qpidmc_motif.sh b/java/management/eclipse-plugin/bin/qpidmc_motif.sh deleted file mode 100755 index f53be75d87..0000000000 --- a/java/management/eclipse-plugin/bin/qpidmc_motif.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -os=`uname | tr A-Z a-z` -arch=`uname -p` - -$QPIDMC_HOME/bin/qpidmc.sh $os motif $arch diff --git a/java/management/eclipse-plugin/build.xml b/java/management/eclipse-plugin/build.xml deleted file mode 100644 index 492783e574..0000000000 --- a/java/management/eclipse-plugin/build.xml +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - - - - Licensed to the Apache Software Foundation (ASF) under one - - or more contributor license agreements. See the NOTICE file - - distributed with this work for additional information - - regarding copyright ownership. The ASF licenses this file - - to you under the Apache License, Version 2.0 (the - - "License"); you may not use this file except in compliance - - with the License. You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, - - software distributed under the License is distributed on an - - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - - KIND, either express or implied. See the License for the - - specific language governing permissions and limitations - - under the License. - - - --> -<project name="Eclipse Plugin" default="build"> - - <property name="module.depends" value="broker common"/> - - <import file="../../module.xml"/> - -</project> diff --git a/java/management/eclipse-plugin/icons/Thumbs.db b/java/management/eclipse-plugin/icons/Thumbs.db Binary files differdeleted file mode 100644 index 306bfb2eda..0000000000 --- a/java/management/eclipse-plugin/icons/Thumbs.db +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/add.gif b/java/management/eclipse-plugin/icons/add.gif Binary files differdeleted file mode 100644 index 252d7ebcb8..0000000000 --- a/java/management/eclipse-plugin/icons/add.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/delete.gif b/java/management/eclipse-plugin/icons/delete.gif Binary files differdeleted file mode 100644 index 6f647666d3..0000000000 --- a/java/management/eclipse-plugin/icons/delete.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/icon_ClosedFolder.gif b/java/management/eclipse-plugin/icons/icon_ClosedFolder.gif Binary files differdeleted file mode 100644 index beb6ed134c..0000000000 --- a/java/management/eclipse-plugin/icons/icon_ClosedFolder.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/icon_OpenFolder.gif b/java/management/eclipse-plugin/icons/icon_OpenFolder.gif Binary files differdeleted file mode 100644 index a9c777343c..0000000000 --- a/java/management/eclipse-plugin/icons/icon_OpenFolder.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/mbean_view.png b/java/management/eclipse-plugin/icons/mbean_view.png Binary files differdeleted file mode 100644 index 9871b72bb8..0000000000 --- a/java/management/eclipse-plugin/icons/mbean_view.png +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/notifications.gif b/java/management/eclipse-plugin/icons/notifications.gif Binary files differdeleted file mode 100644 index f1e585bdf7..0000000000 --- a/java/management/eclipse-plugin/icons/notifications.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/qpidConnections.gif b/java/management/eclipse-plugin/icons/qpidConnections.gif Binary files differdeleted file mode 100644 index 89489f11f2..0000000000 --- a/java/management/eclipse-plugin/icons/qpidConnections.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/qpidmc.gif b/java/management/eclipse-plugin/icons/qpidmc.gif Binary files differdeleted file mode 100644 index baf929fbc5..0000000000 --- a/java/management/eclipse-plugin/icons/qpidmc.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/qpidmc16.gif b/java/management/eclipse-plugin/icons/qpidmc16.gif Binary files differdeleted file mode 100644 index 4df535bb9a..0000000000 --- a/java/management/eclipse-plugin/icons/qpidmc16.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/qpidmc32.bmp b/java/management/eclipse-plugin/icons/qpidmc32.bmp Binary files differdeleted file mode 100644 index e42ce01dff..0000000000 --- a/java/management/eclipse-plugin/icons/qpidmc32.bmp +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/qpidmc32.gif b/java/management/eclipse-plugin/icons/qpidmc32.gif Binary files differdeleted file mode 100644 index e42ce01dff..0000000000 --- a/java/management/eclipse-plugin/icons/qpidmc32.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/reconnect.gif b/java/management/eclipse-plugin/icons/reconnect.gif Binary files differdeleted file mode 100644 index e2f8c3e1fe..0000000000 --- a/java/management/eclipse-plugin/icons/reconnect.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/refresh.gif b/java/management/eclipse-plugin/icons/refresh.gif Binary files differdeleted file mode 100644 index a063c230ac..0000000000 --- a/java/management/eclipse-plugin/icons/refresh.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/splash.bmp b/java/management/eclipse-plugin/icons/splash.bmp Binary files differdeleted file mode 100644 index b528a508c5..0000000000 --- a/java/management/eclipse-plugin/icons/splash.bmp +++ /dev/null diff --git a/java/management/eclipse-plugin/icons/stop.gif b/java/management/eclipse-plugin/icons/stop.gif Binary files differdeleted file mode 100644 index dc47edf069..0000000000 --- a/java/management/eclipse-plugin/icons/stop.gif +++ /dev/null diff --git a/java/management/eclipse-plugin/plugin.properties b/java/management/eclipse-plugin/plugin.properties deleted file mode 100644 index 8507441886..0000000000 --- a/java/management/eclipse-plugin/plugin.properties +++ /dev/null @@ -1,20 +0,0 @@ -############################################################################### -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -############################################################################### -pluginName = Qpid Management Console Plug-in -providerName = Apache Software Foundation
\ No newline at end of file diff --git a/java/management/eclipse-plugin/plugin.xml b/java/management/eclipse-plugin/plugin.xml deleted file mode 100644 index 5774859b47..0000000000 --- a/java/management/eclipse-plugin/plugin.xml +++ /dev/null @@ -1,223 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.2"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<plugin> - - <extension - id="application" - point="org.eclipse.core.runtime.applications"> - <application> - <run - class="org.apache.qpid.management.ui.Application"> - </run> - </application> - </extension> - <extension - point="org.eclipse.ui.perspectives"> - <perspective - name="qpid.management.perspective" - class="org.apache.qpid.management.ui.Perspective" - id="org.apache.qpid.management.ui.perspective"> - </perspective> - </extension> - <extension - point="org.eclipse.ui.views"> - <category - id="org.apache.qpid.management.ui.viewcategory" - name="Qpid Management Console"/> - <view - allowMultiple="false" - category="org.apache.qpid.management.ui.viewcategory" - class="org.apache.qpid.management.ui.views.NavigationView" - icon="icons/qpidConnections.gif" - id="org.apache.qpid.management.ui.navigationView" - name="Qpid Connections"> - </view> - <view - allowMultiple="false" - category="org.apache.qpid.management.ui.viewcategory" - class="org.apache.qpid.management.ui.views.MBeanView" - icon="icons/mbean_view.png" - id="org.apache.qpid.management.ui.mbeanView" - name="Qpid Management"> - </view> - </extension> - <extension - point="org.eclipse.ui.commands"> - <category - name="qpid.manager.commands" - id="org.apache.qpid.management.ui.category"> - </category> - <command - name="New Connection" - description="Created a new Qpid server connection" - categoryId="org.apache.qpid.management.ui.category" - id="org.apache.qpid.management.ui.actions.cmd_add"> - </command> - <command - categoryId="org.apache.qpid.management.ui.category" - description="Reconnect the Qpid server connection" - id="org.apache.qpid.management.ui.actions.cmd_reconnect" - name="Reconnect"/> - <command - categoryId="org.apache.qpid.management.ui.category" - description="Disconnects the Qpid server connection" - id="org.apache.qpid.management.ui.actions.cmd_disconnect" - name="Disconnect"/> - <command - categoryId="org.apache.qpid.management.ui.category" - description="Removes the server from management console" - id="org.apache.qpid.management.ui.actions.cmd_remove" - name="Remove Connection"/> - <command - categoryId="org.apache.qpid.management.ui.category" - description="refreshes the views" - id="org.apache.qpid.management.ui.actions.cmd_refresh" - name="Refresh"/> - <command - categoryId="org.apache.qpid.management.ui.category" - description="pops up the window for editing selected attribute" - id="org.apache.qpid.management.ui.actions.cmd_editAttribute" - name="Edit Attribute"/> - <command - categoryId="org.apache.qpid.management.ui.category" - description="About Qpid Management Console" - id="qpidmc.about" - name="About"/> - </extension> - <extension - point="org.eclipse.ui.bindings"> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_add" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+N"> - </key> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_reconnect" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+C"/> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_disconnect" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+D"> - </key> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_remove" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+R"/> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_refresh" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+F5"/> - <key - commandId="org.apache.qpid.management.ui.actions.cmd_editAttribute" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+E"/> - <key - commandId="org.eclipse.ui.file.exit" - schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" - sequence="CTRL+Alt+X"> - </key> - </extension> - - <extension - id="product" - point="org.eclipse.core.runtime.products"> - <product - application="org.apache.qpid.management.ui.application" - name="Qpid Management Console"> - <property - name="windowImages" - value="icons/qpidmc16.gif,icons/qpidmc32.gif"> - </property> - <property - name="aboutText" - value="Qpid Management Console"/> - </product> - </extension> - <extension - point="org.eclipse.ui.actionSets"> - <actionSet - id="org.apache.qpid.management.ui.actionSet" - label="Qpid Action Set" - visible="true"> - <menu - id="qpidmanager" - label="&Qpid Manager"> - <separator name="qpidActionsGroup"/> - </menu> - <action - class="org.apache.qpid.management.ui.actions.EditAttribute" - definitionId="org.apache.qpid.management.ui.actions.cmd_editAttribute" - id="org.apache.qpid.management.ui.actions.editAttribute" - label="Edit Attribute" - menubarPath="qpidmanager/mbeanactions" - style="push" - tooltip="Edit Attribute"/> - <action - class="org.apache.qpid.management.ui.actions.Refresh" - definitionId="org.apache.qpid.management.ui.actions.cmd_refresh" - icon="icons/refresh.gif" - id="org.apache.qpid.management.ui.actions.refresh" - label="Refresh" - menubarPath="qpidmanager/additions" - style="push" - toolbarPath="qpidActionsGroup" - tooltip="Refresh"/> - <action - class="org.apache.qpid.management.ui.actions.RemoveServer" - definitionId="org.apache.qpid.management.ui.actions.cmd_remove" - icon="icons/delete.gif" - id="org.apache.qpid.management.ui.actions.remove" - label="Remove Connection" - menubarPath="qpidmanager/additions" - style="push" - toolbarPath="qpidActionsGroup"/> - <action - class="org.apache.qpid.management.ui.actions.CloseConnection" - definitionId="org.apache.qpid.management.ui.actions.cmd_disconnect" - icon="icons/stop.gif" - id="org.apache.qpid.management.ui.disconnect" - label="Disconnect" - menubarPath="qpidmanager/additions" - toolbarPath="qpidActionsGroup" - tooltip="Disconnect"/> - <action - class="org.apache.qpid.management.ui.actions.ReconnectServer" - definitionId="org.apache.qpid.management.ui.actions.cmd_reconnect" - icon="icons/reconnect.gif" - id="org.apache.qpid.management.ui.reconnect" - label="Reconnect" - menubarPath="qpidmanager/additions" - toolbarPath="qpidActionsGroup" - tooltip="Reconnect"/> - <action - class="org.apache.qpid.management.ui.actions.AddServer" - definitionId="org.apache.qpid.management.ui.actions.cmd_add" - icon="icons/add.gif" - id="org.apache.qpid.management.ui.add" - label="New Connection" - menubarPath="qpidmanager/additions" - toolbarPath="qpidActionsGroup" - tooltip="New Connection"/> - </actionSet> - </extension> - -</plugin> diff --git a/java/management/eclipse-plugin/pom.xml b/java/management/eclipse-plugin/pom.xml deleted file mode 100644 index 0c220104f8..0000000000 --- a/java/management/eclipse-plugin/pom.xml +++ /dev/null @@ -1,257 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.qpid.management</groupId> - <artifactId>org.apache.qpid.management.ui</artifactId> - <packaging>jar</packaging> - <version>1.0-incubating-M3-SNAPSHOT</version> - <name>Qpid Management</name> - - <parent> - <groupId>org.apache.qpid</groupId> - <artifactId>qpid</artifactId> - <version>1.0-incubating-M3-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <properties> - <topDirectoryLocation>../..</topDirectoryLocation> - </properties> - - <repositories> - <repository> - <id>repo1.maven.org</id> - <name>Maven eclipse Repository</name> - <url>http://repo1.maven.org/eclipse</url> - </repository> - <repository> - <id>apache.snapshots</id> - <name>Apache SNAPSHOT Repository</name> - <url>http://people.apache.org/repo/m2-snapshot-repository</url> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> - </repositories> - - <dependencies> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>1.3</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>com.ibm.icu</groupId> - <artifactId>com.ibm.icu</artifactId> - <version>3.4.4</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.jface</groupId> - <artifactId>org.eclipse.jface</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.commands</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.contenttype</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.expressions</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.jobs</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.runtime</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.runtime.compatibility.auth</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.core</groupId> - <artifactId>org.eclipse.core.runtime.compatibility.registry</artifactId> - <version>3.2.0</version> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>org.eclipse.equinox</groupId> - <artifactId>org.eclipse.equinox.common</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.equinox</groupId> - <artifactId>org.eclipse.equinox.preferences</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.equinox</groupId> - <artifactId>org.eclipse.equinox.registry</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.help</groupId> - <artifactId>org.eclipse.help</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.osgi</groupId> - <artifactId>org.eclipse.osgi</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.swt</groupId> - <artifactId>org.eclipse.swt.win32.win32.x86</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.swt</groupId> - <artifactId>org.eclipse.swt</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.ui</groupId> - <artifactId>org.eclipse.ui.forms</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.ui</groupId> - <artifactId>org.eclipse.ui.workbench</artifactId> - <version>3.2.1</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.eclipse.ui</groupId> - <artifactId>org.eclipse.ui</artifactId> - <version>3.2.0</version> - <scope>compile</scope> - </dependency> - - <!-- Test Dependencies --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.4.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.qpid</groupId> - <artifactId>qpid-broker</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> - - <build> - <resources> - <resource> - <directory>icons/</directory> - <targetPath>icons/</targetPath> - <includes> - <include>**</include> - </includes> - </resource> - <resource> - <directory>icons/</directory> - <targetPath>/</targetPath> - <includes> - <include>splash.bmp</include> - </includes> - </resource> - <resource> - <directory>${basedir}</directory> - <targetPath>/</targetPath> - <includes> - <include>plugin.xml</include> - <include>plugin.properties</include> - </includes> - </resource> - </resources> - <plugins> - <!-- - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - </plugin> - --> - - <!-- This is required to identify the JAR to eclipse as a plugin --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifestFile>META-INF/MANIFEST.MF</manifestFile> - </archive> - <finalName>${artifactId}_${version}</finalName> - </configuration> - </plugin> - - <!-- - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <skip>false</skip> - </configuration> - </plugin> - --> - </plugins> - </build> - -</project> diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java deleted file mode 100644 index 5eab267c28..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Activator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - * @author Bhupendra Bhardwaj - */ -public class Activator extends AbstractUIPlugin -{ - // The plug-in ID - public static final String PLUGIN_ID = "org.apache.qpid.management.ui"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() - { - plugin = this; - } - - /* - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception - { - super.start(context); - } - - /* - * @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; - } - - /** - * 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); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java deleted file mode 100644 index a1c4b7ddb0..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Application.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.eclipse.core.runtime.IPlatformRunnable; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -/** - * This class controls all aspects of the application's execution - * @author Bhupendra Bhardwaj - */ -public class Application implements IPlatformRunnable -{ - static Shell shell = null; - - /* - * The call to createAndRunWorkbench will not return until the workbench is closed. - * The SWT event loop and other low-level logistics are handled inside this method. - * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object) - */ - public Object run(Object args) throws Exception - { - Display display = PlatformUI.createDisplay(); - try - { - int returnCode = PlatformUI.createAndRunWorkbench(display, - new ApplicationWorkbenchAdvisor()); - if (returnCode == PlatformUI.RETURN_RESTART) - { - return IPlatformRunnable.EXIT_RESTART; - } - return IPlatformRunnable.EXIT_OK; - } finally - { - display.dispose(); - } - } - - static Shell getActiveShell() - { - return shell; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationActionBarAdvisor.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationActionBarAdvisor.java deleted file mode 100644 index b5c1b5074a..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationActionBarAdvisor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.apache.qpid.management.ui.actions.VersionAction; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.ICoolBarManager; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; - -/** - * An action bar advisor is responsible for creating, adding, and disposing of the - * actions added to a workbench window. Each window will be populated with - * new actions. - */ -public class ApplicationActionBarAdvisor extends ActionBarAdvisor -{ - - // Actions - important to allocate these only in makeActions, and then use them - // in the fill methods. This ensures that the actions aren't recreated - // when fillActionBars is called with FILL_PROXY. - private IWorkbenchAction exitAction; - private Action _aboutAction; - - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) - { - super(configurer); - } - - protected void makeActions(final IWorkbenchWindow window) - { - // Creates the actions and registers them. - // Registering is needed to ensure that key bindings work. - // The corresponding commands keybindings are defined in the plugin.xml file. - // Registering also provides automatic disposal of the actions when - // the window is closed. - - exitAction = ActionFactory.QUIT.create(window); - register(exitAction); - - _aboutAction = new VersionAction(window); - register(_aboutAction); - } - - - protected void fillMenuBar(IMenuManager menuBar) - { - MenuManager fileMenu = new MenuManager("&Qpid Manager", "qpidmanager"); - MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); - - menuBar.add(fileMenu); - // Add a group marker indicating where action set menus will appear. - menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - menuBar.add(helpMenu); - - fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - fileMenu.add(new Separator()); - fileMenu.add(new GroupMarker("mbeanactions")); - fileMenu.add(new Separator()); - fileMenu.add(exitAction); - - // Help - helpMenu.add(_aboutAction); - } - - protected void fillCoolBar(ICoolBarManager coolBar) - { - - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java deleted file mode 100644 index 0ad85dbf33..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationRegistry.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * Main Application Registry, which contains shared resources and map to all connected servers. - * @author Bhupendra Bhardwaj - */ -public abstract class ApplicationRegistry -{ - private static ImageRegistry imageRegistry = new ImageRegistry(); - private static FontRegistry fontRegistry = new FontRegistry(); - public static final boolean debug = Boolean.getBoolean("eclipse.consoleLog"); - public static final String securityMechanism = System.getProperty("security", null); - public static final String connectorClass = System.getProperty("jmxconnector"); - public static final long timeout = Long.parseLong(System.getProperty("timeout", "5000")); - - static - { - imageRegistry.put(Constants.CONSOLE_IMAGE, - org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/qpidmc.gif")); - imageRegistry.put(Constants.CLOSED_FOLDER_IMAGE, - org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/icon_ClosedFolder.gif")); - imageRegistry.put(Constants.OPEN_FOLDER_IMAGE, - PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)); - imageRegistry.put(Constants.MBEAN_IMAGE, - PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)); - imageRegistry.put(Constants.NOTIFICATION_IMAGE, - org.apache.qpid.management.ui.Activator.getImageDescriptor("/icons/notifications.gif")); - } - - static - { - fontRegistry.put(Constants.FONT_BUTTON, new FontData[]{new FontData("Arial", 8, SWT.BOLD)} ); - fontRegistry.put(Constants.FONT_BOLD, new FontData[]{new FontData("Bold", 9, SWT.BOLD)} ); - fontRegistry.put(Constants.FONT_ITALIC, new FontData[]{new FontData("Italic", 9, SWT.ITALIC)} ); - fontRegistry.put(Constants.FONT_TABLE_CELL, new FontData[]{new FontData("Tablecell", 8, SWT.NORMAL)} ); - fontRegistry.put(Constants.FONT_NORMAL, new FontData[]{new FontData("Normal", 9, SWT.NORMAL)} ); - } - - /* - * This maps all the managed servers to the respective server registry. - * Server can be JMX MBeanServer or a C++ server - */ - private static HashMap<ManagedServer, ServerRegistry> _serverRegistryMap = new HashMap<ManagedServer, ServerRegistry>(); - - // This map gets updated when a server connection closes. - private static List<ManagedServer> _closedServerList = new CopyOnWriteArrayList<ManagedServer>(); - - public static Image getImage(String key) - { - return imageRegistry.get(key); - } - - public static Font getFont(String key) - { - return fontRegistry.get(key); - } - - public static void addServer(ManagedServer server, ServerRegistry registry) - { - _serverRegistryMap.put(server, registry); - } - - public static void removeServer(ManagedServer server) - { - _serverRegistryMap.remove(server); - } - - public static ServerRegistry getServerRegistry(ManagedServer server) - { - return _serverRegistryMap.get(server); - } - - public static ServerRegistry getServerRegistry(ManagedBean mbean) - { - ManagedServer server = mbean.getServer(); - return getServerRegistry(server); - } - - public static boolean isServerConnected(ManagedServer server) - { - return _serverRegistryMap.containsKey(server); - } - - // remove the server from the registry - public static void serverConnectionClosed(ManagedServer server) - { - _closedServerList.add(server); - removeServer(server); - } - - /* - * Returns the lis of closed servers. The Thread in GUI, which keeps checking for closed connection - * will check this and will remove the server links from the GUI. - */ - public static List<ManagedServer> getClosedServers() - { - if (_closedServerList.isEmpty()) - return null; - - List<ManagedServer> list = new CopyOnWriteArrayList<ManagedServer>(_closedServerList); - _closedServerList.clear(); - return list; - } - - public static String getSecurityMechanism() - { - return securityMechanism; - } - - public static String getJMXConnectorClass() - { - return connectorClass; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchAdvisor.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchAdvisor.java deleted file mode 100644 index a46fa870e4..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchAdvisor.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchAdvisor; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -/** - * This workbench advisor creates the window advisor, and specifies - * the perspective id for the initial window. - */ -public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor -{ - public static final String PERSPECTIVE_ID = "org.apache.qpid.management.ui.perspective"; - - public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) - { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } - - - public String getInitialWindowPerspectiveId() - { - return PERSPECTIVE_ID; - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java deleted file mode 100644 index e3aedef28e..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ApplicationWorkbenchWindowAdvisor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -/** - * - * @author Bhupendra Bhardwaj - */ -public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor -{ - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) - { - super(configurer); - } - - public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) - { - return new ApplicationActionBarAdvisor(configurer); - } - - public void preWindowOpen() - { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - int x = Display.getDefault().getBounds().width; - int y = Display.getDefault().getBounds().height; - configurer.setInitialSize(new Point(9*x/10, 8*y/10)); - configurer.setShowCoolBar(true); - configurer.setShowStatusLine(false); - - configurer.setTitle(Constants.APPLICATION_NAME); - } - - public void postWindowCreate() - { - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - Shell shell = configurer.getWindow().getShell(); - shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE)); - } -}
\ No newline at end of file diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java deleted file mode 100644 index d6f895b64a..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -/** - * Contains constants for the application - * @author Bhupendra Bhardwaj - * - */ -public class Constants -{ - public final static String APPLICATION_NAME = "Qpid Management Console"; - - public final static String ACTION_REMOVE_MBEANNODE = "Remove from list"; - public final static String VALUE = "value"; - public final static String TYPE = "type"; - public final static String NODE_TYPE_SERVER = "server"; - public final static String NODE_TYPE_DOMAIN = "domain"; - public final static String NODE_TYPE_MBEANTYPE = "mbeantype"; - // currently used only for virtual host instances, but will work as general also - public final static String NODE_TYPE_TYPEINSTANCE = "mbeantype_instance"; - public final static String MBEAN = "mbean"; - public final static String ATTRIBUTE = "Attribute"; - public final static String ATTRIBUTES = "Attributes"; - public final static String NOTIFICATIONS = "Notifications"; - public final static String RESULT = "Result"; - public final static String VIRTUAL_HOST = "VirtualHost"; - public final static String DEFAULT_VH = "Default"; - public final static String DEFAULT_USERNAME = "guest"; - public final static String DEFAULT_PASSWORD = "guest"; - - public final static String USERNAME = "Username"; - public final static String PASSWORD = "Password"; - - // Attributes and operations are used to customize the GUI for Qpid. If these are changes in the - // Qpid server, then these should be updated accordingly - public final static String ATTRIBUTE_QUEUE_OWNER = "owner"; - public final static String ATTRIBUTE_QUEUE_DEPTH = "QueueDepth"; - public final static String ATTRIBUTE_QUEUE_CONSUMERCOUNT = "ActiveConsumerCount"; - public final static String OPERATION_CREATE_QUEUE = "createNewQueue"; - public final static String OPERATION_CREATE_BINDING = "createNewBinding"; - public final static String OPERATION_MOVE_MESSAGES = "moveMessages"; - - public final static String OPERATION_CREATEUSER = "createUser"; - public final static String OPERATION_DELETEUSER = "deleteUser"; - public final static String OPERATION_VIEWUSERS = "viewUsers"; - public final static String OPERATION_PARAM_USERNAME = "username"; - - public final static String OPERATION_SUCCESSFUL = "Operation successful"; - public final static String OPERATION_UNSUCCESSFUL = "Operation unsuccessful"; - - public final static String ALL = "All"; - - public final static String NAVIGATION_ROOT = "Qpid Connections"; - public final static String DESCRIPTION = " Description"; - - public final static String ADMIN_MBEAN_TYPE = "UserManagement"; - public final static String QUEUE = "Queue"; - public final static String CONNECTION ="Connection"; - public final static String EXCHANGE = "Exchange"; - public final static String EXCHANGE_TYPE = "ExchangeType"; - public final static String[] EXCHANGE_TYPE_VALUES = {"direct", "fanout", "headers", "topic"}; - public final static String[] BOOLEAN_TYPE_VALUES = {"false", "true"}; - public final static String[] ATTRIBUTE_TABLE_TITLES = {"Attribute Name", "Value"}; - public static final String[] CONNECTION_PROTOCOLS ={"RMI"}; - public static final String DEFAULT_PROTOCOL = CONNECTION_PROTOCOLS[0]; - - public final static String ACTION_ADDSERVER = "New Connection"; - public final static String ACTION_RECONNECT = "Reconnect"; - public final static String ACTION_CLOSE = "Close Connection"; - public final static String ACTION_EDITATTRIBUTE = "Edit Attribute"; - public final static String ACTION_LOGIN = "Login"; - - public final static String QUEUE_SORT_BY_NAME = "Queue Name"; - public final static String QUEUE_SORT_BY_DEPTH = "Queue Depth"; - public final static String QUEUE_SORT_BY_CONSUMERCOUNT = "Consumer Count"; - public final static String QUEUE_SHOW_TEMP_QUEUES= "show temporary queues"; - - public final static String SUBSCRIBE_BUTTON = "Subscribe"; - public final static String UNSUBSCRIBE_BUTTON = "Unsubscribe"; - - public final static String CONSOLE_IMAGE = "ConsoelImage"; - public final static String CLOSED_FOLDER_IMAGE = "ClosedFolderImage"; - public final static String OPEN_FOLDER_IMAGE = "OpenFolderImage"; - public final static String MBEAN_IMAGE = "MBeanImage"; - public final static String NOTIFICATION_IMAGE = "NotificationImage"; - - public final static String FONT_BUTTON = "ButtonFont"; - public final static String FONT_BOLD = "BoldFont"; - public final static String FONT_ITALIC = "ItalicFont"; - public final static String FONT_TABLE_CELL = "TableCellFont"; - public final static String FONT_NORMAL = "Normal"; - - public final static String BUTTON_DETAILS = "Details"; - public final static String BUTTON_EDIT_ATTRIBUTE = "Edit Attribute"; - public final static String BUTTON_REFRESH = "Refresh"; - public final static String BUTTON_GRAPH = "Graph"; - public final static int TIMER_INTERVAL = 5000; - public final static String BUTTON_EXECUTE = "Execute"; - public final static String BUTTON_CLEAR = "Clear"; - public final static String BUTTON_CONNECT = "Connect"; - public final static String BUTTON_CANCEL = "Cancel"; - public final static String BUTTON_UPDATE = "Update"; - - - public final static int OPERATION_IMPACT_INFO = 0; - public final static int OPERATION_IMPACT_ACTION = 1; - public final static int OPERATION_IMPACT_ACTIONINFO = 2; - public final static int OPERATION_IMPACT_UNKNOWN = 3; - - public final static String ERROR_SERVER_CONNECTION = "Server Connection Failed"; - public final static String INFO_PROTOCOL = "Please select the protocol"; - public final static String INFO_HOST_ADDRESS = "Please enter the host address"; - public final static String INFO_HOST_PORT = "Please enter the port number"; - public final static String INFO_USERNAME = "Please enter the " + USERNAME; - public final static String INFO_PASSWORD = "Please enter the " + PASSWORD; - - public final static String MECH_CRAMMD5 = "CRAM-MD5"; - public final static String MECH_PLAIN = "PLAIN"; - public final static String SASL_CRAMMD5 = "SASL/CRAM-MD5"; - public final static String SASL_PLAIN = "SASL/PLAIN"; -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java deleted file mode 100644 index 31825e925d..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedBean.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import static org.apache.qpid.management.ui.Constants.*; -import java.util.HashMap; - -/** - * Class representing a managed bean on the managed server - * @author Bhupendra Bhardwaj - * - */ -public abstract class ManagedBean extends ManagedObject -{ - private String _uniqueName = ""; - private String _domain = ""; - private String _type = ""; - private String _virtualHostName = null; - private ManagedServer _server = null; - private HashMap _properties = null; - - public String getProperty(String key) - { - return (String)_properties.get(key); - } - - public HashMap getProperties() - { - return _properties; - } - public void setProperties(HashMap properties) - { - this._properties = properties; - setName(getProperty("name")); - setType(getProperty("type")); - _virtualHostName = getProperty(VIRTUAL_HOST); - } - public String getDomain() - { - return _domain; - } - public void setDomain(String domain) - { - this._domain = domain; - } - - public ManagedServer getServer() - { - return _server; - } - public void setServer(ManagedServer server) - { - this._server = server; - } - public String getType() - { - return _type; - } - public void setType(String type) - { - this._type = type; - } - public String getUniqueName() - { - return _uniqueName; - } - public void setUniqueName(String uniqueName) - { - this._uniqueName = uniqueName; - } - - public String getVirtualHostName() - { - // To make it work with the broker with no virtual host implementation - return _virtualHostName == null ? DEFAULT_VH : _virtualHostName; - } - - /** - * Returns mbean instance name. MBeans which have only one instance, the type attribute will be returned - * @return - */ - public String getInstanceName() - { - if (getName() != null) - return getName(); - else - return getType(); - } - - public boolean isQueue() - { - return _type.endsWith(QUEUE); - } - - public boolean isConnection() - { - return _type.endsWith(CONNECTION); - } - - public boolean isExchange() - { - return _type.endsWith(EXCHANGE); - } - - public boolean isTempQueue() - { - return (isQueue() && getName().startsWith("tmp_")); - } - - public boolean isAdmin() - { - return _type.endsWith(ADMIN_MBEAN_TYPE); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java deleted file mode 100644 index 96e0fa46c6..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedObject.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -/** - * Abstract class representing a managed object - * @author Bhupendra Bhardwaj - */ -public abstract class ManagedObject -{ - private String _name; - - public String getName() - { - return _name; - } - - public void setName(String name) - { - this._name = name; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java deleted file mode 100644 index 480fdb429a..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ManagedServer.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import static org.apache.qpid.management.ui.Constants.DEFAULT_PROTOCOL; -/** - * Class representing a server being managed eg. MBeanServer - * @author Bhupendra Bhardwaj - */ -public class ManagedServer extends ManagedObject -{ - private String _host; - private int _port; - private String _url; - private String _domain; - private String _user; - private String _password; - private String _protocol = DEFAULT_PROTOCOL; - - public ManagedServer(String host, int port, String domain) - { - this(host, port, domain, null, null); - } - - public ManagedServer(String host, int port, String domain, String user, String password) - { - setName(host + ":" + port); - _host = host; - _port = port; - _domain = domain; - _url = getRMIURL(host, port); - _user = user; - _password = password; - } - - public String getDomain() - { - return _domain; - } - - public String getHost() - { - return _host; - } - - public int getPort() - { - return _port; - } - - public String getUrl() - { - return _url; - } - - public String getProtocol() - { - return _protocol; - } - - public String getPassword() - { - return _password; - } - - public void setPassword(String password) - { - _password = password; - } - - public String getUser() - { - return _user; - } - - public void setUser(String user) - { - _user = user; - } - - private String getRMIURL(String host, int port) - { - return "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java deleted file mode 100644 index f93200cadf..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Perspective.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import org.apache.qpid.management.ui.views.MBeanView; -import org.apache.qpid.management.ui.views.NavigationView; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -/** - * - * @author Bhupendra Bhardwaj - */ -public class Perspective implements IPerspectiveFactory -{ - public void createInitialLayout(IPageLayout layout) - { - String editorArea = layout.getEditorArea(); - layout.setEditorAreaVisible(false); - - // standalone view meaning it can't be docked or stacked with other views, and it doesn't have a title bar. - layout.addStandaloneView(NavigationView.ID, true, IPageLayout.LEFT, 0.30f, editorArea); - layout.addStandaloneView(MBeanView.ID, true, IPageLayout.RIGHT, 0.70f, editorArea); - - layout.getViewLayout(NavigationView.ID).setCloseable(false); - layout.getViewLayout(MBeanView.ID).setCloseable(false); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java deleted file mode 100644 index 313e143df5..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/ServerRegistry.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.apache.qpid.management.ui.jmx.ClientListener; -import org.apache.qpid.management.ui.model.ManagedAttributeModel; -import org.apache.qpid.management.ui.model.NotificationObject; -import org.apache.qpid.management.ui.model.OperationDataModel; - -public abstract class ServerRegistry -{ - private ManagedServer _managedServer = null; - - // list of virtual hosts for this server - private List<String> _virtualHosts = new ArrayList<String>(); - // map of all Connection mbeans - private ConcurrentMap<String,List<ManagedBean>> _connections = new ConcurrentHashMap<String,List<ManagedBean>>(); - // map of all exchange mbeans - private ConcurrentMap<String,List<ManagedBean>> _exchanges = new ConcurrentHashMap<String,List<ManagedBean>>(); - // map of all queue mbenas - private ConcurrentMap<String,List<ManagedBean>> _queues = new ConcurrentHashMap<String,List<ManagedBean>>(); - - public ServerRegistry() - { - - } - - public ServerRegistry(ManagedServer server) - { - _managedServer = server; - } - - public ManagedServer getManagedServer() - { - return _managedServer; - } - - public void setManagedServer(ManagedServer server) - { - _managedServer = server; - } - - protected void addConnectionMBean(ManagedBean mbean) - { - String vHost = mbean.getVirtualHostName(); - _connections.putIfAbsent(vHost, new ArrayList<ManagedBean>()); - _connections.get(vHost).add(mbean); - } - - protected void addExchangeMBean(ManagedBean mbean) - { - String vHost = mbean.getVirtualHostName(); - _exchanges.putIfAbsent(vHost, new ArrayList<ManagedBean>()); - _exchanges.get(vHost).add(mbean); - } - - protected void addQueueMBean(ManagedBean mbean) - { - String vHost = mbean.getVirtualHostName(); - _queues.putIfAbsent(vHost, new ArrayList<ManagedBean>()); - _queues.get(vHost).add(mbean); - } - - protected void removeConnectionMBean(ManagedBean mbean) - { - _connections.get(mbean.getVirtualHostName()).remove(mbean); - } - - protected void removeExchangeMBean(ManagedBean mbean) - { - _exchanges.get(mbean.getVirtualHostName()).remove(mbean); - } - - protected void removeQueueMBean(ManagedBean mbean) - { - _queues.get(mbean.getVirtualHostName()).remove(mbean); - } - - public List<ManagedBean> getConnections(String virtualHost) - { - return _connections.get(virtualHost); - } - - public List<ManagedBean> getExchanges(String virtualHost) - { - return _exchanges.get(virtualHost); - } - - public List<ManagedBean> getQueues(String virtualHost) - { - return _queues.get(virtualHost); - } - - public void addVirtualHost(String name) - { - if (!_virtualHosts.contains(name)) - { - _virtualHosts.add(name); - } - } - - public List<String> getVirtualHosts() - { - return _virtualHosts; - } - - public abstract void setUserList(List<String> list); - - public abstract List<String> getUsernames(); - - public abstract void addManagedObject(ManagedBean key); - - public abstract List<ManagedBean> getMBeans(); - - public abstract void removeManagedObject(ManagedBean mbean); - - public abstract List<ManagedBean> getObjectsToBeRemoved(); - - public abstract ManagedAttributeModel getAttributeModel(ManagedBean mbean); - - public abstract Object getServerConnection(); - - public abstract void closeServerConnection() throws Exception; - - public abstract OperationDataModel getOperationModel(ManagedBean mbean); - - public abstract List<String> getQueueNames(String vistualHostName); - - public abstract String[] getExchangeNames(String vistualHostName); - - public abstract String[] getConnectionNames(String vistualHostName); - - public abstract List<NotificationObject> getNotifications(ManagedBean mbean); - - public abstract boolean hasSubscribedForNotifications(ManagedBean mbean, String name, String type); - - public abstract void clearNotifications(ManagedBean mbean, List<NotificationObject> list); - - public ClientListener getNotificationListener() - { - return null; - } - - public ClientListener getClientListener() - { - return null; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java deleted file mode 100644 index 53aa927299..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AbstractAction.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import static org.apache.qpid.management.ui.Constants.ERROR_SERVER_CONNECTION; - -import java.io.IOException; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.views.NavigationView; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class AbstractAction -{ - private NavigationView _navigationView; - - protected IWorkbenchWindow _window; - - public static final String RMI_SASL_ERROR = "non-JRMP server"; - public static final String SECURITY_FAILURE = "User authentication has failed"; - public static final String SERVER_UNAVAILABLE = "Qpid server is not running"; - - /** - * We will cache window object in order to - * be able to provide parent shell for the message dialog. - * @see IWorkbenchWindowActionDelegate#init - */ - public void init(IWorkbenchWindow window) - { - this._window = window; - if (_window.getShell() != null) - { - _window.getShell().setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE)); - } - } - - protected NavigationView getNavigationView() - { - if (_navigationView == null) - { - _navigationView = (NavigationView)_window.getActivePage().findView(NavigationView.ID); - } - - return _navigationView; - } - - - protected void handleException(Throwable ex, String title, String msg) - { - MBeanUtility.printStackTrace(ex); - if (msg == null) - { - if (ex instanceof IOException) - { - if ((ex.getMessage() != null) && (ex.getMessage().indexOf(RMI_SASL_ERROR) != -1)) - { - msg = SECURITY_FAILURE; - } - else - { - msg = SERVER_UNAVAILABLE; - } - } - else if (ex instanceof SecurityException) - { - msg = SECURITY_FAILURE; - } - else - { - msg = ex.getMessage(); - } - } - - if ((msg == null) && (ex.getCause() != null)) - { - msg = ex.getCause().getMessage(); - } - - if (msg == null) - { - msg = ERROR_SERVER_CONNECTION; - } - - if (title == null) - { - title = ERROR_SERVER_CONNECTION; - } - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.OK, msg, null); - ErrorDialog.openError(_window.getShell(), "Error", title, status); - } - - - /** - * Selection in the workbench has been changed. We can change the state of the 'real' action here - * if we want, but this can only happen after the delegate has been created. - * @see IWorkbenchWindowActionDelegate#selectionChanged - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /** - * We can use this method to dispose of any system resources we previously allocated. - * @see IWorkbenchWindowActionDelegate#dispose - */ - public void dispose() { - - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java deleted file mode 100644 index 7a36ca6160..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/AddServer.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import static org.apache.qpid.management.ui.Constants.*; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.views.NumberVerifyListener; -import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class AddServer extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - private static final String[] _domains ={"org.apache.qpid"}; - - private String _transport = DEFAULT_PROTOCOL; - private String _host; - private String _port; - private String _domain; - private String _user; - private String _password; - - private boolean _addServer; - - public AddServer() - { - - } - - public void run(IAction action) - { - if(_window == null) - return; - - reset(); - createAddServerPopup(); - try - { - if (_addServer) - { - getNavigationView().addNewServer(_transport, _host, Integer.parseInt(_port), _domain, _user, _password); - } - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, ex.getMessage()); - } - catch (Exception ex) - { - handleException(ex, null, null); - } - } - - private void reset() - { - _addServer = false; - _host = null; - _port = null; - _domain = null; - _user = null; - _password = null; - } - - /** - * Creates the shell and then opens the popup where user can enter new connection details. - * Connects to the new server and adds the server in the navigation page. - * Pops up any error occured in connecting to the new server - */ - private void createAddServerPopup() - { - Display display = Display.getCurrent(); - final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE); - shell.setText(ACTION_ADDSERVER); - shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE)); - shell.setLayout(new GridLayout()); - - int x = display.getBounds().width; - int y = display.getBounds().height; - shell.setBounds(x/3, y/3, 425, 275); - - createWidgets(shell); - - shell.open(); - _window.getShell().setEnabled(false); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - // enable the main shell - _window.getShell().setEnabled(true); - _window.getShell().open(); - } - - // Creates SWT widgets for the user to add server connection details. - // Adds listeners to the widgets to take appropriate action - private void createWidgets(final Shell shell) - { - Composite composite = new Composite(shell, SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 10; - layout.verticalSpacing = 10; - layout.marginHeight = 20; - layout.marginWidth = 20; - composite.setLayout(layout); - - /* Commenting this, as there is only one protocol at the moment. - * This can be uncommented and enhanced, if more protocols are added in future - Label name = new Label(composite, SWT.NONE); - name.setText("Connection Type"); - GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false); - name.setLayoutData(layoutData); - - final Combo comboTransport = new Combo(composite, SWT.READ_ONLY); - comboTransport.setItems(CONNECTION_PROTOCOLS); - comboTransport.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - comboTransport.select(0); - */ - - Label host = new Label(composite, SWT.NONE); - host.setText("Host"); - host.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textHost = new Text(composite, SWT.BORDER); - textHost.setText(""); - textHost.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - textHost.setFocus(); - - Label port = new Label(composite, SWT.NONE); - port.setText("Port"); - port.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textPort = new Text(composite, SWT.BORDER); - textPort.setText(""); - textPort.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - // Verify if the value entered is numeric - textPort.addVerifyListener(new NumberVerifyListener()); - - - Label domain = new Label(composite, SWT.NONE); - domain.setText("Domain"); - domain.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Combo comboDomain = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); - comboDomain.setItems(_domains); - comboDomain.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - comboDomain.select(0); - - - Label user = new Label(composite, SWT.NONE); - user.setText(USERNAME); - user.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textUser = new Text(composite, SWT.BORDER); - textUser.setText(""); - textUser.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - Label password = new Label(composite, SWT.NONE); - password.setText(PASSWORD); - password.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textPwd = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD); - textPwd.setText(""); - //textPwd.setEchoChar('*'); - textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - Composite buttonsComposite = new Composite(composite, SWT.NONE); - buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); - buttonsComposite.setLayout(new GridLayout(2, true)); - - - final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER); - connectButton.setText(BUTTON_CONNECT); - GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true); - gridData.widthHint = 100; - connectButton.setLayoutData(gridData); - connectButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - connectButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent event) - { - _host = textHost.getText(); - if ((_host == null) || (_host.trim().length() == 0)) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_ADDRESS); - textHost.setText(""); - textHost.setFocus(); - return; - } - - _port = textPort.getText(); - if ((_port == null) || (_port.trim().length() == 0)) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_HOST_PORT); - textPort.setText(""); - textPort.setFocus(); - return; - } - - _user = textUser.getText(); - if ((_user == null) || (_user.trim().length() == 0)) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_USERNAME); - textUser.setText(""); - textUser.setFocus(); - return; - } - - _password = textPwd.getText(); - if (_password == null) - { - ViewUtility.popupInfoMessage(ACTION_ADDSERVER, INFO_PASSWORD); - textPwd.setText(""); - textPwd.setFocus(); - return; - } - - _domain = comboDomain.getText(); - _addServer = true; - shell.dispose(); - } - }); - - final Button cancelButton = new Button(buttonsComposite, SWT.PUSH); - cancelButton.setText(BUTTON_CANCEL); - gridData = new GridData (SWT.LEAD, SWT.BOTTOM, true, true); - gridData.widthHint = 100; - cancelButton.setLayoutData(gridData); - cancelButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - cancelButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); - } - }); - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java deleted file mode 100644 index a3e52149df..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/CloseConnection.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import static org.apache.qpid.management.ui.Constants.ACTION_CLOSE; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.views.NavigationView; -import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class CloseConnection extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - public CloseConnection() - { - - } - - public void run(IAction action) - { - if(_window != null) - { - NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID); - try - { - view.disconnect(); - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage(ACTION_CLOSE, ex.getMessage()); - } - catch(Exception ex) - { - handleException(ex, null, null); - } - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java deleted file mode 100644 index d3af3661b0..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/EditAttribute.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import static org.apache.qpid.management.ui.Constants.ACTION_EDITATTRIBUTE; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.views.MBeanView; -import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class EditAttribute extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - public void run(IAction action) - { - if(_window != null) - { - MBeanView view = (MBeanView)_window.getActivePage().findView(MBeanView.ID); - try - { - view.editAttribute(); - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage(ACTION_EDITATTRIBUTE, ex.getMessage()); - } - catch(Exception ex) - { - handleException(ex, "Attribute could not be edited", null); - } - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java deleted file mode 100644 index dd9e792912..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/ReconnectServer.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import static org.apache.qpid.management.ui.Constants.ACTION_LOGIN; -import static org.apache.qpid.management.ui.Constants.CONSOLE_IMAGE; -import static org.apache.qpid.management.ui.Constants.INFO_PASSWORD; -import static org.apache.qpid.management.ui.Constants.INFO_USERNAME; -import static org.apache.qpid.management.ui.Constants.PASSWORD; -import static org.apache.qpid.management.ui.Constants.USERNAME; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.views.TreeObject; -import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class ReconnectServer extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - private String _title; - private String _serverName; - private String _user; - private String _password; - private boolean _connect; - - public void run(IAction action) - { - if(_window == null) - return; - - try - { - reset(); - // Check if a server node is selected to be reconnected. - TreeObject serverNode = getNavigationView().getSelectedServerNode(); - _serverName = serverNode.getName(); - _title = ACTION_LOGIN + " (" + _serverName + ")"; - - // Get the login details(username/password) - createLoginPopup(); - - if (_connect) - { - // Connect the server - getNavigationView().reconnect(_user, _password); - } - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage("Reconnect Qpid server", ex.getMessage()); - } - catch (Exception ex) - { - handleException(ex, null, null); - } - } - - private void reset() - { - _connect = false; - _user = null; - _password = null; - } - - // Create the login popup fot th user to enter usernaem and password - private void createLoginPopup() - { - Display display = Display.getCurrent(); - final Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE); - shell.setText(_title); - shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE)); - shell.setLayout(new GridLayout()); - - int x = display.getBounds().width; - int y = display.getBounds().height; - shell.setBounds(x/3, y/3, 350, 200); - - createWidgets(shell); - - shell.open(); - _window.getShell().setEnabled(false); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - // enable the main shell - _window.getShell().setEnabled(true); - _window.getShell().open(); - } - - // Creates the SWT widgets in the popup shell, to enter username and password. - // Adds listeners to the widgets to take appropriate action - private void createWidgets(final Shell shell) - { - Composite composite = new Composite(shell, SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 10; - layout.verticalSpacing = 10; - layout.marginHeight = 20; - layout.marginWidth = 20; - composite.setLayout(layout); - - Label user = new Label(composite, SWT.NONE); - user.setText(USERNAME); - user.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textUser = new Text(composite, SWT.BORDER); - textUser.setText(""); - textUser.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - // Put cursor on this field - textUser.setFocus(); - - Label password = new Label(composite, SWT.NONE); - password.setText(PASSWORD); - password.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - final Text textPwd = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD); - textPwd.setText(""); - textPwd.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - Composite buttonsComposite = new Composite(composite, SWT.NONE); - buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); - buttonsComposite.setLayout(new GridLayout(2, true)); - - - final Button connectButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER); - connectButton.setText(Constants.BUTTON_CONNECT); - GridData gridData = new GridData (SWT.TRAIL, SWT.BOTTOM, true, true); - gridData.widthHint = 100; - connectButton.setLayoutData(gridData); - connectButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - connectButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent event) - { - _user = textUser.getText(); - if ((_user == null) || (_user.trim().length() == 0)) - { - ViewUtility.popupInfoMessage(_title, INFO_USERNAME); - textUser.setText(""); - textUser.setFocus(); - return; - } - - _password = textPwd.getText(); - if (_password == null) - { - ViewUtility.popupInfoMessage(_title, INFO_PASSWORD); - textPwd.setText(""); - textPwd.setFocus(); - return; - } - - _connect = true; - shell.dispose(); - } - }); - - final Button cancelButton = new Button(buttonsComposite, SWT.PUSH); - cancelButton.setText(Constants.BUTTON_CANCEL); - gridData = new GridData (SWT.LEAD, SWT.BOTTOM, true, true); - gridData.widthHint = 100; - cancelButton.setLayoutData(gridData); - cancelButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - cancelButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); - } - }); - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java deleted file mode 100644 index 34251c12d7..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/Refresh.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.views.MBeanView; -import org.apache.qpid.management.ui.views.NavigationView; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -/** - * This action refreshes both the views -Navigation and MBeanView - * @author Bhupendra Bhardwaj - */ -public class Refresh extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - public void run(IAction action) - { - if(_window != null) - { - NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID); - view.refresh(); - - MBeanView mbeanview = (MBeanView)_window.getActivePage().findView(MBeanView.ID); - try - { - mbeanview.refreshMBeanView(); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java deleted file mode 100644 index e329255414..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/RemoveServer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.views.NavigationView; -import org.apache.qpid.management.ui.views.ViewUtility; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public class RemoveServer extends AbstractAction implements IWorkbenchWindowActionDelegate -{ - public void run(IAction action) - { - if(_window != null) - { - NavigationView view = (NavigationView)_window.getActivePage().findView(NavigationView.ID); - try - { - view.removeServer(); - } - catch(InfoRequiredException ex) - { - ViewUtility.popupInfoMessage("Remove Qpid server", ex.getMessage()); - } - catch(Exception ex) - { - handleException(ex, "Server could not be removed", null); - } - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java deleted file mode 100644 index 11db02f5a2..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/actions/VersionAction.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.actions; - -import java.io.InputStream; -import java.util.Properties; - -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.ui.IWorkbenchWindow; - -public class VersionAction extends Action -{ - private IWorkbenchWindow _window; - public static final String VERSION_RESOURCE = "qpidversion.properties"; - - public static final String PRODUCT_NAME_PROPERTY = "qpid.name"; - public static final String RELEASE_VERSION_PROPERTY = "qpid.version"; - public static final String BUILD_VERSION_PROPERTY = "qpid.svnversion"; - - private static final String DEFAULT = "unknown"; - private static String _releaseVersion; - private static String _buildVersion; - private static String _text; - - static - { - Properties props = new Properties(); - try - { - InputStream propertyStream = VersionAction.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE); - if (propertyStream != null) - { - props.load(propertyStream); - _releaseVersion = readPropertyValue(props, RELEASE_VERSION_PROPERTY); - _buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY); - _text = "Build Version : " + _buildVersion + "\n" + - "Release Version : " + _releaseVersion; - } - } - catch (Exception ex) - { - MBeanUtility.printStackTrace(ex); - } - } - - public VersionAction(IWorkbenchWindow window) - { - _window = window; - setText("About " + Constants.APPLICATION_NAME); - setId("qpidmc.about"); - setActionDefinitionId("qpidmc.about"); - } - - private static String readPropertyValue(Properties props, String propertyName) - { - String retVal = (String) props.get(propertyName); - if (retVal == null) - { - retVal = DEFAULT; - } - return retVal; - } - - public void run() - { - MessageDialog.openInformation(_window.getShell(), Constants.APPLICATION_NAME, _text); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/InfoRequiredException.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/InfoRequiredException.java deleted file mode 100644 index 672426a59d..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/InfoRequiredException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.exceptions; - -public class InfoRequiredException extends Exception -{ - private static final long serialVersionUID = 1L; - - public InfoRequiredException(String message) - { - super(message); - } - - public InfoRequiredException(String msg, Throwable t) - { - super(msg, t); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java deleted file mode 100644 index 17c127c01a..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/exceptions/ManagementConsoleException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.exceptions; - -@SuppressWarnings("serial") -public class ManagementConsoleException extends Exception -{ - public ManagementConsoleException(String message) - { - super(message); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java deleted file mode 100644 index 2be0ddbebf..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientListener.java +++ /dev/null @@ -1,77 +0,0 @@ - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */package org.apache.qpid.management.ui.jmx; - -import javax.management.MBeanServerNotification; -import javax.management.Notification; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.management.remote.JMXConnectionNotification; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedServer; - - -public class ClientListener implements NotificationListener -{ - protected ManagedServer server = null; - protected JMXServerRegistry serverRegistry = null; - - public ClientListener(ManagedServer server) - { - this.server = server; - serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - } - - public void handleNotification(Notification notification, Object handback) - { - ObjectName objName = null; - String type = notification.getType(); - MBeanUtility.printOutput(type + ":" + objName); - - if (MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(type)) - { - objName = ((MBeanServerNotification)notification).getMBeanName(); - getServerRegistry().registerManagedObject(objName); - } - else if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(type)) - { - objName = ((MBeanServerNotification)notification).getMBeanName(); - getServerRegistry().unregisterManagedObject(objName); - } - else if (JMXConnectionNotification.FAILED.equals(type)) - { - ApplicationRegistry.serverConnectionClosed(server); - } - } - - protected JMXServerRegistry getServerRegistry() - { - if (serverRegistry == null) - serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - - return serverRegistry; - } - public ManagedServer getServer() - { - return server; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java deleted file mode 100644 index c6ecda4b4c..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/ClientNotificationListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.jmx; - -import javax.management.Notification; -import javax.management.ObjectName; - -import org.apache.qpid.management.ui.ManagedServer; - -public class ClientNotificationListener extends ClientListener -{ - public ClientNotificationListener(ManagedServer server) - { - super(server); - } - - public void handleNotification(Notification notification, Object handback) - { - ObjectName objName = (ObjectName)notification.getSource(); - //String type = notification.getType(); - getServerRegistry().addNotification(objName, notification); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXManagedObject.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXManagedObject.java deleted file mode 100644 index 3561e16098..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXManagedObject.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.jmx; - -import java.util.HashMap; - -import javax.management.ObjectName; - -import org.apache.qpid.management.ui.ManagedBean; - - -public class JMXManagedObject extends ManagedBean -{ - private ObjectName _objName; - - @SuppressWarnings("unchecked") - public JMXManagedObject(ObjectName objName) - { - super(); - this._objName = objName; - setUniqueName(_objName.toString()); - setDomain(_objName.getDomain()); - super.setProperties(new HashMap(_objName.getKeyPropertyList())); - } - - public ObjectName getObjectName() - { - return _objName; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java deleted file mode 100644 index f671a1dc9a..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/JMXServerRegistry.java +++ /dev/null @@ -1,628 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.jmx; - -import static org.apache.qpid.management.ui.Constants.*; - -import java.lang.reflect.Constructor; -import java.security.Security; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; - -import javax.management.ListenerNotFoundException; -import javax.management.MBeanInfo; -import javax.management.MBeanServerConnection; -import javax.management.Notification; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.SaslClientFactory; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ManagedServer; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.model.ManagedAttributeModel; -import org.apache.qpid.management.ui.model.NotificationInfoModel; -import org.apache.qpid.management.ui.model.NotificationObject; -import org.apache.qpid.management.ui.model.OperationDataModel; -import org.apache.qpid.management.ui.sasl.JCAProvider; -import org.apache.qpid.management.ui.sasl.SaslProvider; -import org.apache.qpid.management.ui.sasl.UserPasswordCallbackHandler; -import org.apache.qpid.management.ui.sasl.UsernameHashedPasswordCallbackHandler; - - -public class JMXServerRegistry extends ServerRegistry -{ - private boolean _connected = false; - private ObjectName _serverObjectName = null; - private Map<String, Object> _env = null; - private JMXServiceURL _jmxUrl = null; - private JMXConnector _jmxc = null; - private MBeanServerConnection _mbsc = null; - private Exception _connectionException = null; - - private List<String> _usersList; - // When an mbean gets removed from mbean server, then the notification listener - // will add that mbean in this list. - private List<ManagedBean> _mbeansToBeRemoved = new ArrayList<ManagedBean>(); - - // Map containing all managed beans and mapped with unique mbean name - private HashMap<String, ManagedBean> _mbeansMap = new HashMap<String, ManagedBean>(); - // Map containing MBeanInfo for all mbeans and mapped with unique mbean name - private HashMap<String, MBeanInfo> _mbeanInfoMap = new HashMap<String, MBeanInfo>(); - // Map containing attribute model for all mbeans and mapped with unique mbean name - private HashMap<String, ManagedAttributeModel> _attributeModelMap = new HashMap<String, ManagedAttributeModel>(); - // Map containing operation model for all mbeans and mapped with unique mbean name - private HashMap<String, OperationDataModel> _operationModelMap = new HashMap<String, OperationDataModel>(); - // Map containing NotificationInfo for all mbeans and mapped with unique mbean name - private HashMap<String, List<NotificationInfoModel>> _notificationInfoMap = new HashMap<String, List<NotificationInfoModel>>(); - // Map containing all notifications sent for all mbeans, which are registered for notification - private HashMap<String, List<NotificationObject>> _notificationsMap = new HashMap<String, List<NotificationObject>>(); - // For mbeans which have subscribed for a notification type - // mbean unique name mapped with notification map. Notification map contains list of notification type - // mapped with notification name. Notification type list contains those notification types, - // which are subscribed for notification. - private HashMap<String, HashMap<String, List<String>>> _subscribedNotificationMap = new HashMap<String, HashMap<String, List<String>>>(); - - // listener for registration or unregistratioj of mbeans on mbean server - private ClientNotificationListener _notificationListener = null; - // listener for server connection. Receives notification if server connection goes down - private ClientListener _clientListener = null; - - public JMXServerRegistry(ManagedServer server) throws Exception - { - super(server); - String securityMechanism = ApplicationRegistry.getSecurityMechanism(); - String connectorClassName = ApplicationRegistry.getJMXConnectorClass(); - - if ((securityMechanism != null) && (connectorClassName != null)) - { - createSASLConnector(securityMechanism, connectorClassName); - } - else - { - _jmxUrl = new JMXServiceURL(server.getUrl()); - _jmxc = JMXConnectorFactory.connect(_jmxUrl, null); - } - - _mbsc = _jmxc.getMBeanServerConnection(); - - _clientListener = new ClientListener(server); - _notificationListener = new ClientNotificationListener(server); - - _jmxc.addConnectionNotificationListener(_clientListener, null, null); - _serverObjectName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); - _mbsc.addNotificationListener(_serverObjectName, _clientListener, null, null); - } - - public MBeanServerConnection getServerConnection() - { - return _mbsc; - } - - private void createSASLConnector(String mech, String className) throws Exception - { - String text = "Security mechanism " + mech + " is not supported."; - // Check if the given connector, which supports SASL is available - Class connectorClass = Class.forName(className); - - _jmxUrl = new JMXServiceURL("jmxmp", getManagedServer().getHost(), getManagedServer().getPort()); - _env = new HashMap<String, Object>(); - CallbackHandler handler; - if (MECH_CRAMMD5.equals(mech)) - { - // For SASL/CRAM-MD5 - Map<String, Class<? extends SaslClientFactory>> map = new HashMap<String, Class<? extends SaslClientFactory>>(); - Class<?> clazz = Class.forName("org.apache.qpid.management.ui.sasl.CRAMMD5HashedSaslClientFactory"); - map.put("CRAM-MD5-HASHED", (Class<? extends SaslClientFactory>) clazz); - - Security.addProvider(new JCAProvider(map)); - handler = new UsernameHashedPasswordCallbackHandler(getManagedServer().getUser(), - getManagedServer().getPassword()); - _env.put("jmx.remote.profiles", SASL_CRAMMD5); - _env.put("jmx.remote.sasl.callback.handler", handler); - - } - else if (MECH_PLAIN.equals(mech)) - { - // For SASL/PLAIN - Security.addProvider(new SaslProvider()); - handler = new UserPasswordCallbackHandler(getManagedServer().getUser(), getManagedServer().getPassword()); - _env.put("jmx.remote.profiles", SASL_PLAIN); - _env.put("jmx.remote.sasl.callback.handler", handler); - } - else - { - MBeanUtility.printOutput(text); - throw new Exception(text); - } - // Now create the instance of JMXMPConnector - Class[] paramTypes = {JMXServiceURL.class, Map.class}; - Constructor cons = connectorClass.getConstructor(paramTypes); - - Object[] args = {_jmxUrl, _env}; - Object theObject = cons.newInstance(args); - - _jmxc = (JMXConnector)theObject; - - Thread connectorThread = new Thread(new ConnectorThread()); - connectorThread.start(); - long timeNow = System.currentTimeMillis(); - connectorThread.join(ApplicationRegistry.timeout); - - if (_connectionException != null) - { - throw _connectionException; - } - if (!_connected) - { - if (System.currentTimeMillis() - timeNow >= ApplicationRegistry.timeout) - throw new Exception("Qpid server connection timed out"); - else - throw new Exception("Qpid server connection failed"); - } - } - - private class ConnectorThread implements Runnable - { - public void run() - { - try - { - _connected = false; - _connectionException = null; - - _jmxc.connect(); - _connected = true; - } - catch (Exception ex) - { - _connectionException = ex; - MBeanUtility.printStackTrace(ex); - } - } - } - /** - * removes all listeners from the mbean server. This is required when user - * disconnects the Qpid server connection - */ - public void closeServerConnection() throws Exception - { - try - { - if (_jmxc != null && _clientListener != null) - _jmxc.removeConnectionNotificationListener(_clientListener); - - if (_mbsc != null && _clientListener != null) - _mbsc.removeNotificationListener(_serverObjectName, _clientListener); - - // remove mbean notification listeners - for (String mbeanName : _subscribedNotificationMap.keySet()) - { - _mbsc.removeNotificationListener(new ObjectName(mbeanName), _notificationListener); - } - } - catch (ListenerNotFoundException ex) - { - MBeanUtility.printOutput(ex.toString()); - } - } - - public ManagedBean getManagedObject(String uniqueName) - { - return _mbeansMap.get(uniqueName); - } - - public void addManagedObject(ManagedBean mbean) - { - if (mbean.isQueue()) - { - addQueueMBean(mbean); - } - else if (mbean.isExchange()) - { - addExchangeMBean(mbean); - } - else if (mbean.isConnection()) - { - addConnectionMBean(mbean); - } - - addVirtualHost(mbean.getVirtualHostName()); - _mbeansMap.put(mbean.getUniqueName(), mbean); - } - - public void removeManagedObject(ManagedBean mbean) - { - MBeanUtility.printOutput("Removing MBean:" + mbean.getUniqueName()); - - if (mbean.isQueue()) - { - removeQueueMBean(mbean); - } - else if (mbean.isExchange()) - { - removeExchangeMBean(mbean); - } - else if (mbean.isConnection()) - { - removeConnectionMBean(mbean); - } - - _mbeansMap.remove(mbean.getUniqueName()); - } - - public void putMBeanInfo(ManagedBean mbean, MBeanInfo mbeanInfo) - { - _mbeanInfoMap.put(mbean.getUniqueName(), mbeanInfo); - } - public MBeanInfo getMBeanInfo(ManagedBean mbean) - { - return _mbeanInfoMap.get(mbean.getUniqueName()); - } - - public List<ManagedBean> getMBeans() - { - return new ArrayList<ManagedBean>(_mbeansMap.values()); - } - - public void setNotificationInfo(ManagedBean mbean, List<NotificationInfoModel>value) - { - _notificationInfoMap.put(mbean.getUniqueName(), value); - } - - public List<NotificationInfoModel> getNotificationInfo(ManagedBean mbean) - { - return _notificationInfoMap.get(mbean.getUniqueName()); - } - - public void addNotification(ObjectName objName, Notification notification) - { - List<NotificationObject> list = _notificationsMap.get(objName.toString()); - NotificationObject obj = new NotificationObject(notification.getSequenceNumber(), - new Date(notification.getTimeStamp()), - notification.getMessage(), - notification.getSource(), - notification.getType()); - - if (list == null) - { - list = new ArrayList<NotificationObject>(); - _notificationsMap.put(objName.toString(), list); - } - - list.add(obj); - } - - /** - * Returns all the notification objects for a given mbean. If mbean is null, it returns - * notification objects for all the mbeans. - */ - public List<NotificationObject> getNotifications(ManagedBean mbean) - { - if (mbean == null) - { - List<NotificationObject> totalList = new ArrayList<NotificationObject>(); - for (List<NotificationObject> list : _notificationsMap.values()) - { - totalList.addAll(list); - } - return totalList; - } - else - { - return _notificationsMap.get(mbean.getUniqueName()); - } - } - - public void clearNotifications(ManagedBean mbean, List<NotificationObject> list) - { - if (mbean == null) - { - if (list == null || list.isEmpty()) - { - // All notifications of all mbeans to be cleared - _notificationsMap.clear(); - } - else - { - // Clear the selected notifications - for (NotificationObject obj : list) - { - mbean = _mbeansMap.get(obj.getSource().toString()); - List<NotificationObject> nList = _notificationsMap.get(mbean.getUniqueName()); - if (nList != null && !nList.isEmpty()) - { - nList.remove(obj); - } - } - } - } - else - { - if (list == null || list.isEmpty()) - { - // All notifications of this mbean to be cleared - List<NotificationObject> nList = _notificationsMap.get(mbean.getUniqueName()); - if (nList != null && !nList.isEmpty()) - { - nList.clear(); - } - } - else - { - // Clear the selected notifications - for (NotificationObject obj : list) - { - List<NotificationObject> nList = _notificationsMap.get(mbean.getUniqueName()); - if (nList != null && !nList.isEmpty()) - { - nList.remove(obj); - } - } - } - } - } - - - - /** - * Adds notification name and type to the map. The map contains all the notification names, - * subscribed for an mbean. - * @param mbean - * @param name - * @param type - */ - public void addNotificationListener(ManagedBean mbean, String name, String type) - { - // Get the subscribed notifications map for given mbean. If map is null then create a new one. - HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName()); - if (map == null) - { - map = new HashMap<String, List<String>>(); - _subscribedNotificationMap.put(mbean.getUniqueName(),map); - } - - // Get the list of notification types for given notification name. If null, then create a new list. - List<String> list = map.get(name); - if (list == null) - { - list = new ArrayList<String>(); - map.put(name, list); - } - // Now add the notification type to the list - if (ALL.equals(type)) - { - List<NotificationInfoModel> infoList = _notificationInfoMap.get(mbean.getUniqueName()); - for (NotificationInfoModel model : infoList) - { - if (model.getName().equals(name)) - { - String[] types = model.getTypes(); - for (int i = 0; i < types.length; i++) - { - list.add(types[i]); - } - } - } - } - else - { - list.add(type); - } - - //System.out.println("Subscribed for notification :" + mbean.getUniqueName()); - } - - /** - * Checks if the given notification name and type are subscribed for the mbean. - */ - public boolean hasSubscribedForNotifications(ManagedBean mbean, String name, String type) - { - if (_subscribedNotificationMap.containsKey(mbean.getUniqueName())) - { - HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName()); - if (map.containsKey(name)) - { - if (map.get(name).contains(type)) - { - return true; - } - } - } - return false; - } - - /** - * Clears the notification name and type information from the subscribed notifications map - * and removes the listener from mbeanserver connection - * @param mbean - * @param name - * @param type - * @throws Exception - */ - public void removeNotificationListener(ManagedBean mbean, String name, String type) throws Exception - { - //System.out.println("Removed notification listener :" + mbean.getUniqueName() + name +type); - if (_subscribedNotificationMap.containsKey(mbean.getUniqueName())) - { - // get the notifications map. This map contains the notification name mapped with the notification types - HashMap<String, List<String>> map = _subscribedNotificationMap.get(mbean.getUniqueName()); - if (map.containsKey(name)) - { - if (ALL.equals(type)) - { - map.remove(name); - } - else if (type != null) - { - map.get(name).remove(type); - if (map.get(name).isEmpty()) - { - map.remove(name); - } - } - } - if (map.size() == 0) - { - _subscribedNotificationMap.remove(mbean.getUniqueName()); - } - - JMXManagedObject jmxbean = (JMXManagedObject)mbean; - _mbsc.removeNotificationListener(jmxbean.getObjectName(), _notificationListener); - } - } - - /** - * When the mbean registration request is received from the mbean server, then the client listener - * can use this method. It will add the mbean to a list, which will be used to add the mbean to - * the registry and gui - * @param objName - */ - public void registerManagedObject(ObjectName objName) - { - JMXManagedObject managedObject = new JMXManagedObject(objName); - managedObject.setServer(getManagedServer()); - addManagedObject(managedObject); - } - - /** - * When mbean unregistration notification is received from the mbean server, then client listener - * can invoke this method. It will add the mbean to the list of mbeans to be removed from registry - * @param objName - */ - public void unregisterManagedObject(ObjectName objName) - { - ManagedBean mbean = _mbeansMap.get(objName.toString()); - removeManagedObject(mbean); - // Check if mbean was not available in the map. It can happen if mbean unregistration - // notification is received and the mbean is not added in the map. - if (mbean != null) - { - _mbeansToBeRemoved.add(mbean); - } - } - - public List<ManagedBean> getObjectsToBeRemoved() - { - if (_mbeansToBeRemoved.isEmpty()) - return null; - else - { - List<ManagedBean> list = new CopyOnWriteArrayList<ManagedBean>(_mbeansToBeRemoved); - _mbeansToBeRemoved.clear(); - return list; - } - } - - public void setAttributeModel(ManagedBean mbean, ManagedAttributeModel value) - { - _attributeModelMap.put(mbean.getUniqueName(), value); - } - - public ManagedAttributeModel getAttributeModel(ManagedBean mbean) - { - return _attributeModelMap.get(mbean.getUniqueName()); - } - - public void setOperationModel(ManagedBean mbean, OperationDataModel value) - { - _operationModelMap.put(mbean.getUniqueName(), value); - } - - public OperationDataModel getOperationModel(ManagedBean mbean) - { - return _operationModelMap.get(mbean.getUniqueName()); - } - - public List<String> getQueueNames(String virtualHostName) - { - List<ManagedBean> list = getQueues(virtualHostName); - if (list == null) - return null; - - List<String> queueNames = new ArrayList<String>(); - for (ManagedBean mbean : list) - { - queueNames.add(mbean.getName()); - } - return queueNames; - } - - public String[] getExchangeNames(String virtualHostName) - { - List<ManagedBean> list = getExchanges(virtualHostName); - if (list == null) - return null; - - String[] exchanges = new String[list.size()]; - int i = 0; - for (ManagedBean mbean : list) - { - exchanges[i++] = mbean.getName(); - } - return exchanges; - } - - public String[] getConnectionNames(String virtualHostName) - { - List<ManagedBean> list = getExchanges(virtualHostName); - if (list == null) - return null; - - String[] connections = new String[list.size()]; - int i = 0; - for (ManagedBean mbean : list) - { - connections[i++] = mbean.getName(); - } - return connections; - } - - public void setUserList(List<String> list) - { - _usersList = list; - Collections.sort(_usersList); - } - - public List<String> getUsernames() - { - return _usersList; - } - - public ClientNotificationListener getNotificationListener() - { - return _notificationListener; - } - - public ClientListener getClientListener() - { - return _clientListener; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java deleted file mode 100644 index 2d1883533b..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/jmx/MBeanUtility.java +++ /dev/null @@ -1,466 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.jmx; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.InstanceNotFoundException; -import javax.management.JMException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanOperationInfo; -import javax.management.MBeanServerConnection; -import javax.management.ObjectInstance; -import javax.management.ObjectName; -import javax.management.ReflectionException; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ManagedServer; -import org.apache.qpid.management.ui.exceptions.ManagementConsoleException; -import org.apache.qpid.management.ui.model.AttributeData; -import org.apache.qpid.management.ui.model.ManagedAttributeModel; -import org.apache.qpid.management.ui.model.NotificationInfoModel; -import org.apache.qpid.management.ui.model.OperationData; -import org.apache.qpid.management.ui.model.OperationDataModel; -import org.apache.qpid.management.ui.model.ParameterData; -import org.apache.qpid.management.ui.views.ViewUtility; - -/** - * Utility class for all mbeanserver related operations. Keeps all JMX code out from view and model classes - * @author Bhupendra Bhardwaj - */ -public class MBeanUtility -{ - public static final BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE); - public static final BigInteger MAX_INT = BigInteger.valueOf(Integer.MAX_VALUE); - /** - * Retrieves the MBeanInfo from MBeanServer and stores in the application registry - * @param mbean managed bean - * @return MBeanInfo - * @throws Exception, if server connection is null or if server throws Exception - */ - public static MBeanInfo getMBeanInfo(ManagedBean mbean) throws Exception - { - ManagedServer server = mbean.getServer(); - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - if (mbsc == null) - { - throw new ManagementConsoleException("Server connection is broken"); - } - - JMXManagedObject jmxbean = (JMXManagedObject)mbean; - MBeanInfo mbeanInfo = mbsc.getMBeanInfo(jmxbean.getObjectName()); - serverRegistry.putMBeanInfo(mbean, mbeanInfo); - - // populate the server registry with attribute and operation info - getAttributes(mbean); - getOperations(mbean); - - return mbeanInfo; - } - - /** - * executes the MBean operation - * @param mbean - * @param opData - * @return MBean operation return value - * @throws Exception if server connection is broken or if operation execution fails on the mbean server - */ - public static Object execute(ManagedBean mbean, OperationData opData) throws Exception - { - String opName = opData.getName(); - Object[] values = null; - String[] signature = null; - - List<ParameterData> params = opData.getParameters(); - if (params != null && !params.isEmpty()) - { - signature = new String[params.size()];; - values = new Object[params.size()]; - for (int i = 0; i < params.size(); i++) - { - signature[i] = params.get(i).getType(); - values[i] = params.get(i).getValue(); - } - } - - ManagedServer server = mbean.getServer(); - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - if (mbsc == null) - { - throw new ManagementConsoleException("Server connection is broken"); - // TODO - // try and get the connection again if it was disconnected - } - JMXManagedObject jmxbean = (JMXManagedObject)mbean; - return mbsc.invoke(jmxbean.getObjectName(), opName, values, signature); - } - - /** - * @see MBeanUtility#handleException(ManagedBean, Exception) - */ - public static void handleException(Exception ex) - { - handleException(null, ex); - } - - /** - * handels the exception received. Shows the exception to the user in best suitable way - * @param mbean managed bean - * @param ex Exception - */ - public static void handleException(ManagedBean mbean, Throwable ex) - { - if (mbean == null) - { - ViewUtility.popupErrorMessage("Error", "Managed Object is null \n" + ex.toString()); - printStackTrace(ex); - } - else if (ex instanceof ReflectionException) - { - ViewUtility.popupErrorMessage(mbean.getInstanceName(), "Server has thrown error \n" + ex.toString()); - printStackTrace(ex); - } - else if (ex instanceof InstanceNotFoundException) - { - ViewUtility.popupErrorMessage(mbean.getInstanceName(), "Managed Object Not Found \n" + ex.toString()); - printStackTrace(ex); - } - else if (ex instanceof MBeanException) - { - String cause = ((MBeanException)ex).getTargetException().getMessage(); - if (cause == null) - cause = ex.toString(); - ViewUtility.popupInfoMessage(mbean.getInstanceName(), cause); - } - else if (ex instanceof JMException) - { - ViewUtility.popupErrorMessage(mbean.getInstanceName(), "Management Exception occured \n" + ex.toString()); - } - else if (ex instanceof ManagementConsoleException) - { - ViewUtility.popupErrorMessage(mbean.getInstanceName(), ex.getMessage()); - } - else - { - if (ex.getCause() != null) - { - handleException(mbean, ex.getCause()); - } - else - { - String msg = ex.getMessage(); - if (msg == null) - { - msg = ex.toString(); - } - ViewUtility.popupErrorMessage(mbean.getInstanceName(), msg); - printStackTrace(ex); - } - } - - } - - /** - * Registers the notification listener with the MBeanServer - * @param mbean managed bean - * @param name notification name - * @param type notification type - * @throws Exception if server connection is broken or if listener could not be created - */ - public static void createNotificationlistener(ManagedBean mbean, String name, String type) - throws Exception - { - JMXManagedObject jmxbean = (JMXManagedObject)mbean; - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - serverRegistry.addNotificationListener(mbean, name, type); - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - - if (mbsc == null) - { - throw new ManagementConsoleException("Server connection is broken"); - } - mbsc.addNotificationListener(jmxbean.getObjectName(), serverRegistry.getNotificationListener(), null, null); - } - - public static void removeNotificationListener(ManagedBean mbean, String name, String type) throws Exception - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - serverRegistry.removeNotificationListener(mbean, name, type); - } - - /** - * Checks if the server registry contains attribute information for this mbean. If not then it queries the - * mbean server for complete mbean information, else it gets the latest value of the given attribute - * from mbean server. - * @return attribute data for the given mbean attribute - */ - public static AttributeData getAttributeData(ManagedBean mbean, String attribute) throws Exception - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean); - if (attributeModel == null) - { - // If process is here, it means the mbeanInfo is not retrieved from mbean server even once for this mbean - getMBeanInfo(mbean); - } - else - { - // refresh attribute value from mbean server - refreshAttribute(mbean, attribute); - } - attributeModel = serverRegistry.getAttributeModel(mbean); - return attributeModel.getAttribute(attribute); - } - - /** - * Retrieves the latest attribute value from mbean server for the given mbean attribute - * and also sets that value in the attribute model in the server registry - * @return latest attribute value for the given mbean attribute - */ - public static Object refreshAttribute(ManagedBean mbean, String attribute) throws Exception - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - - if (mbsc == null) - { - throw new ManagementConsoleException("Server connection is broken"); - } - - Object value = mbsc.getAttribute(((JMXManagedObject)mbean).getObjectName(), attribute); - // update the attribute data in server registry for this attribute - ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean); - attributeModel.setAttributeValue(attribute, value); - return value; - } - - /** - * Retrieves the attribute values from MBeanSever and stores in the server registry. - * @param mbean - * @return the attribute model - * @throws Exception if attributes can not be retrieved from MBeanServer - */ - public static ManagedAttributeModel getAttributes(ManagedBean mbean) throws Exception - { - ObjectName objName = ((JMXManagedObject)mbean).getObjectName(); - String[] attributes = null; - AttributeList list = null; - - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - MBeanAttributeInfo[] attributesInfo = null; - ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean); - - if (attributeModel == null) - { - // If the process is here, then it means the attribute values are not retrieved from mbean server - // even once for this mbean. Create attribute model, retrieve values from mbean server and - // set the attribute model in server registry for this mbean - attributeModel = new ManagedAttributeModel(); - attributesInfo = serverRegistry.getMBeanInfo(mbean).getAttributes(); - attributes = new String[attributesInfo.length]; - for (int i = 0; i< attributesInfo.length ; i++) - { - attributes[i] = attributesInfo[i].getName(); - attributeModel.setAttributeDescription(attributes[i], attributesInfo[i].getDescription()); - attributeModel.setAttributeWritable(attributes[i], attributesInfo[i].isWritable()); - attributeModel.setAttributeReadable(attributes[i], attributesInfo[i].isReadable()); - } - } - else - { - attributes = attributeModel.getAttributeNames().toArray(new String[0]); - } - - if (attributes.length != 0) - { - list = mbsc.getAttributes(objName, attributes); - for (Iterator itr = list.iterator(); itr.hasNext();) - { - Attribute attrib = (Attribute)itr.next(); - attributeModel.setAttributeValue(attrib.getName(), attrib.getValue()); - } - } - - serverRegistry.setAttributeModel(mbean, attributeModel); - return attributeModel; - } - - /** - * Updates the attribute value of an MBean - * @param mbean - * @param attribute - * @param value - * @throws Exception if MBeanServer throws exception in updating the attribute value - */ - public static void updateAttribute(ManagedBean mbean, AttributeData attribute, String value) throws Exception - { - JMXManagedObject jmxbean = (JMXManagedObject)mbean; - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - - Object newValue = value; - if (attribute.getDataType().equals(Long.class.getName())) - { - if (MAX_LONG.compareTo(new BigInteger(value)) == -1) - { - throw new ManagementConsoleException("Entered value is too big for \"" + - ViewUtility.getDisplayText(attribute.getName()) + "\""); - } - newValue = new Long(Long.parseLong(value)); - } - else if (attribute.getDataType().equals(Integer.class.getName())) - { - if (MAX_INT.compareTo(new BigInteger(value)) == -1) - { - throw new ManagementConsoleException("Entered value is too big for " + attribute.getName()); - } - newValue = new Integer(Integer.parseInt(value)); - } - - mbsc.setAttribute(jmxbean.getObjectName(), new Attribute(attribute.getName(), newValue)); - // Update the value in the registry, to avoid refreshing from mbsc - ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean); - attributeModel.setAttributeValue(attribute.getName(), newValue); - } - - /** - * populates the operation data model in server registry for given mbean - * @param mbean - * @return operation data model - */ - public static OperationDataModel getOperations(ManagedBean mbean) - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - OperationDataModel dataModel = serverRegistry.getOperationModel(mbean); - if (dataModel == null) - { - // Create operation model and set it in server registry for this mbean - MBeanOperationInfo[] operationsInfo = serverRegistry.getMBeanInfo(mbean).getOperations(); - dataModel = new OperationDataModel(); - - for (int i = 0; i < operationsInfo.length; i++) - { - dataModel.addOperation(operationsInfo[i]); - } - - serverRegistry.setOperationModel(mbean, dataModel); - } - return dataModel; - } - - /** - * populates the notification in the server registry for given mbean - * @param mbean - * @return notification info model - */ - public static NotificationInfoModel[] getNotificationInfo(ManagedBean mbean) - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean); - MBeanNotificationInfo[] info = serverRegistry.getMBeanInfo(mbean).getNotifications(); - - // Check if this mbean sends any notification - if (info == null || info.length == 0) - return null; - - // Create notification model if not already set in the server registry for this mbean - List<NotificationInfoModel> list = serverRegistry.getNotificationInfo(mbean); - if (list != null) - return list.toArray(new NotificationInfoModel[0]); - else - list = new ArrayList<NotificationInfoModel>(); - - for (int i = 0; i < info.length; i++) - { - list.add(new NotificationInfoModel(info[i].getName(), info[i].getDescription(), info[i].getNotifTypes())); - } - - // Set the notification model in the server registry for this mbean - serverRegistry.setNotificationInfo(mbean, list); - return list.toArray(new NotificationInfoModel[0]); - } - - /** - * Retrieves all the MBeans from mbean server for a given domain - * @return list of ManagedBeans - */ - public static List<ManagedBean> getManagedObjectsForDomain(ManagedServer server, String domain) throws Exception - { - List<ManagedBean> mbeans = new ArrayList<ManagedBean>(); - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - ObjectName objName = new ObjectName(domain + ":*"); - Set objectInstances = mbsc.queryMBeans(objName, null); - - for (Iterator itr = objectInstances.iterator(); itr.hasNext();) - { - ObjectInstance instance = (ObjectInstance)itr.next(); - ManagedBean obj = new JMXManagedObject(instance.getObjectName()); - mbeans.add(obj); - } - - return mbeans; - } - - /** - * Returns all the domains for the given server. This method can be removed as now this RCP is specific to - * Qpid and domain is also fixed - */ - public static List<String> getAllDomains(ManagedServer server) throws Exception - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(server); - MBeanServerConnection mbsc = serverRegistry.getServerConnection(); - String[] domains = mbsc.getDomains(); - return Arrays.asList(domains); - } - - public static void printOutput(String statement) - { - if (ApplicationRegistry.debug) - { - System.out.println(statement); - } - } - - public static void printStackTrace(Throwable ex) - { - if (ApplicationRegistry.debug) - { - ex.printStackTrace(); - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java deleted file mode 100644 index ccd4cf8df8..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -public class AttributeData -{ - String name = ""; - String description = ""; - String dataType = ""; - Object value = ""; - boolean readable = true; - boolean writable = false; - - - public String getDataType() - { - return dataType; - } - public void setDataType(String dataType) - { - this.dataType = dataType; - } - - public String getDescription() - { - return description; - } - public void setDescription(String description) - { - this.description = description; - } - - public String getName() - { - return name; - } - public void setName(String name) - { - this.name = name; - } - - public Object getValue() - { - return value; - } - public void setValue(Object value) - { - if (value != null) - this.value = value; - } - public boolean isReadable() - { - return readable; - } - public void setReadable(boolean readable) - { - this.readable = readable; - } - public boolean isWritable() - { - return writable; - } - public void setWritable(boolean writable) - { - this.writable = writable; - } - - public boolean isNumber() - { - if ("int".equals(dataType) || "java.lang.Integer".equals(dataType) || - "long".equals(dataType) || "java.lang.Long".equals(dataType) ) - { - return true; - } - else - return false; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java deleted file mode 100644 index b3219f15ea..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class ManagedAttributeModel -{ - HashMap<String, AttributeData> _attributeMap = new HashMap<String, AttributeData>(); - - public void setAttributeValue(String name, Object value) - { - if (value == null) - return; - - AttributeData data = null; - String dataType = value.getClass().getName(); - if (_attributeMap.containsKey(name)) - { - data = _attributeMap.get(name); - data.setValue(value); - } - else - { - data = new AttributeData(); - data.setName(name); - data.setValue(value); - _attributeMap.put(name, data); - } - data.setDataType(dataType); - } - - - public void setAttributeDescription(String name, String value) - { - if (_attributeMap.containsKey(name)) - { - _attributeMap.get(name).setDescription(value); - } - else - { - AttributeData data = new AttributeData(); - data.setName(name); - data.setDescription(value); - _attributeMap.put(name, data); - } - } - - public void setAttributeReadable(String name, boolean readable) - { - if (_attributeMap.containsKey(name)) - { - _attributeMap.get(name).setReadable(readable); - } - else - { - AttributeData data = new AttributeData(); - data.setName(name); - data.setReadable(readable); - _attributeMap.put(name, data); - } - } - - public void setAttributeWritable(String name, boolean writable) - { - if (_attributeMap.containsKey(name)) - { - _attributeMap.get(name).setWritable(writable); - } - else - { - AttributeData data = new AttributeData(); - data.setName(name); - data.setWritable(writable); - _attributeMap.put(name, data); - } - } - - public List<String> getAttributeNames() - { - return new ArrayList<String>(_attributeMap.keySet()); - } - - public AttributeData[] getAttributes() - { - return _attributeMap.values().toArray(new AttributeData[0]); - } - - public AttributeData getAttribute(String name) - { - return _attributeMap.get(name); - } - - public int getCount() - { - return _attributeMap.size(); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java deleted file mode 100644 index 6d4160889e..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -public class NotificationInfoModel -{ - String name; - String description; - String[] types; - - public NotificationInfoModel(String name, String desc, String[] types) - { - this.name = name; - this.description = desc; - this.types = types; - } - - public String getDescription() - { - return description; - } - - public String getName() - { - return name; - } - - public String[] getTypes() - { - return types; - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java deleted file mode 100644 index 926e5f0a24..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -import javax.management.ObjectName; - -public class NotificationObject -{ - - private long _sequenceNo; - private Date _timeStamp; - private String _message; - private Object _source; - private String _type; // INFO, WARN, etc - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss dd/MM/yy z"); - - public NotificationObject(long seqNo, Date timeStamp, String message, Object source, String type) - { - this._sequenceNo = seqNo; - this._message = message; - this._source = source; - this._type = type; - this._timeStamp = timeStamp; - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - public Object getSource() - { - return _source; - } - public void setSource(Object _source) - { - this._source = _source; - } - - public String getSourceName() - { - if (_source instanceof ObjectName) - { - return ((ObjectName)_source).getKeyProperty("name"); - } - - return null; - } - - public String getMessage() - { - return _message; - } - public void setMessage(String _message) - { - this._message = _message; - } - public long getSequenceNo() - { - return _sequenceNo; - } - public void setSequenceNo(long no) - { - _sequenceNo = no; - } - public String getTimeStamp() - { - return dateFormat.format(_timeStamp); - } - public void setTimeStamp(Date stamp) - { - _timeStamp = stamp; - } - public String getType() - { - return _type; - } - public void setType(String _type) - { - this._type = _type; - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java deleted file mode 100644 index bf3b730b3e..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -import java.util.List; - -public class OperationData -{ - private String _name; - private String _description; - private String _returnType; - private int _impact; - private List<ParameterData> _parameters; - - public OperationData(String value) - { - this._name = value; - } - - public String getName() - { - return _name; - } - - public String getDescription() - { - return _description; - } - - public void setDescription(String description) - { - this._description = description; - } - - public List<ParameterData> getParameters() - { - return _parameters; - } - - public void setParameters(List<ParameterData> parameters) - { - this._parameters = parameters; - } - - public int getImpact() - { - return _impact; - } - - public void setImpact(int impact) - { - this._impact = impact; - } - - public String getReturnType() - { - return _returnType; - } - - public void setReturnType(String returnType) - { - this._returnType = returnType; - } - - public boolean isReturnTypeBoolean() - { - return (_returnType.equals("boolean") || _returnType.equals("java.lang.Boolean")); - } - - public boolean isReturnTypeVoid() - { - return (_returnType.equals("void") || _returnType.equals("java.lang.Void")); - } - - public Object getParameterValue(String paramName) - { - if (_parameters == null) - { - return null; - } - - for (int i = 0; i < _parameters.size(); i++) - { - if (paramName.equalsIgnoreCase(_parameters.get(i).getName())) - { - return _parameters.get(i).getValue(); - } - } - - return null; - } -}
\ No newline at end of file diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java deleted file mode 100644 index 96964a81ef..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.management.MBeanOperationInfo; -import javax.management.MBeanParameterInfo; - -public class OperationDataModel -{ - HashMap<String, OperationData> _operationMap = new HashMap<String, OperationData>(); - - public void addOperation(MBeanOperationInfo opInfo) - { - OperationData opData = new OperationData(opInfo.getName()); - opData.setDescription(opInfo.getDescription()); - opData.setImpact(opInfo.getImpact()); - opData.setReturnType(opInfo.getReturnType()); - - int parametersCount = opInfo.getSignature().length; - if (parametersCount != 0) - { - List<ParameterData> paramList = new ArrayList<ParameterData>(); - for (int i = 0; i < parametersCount; i++) - { - MBeanParameterInfo paramInfo = opInfo.getSignature()[i]; - ParameterData param = new ParameterData(paramInfo.getName(), paramInfo.getDescription(), - paramInfo.getType()); - paramList.add(param); - } - opData.setParameters(paramList); - } - - _operationMap.put(opInfo.getName(), opData); - } - - public OperationData getOperation(String name) - { - return _operationMap.get(name); - } - - public List<OperationData> getOperations() - { - return new ArrayList<OperationData>(_operationMap.values()); - } - - public int getCount() - { - return _operationMap.size(); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java deleted file mode 100644 index d12217c6eb..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.model; - -/** - * Class representing an mbean operation parameter - * @author Bhupendra Bhardwaj - */ -public class ParameterData -{ - private String _name; - private String _description; - private String _type; - private Object _value; - - ParameterData(String name, String desc, String type) - { - this._name = name; - this._description = desc; - this._type = type; - setDefaultValue(); - } - - public String getDescription() - { - return _description; - } - - public String getName() - { - return _name; - } - - public String getType() - { - return _type; - } - - public Object getValue() - { - return _value; - } - - public void setValueFromString(String strValue) - { - if ("int".equals(_type)) - _value = Integer.parseInt(strValue); - else if (isBoolean()) - _value = Boolean.valueOf(strValue); - else if ("long".equals(_type)) - _value = Long.parseLong(strValue); - else - _value = strValue; - } - - public void setValue(Object value) - { - this._value = value; - } - - public boolean isBoolean() - { - return (_type.equals("boolean") || _type.equals("java.lang.Boolean")); - } - - public void setDefaultValue() - { - if (isBoolean()) - { - _value = Boolean.valueOf("false"); - } - else - { - _value = null; - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java deleted file mode 100644 index 32a0c12344..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/CRAMMD5HashedSaslClientFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.util.Map; - -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.Sasl; -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslClientFactory; -import javax.security.sasl.SaslException; - -public class CRAMMD5HashedSaslClientFactory implements SaslClientFactory -{ - /** The name of this mechanism */ - public static final String MECHANISM = "CRAM-MD5-HASHED"; - - public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol, - String serverName, Map<String, ?> props, CallbackHandler cbh) - throws SaslException - { - for (int i = 0; i < mechanisms.length; i++) - { - if (mechanisms[i].equals(MECHANISM)) - { - if (cbh == null) - { - throw new SaslException("CallbackHandler must not be null"); - } - - String[] mechs = {"CRAM-MD5"}; - return Sasl.createSaslClient(mechs, authorizationId, protocol, serverName, props, cbh); - } - } - return null; - } - - public String[] getMechanismNames(Map props) - { - return new String[]{MECHANISM}; - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java deleted file mode 100644 index ce9a273eaa..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/ClientSaslFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.util.Map; - -import javax.security.auth.callback.CallbackHandler; -import javax.security.sasl.SaslClient; -import javax.security.sasl.SaslClientFactory; -import javax.security.sasl.SaslException; - -public class ClientSaslFactory implements SaslClientFactory -{ - public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol, - String serverName, Map props, CallbackHandler cbh) - throws SaslException - { - for (int i = 0; i < mechs.length; i++) - { - if (mechs[i].equals("PLAIN")) - { - return new PlainSaslClient(authorizationId, cbh); - } - } - return null; - } - - /** - * Simple-minded implementation that ignores props - */ - public String[] getMechanismNames(Map props) - { - return new String[]{"PLAIN"}; - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java deleted file mode 100644 index d8189f3ac3..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/JCAProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.security.Provider; -import java.util.Map; - -import javax.security.sasl.SaslClientFactory; - -public class JCAProvider extends Provider -{ - private static final long serialVersionUID = 1L; - - /** - * Creates the security provider with a map from SASL mechanisms to implementing factories. - * - * @param providerMap The map from SASL mechanims to implementing factory classes. - */ - public JCAProvider(Map<String, Class<? extends SaslClientFactory>> providerMap) - { - super("AMQSASLProvider", 1.0, "A JCA provider that registers all " - + "AMQ SASL providers that want to be registered"); - register(providerMap); - } - - /** - * Registers client factory classes for a map of mechanism names to client factory classes. - * - * @param providerMap The map from SASL mechanims to implementing factory classes. - */ - private void register(Map<String, Class<? extends SaslClientFactory>> providerMap) - { - for (Map.Entry<String, Class<? extends SaslClientFactory>> me : providerMap.entrySet()) - { - put("SaslClientFactory." + me.getKey(), me.getValue().getName()); - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java deleted file mode 100644 index 22190f29eb..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/PlainSaslClient.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.io.*; -import javax.security.auth.callback.*; -import javax.security.sasl.*; - -public class PlainSaslClient implements SaslClient -{ - - private boolean completed; - private CallbackHandler cbh; - private String authorizationID; - private String authenticationID; - private byte password[]; - private static byte SEPARATOR = 0; - - public PlainSaslClient(String authorizationID, CallbackHandler cbh) throws SaslException - { - completed = false; - this.cbh = cbh; - Object[] userInfo = getUserInfo(); - this.authorizationID = authorizationID; - this.authenticationID = (String) userInfo[0]; - this.password = (byte[]) userInfo[1]; - if (authenticationID == null || password == null) - { - throw new SaslException("PLAIN: authenticationID and password must be specified"); - } - } - - public byte[] evaluateChallenge(byte[] challenge) throws SaslException - { - if (completed) - { - throw new IllegalStateException("PLAIN: authentication already " + - "completed"); - } - completed = true; - try - { - byte authzid[] = - authorizationID == null ? null : authorizationID.getBytes("UTF8"); - byte authnid[] = authenticationID.getBytes("UTF8"); - byte response[] = - new byte[ - password.length + - authnid.length + - 2 + // SEPARATOR - (authzid != null ? authzid.length : 0) - ]; - int size = 0; - if (authzid != null) { - System.arraycopy(authzid, 0, response, 0, authzid.length); - size = authzid.length; - } - response[size++] = SEPARATOR; - System.arraycopy(authnid, 0, response, size, authnid.length); - size += authnid.length; - response[size++] = SEPARATOR; - System.arraycopy(password, 0, response, size, password.length); - clearPassword(); - return response; - } catch (UnsupportedEncodingException e) { - throw new SaslException("PLAIN: Cannot get UTF-8 encoding of ids", - e); - } - } - - public String getMechanismName() - { - return "PLAIN"; - } - - public boolean hasInitialResponse() - { - return true; - } - - public boolean isComplete() - { - return completed; - } - - public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException - { - if (completed) { - throw new IllegalStateException("PLAIN: this mechanism supports " + - "neither integrity nor privacy"); - } else { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException - { - if (completed) - { - throw new IllegalStateException("PLAIN: this mechanism supports " + - "neither integrity nor privacy"); - } - else - { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - public Object getNegotiatedProperty(String propName) - { - if (completed) - { - if (propName.equals(Sasl.QOP)) - { - return "auth"; - } - else - { - return null; - } - } - else - { - throw new IllegalStateException("PLAIN: authentication not " + - "completed"); - } - } - - private void clearPassword() - { - if (password != null) - { - for (int i = 0 ; i < password.length ; i++) - { - password[i] = 0; - } - password = null; - } - } - - public void dispose() throws SaslException - { - clearPassword(); - } - - protected void finalize() - { - clearPassword(); - } - - private Object[] getUserInfo() throws SaslException - { - try - { - final String userPrompt = "PLAIN authentication id: "; - final String pwPrompt = "PLAIN password: "; - NameCallback nameCb = new NameCallback(userPrompt); - PasswordCallback passwordCb = new PasswordCallback(pwPrompt, false); - cbh.handle(new Callback[] { nameCb, passwordCb }); - String userid = nameCb.getName(); - char pwchars[] = passwordCb.getPassword(); - byte pwbytes[]; - if (pwchars != null) - { - pwbytes = (new String(pwchars)).getBytes("UTF8"); - passwordCb.clearPassword(); - } - else - { - pwbytes = null; - } - return (new Object[] { userid, pwbytes }); - } - catch (IOException e) - { - throw new SaslException("Cannot get password", e); - } - catch (UnsupportedCallbackException e) - { - throw new SaslException("Cannot get userid/password", e); - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java deleted file mode 100644 index 2917de8740..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/SaslProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.security.Provider; - -public class SaslProvider extends Provider -{ - private static final long serialVersionUID = -6978096016899676466L; - - public SaslProvider() - { - super("SaslClientFactory", 1.0, "SASL PLAIN CLIENT MECHANISM"); - put("SaslClientFactory.PLAIN", "ClientSaslFactory"); - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java deleted file mode 100644 index 1602229c85..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UserPasswordCallbackHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.io.*; -import javax.security.auth.callback.*; - -public class UserPasswordCallbackHandler implements CallbackHandler -{ - private String user; - private char[] pwchars; - - public UserPasswordCallbackHandler(String user, String password) - { - this.user = user; - this.pwchars = password.toCharArray(); - } - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException - { - for (int i = 0; i < callbacks.length; i++) - { - if (callbacks[i] instanceof NameCallback) - { - NameCallback ncb = (NameCallback) callbacks[i]; - ncb.setName(user); - } - else if (callbacks[i] instanceof PasswordCallback) - { - PasswordCallback pcb = (PasswordCallback) callbacks[i]; - pcb.setPassword(pwchars); - } - else - { - throw new UnsupportedCallbackException(callbacks[i]); - } - } - } - - private void clearPassword() - { - if (pwchars != null) - { - for (int i = 0 ; i < pwchars.length ; i++) - { - pwchars[i] = 0; - } - pwchars = null; - } - } - - protected void finalize() - { - clearPassword(); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java deleted file mode 100644 index f4e3d2661e..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/sasl/UsernameHashedPasswordCallbackHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.sasl; - -import java.io.IOException; - -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - -import org.apache.qpid.management.ui.views.ViewUtility; - -public class UsernameHashedPasswordCallbackHandler implements CallbackHandler -{ - private String user; - private char[] pwchars; - - public UsernameHashedPasswordCallbackHandler(String user, String password) throws Exception - { - this.user = user; - this.pwchars = ViewUtility.getHash(password); - } - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException - { - for (int i = 0; i < callbacks.length; i++) - { - if (callbacks[i] instanceof NameCallback) - { - NameCallback ncb = (NameCallback) callbacks[i]; - ncb.setName(user); - } - else if (callbacks[i] instanceof PasswordCallback) - { - PasswordCallback pcb = (PasswordCallback) callbacks[i]; - pcb.setPassword(pwchars); - } - else - { - throw new UnsupportedCallbackException(callbacks[i]); - } - } - } - - - private void clearPassword() - { - if (pwchars != null) - { - for (int i = 0 ; i < pwchars.length ; i++) - { - pwchars[i] = 0; - } - pwchars = null; - } - } - - protected void finalize() - { - clearPassword(); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java deleted file mode 100644 index 3234503fb5..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java +++ /dev/null @@ -1,936 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import static org.apache.qpid.management.ui.Constants.*; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.jmx.JMXServerRegistry; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.AttributeData; -import org.apache.qpid.management.ui.model.ManagedAttributeModel; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IFontProvider; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.Form; -import org.eclipse.ui.forms.widgets.FormToolkit; - - -/** - * Creates controller composite for the attribute's tab. - * @author Bhupendra Bhardwaj - */ -public class AttributesTabControl extends TabControl -{ - private FormToolkit _toolkit; - private Form _form; - private Table _table = null; - private TableViewer _tableViewer = null; - private static final int[] tableWidths = new int[] {300, 300}; - - private Composite _tableComposite = null; - private Composite _buttonsComposite = null; - - private DisposeListener tableDisposeListener = new DisposeListenerImpl(); - final Image image; - private Button _detailsButton = null; - private Button _editButton = null; - private Button _graphButton = null; - private Button _refreshButton = null; - private boolean disableEditing = false; - - private static final String MAX_VALUE = "MaxValue"; - private static final String GRAPH_VALUES = "GraphValues"; - private int GRAPH_WIDTH = 700; - private int GRAPH_HEIGHT = 450; - private int GRAPH_ITEM_GAP = 100; - private int startX = 80; - private int startY = 60; - - public AttributesTabControl(TabFolder tabFolder) - { - super(tabFolder); - _toolkit = new FormToolkit(_tabFolder.getDisplay()); - _form = _toolkit.createForm(_tabFolder); - GridLayout gridLayout = new GridLayout(2, false); - gridLayout.marginWidth = 0; - gridLayout.marginHeight = 0; - _form.getBody().setLayout(gridLayout); - _tableComposite = _toolkit.createComposite(_form.getBody()); - _tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - _tableComposite.setLayout(new GridLayout()); - _buttonsComposite = _toolkit.createComposite(_form.getBody()); - _buttonsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); - _buttonsComposite.setLayout(new GridLayout()); - - image = Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION); - createWidgets(); - } - - /** - * @see TabControl#getControl() - */ - public Control getControl() - { - return _form; - } - - /** - * Creates required widgets for Attribute's tab - */ - protected void createWidgets() - { - createTable(); - createTableViewer(); - createButtons(); - addTableListeners(); - } - - /** - * Creates table for listing the MBean attributes - */ - private void createTable() - { - _table = _toolkit.createTable(_tableComposite, SWT.FULL_SELECTION); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - _table.setLayoutData(gridData); - - for (int i = 0; i < ATTRIBUTE_TABLE_TITLES.length; ++i) - { - final TableColumn column = new TableColumn(_table, SWT.NONE); - column.setText(ATTRIBUTE_TABLE_TITLES[i]); - column.setWidth(tableWidths[i]); - column.setResizable(false); - } - - _table.setLinesVisible (true); - _table.setHeaderVisible (true); - } - - /** - * Creates tableviewer for the attribute's table - */ - private void createTableViewer() - { - _tableViewer = new TableViewer(_table); - _tableViewer.setUseHashlookup(true); - _tableViewer.setColumnProperties(ATTRIBUTE_TABLE_TITLES); - _tableViewer.setContentProvider(new ContentProviderImpl()); - _tableViewer.setLabelProvider(new LabelProviderImpl()); - _tableViewer.setSorter(new ViewerSorterImpl()); - } - - private void createButtons() - { - addDetailsButton(); - addEditButton(); - addGraphButton(); - addRefreshButton(); - } - - private void addDetailsButton() - { - // Create and configure the button for attribute details - _detailsButton = _toolkit.createButton(_buttonsComposite, BUTTON_DETAILS, SWT.PUSH | SWT.CENTER); - _detailsButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); - gridData.widthHint = 80; - _detailsButton.setLayoutData(gridData); - _detailsButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - disableEditing = true; - int index = _table.getSelectionIndex(); - TableItem item = _table.getItem(index); - createDetailsPopup((AttributeData)item.getData()); - disableEditing = false; - setFocus(); - } - }); - } - - /** - * Creates the button for editing attributes. - */ - private void addEditButton() - { - // Create and configure the button for editing attribute - _editButton = _toolkit.createButton(_buttonsComposite, BUTTON_EDIT_ATTRIBUTE, SWT.PUSH | SWT.CENTER); - _editButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); - gridData.widthHint = 80; - _editButton.setLayoutData(gridData); - _editButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - int index = _table.getSelectionIndex(); - TableItem item = _table.getItem(index); - createDetailsPopup((AttributeData)item.getData()); - setFocus(); - } - }); - } - - /** - * Creates the button for viewing Graphs - */ - private void addGraphButton() - { - _graphButton = _toolkit.createButton(_buttonsComposite, BUTTON_GRAPH, SWT.PUSH | SWT.CENTER); - _graphButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); - gridData.widthHint = 80; - _graphButton.setLayoutData(gridData); - _graphButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent event) - { - int selectionIndex = _table.getSelectionIndex(); - AttributeData data = (AttributeData)_table.getItem(selectionIndex).getData(); - createGraph(data); - setFocus(); - } - }); - } - - /** - * Creates the "Refresh" button - */ - private void addRefreshButton() - { - _refreshButton = _toolkit.createButton(_buttonsComposite, BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); - - _refreshButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); - gridData.widthHint = 80; - _refreshButton.setLayoutData(gridData); - _refreshButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - try - { - // refresh the attributes list - refresh(_mbean); - } - catch (Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - } - - } - }); - } - - private void addTableListeners() - { - _tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){ - public void selectionChanged(SelectionChangedEvent evt) - { - IStructuredSelection ss = (IStructuredSelection)evt.getSelection(); - checkForEnablingButtons((AttributeData)ss.getFirstElement()); - } - }); - - MouseListenerImpl listener = new MouseListenerImpl(); - _tableViewer.getTable().addMouseTrackListener(listener); - _tableViewer.getTable().addMouseMoveListener(listener); - _tableViewer.getTable().addMouseListener(listener); - - _table.addDisposeListener(tableDisposeListener); - - // _table is equal to _tableViewer.getControl() - _table.addListener(SWT.MeasureItem, new Listener() { - public void handleEvent(Event event) - { - event.height = event.gc.getFontMetrics().getHeight() * 3/2; - } - }); - } - - /** - * Listeners implementation class for showing table tooltip - * @author Bhupendra Bhardwaj - */ - private class MouseListenerImpl implements MouseTrackListener, MouseMoveListener, KeyListener, MouseListener - { - Shell tooltipShell = null; - Label tooltipLabel = null; - public void mouseHover(MouseEvent event) - { - TableItem item = _table.getItem (new Point (event.x, event.y)); - - if (item != null) - { - AttributeData data = (AttributeData)item.getData(); - if (tooltipShell != null && !tooltipShell.isDisposed ()) tooltipShell.dispose (); - tooltipShell = new Shell(_table.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - tooltipShell.setBackground(event.display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - FillLayout layout = new FillLayout(); - layout.marginWidth = 2; - tooltipShell.setLayout(layout); - tooltipLabel = new Label(tooltipShell, SWT.NONE); - tooltipLabel.setForeground(event.display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - tooltipLabel.setBackground(event.display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - tooltipLabel.setText(data.getDescription()); - tooltipLabel.setData("_TABLEITEM", item); - tooltipLabel.addListener(SWT.MouseExit, tooltipLabelListener); - tooltipLabel.addListener(SWT.MouseDown, tooltipLabelListener); - Point size = tooltipShell.computeSize(SWT.DEFAULT, SWT.DEFAULT); - Rectangle rect = item.getBounds(0); - Point pt = _table.toDisplay(rect.x, rect.y); - tooltipShell.setBounds(pt.x, pt.y, size.x, size.y); - tooltipShell.setVisible(true); - } - } - public void mouseEnter(MouseEvent e) - { - } - public void mouseExit(MouseEvent e) - { - } - - // MouseMoveListener implementation - public void mouseMove(MouseEvent event) - { - if (tooltipShell == null) - return; - - tooltipShell.dispose(); - tooltipShell = null; - tooltipLabel = null; - } - - // KeyListener implementation - public void keyPressed(KeyEvent e) - { - if (tooltipShell == null) - return; - - tooltipShell.dispose(); - tooltipShell = null; - tooltipLabel = null; - } - public void keyReleased(KeyEvent e) - { - - } - - // MouseListener implementation - public void mouseDoubleClick(MouseEvent event) - { - if (tooltipShell != null) - { - tooltipShell.dispose(); - tooltipShell = null; - tooltipLabel = null; - } - Table table = (Table)event.getSource(); - int selectionIndex = table.getSelectionIndex(); - AttributeData data = (AttributeData)table.getItem(selectionIndex).getData(); - createDetailsPopup(data); - } - public void mouseDown(MouseEvent e) - { - if (tooltipShell != null) - { - tooltipShell.dispose(); - tooltipShell = null; - tooltipLabel = null; - } - } - public void mouseUp(MouseEvent e) - { - - } - } // end of MouseListenerImpl - - /** - * Creates pop-up window for showing attribute details - * @param data - Selectes attribute - */ - public void createDetailsPopup(AttributeData data) - { - int width = 500; - int height = 250; - if (!isSimpleType(data.getValue())) - { - width = 650; - height = 450; - } - - Display display = Display.getCurrent(); - Shell shell = ViewUtility.createPopupShell(ATTRIBUTE, width, height); - createDetailsPopupContents(shell, data); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - shell.dispose(); - } - - /** - * Listener class for table tooltip label - */ - final Listener tooltipLabelListener = new Listener () - { - public void handleEvent (Event event) - { - Label label = (Label)event.widget; - Shell shell = label.getShell(); - switch (event.type) - { - case SWT.MouseDown: - Event e = new Event(); - e.item = (TableItem)label.getData ("_TABLEITEM"); - _table.setSelection(new TableItem[] {(TableItem)e.item}); - shell.dispose(); - _table.setFocus(); - break; - case SWT.MouseExit: - shell.dispose(); - break; - } - } - }; - - - /** - * Create the contents for the attribute details window pop-up - * @param shell - The shell that will be filled with details. - * @param attribute - Selected attribute - */ - private void createDetailsPopupContents(Composite shell, AttributeData attribute) - { - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 10; - layout.verticalSpacing = 10; - layout.marginHeight = 20; - layout.marginWidth = 20; - - Composite parent = _toolkit.createComposite(shell, SWT.NONE); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - parent.setLayout(layout); - - // Name - Label label = _toolkit.createLabel(parent, ATTRIBUTE_TABLE_TITLES[0], SWT.NONE); - GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false); - label.setLayoutData(layoutData); - int textStyle = SWT.BEGINNING | SWT.BORDER |SWT.READ_ONLY; - Text value = _toolkit.createText(parent, ViewUtility.getDisplayText(attribute.getName()), textStyle); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - - // Description - label = _toolkit.createLabel(parent, DESCRIPTION, SWT.NONE); - label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - value = _toolkit.createText(parent, attribute.getDescription(), textStyle); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - // value - label = _toolkit.createLabel(parent, ATTRIBUTE_TABLE_TITLES[1], SWT.NONE); - label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - if (!attribute.isReadable()) - { - value = _toolkit.createText(parent, "", textStyle); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - } - else - { - if (!isSimpleType(attribute.getValue())) - { - Composite composite = new Composite(parent, SWT.BORDER); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - ViewUtility.populateCompositeWithData(_toolkit, composite, attribute.getValue()); - } - else - { - if (attribute.isWritable()) - { - value = _toolkit.createText(parent, "", SWT.BEGINNING | SWT.BORDER); - value.addVerifyListener(new NumberVerifyListener()); - - // set data to access in the listener - parent.setData(attribute); - } - else - { - value = _toolkit.createText(parent, "", textStyle); - } - - value.setText(attribute.getValue().toString()); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - } - } - - - // Update button - Button updateButton = addUpdateButton(parent); - updateButton.setData(value); - if (!attribute.isWritable()) - { - updateButton.setVisible(false); - } - - if (disableEditing) - { - value.setEditable(false); - updateButton.setVisible(false); - } - } - - /** - * Create the button for updating attributes. This should be enabled for writable attribute - */ - private Button addUpdateButton(Composite parent) - { - final Button updateButton = new Button(parent, SWT.PUSH | SWT.CENTER); - // set the data to access in the listener - parent.setData(BUTTON_UPDATE, updateButton); - - updateButton.setText(BUTTON_UPDATE); - GridData gridData = new GridData (SWT.CENTER, SWT.BOTTOM, true, true, 2, 1); - gridData.widthHint = 100; - updateButton.setLayoutData(gridData); - updateButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent event) - { - try - { - Button button = (Button)event.widget; - Text text = (Text)button.getData(); - AttributeData data = (AttributeData)button.getParent().getData(); - MBeanUtility.updateAttribute(_mbean, data, text.getText()); - button.getShell().close(); - refresh(); - } - catch (Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - } - } - }); - - return updateButton; - } - - // Refresh from the server registry - public void refresh() - { - JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(_mbean); - ManagedAttributeModel attributesList = serverRegistry.getAttributeModel(_mbean); - _tableViewer.setInput(attributesList); - } - - /** - * Refreshes the attribute tab by querying the mbean server for latest values - */ - @Override - public void refresh(ManagedBean mbean) - { - _mbean = mbean; - if (_mbean == null) - { - _tableViewer.setInput(null); - return; - } - ManagedAttributeModel attributesList = null; - try - { - attributesList = MBeanUtility.getAttributes(mbean); - } - catch(Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - } - _tableViewer.setInput(attributesList); - checkForEnablingButtons(getSelectionAttribute()); - - _form.layout(true); - _form.getBody().layout(true, true); - } - - /** - * @see TabControl#setFocus() - */ - public void setFocus() - { - _table.setFocus(); - } - - /** - * Checks which buttons are to be enabled or disabled. The graph button will be enabled only - * for readable number attributes. Editing is enabled for writeable attribtues. - * @param attribute - */ - private void checkForEnablingButtons(AttributeData attribute) - { - if (attribute == null) - { - _detailsButton.setEnabled(false); - _editButton.setEnabled(false); - _graphButton.setEnabled(false); - _refreshButton.setEnabled(false); - return; - } - - _detailsButton.setEnabled(true); - _refreshButton.setEnabled(true); - if (attribute.isWritable()) - { - _editButton.setEnabled(true); - _graphButton.setEnabled(false); - } - else - { - _editButton.setEnabled(false); - // Currently only Queues are having attributes, which are suitable for a graph - if (attribute.isNumber() && _mbean.isQueue()) - { - _graphButton.setEnabled(true); - } - else - { - _graphButton.setEnabled(false); - } - } - } - - /** - * Creates graph in a pop-up window for given attribute. - * @param data - */ - private void createGraph(final AttributeData data) - { - Display display = Display.getCurrent(); - Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX); - shell.setText(_mbean.getName()); - int x = display.getBounds().width; - int y = display.getBounds().height; - shell.setBounds(x/4, y/4, GRAPH_WIDTH, GRAPH_HEIGHT); - shell.setLayout(new FillLayout()); - - final Canvas canvas = new Canvas(shell, SWT.NONE); - long currentValue = Long.parseLong(data.getValue().toString()); - long mValue = getGraphMaxValue(currentValue); - canvas.setData(MAX_VALUE, mValue); - canvas.setData(GRAPH_VALUES, new long[] {0,0,0,0,0,currentValue}); - - canvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); - canvas.addPaintListener(new PaintListener() - { - public void paintControl(PaintEvent event) - { - Canvas canvas = (Canvas)event.widget; - int maxX = canvas.getSize().x; - int maxY = canvas.getSize().y; - event.gc.fillRectangle(canvas.getBounds()); - event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - event.gc.setLineWidth(4); - - Object canvasData = canvas.getData(MAX_VALUE); - String str = canvasData.toString(); - long maxValue = Long.parseLong(str); - // Set the graph dimensions - event.gc.drawText("0", startX - 40, maxY - startY - 10); - event.gc.drawText("" + maxValue/2, startX - 40, maxY/2); - event.gc.drawText("" + maxValue, startX - 40, startY); - - // horizontal line - event.gc.drawLine(startX, maxY - startY, maxX - 60, maxY - startY); - // vertical line - event.gc.drawLine(startX, maxY - startY, startX, startY); - // set graph text - event.gc.drawText(data.getName(), startX - 40, startY - 40); - event.gc.drawText("25 sec", startX, maxY - startY + 10); - event.gc.drawText("20 sec", startX + GRAPH_ITEM_GAP, maxY - startY + 10); - event.gc.drawText("15 sec", startX + GRAPH_ITEM_GAP * 2, maxY - startY + 10); - event.gc.drawText("10 sec", startX + GRAPH_ITEM_GAP * 3, maxY - startY + 10); - event.gc.drawText(" 5 sec", startX + GRAPH_ITEM_GAP * 4, maxY - startY + 10); - event.gc.drawText(" 0 sec", startX + GRAPH_ITEM_GAP * 5, maxY - startY + 10); - - // plot the graph now for values - event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)); - canvasData = canvas.getData(GRAPH_VALUES); - long[] graphValues = (long[]) canvasData; - for (int i = 0; i < graphValues.length; i++) - { - int x = startX + i * GRAPH_ITEM_GAP; - int yTotalLength = (maxY - 2 * startY); - float ratio = ((float)graphValues[i]/(float)maxValue); - int itemlength = (int)(yTotalLength * ratio); - int y = maxY - startY - itemlength; - event.gc.drawLine(x, maxY- startY, x, y); - event.gc.drawText(String.valueOf(graphValues[i]), x, y - 20); - } - } - }); - - shell.open(); - - // Set up the timer for the animation - Runnable runnable = new Runnable() - { - public void run() - { - try - { - animate(canvas, data); - Display.getCurrent().timerExec(TIMER_INTERVAL, this); - } - catch(Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }; - - // Launch the timer - display.timerExec(TIMER_INTERVAL, runnable); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - // Kill the timer - display.timerExec(-1, runnable); - shell.dispose(); - } - - /** - * @return selected attribute in the table - */ - public AttributeData getSelectionAttribute() - { - int index = _table.getSelectionIndex(); - if (index == -1) - return null; - - return (AttributeData)_table.getItem(index).getData(); - } - - /** - * checks for newer values of selected attribute to update the graph - * @param canvas - * @param data - * @throws Exception - */ - private void animate(Canvas canvas, AttributeData data) throws Exception - { - String attribute = data.getName(); - Object valueObj = MBeanUtility.refreshAttribute(_mbean, attribute); - int value = Integer.parseInt(String.valueOf(valueObj)); - Object canvasData = canvas.getData(GRAPH_VALUES); - long[] graphValues = (long[]) canvasData; - - for (int i = 0; i < graphValues.length -1; i++) - { - graphValues[i] = graphValues[i + 1]; - } - graphValues[graphValues.length - 1] = value; - - canvasData = canvas.getData(MAX_VALUE); - long maxValue = Long.parseLong(String.valueOf(canvasData)); - if (maxValue < value) - { - maxValue = getGraphMaxValue(value); - canvas.setData(MAX_VALUE, maxValue); - } - - canvas.redraw(); - } - - /** - * @param maxAttributeValue - * @return dynamically calculated value for y-axis on the graph - */ - private long getGraphMaxValue(long maxAttributeValue) - { - long maxGraphValue = 100; - long temp = maxAttributeValue * 3/2; - if (temp > maxGraphValue) - { - long modulus = temp % 100; - maxGraphValue = temp + ( 100 - modulus); - } - - return maxGraphValue; - } - - /** - * Content Provider class for the table viewer - * @author Bhupendra Bhardwaj - */ - private class ContentProviderImpl implements IStructuredContentProvider - { - - public void inputChanged(Viewer v, Object oldInput, Object newInput) - { - - } - - public void dispose() - { - - } - - public Object[] getElements(Object parent) - { - return ((ManagedAttributeModel)parent).getAttributes(); - } - } - - /** - * Label Provider class for the table viewer - * @author Bhupendra Bhardwaj - */ - private class LabelProviderImpl extends LabelProvider implements ITableLabelProvider, - IFontProvider, - IColorProvider - { - AttributeData attribute = null; - public String getColumnText(Object element, int columnIndex) - { - String result = ""; - attribute = (AttributeData) element; - - switch (columnIndex) - { - case 0 : // attribute name column - result = ViewUtility.getDisplayText(attribute.getName()); - break; - case 1 : // attribute value column - if (attribute.getValue() != null) - result = String.valueOf(attribute.getValue()); - break; - default : - result = ""; - } - - return result; - } - - public Image getColumnImage(Object element, int columnIndex) - { - return null; - } - - public Font getFont(Object element) - { - return ApplicationRegistry.getFont(FONT_TABLE_CELL); - } - - public Color getForeground(Object element) - { - attribute = (AttributeData) element; - if (attribute.isWritable()) - return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE); - else - return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); - } - public Color getBackground(Object element) - { - return _form.getBackground(); - } - } - - private class DisposeListenerImpl implements DisposeListener - { - public void widgetDisposed(DisposeEvent e) - { - - } - } - - /** - * Sorter class for the table viewer. It sorts the table for according to attribute name. - * @author Bhupendra Bhardwaj - * - */ - private class ViewerSorterImpl extends ViewerSorter - { - public int compare(Viewer viewer, Object o1, Object o2) - { - AttributeData attribtue1 = (AttributeData)o1; - AttributeData attribtue2 = (AttributeData)o2; - - return collator.compare(attribtue1.getName(), attribtue2.getName()); - } - } -}
\ No newline at end of file diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java deleted file mode 100644 index d891a45210..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ConnectionTypeTabControl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.views; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ServerRegistry; -import org.eclipse.swt.widgets.TabFolder; - -/** - * Controller class, which takes care of displaying appropriate information and widgets for Connections. - * This allows user to select Connections and add those to the navigation view - */ -public class ConnectionTypeTabControl extends MBeanTypeTabControl -{ - - public ConnectionTypeTabControl(TabFolder tabFolder) - { - super(tabFolder, Constants.CONNECTION); - createWidgets(); - } - - protected void createWidgets() - { - createHeaderComposite(getFormComposite()); - createButtonsComposite(getFormComposite()); - createListComposite(getFormComposite()); - } - - protected void populateList() throws Exception - { - // map should be cleared before populating it with new values - getMBeansMap().clear(); - - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - java.util.List<ManagedBean> list = serverRegistry.getConnections(MBeanView.getVirtualHost()); - getListWidget().setItems(getItems(list)); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java deleted file mode 100644 index ee55b251ee..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ExchangeTypeTabControl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.views; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ServerRegistry; -import org.eclipse.swt.widgets.TabFolder; - -/** - * Controller class, which takes care of displaying appropriate information and widgets for Exchanges. - * This allows user to select Exchanges and add those to the navigation view - * @author Bhupendra Bhardwaj - */ -public class ExchangeTypeTabControl extends MBeanTypeTabControl -{ - - public ExchangeTypeTabControl(TabFolder tabFolder) - { - super(tabFolder, Constants.EXCHANGE); - createWidgets(); - } - - protected void createWidgets() - { - createHeaderComposite(getFormComposite()); - createButtonsComposite(getFormComposite()); - createListComposite(getFormComposite()); - } - - protected void populateList() throws Exception - { - // map should be cleared before populating it with new values - getMBeansMap().clear(); - - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - java.util.List<ManagedBean> list = serverRegistry.getExchanges(MBeanView.getVirtualHost()); - getListWidget().setItems(getItems(list)); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/INotificationViewer.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/INotificationViewer.java deleted file mode 100644 index bc560b6064..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/INotificationViewer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import java.util.List; - -import org.apache.qpid.management.ui.model.NotificationObject; - -public interface INotificationViewer -{ - public void addNotification(NotificationObject notification); - - public void addNotification(List<NotificationObject> notificationList); -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java deleted file mode 100644 index 24dfb519fd..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.views; - -import static org.apache.qpid.management.ui.Constants.BUTTON_REFRESH; -import static org.apache.qpid.management.ui.Constants.FONT_BOLD; -import static org.apache.qpid.management.ui.Constants.FONT_ITALIC; -import static org.apache.qpid.management.ui.Constants.FONT_NORMAL; - -import java.util.Collections; -import java.util.HashMap; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.AttributeData; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.Form; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * Abstract class to be extended by the Controller classes for different MBean types (Connection, Queue, Exchange) - */ -public abstract class MBeanTypeTabControl -{ - private FormToolkit _toolkit = null; - private Form _form = null; - private TabFolder _tabFolder = null; - private Composite _composite = null; - private Composite _headerComposite = null; - private Composite _listComposite = null; - private Label _labelName = null; - private Label _labelDesc = null; - private Label _labelList = null; - - private org.eclipse.swt.widgets.List _list = null; - private Button _refreshButton = null; - private Button _addButton = null; - - private String _type = null; - - // maps an mbean name with the mbean object. Required to get mbean object when an mbean - // is to be added to the navigation view. - private HashMap<String, ManagedBean> _objectsMap = new HashMap<String, ManagedBean>(); - private Sorter _sorterByName = new Sorter(); - - public MBeanTypeTabControl(TabFolder tabFolder, String type) - { - _type = type; - _tabFolder = tabFolder; - _toolkit = new FormToolkit(_tabFolder.getDisplay()); - _form = _toolkit.createForm(_tabFolder); - createFormComposite(); - } - - public FormToolkit getToolkit() - { - return _toolkit; - } - - public Control getControl() - { - return _form; - } - - public String getType() - { - return _type; - } - - protected List getListWidget() - { - return _list; - } - - protected HashMap<String, ManagedBean> getMBeansMap() - { - return _objectsMap; - } - - public Sorter getMBeanNameSorter() - { - return _sorterByName; - } - - public Button getAddButton() - { - return _addButton; - } - - public Button getRefreshButton() - { - return _refreshButton; - } - - /** - * Creates the main Composite, which will contain all other Composites and Widgets - */ - protected void createFormComposite() - { - _form.getBody().setLayout(new GridLayout()); - _composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - _composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 10; - layout.horizontalSpacing = 0; - _composite.setLayout(layout); - } - - protected Composite getFormComposite() - { - return _composite; - } - - /** - * Creates the header composite, which has MBean type name and description - * @param parentComposite - */ - protected void createHeaderComposite(Composite parentComposite) - { - _headerComposite = _toolkit.createComposite(parentComposite); - _headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 10; - layout.horizontalSpacing = 0; - _headerComposite.setLayout(layout); - - _labelName = _toolkit.createLabel(_headerComposite, "Type:", SWT.NONE); - GridData gridData = new GridData(SWT.CENTER, SWT.TOP, true, false); - _labelName.setLayoutData(gridData); - _labelName.setFont(ApplicationRegistry.getFont(FONT_BOLD)); - - _labelDesc = _toolkit.createLabel(_headerComposite, " ", SWT.NONE); - _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); - _labelDesc.setFont(ApplicationRegistry.getFont(FONT_ITALIC)); - - _headerComposite.layout(); - } - - /** - * Creates Composite, which contains the common buttons - Add and Refresh. - * @param parentComposite - */ - protected void createButtonsComposite(Composite parentComposite) - { - Composite composite = _toolkit.createComposite(parentComposite); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - GridLayout layout = new GridLayout(2, true); - layout.verticalSpacing = 10; - layout.horizontalSpacing = 20; - composite.setLayout(layout); - - createAddButton(composite); - createRefreshButton(composite); - } - - /** - * Creates the Add button, which adds the selected item to the navigation view - * @param parentComposite - */ - protected void createAddButton(Composite parentComposite) - { - Button _addButton = _toolkit.createButton(parentComposite, "<- Add to Navigation", SWT.PUSH); - GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); - _addButton.setLayoutData(gridData); - _addButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - if (_list.getSelectionCount() == 0) - return; - - String[] selectedItems = _list.getSelection(); - for (int i = 0; i < selectedItems.length; i++) - { - String name = selectedItems[i]; - // pass the ManagedBean to the navigation view to be added - ManagedBean mbean = _objectsMap.get(name); - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - NavigationView view = (NavigationView)window.getActivePage().findView(NavigationView.ID); - try - { - view.addManagedBean(mbean); - } - catch (Exception ex) - { - MBeanUtility.handleException(mbean, ex); - } - } - } - }); - } - - /** - * Creates the Refresh button, which gets syncs the items with the broker server - * @param parentComposite - */ - protected void createRefreshButton(Composite parentComposite) - { - Button _refreshButton = _toolkit.createButton(parentComposite, BUTTON_REFRESH, SWT.PUSH); - GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); - gridData.widthHint = 120; - _refreshButton.setLayoutData(gridData); - _refreshButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - try - { - // refresh the list from the broker server - populateList(); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - } - - /** - * Creates the Composite, which contains the items ( Connections, Exchanges or Queues) - * @param parentComposite - */ - protected void createListComposite(Composite parentComposite) - { - // Composite to contain the item list - _listComposite = _toolkit.createComposite(parentComposite); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - _listComposite.setLayoutData(gridData); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 0; - _listComposite.setLayout(layout); - - // Label for item name - _labelList = _toolkit.createLabel(_listComposite, " ", SWT.CENTER); - gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 1, 1); - _labelList.setLayoutData(gridData); - _labelList.setFont(ApplicationRegistry.getFont(FONT_NORMAL)); - - _list = new List(_listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); - gridData = new GridData(SWT.FILL, SWT.FILL, true, true,1, 1); - _list.setLayoutData(gridData); - - } - - /** - * This is called from MBean View to refresh the tab contents - * @throws Exception - */ - public void refresh() throws Exception - { - setLabelValues(); - populateList(); - layout(); - } - - protected void setLabelValues() - { - _labelName.setText("Type : " + _type); - _labelDesc.setText("Select the " + _type + "(s) to add in the Navigation View"); - _labelList.setText("-- List of " + _type + "s --"); - } - - protected abstract void populateList() throws Exception; - - public void layout() - { - _form.layout(true); - _form.getBody().layout(true, true); - } - - // sets the map with appropriate mbean and name - protected String[] getItems(java.util.List<ManagedBean> list) - { - if (list == null) - return new String[0]; - - Collections.sort(list, _sorterByName); - String[] items = new String[list.size()]; - int i = 0; - for (ManagedBean mbean : list) - { - items[i++] = mbean.getName(); - _objectsMap.put(mbean.getName(), mbean); - } - return items; - } - - protected class ComparatorImpl implements java.util.Comparator<AttributeData> - { - public int compare(AttributeData data1, AttributeData data2) - { - Integer int1 = Integer.parseInt(data1.getValue().toString()); - Integer int2 = Integer.parseInt(data2.getValue().toString()); - return int1.compareTo(int2) * -1; - } - } - - protected class Sorter implements java.util.Comparator<ManagedBean> - { - public int compare(ManagedBean mbean1, ManagedBean mbean2) - { - return mbean1.getName().compareTo(mbean2.getName()); - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java deleted file mode 100644 index 344c3c4e7f..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import java.util.HashMap; - -import static org.apache.qpid.management.ui.Constants.*; -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ManagedServer; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.AttributeData; -import org.apache.qpid.management.ui.model.OperationData; -import org.apache.qpid.management.ui.model.OperationDataModel; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.forms.widgets.Form; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.part.ViewPart; - -/** - * MBean View create appropriate view based on the user selection on the Navigation View. - * Create TabFolder for all MBeans and displays the attribtues and method tabs. - * @author Bhupendra Bhardwaj - * - */ -public class MBeanView extends ViewPart -{ - public static final String ID = "org.apache.qpid.management.ui.mbeanView"; - private static final String CONTROLLER = "CONTROLLER"; - - private FormToolkit _toolkit = null; - private Form _form = null; - private String _formText = APPLICATION_NAME; - private static ManagedServer _server = null; - private TreeObject _selectedNode = null; - private ManagedBean _mbean = null; - private static String _virtualHostName = null; - // This map contains a TabFolder for each kind of MBean. - // TabFolder is mapped with mbeantype(Connection, Queue and Exchange) - private HashMap<String, TabFolder> tabFolderMap = new HashMap<String, TabFolder>(); - private ISelectionListener selectionListener = new SelectionListenerImpl(); - - // TabFolder to list all the mbeans for a given mbeantype(eg Connection, Queue, Exchange) - private TabFolder typeTabFolder = null; - - private TabFolder notificationTabFolder = null; - /* - * Listener for the selection events in the navigation view - */ - private class SelectionListenerImpl implements ISelectionListener - { - public void selectionChanged(IWorkbenchPart part, ISelection sel) - { - if (!(sel instanceof IStructuredSelection)) - return; - - IStructuredSelection ss = (IStructuredSelection) sel; - _selectedNode = (TreeObject)ss.getFirstElement(); - - - // mbean should be set to null. A selection done on the navigation view can be either an mbean or - // an mbeantype. For mbeantype selection(eg Connection, Queue, Exchange) _mbean will remain null. - _mbean = null; - setInvisible(); - - // If a selected node(mbean) gets unregistered from mbean server, mbeanview should - // make the tabfolber for that mbean invisible - if (_selectedNode == null) - return; - - setServer(); - refreshMBeanView(); - setFormTitle(); - } - } - - private void setFormTitle() - { - if (_mbean != null) - { - _formText = _mbean.getType(); - if ((_mbean.getVirtualHostName() != null) && (!DEFAULT_VH.equals(_mbean.getVirtualHostName())) ) - { - _formText = _formText.replaceFirst(VIRTUAL_HOST, _mbean.getVirtualHostName()); - if (_mbean.getName() != null && _mbean.getName().length() != 0) - { - _formText = _formText + ": " + _mbean.getName(); - } - } - } - else if ((_selectedNode.getVirtualHost() != null) && (!DEFAULT_VH.equals(_selectedNode.getVirtualHost()))) - { - _formText = _selectedNode.getVirtualHost(); - } - else - { - _formText = APPLICATION_NAME; - } - _form.setText(_formText); - } - - public void refreshMBeanView() - { - try - { - if (NODE_TYPE_SERVER.equals(_selectedNode.getType()) || - NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) ) - { - return; - } - else if (NODE_TYPE_TYPEINSTANCE.equals(_selectedNode.getType())) - { - // An virtual host instance is selected - refreshTypeTabFolder(typeTabFolder.getItem(0)); - } - else if (NODE_TYPE_MBEANTYPE.equals(_selectedNode.getType())) - { - refreshTypeTabFolder(_selectedNode.getName()); - } - else if (NOTIFICATIONS.equals(_selectedNode.getType())) - { - refreshNotificationPage(); - } - else if (MBEAN.equals(_selectedNode.getType())) - { - _mbean = (ManagedBean)_selectedNode.getManagedObject(); - showSelectedMBean(); - } - - _form.layout(true); - _form.getBody().layout(true, true); - } - catch(Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - } - } - - /** - * Sets the managedServer based on the selection in the navigation view - * At any given time MBeanView will be displaying information for an mbean of mbeantype - * for a specifiv managed server. This server information will be used by the tab controllers - * to get server registry. - */ - private void setServer() - { - if (NODE_TYPE_SERVER.equals(_selectedNode.getType()) || - NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) ) - { - _server = (ManagedServer)_selectedNode.getManagedObject(); - _virtualHostName = null; - } - else - { - TreeObject parent = _selectedNode.getParent(); - while (parent != null && !parent.getType().equals(NODE_TYPE_SERVER)) - { - parent = parent.getParent(); - } - - if (parent != null && parent.getType().equals(NODE_TYPE_SERVER)) - _server = (ManagedServer)parent.getManagedObject(); - - _virtualHostName = _selectedNode.getVirtualHost(); - } - } - - public static ManagedServer getServer() - { - return _server; - } - - public static String getVirtualHost() - { - return _virtualHostName; - } - - private void showSelectedMBean() throws Exception - { - try - { - MBeanUtility.getMBeanInfo(_mbean); - } - catch(Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - return; - } - - TabFolder tabFolder = tabFolderMap.get(_mbean.getType()); - /* - * This solution can be used if there are many versions of Qpid running. Otherwise - * there is no need to create a tabFolder everytime a bean is selected. - if (tabFolder != null && !tabFolder.isDisposed()) - { - tabFolder.dispose(); - } - tabFolder = createTabFolder(); - */ - if (tabFolder == null) - { - tabFolder = createMBeanTabFolder(); - } - - int tabIndex = 0; - if (NOTIFICATIONS.equals(_selectedNode.getType())) - { - tabIndex = tabFolder.getItemCount() -1; - } - - TabItem tab = tabFolder.getItem(tabIndex); - // If folder is being set as visible after tab refresh, then the tab - // doesn't have the focus. - tabFolder.setSelection(tabIndex); - refreshTab(tab); - setVisible(tabFolder); - } - - public void createPartControl(Composite parent) - { - // Create the Form - _toolkit = new FormToolkit(parent.getDisplay()); - _form = _toolkit.createForm(parent); - _form.getBody().setLayout(new FormLayout()); - _form.setText(APPLICATION_NAME); - - // Add selection listener for selection events in the Navigation view - getSite().getPage().addSelectionListener(NavigationView.ID, selectionListener); - - // Add mbeantype TabFolder. This will list all the mbeans under a mbeantype (eg Queue, Exchange). - // Using this list mbeans will be added in the navigation view - createMBeanTypeTabFolder(); - - createNotificationsTabFolder(); - } - - private TabFolder createMBeanTabFolder() - { - TabFolder tabFolder = new TabFolder(_form.getBody(), SWT.NONE); - FormData layoutData = new FormData(); - layoutData.left = new FormAttachment(0); - layoutData.top = new FormAttachment(0); - layoutData.right = new FormAttachment(100); - layoutData.bottom = new FormAttachment(100); - tabFolder.setLayoutData(layoutData); - tabFolder.setVisible(false); - - createAttributesTab(tabFolder); - createOperationTabs(tabFolder); - createNotificationsTab(tabFolder); - - tabFolder.addListener(SWT.Selection, new Listener() - { - public void handleEvent(Event evt) - { - TabItem tab = (TabItem)evt.item; - refreshTab(tab); - } - }); - - tabFolderMap.put(_mbean.getType(), tabFolder); - return tabFolder; - } - - private void refreshTab(TabItem tab) - { - // We can avoid refreshing the attributes tab because it's control - // already contains the required values. But it is added for now and - // will remove if there is any performance issue or any other issue. - // The operations control should be refreshed because there is only one - // controller for all operations tab. - // The Notifications control needs to refresh with latest set of notifications - - if (tab == null) - return; - - TabControl controller = (TabControl)tab.getData(CONTROLLER); - controller.refresh(_mbean); - } - - public void setFocus() - { - //_form.setFocus(); - } - - public void dispose() - { - _toolkit.dispose(); - super.dispose(); - } - - private void createAttributesTab(TabFolder tabFolder) - { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - if (serverRegistry.getAttributeModel(_mbean).getCount() == 0) - { - return; - } - - TabItem tab = new TabItem(tabFolder, SWT.NONE); - tab.setText(ATTRIBUTES); - AttributesTabControl controller = new AttributesTabControl(tabFolder); - tab.setControl(controller.getControl()); - tab.setData(CONTROLLER, controller); - } - - private void createOperationTabs(TabFolder tabFolder) - { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - int operationsCount = serverRegistry.getOperationModel(_mbean).getCount(); - if (operationsCount == 0) - { - return; - } - - OperationDataModel operationModel = serverRegistry.getOperationModel(_mbean); - for (OperationData operationData : operationModel.getOperations()) - { - TabItem operationTab = new TabItem(tabFolder, SWT.NONE); - operationTab.setText(ViewUtility.getDisplayText(operationData.getName())); - operationTab.setData(operationData); - OperationTabControl control = new OperationTabControl(tabFolder, operationData); - operationTab.setData(CONTROLLER, control); - operationTab.setControl(control.getControl()); - } - } - - private void createNotificationsTab(TabFolder tabFolder) - { - NotificationsTabControl controller = new NotificationsTabControl(tabFolder); - - TabItem tab = new TabItem(tabFolder, SWT.NONE); - tab.setText(NOTIFICATIONS); - tab.setData(CONTROLLER, controller); - tab.setControl(controller.getControl()); - } - - /** - * For the EditAttribtue Action. Invoking this from action is same as clicking - * "EditAttribute" button from Attribute tab. - */ - public void editAttribute() throws Exception - { - if (_mbean == null) - throw new InfoRequiredException("Please select the managed object and then attribute to be edited"); - - String name = (_mbean.getName() != null) ? _mbean.getName() : _mbean.getType(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - if (serverRegistry.getAttributeModel(_mbean).getCount() == 0) - { - throw new InfoRequiredException("There are no attributes to be edited for " + name); - } - - TabFolder tabFolder = tabFolderMap.get(_mbean.getType()); - int index = tabFolder.getSelectionIndex(); - if (index != 0) - { - tabFolder.setSelection(0); - throw new InfoRequiredException("Please select the attribute to be edited"); - } - - TabItem tab = tabFolder.getItem(0); - AttributesTabControl tabControl = (AttributesTabControl)tab.getData(CONTROLLER); - AttributeData attribute = tabControl.getSelectionAttribute(); - if (attribute == null) - throw new InfoRequiredException("Please select the attribute to be edited"); - - tabControl.createDetailsPopup(attribute); - } - - /** - * Creates TabFolder and tabs for each mbeantype (eg Connection, Queue, Exchange) - */ - private void createMBeanTypeTabFolder() - { - typeTabFolder = new TabFolder(_form.getBody(), SWT.NONE); - FormData layoutData = new FormData(); - layoutData.left = new FormAttachment(0); - layoutData.top = new FormAttachment(0); - layoutData.right = new FormAttachment(100); - layoutData.bottom = new FormAttachment(100); - typeTabFolder.setLayoutData(layoutData); - typeTabFolder.setVisible(false); - - TabItem tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(CONNECTION); - MBeanTypeTabControl controller = new ConnectionTypeTabControl(typeTabFolder); - tab.setData(CONTROLLER, controller); - tab.setControl(controller.getControl()); - - tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(EXCHANGE); - controller = new ExchangeTypeTabControl(typeTabFolder); - tab.setData(CONTROLLER, controller); - tab.setControl(controller.getControl()); - - tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(QUEUE); - controller = new QueueTypeTabControl(typeTabFolder); - tab.setData(CONTROLLER, controller); - tab.setControl(controller.getControl()); - - typeTabFolder.addListener(SWT.Selection, new Listener() - { - public void handleEvent(Event evt) - { - TabItem tab = (TabItem)evt.item; - try - { - refreshTypeTabFolder(tab); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - } - - private void createNotificationsTabFolder() - { - notificationTabFolder = new TabFolder(_form.getBody(), SWT.NONE); - FormData layoutData = new FormData(); - layoutData.left = new FormAttachment(0); - layoutData.top = new FormAttachment(0); - layoutData.right = new FormAttachment(100); - layoutData.bottom = new FormAttachment(100); - notificationTabFolder.setLayoutData(layoutData); - notificationTabFolder.setVisible(false); - - VHNotificationsTabControl controller = new VHNotificationsTabControl(notificationTabFolder); - TabItem tab = new TabItem(notificationTabFolder, SWT.NONE); - tab.setText(NOTIFICATIONS); - tab.setData(CONTROLLER, controller); - tab.setControl(controller.getControl()); - } - - private void refreshNotificationPage() - { - TabItem tab = notificationTabFolder.getItem(0); - VHNotificationsTabControl controller = (VHNotificationsTabControl)tab.getData(CONTROLLER); - controller.refresh(); - notificationTabFolder.setVisible(true); - } - - /** - * Refreshes the Selected mbeantype tab. The control lists all the available mbeans - * for an mbeantype(eg Queue, Exchange etc) - * @param tab - * @throws Exception - */ - private void refreshTypeTabFolder(TabItem tab) throws Exception - { - if (tab == null) - { - return; - } - typeTabFolder.setSelection(tab); - MBeanTypeTabControl controller = (MBeanTypeTabControl)tab.getData(CONTROLLER); - controller.refresh(); - typeTabFolder.setVisible(true); - } - - private void refreshTypeTabFolder(String type) throws Exception - { - if (CONNECTION.equals(type)) - { - refreshTypeTabFolder(typeTabFolder.getItem(0)); - } - else if (EXCHANGE.equals(type)) - { - refreshTypeTabFolder(typeTabFolder.getItem(1)); - } - else if (QUEUE.equals(type)) - { - refreshTypeTabFolder(typeTabFolder.getItem(2)); - } - } - - /** - * hides other folders and makes the given one visible. - * @param tabFolder - */ - private void setVisible(TabFolder tabFolder) - { - for (TabFolder folder : tabFolderMap.values()) - { - if (folder == tabFolder) - folder.setVisible(true); - else - folder.setVisible(false); - } - } - - private void setInvisible() - { - for (TabFolder folder : tabFolderMap.values()) - { - folder.setVisible(false); - } - - if (typeTabFolder != null) - { - typeTabFolder.setVisible(false); - } - - if (notificationTabFolder != null) - { - notificationTabFolder.setVisible(false); - } - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java deleted file mode 100644 index 1da13a9b56..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java +++ /dev/null @@ -1,1253 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import static org.apache.qpid.management.ui.Constants.*; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ManagedServer; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.exceptions.InfoRequiredException; -import org.apache.qpid.management.ui.jmx.JMXServerRegistry; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.eclipse.jface.preference.PreferenceStore; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.IFontProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.ITreeViewerListener; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeExpansionEvent; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -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.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.part.ViewPart; - -/** - * Navigation View for navigating the managed servers and managed beans on - * those servers - * @author Bhupendra Bhardwaj - */ -public class NavigationView extends ViewPart -{ - public static final String ID = "org.apache.qpid.management.ui.navigationView"; - public static final String INI_FILENAME = System.getProperty("user.home") + File.separator + "qpidManagementConsole.ini"; - - private static final String INI_SERVERS = "Servers"; - private static final String INI_QUEUES = QUEUE + "s"; - private static final String INI_CONNECTIONS = CONNECTION + "s"; - private static final String INI_EXCHANGES = EXCHANGE + "s"; - - private TreeViewer _treeViewer = null; - private TreeObject _rootNode = null; - private TreeObject _serversRootNode = null; - - private PreferenceStore _preferences; - // Map of connected servers - private HashMap<ManagedServer, TreeObject> _managedServerMap = new HashMap<ManagedServer, TreeObject>(); - - private void createTreeViewer(Composite parent) - { - _treeViewer = new TreeViewer(parent); - _treeViewer.setContentProvider(new ContentProviderImpl()); - _treeViewer.setLabelProvider(new LabelProviderImpl()); - _treeViewer.setSorter(new ViewerSorterImpl()); - - // layout the tree viewer below the label field, to cover the area - GridData layoutData = new GridData(); - layoutData = new GridData(); - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = true; - layoutData.horizontalAlignment = GridData.FILL; - layoutData.verticalAlignment = GridData.FILL; - _treeViewer.getControl().setLayoutData(layoutData); - _treeViewer.setUseHashlookup(true); - - createListeners(); - } - - /** - * Creates listeners for the JFace treeviewer - */ - private void createListeners() - { - _treeViewer.addDoubleClickListener(new IDoubleClickListener() - { - public void doubleClick(DoubleClickEvent event) - { - IStructuredSelection ss = (IStructuredSelection) event.getSelection(); - if ((ss == null) || (ss.getFirstElement() == null)) - { - return; - } - - boolean state = _treeViewer.getExpandedState(ss.getFirstElement()); - _treeViewer.setExpandedState(ss.getFirstElement(), !state); - } - }); - - _treeViewer.addTreeListener(new ITreeViewerListener() - { - public void treeExpanded(TreeExpansionEvent event) - { - _treeViewer.setExpandedState(event.getElement(), true); - // Following will cause the selection event to be sent, so commented - // _treeViewer.setSelection(new StructuredSelection(event.getElement())); - _treeViewer.refresh(); - } - - public void treeCollapsed(TreeExpansionEvent event) - { - _treeViewer.setExpandedState(event.getElement(), false); - _treeViewer.refresh(); - } - }); - - // This listener is for popup menu, which pops up if a queue,exchange or connection is selected - // with right click. - _treeViewer.getTree().addListener(SWT.MenuDetect, new Listener() - { - Display display = getSite().getShell().getDisplay(); - final Shell shell = new Shell(display); - - public void handleEvent(Event event) - { - Tree widget = (Tree) event.widget; - TreeItem[] items = widget.getSelection(); - if (items == null) - { - return; - } - - // Get the selected node - final TreeObject selectedNode = (TreeObject) items[0].getData(); - final TreeObject parentNode = selectedNode.getParent(); - - // This popup is only for mbeans and only connection,exchange and queue types - if ((parentNode == null) || !MBEAN.equals(selectedNode.getType()) - || !(CONNECTION.equals(parentNode.getName()) || QUEUE.equals(parentNode.getName()) - || EXCHANGE.equals(parentNode.getName()))) - { - return; - } - - Menu menu = new Menu(shell, SWT.POP_UP); - MenuItem item = new MenuItem(menu, SWT.PUSH); - // Add the action item, which will remove the node from the tree if selected - item.setText(ACTION_REMOVE_MBEANNODE); - item.addListener(SWT.Selection, new Listener() - { - public void handleEvent(Event e) - { - removeManagedObject(parentNode, (ManagedBean) selectedNode.getManagedObject()); - _treeViewer.refresh(); - // set the selection to the parent node - _treeViewer.setSelection(new StructuredSelection(parentNode)); - } - }); - menu.setLocation(event.x, event.y); - menu.setVisible(true); - while (!menu.isDisposed() && menu.isVisible()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - menu.dispose(); - } - }); - } - - /** - * Creates Qpid Server connection using JMX RMI protocol - * @param server - * @throws Exception - */ - private void createRMIServerConnection(ManagedServer server) throws Exception - { - // Currently Qpid Management Console only supports JMX MBeanServer - ServerRegistry serverRegistry = new JMXServerRegistry(server); - ApplicationRegistry.addServer(server, serverRegistry); - } - - /** - * Adds a new server node in the navigation view if server connection is successful. - * @param transportProtocol - * @param host - * @param port - * @param domain - * @throws Exception - */ - public void addNewServer(String transportProtocol, String host, int port, String domain, String user, String pwd) - throws Exception - { - String serverAddress = host + ":" + port; - String url = null; - ManagedServer managedServer = new ManagedServer(host, port, domain, user, pwd); - - if ("RMI".equals(transportProtocol)) - { - url = managedServer.getUrl(); - List<TreeObject> list = _serversRootNode.getChildren(); - for (TreeObject node : list) - { - ManagedServer nodeServer = (ManagedServer)node.getManagedObject(); - if (url.equals(nodeServer.getUrl())) - { - // Server is already in the list of added servers, so now connect it. - // Set the server node as selected and then connect it. - _treeViewer.setSelection(new StructuredSelection(node)); - reconnect(user, pwd); - - return; - } - } - - // The server is not in the list of already added servers, so now connect and add it. - managedServer.setName(serverAddress); - createRMIServerConnection(managedServer); - } - else - { - throw new InfoRequiredException(transportProtocol + " transport is not supported"); - } - - // Server connection is successful. Now add the server in the tree - TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER); - serverNode.setManagedObject(managedServer); - _serversRootNode.addChild(serverNode); - - // Add server in the connected server map - _managedServerMap.put(managedServer, serverNode); - - // populate the server tree - try - { - populateServer(serverNode); - } - catch (SecurityException ex) - { - disconnect(managedServer); - throw ex; - } - - // Add the Queue/Exchanges/Connections from config file into the navigation tree - addConfiguredItems(managedServer); - - _treeViewer.refresh(); - - // save server address in file - addServerInConfigFile(serverAddress); - } - - /** - * Create the config file, if it doesn't already exist. - * Exits the application if the file could not be created. - */ - private void createConfigFile() - { - File file = new File(INI_FILENAME); - try - { - if (!file.exists()) - { - file.createNewFile(); - } - } - catch (IOException ex) - { - System.out.println("Could not write to the file " + INI_FILENAME); - System.out.println(ex); - System.exit(1); - } - } - - /** - * Server addresses are stored in a file. When user launches the application again, the - * server addresses are picked up from the file and shown in the navigfation view. This method - * adds the server address in a file, when a new server is added in the navigation view. - * @param serverAddress - */ - private void addServerInConfigFile(String serverAddress) - { - // Check if the address already exists - List<String> list = getServerListFromFile(); - if ((list != null) && list.contains(serverAddress)) - { - return; - } - - // Get the existing server list and add to that - String servers = _preferences.getString(INI_SERVERS); - String value = (servers.length() != 0) ? (servers + "," + serverAddress) : serverAddress; - _preferences.putValue(INI_SERVERS, value); - try - { - _preferences.save(); - } - catch (IOException ex) - { - System.err.println("Could not add " + serverAddress + " in " + INI_SERVERS + " (" + INI_FILENAME + ")"); - System.out.println(ex); - } - } - - /** - * Adds the item (Queue/Exchange/Connection) to the config file - * @param server - * @param virtualhost - * @param type - (Queue or Exchange or Connection) - * @param name - item name - */ - private void addItemInConfigFile(TreeObject node) - { - ManagedBean mbean = (ManagedBean) node.getManagedObject(); - String server = mbean.getServer().getName(); - String virtualhost = mbean.getVirtualHostName(); - String type = node.getParent().getName() + "s"; - String name = node.getName(); - String itemKey = server + "." + virtualhost + "." + type; - - // Check if the item already exists in the config file - List<String> list = getConfiguredItemsFromFile(itemKey); - if ((list != null) && list.contains(name)) - { - return; - } - - // Add this item to the existing list of items - String items = _preferences.getString(itemKey); - String value = (items.length() != 0) ? (items + "," + name) : name; - _preferences.putValue(itemKey, value); - try - { - _preferences.save(); - } - catch (IOException ex) - { - System.err.println("Could not add " + name + " in " + itemKey + " (" + INI_FILENAME + ")"); - System.out.println(ex); - } - } - - private void removeItemFromConfigFile(TreeObject node) - { - ManagedBean mbean = (ManagedBean) node.getManagedObject(); - String server = mbean.getServer().getName(); - String vHost = mbean.getVirtualHostName(); - String type = node.getParent().getName() + "s"; - String itemKey = server + "." + vHost + "." + type; - - List<String> list = getConfiguredItemsFromFile(itemKey); - if (list.contains(node.getName())) - { - list.remove(node.getName()); - String value = ""; - for (String item : list) - { - value += item + ","; - } - - value = (value.lastIndexOf(",") != -1) ? value.substring(0, value.lastIndexOf(",")) : value; - - _preferences.putValue(itemKey, value); - try - { - _preferences.save(); - } - catch (IOException ex) - { - System.err.println("Error in updating the config file " + INI_FILENAME); - System.out.println(ex); - } - } - } - - /** - * Queries the qpid server for MBeans and populates the navigation view with all MBeans for - * the given server node. - * @param serverNode - */ - private void populateServer(TreeObject serverNode) throws Exception - { - ManagedServer server = (ManagedServer) serverNode.getManagedObject(); - String domain = server.getDomain(); - if (!domain.equals(ALL)) - { - TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN); - domainNode.setParent(serverNode); - - populateDomain(domainNode); - } - else - { - List<TreeObject> domainList = new ArrayList<TreeObject>(); - List<String> domains = MBeanUtility.getAllDomains(server); - - for (String domainName : domains) - { - TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN); - domainNode.setParent(serverNode); - - domainList.add(domainNode); - populateDomain(domainNode); - } - } - } - - /** - * Queries the Qpid Server and populates the given domain node with all MBeans undser that domain. - * @param domain - * @throws IOException - * @throws Exception - */ - @SuppressWarnings("unchecked") - private void populateDomain(TreeObject domain) throws IOException, Exception - { - ManagedServer server = (ManagedServer) domain.getParent().getManagedObject(); - - // Now populate the mbenas under those types - List<ManagedBean> mbeans = MBeanUtility.getManagedObjectsForDomain(server, domain.getName()); - for (ManagedBean mbean : mbeans) - { - mbean.setServer(server); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(server); - serverRegistry.addManagedObject(mbean); - - // Add all mbeans other than Connections, Exchanges and Queues. Because these will be added - // manually by selecting from MBeanView - if (!(mbean.isConnection() || mbean.isExchange() || mbean.isQueue())) - { - addManagedBean(domain, mbean); - } - } - // To make it work with the broker without virtual host implementation. - // This will add the default nodes to the domain node - for (TreeObject child : domain.getChildren()) - { - if (!child.getName().startsWith(VIRTUAL_HOST)) - { - addDefaultNodes(domain); - } - - break; - } - } - - /** - * Add these three types - Connection, Exchange, Queue - * By adding these, these will always be available, even if there are no mbeans under thse types - * This is required because, the mbeans will be added from mbeanview, by selecting from the list - * @param parent Node - */ - private void addDefaultNodes(TreeObject parent) - { - TreeObject typeChild = new TreeObject(CONNECTION, NODE_TYPE_MBEANTYPE); - typeChild.setParent(parent); - typeChild.setVirtualHost(parent.getVirtualHost()); - typeChild = new TreeObject(EXCHANGE, NODE_TYPE_MBEANTYPE); - typeChild.setParent(parent); - typeChild.setVirtualHost(parent.getVirtualHost()); - typeChild = new TreeObject(QUEUE, NODE_TYPE_MBEANTYPE); - typeChild.setParent(parent); - typeChild.setVirtualHost(parent.getVirtualHost()); - - // Add common notification node for virtual host - TreeObject notificationNode = new TreeObject(NOTIFICATIONS, NOTIFICATIONS); - notificationNode.setParent(parent); - notificationNode.setVirtualHost(parent.getVirtualHost()); - } - - /** - * Checks if a particular mbeantype is already there in the navigation view for a domain. - * This is used while populating domain with mbeans. - * @param parent - * @param typeName - * @return Node if given mbeantype already exists, otherwise null - */ - private TreeObject getMBeanTypeNode(TreeObject parent, String typeName) - { - List<TreeObject> childNodes = parent.getChildren(); - for (TreeObject child : childNodes) - { - if ((NODE_TYPE_MBEANTYPE.equals(child.getType()) || NODE_TYPE_TYPEINSTANCE.equals(child.getType())) - && typeName.equals(child.getName())) - { - return child; - } - } - - return null; - } - - private boolean doesMBeanNodeAlreadyExist(TreeObject typeNode, String mbeanName) - { - List<TreeObject> childNodes = typeNode.getChildren(); - for (TreeObject child : childNodes) - { - if (MBEAN.equals(child.getType()) && mbeanName.equals(child.getName())) - { - return true; - } - } - - return false; - } - - /** - * Adds the given MBean to the given domain node. Creates Notification node for the MBean. - * sample ObjectNames - - * org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=localhost - * org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,name=ping_1 - * @param domain - * @param mbean - * @throws Exception - */ - private void addManagedBean(TreeObject domain, ManagedBean mbean) // throws Exception - { - String name = mbean.getName(); - // Split the mbean type into array of Strings, to create hierarchy - // eg. type=VirtualHost.VirtualHostManager,VirtualHost=localhost will be: - // localhost->VirtualHostManager - // eg. type=org.apache.qpid:type=VirtualHost.Queue,VirtualHost=test,name=ping will be: - // test->Queue->ping - String[] types = mbean.getType().split("\\."); - TreeObject typeNode = null; - TreeObject parentNode = domain; - - // Run this loop till all nodes(hierarchy) for this mbean are created. This loop only creates - // all the required parent nodes for the mbean - for (int i = 0; i < types.length; i++) - { - String type = types[i]; - String valueOftype = mbean.getProperty(type); - // If value is not null, then there will be a parent node for this mbean - // eg. for type=VirtualHost the value is "test" - typeNode = getMBeanTypeNode(parentNode, type); - - // create the type node if not already created - if (typeNode == null) - { - // If the ObjectName doesn't have name property, that means there will be only one instance - // of this mbean for given "type". So there will be no type node created for this mbean. - if ((name == null) && (i == (types.length - 1))) - { - break; - } - - // create a node for "type" - typeNode = createTypeNode(parentNode, type); - if (!type.equals(VIRTUAL_HOST)) - { - typeNode.setVirtualHost(mbean.getVirtualHostName()); - } - } - - // now type node create becomes the parent node for next node in hierarchy - parentNode = typeNode; - - /* - * Now create instances node for this type if value exists. - */ - if (valueOftype == null) - { - // No instance node will be created when value is null (eg type=Queue) - break; - } - - // For different virtual hosts, the nodes with given value will be created. - // eg type=VirtualHost, value=test - typeNode = getMBeanTypeNode(parentNode, valueOftype); - if (typeNode == null) - { - typeNode = createTypeInstanceNode(parentNode, valueOftype); - typeNode.setVirtualHost(mbean.getVirtualHostName()); - - // Create default nodes for VHost instances - if (type.equals(VIRTUAL_HOST)) - { - addDefaultNodes(typeNode); - } - } - - parentNode = typeNode; - } - - if (typeNode == null) - { - typeNode = parentNode; - } - - // Check if an MBean is already added - if (doesMBeanNodeAlreadyExist(typeNode, name)) - { - return; - } - - // Add the mbean node now - TreeObject mbeanNode = new TreeObject(mbean); - mbeanNode.setParent(typeNode); - - // Add the mbean to the config file - if (mbean.isQueue() || mbean.isExchange() || mbean.isConnection()) - { - addItemInConfigFile(mbeanNode); - } - - // Add notification node - // TODO: show this only if the mbean sends any notification - //TreeObject notificationNode = new TreeObject(NOTIFICATION, NOTIFICATION); - //notificationNode.setParent(mbeanNode); - } - - private TreeObject createTypeNode(TreeObject parent, String name) - { - TreeObject typeNode = new TreeObject(name, NODE_TYPE_MBEANTYPE); - typeNode.setParent(parent); - - return typeNode; - } - - private TreeObject createTypeInstanceNode(TreeObject parent, String name) - { - TreeObject typeNode = new TreeObject(name, NODE_TYPE_TYPEINSTANCE); - typeNode.setParent(parent); - - return typeNode; - } - - /** - * Removes all the child nodes of the given parent node. Used when closing a server. - * @param parent - */ - private void removeManagedObject(TreeObject parent) - { - List<TreeObject> list = parent.getChildren(); - for (TreeObject child : list) - { - removeManagedObject(child); - } - - list.clear(); - } - - /** - * Removes the mbean from the tree - * @param parent - * @param mbean - */ - private void removeManagedObject(TreeObject parent, ManagedBean mbean) - { - List<TreeObject> list = parent.getChildren(); - TreeObject objectToRemove = null; - for (TreeObject child : list) - { - if (MBEAN.equals(child.getType())) - { - String name = (mbean.getName() != null) ? mbean.getName() : mbean.getType(); - if (child.getName().equals(name)) - { - objectToRemove = child; - - break; - } - } - else - { - removeManagedObject(child, mbean); - } - } - - if (objectToRemove != null) - { - list.remove(objectToRemove); - removeItemFromConfigFile(objectToRemove); - } - - } - - /** - * Closes the Qpid server connection - */ - public void disconnect() throws Exception - { - TreeObject selectedNode = getSelectedServerNode(); - ManagedServer managedServer = (ManagedServer) selectedNode.getManagedObject(); - disconnect(managedServer); - } - - private void disconnect(ManagedServer managedServer) throws Exception - { - if (!_managedServerMap.containsKey(managedServer)) - { - return; - } - - // Close server connection - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(managedServer); - if (serverRegistry == null) // server connection is already closed - { - return; - } - - serverRegistry.closeServerConnection(); - // Add server to the closed server list and the worker thread will remove the server from required places. - ApplicationRegistry.serverConnectionClosed(managedServer); - } - - /** - * Connects the selected server node - * @throws Exception - */ - public void reconnect(String user, String password) throws Exception - { - TreeObject selectedNode = getSelectedServerNode(); - ManagedServer managedServer = (ManagedServer) selectedNode.getManagedObject(); - if (_managedServerMap.containsKey(managedServer)) - { - throw new InfoRequiredException("Server " + managedServer.getName() + " is already connected"); - } - - managedServer.setUser(user); - managedServer.setPassword(password); - createRMIServerConnection(managedServer); - - // put the server in the managed server map - _managedServerMap.put(managedServer, selectedNode); - - try - { - // populate the server tree now - populateServer(selectedNode); - } - catch (SecurityException ex) - { - disconnect(managedServer); - throw ex; - } - - - // Add the Queue/Exchanges/Connections from config file into the navigation tree - addConfiguredItems(managedServer); - - _treeViewer.refresh(); - } - - /** - * Adds the items(queues/exchanges/connectins) from config file to the server tree - * @param server - */ - private void addConfiguredItems(ManagedServer server) - { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(server); - List<String> list = serverRegistry.getVirtualHosts(); - for (String virtualHost : list) - { - // Add Queues - String itemKey = server.getName() + "." + virtualHost + "." + INI_QUEUES; - List<String> items = getConfiguredItemsFromFile(itemKey); - List<ManagedBean> mbeans = serverRegistry.getQueues(virtualHost); - addConfiguredItems(items, mbeans); - - // Add Exchanges - itemKey = server.getName() + "." + virtualHost + "." + INI_EXCHANGES; - items = getConfiguredItemsFromFile(itemKey); - mbeans = serverRegistry.getExchanges(virtualHost); - addConfiguredItems(items, mbeans); - - // Add Connections - itemKey = server.getName() + "." + virtualHost + "." + INI_CONNECTIONS; - items = getConfiguredItemsFromFile(itemKey); - mbeans = serverRegistry.getConnections(virtualHost); - addConfiguredItems(items, mbeans); - } - } - - /** - * Gets the mbeans corresponding to the items and adds those to the navigation tree - * @param items - * @param mbeans - */ - private void addConfiguredItems(List<String> items, List<ManagedBean> mbeans) - { - if ((items == null) || (items.isEmpty() | (mbeans == null)) || mbeans.isEmpty()) - { - return; - } - - for (String item : items) - { - for (ManagedBean mbean : mbeans) - { - if (item.equals(mbean.getName())) - { - addManagedBean(mbean); - - break; - } - } - } - } - - /** - * Closes the Qpid server connection if not already closed and removes the server node from the navigation view and - * also from the ini file stored in the system. - * @throws Exception - */ - public void removeServer() throws Exception - { - disconnect(); - - // Remove from the Tree - String serverNodeName = getSelectedServerNode().getName(); - List<TreeObject> list = _serversRootNode.getChildren(); - TreeObject objectToRemove = null; - for (TreeObject child : list) - { - if (child.getName().equals(serverNodeName)) - { - objectToRemove = child; - - break; - } - } - - if (objectToRemove != null) - { - list.remove(objectToRemove); - } - - _treeViewer.refresh(); - - // Remove from the ini file - removeServerFromConfigFile(serverNodeName); - } - - private void removeServerFromConfigFile(String serverNodeName) - { - List<String> serversList = getServerListFromFile(); - serversList.remove(serverNodeName); - - String value = ""; - for (String item : serversList) - { - value += item + ","; - } - - value = (value.lastIndexOf(",") != -1) ? value.substring(0, value.lastIndexOf(",")) : value; - - _preferences.putValue(INI_SERVERS, value); - - try - { - _preferences.save(); - } - catch (IOException ex) - { - System.err.println("Error in updating the config file " + INI_FILENAME); - System.out.println(ex); - } - } - - /** - * @return the server addresses from the ini file - * @throws Exception - */ - private List<String> getServerListFromFile() - { - return getConfiguredItemsFromFile(INI_SERVERS); - } - - /** - * Returns the list of items from the config file. - * sample ini file: - * Servers=localhost:8999,127.0.0.1:8999 - * localhost.virtualhost1.Queues=queue1,queue2 - * localhost.virtualhost1.Exchanges=exchange1,exchange2 - * localhost.virtualhost2.Connections=conn1 - * @param key - * @return - */ - private List<String> getConfiguredItemsFromFile(String key) - { - List<String> list = new ArrayList<String>(); - String items = _preferences.getString(key); - if (items.length() != 0) - { - String[] array = items.split(","); - for (String item : array) - { - list.add(item); - } - } - - return list; - } - - public TreeObject getSelectedServerNode() throws Exception - { - IStructuredSelection ss = (IStructuredSelection) _treeViewer.getSelection(); - TreeObject selectedNode = (TreeObject) ss.getFirstElement(); - if (ss.isEmpty() || (selectedNode == null) || (!selectedNode.getType().equals(NODE_TYPE_SERVER))) - { - throw new InfoRequiredException("Please select the server"); - } - - return selectedNode; - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - public void createPartControl(Composite parent) - { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.marginHeight = 2; - gridLayout.marginWidth = 2; - gridLayout.horizontalSpacing = 0; - gridLayout.verticalSpacing = 2; - composite.setLayout(gridLayout); - - createTreeViewer(composite); - _rootNode = new TreeObject("ROOT", "ROOT"); - _serversRootNode = new TreeObject(NAVIGATION_ROOT, "ROOT"); - _serversRootNode.setParent(_rootNode); - - _treeViewer.setInput(_rootNode); - // set viewer as selection event provider for MBeanView - getSite().setSelectionProvider(_treeViewer); - - // Start worker thread to refresh tree for added or removed objects - (new Thread(new Worker())).start(); - - createConfigFile(); - _preferences = new PreferenceStore(INI_FILENAME); - - try - { - _preferences.load(); - } - catch (IOException ex) - { - System.out.println(ex); - } - - // load the list of servers already added from file - List<String> serversList = getServerListFromFile(); - if (serversList != null) - { - for (String serverAddress : serversList) - { - String[] server = serverAddress.split(":"); - ManagedServer managedServer = new ManagedServer(server[0], Integer.parseInt(server[1]), "org.apache.qpid"); - TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER); - serverNode.setManagedObject(managedServer); - _serversRootNode.addChild(serverNode); - } - } - - _treeViewer.refresh(); - - } - - /** - * Passing the focus request to the viewer's control. - */ - public void setFocus() - { } - - public void refresh() - { - _treeViewer.refresh(); - } - - /** - * Content provider class for the tree viewer - */ - private class ContentProviderImpl implements ITreeContentProvider - { - public Object[] getElements(Object parent) - { - return getChildren(parent); - } - - public Object[] getChildren(final Object parentElement) - { - final TreeObject node = (TreeObject) parentElement; - - return node.getChildren().toArray(new TreeObject[0]); - } - - public Object getParent(final Object element) - { - final TreeObject node = (TreeObject) element; - - return node.getParent(); - } - - public boolean hasChildren(final Object element) - { - final TreeObject node = (TreeObject) element; - - return !node.getChildren().isEmpty(); - } - - public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) - { - // Do nothing - } - - public void dispose() - { - // Do nothing - } - } - - /** - * Label provider class for the tree viewer - */ - private class LabelProviderImpl extends LabelProvider implements IFontProvider - { - public Image getImage(Object element) - { - TreeObject node = (TreeObject) element; - if (node.getType().equals(NOTIFICATIONS)) - { - return ApplicationRegistry.getImage(NOTIFICATION_IMAGE); - } - else if (!node.getType().equals(MBEAN)) - { - if (_treeViewer.getExpandedState(node)) - { - return ApplicationRegistry.getImage(OPEN_FOLDER_IMAGE); - } - else - { - return ApplicationRegistry.getImage(CLOSED_FOLDER_IMAGE); - } - - } - else - { - return ApplicationRegistry.getImage(MBEAN_IMAGE); - } - } - - public String getText(Object element) - { - TreeObject node = (TreeObject) element; - if (node.getType().equals(NODE_TYPE_MBEANTYPE)) - { - return node.getName() + "s"; - } - else - { - return node.getName(); - } - } - - public Font getFont(Object element) - { - TreeObject node = (TreeObject) element; - if (node.getType().equals(NODE_TYPE_SERVER)) - { - if (node.getChildren().isEmpty()) - { - return ApplicationRegistry.getFont(FONT_NORMAL); - } - else - { - return ApplicationRegistry.getFont(FONT_BOLD); - } - } - - return ApplicationRegistry.getFont(FONT_NORMAL); - } - } // End of LabelProviderImpl - - private class ViewerSorterImpl extends ViewerSorter - { - public int category(Object element) - { - TreeObject node = (TreeObject) element; - if (node.getType().equals(MBEAN)) - { - return 1; - } - if (node.getType().equals(NOTIFICATIONS)) - { - return 2; - } - return 3; - } - } - - /** - * Worker thread, which keeps looking for new ManagedObjects to be added and - * unregistered objects to be removed from the tree. - * @author Bhupendra Bhardwaj - */ - private class Worker implements Runnable - { - public void run() - { - while (true) - { - if (!_managedServerMap.isEmpty()) - { - refreshRemovedObjects(); - refreshClosedServerConnections(); - } - - try - { - Thread.sleep(3000); - } - catch (Exception ex) - { } - - } // end of while loop - } // end of run method. - } // end of Worker class - - /** - * Adds the mbean to the navigation tree - * @param mbean - * @throws Exception - */ - public void addManagedBean(ManagedBean mbean) // throws Exception - { - TreeObject treeServerObject = _managedServerMap.get(mbean.getServer()); - List<TreeObject> domains = treeServerObject.getChildren(); - TreeObject domain = null; - for (TreeObject child : domains) - { - if (child.getName().equals(mbean.getDomain())) - { - domain = child; - - break; - } - } - - addManagedBean(domain, mbean); - _treeViewer.refresh(); - } - - private void refreshRemovedObjects() - { - for (ManagedServer server : _managedServerMap.keySet()) - { - final ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(server); - if (serverRegistry == null) // server connection is closed - { - continue; - } - - final List<ManagedBean> removalList = serverRegistry.getObjectsToBeRemoved(); - if (removalList != null) - { - Display display = getSite().getShell().getDisplay(); - display.syncExec(new Runnable() - { - public void run() - { - for (ManagedBean mbean : removalList) - { - TreeObject treeServerObject = _managedServerMap.get(mbean.getServer()); - List<TreeObject> domains = treeServerObject.getChildren(); - TreeObject domain = null; - for (TreeObject child : domains) - { - if (child.getName().equals(mbean.getDomain())) - { - domain = child; - - break; - } - } - - removeManagedObject(domain, mbean); - // serverRegistry.removeManagedObject(mbean); - } - - _treeViewer.refresh(); - } - }); - } - } - } - - /** - * Gets the list of closed server connection from the ApplicationRegistry and then removes - * the closed server nodes from the navigation view - */ - private void refreshClosedServerConnections() - { - final List<ManagedServer> closedServers = ApplicationRegistry.getClosedServers(); - if (closedServers != null) - { - Display display = getSite().getShell().getDisplay(); - display.syncExec(new Runnable() - { - public void run() - { - for (ManagedServer server : closedServers) - { - removeManagedObject(_managedServerMap.get(server)); - _managedServerMap.remove(server); - ApplicationRegistry.removeServer(server); - } - - _treeViewer.refresh(); - } - }); - } - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java deleted file mode 100644 index 6894080859..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import static org.apache.qpid.management.ui.Constants.BUTTON_CLEAR; -import static org.apache.qpid.management.ui.Constants.BUTTON_REFRESH; -import static org.apache.qpid.management.ui.Constants.DESCRIPTION; -import static org.apache.qpid.management.ui.Constants.FONT_BOLD; -import static org.apache.qpid.management.ui.Constants.FONT_BUTTON; -import static org.apache.qpid.management.ui.Constants.FONT_ITALIC; -import static org.apache.qpid.management.ui.Constants.SUBSCRIBE_BUTTON; -import static org.apache.qpid.management.ui.Constants.UNSUBSCRIBE_BUTTON; - -import java.util.List; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.NotificationInfoModel; -import org.apache.qpid.management.ui.model.NotificationObject; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; - -/** - * Creates control composite for Notifications tab - * @author Bhupendra Bhardwaj - */ -public class NotificationsTabControl extends VHNotificationsTabControl -{ - private static final String SELECT_NOTIFICATIONNAME = "Select Notification"; - private static final String SELECT_NOTIFICATIONTYPE = "Select Type"; - private SelectionListener selectionListener; - private SelectionListener comboListener; - - private Combo notificationNameCombo = null; - private Combo typesCombo = null; - private Label descriptionLabel = null; - private Button _subscribeButton = null; - private Button _unsubscribeButton = null; - - public NotificationsTabControl(TabFolder tabFolder) - { - super(tabFolder); - } - - protected void createWidgets() - { - selectionListener = new SelectionListenerImpl(); - comboListener = new ComboSelectionListener(); - createNotificationInfoComposite(); - //addFilterComposite(); - addButtons(); - createTableViewer(); - } - - /** - * Creates composite and populates for displaying Notification Information (name, type, description) - * and creates buttons for subscribing or unsubscribing for notifications - */ - private void createNotificationInfoComposite() - { - Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new FormLayout()); - - Label label = _toolkit.createLabel(composite, "Select the notification to subscribe or unsubscribe"); - label.setFont(ApplicationRegistry.getFont(FONT_BOLD)); - FormData formData = new FormData(); - formData.top = new FormAttachment(0, 10); - formData.left = new FormAttachment(0, 10); - label.setLayoutData(formData); - - notificationNameCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN); - formData = new FormData(); - formData.top = new FormAttachment(label, 10); - formData.left = new FormAttachment(0, 10); - formData.right = new FormAttachment(40); - notificationNameCombo.setLayoutData(formData); - notificationNameCombo.addSelectionListener(comboListener); - - typesCombo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN); - formData = new FormData(); - formData.top = new FormAttachment(label, 10); - formData.left = new FormAttachment(notificationNameCombo, 5); - formData.right = new FormAttachment(65); - typesCombo.setLayoutData(formData); - typesCombo.addSelectionListener(comboListener); - - _subscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER); - _subscribeButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - _subscribeButton.setText(SUBSCRIBE_BUTTON); - formData = new FormData(); - formData.top = new FormAttachment(label, 10); - formData.left = new FormAttachment(65, 10); - formData.width = 80; - _subscribeButton.setLayoutData(formData); - _subscribeButton.addSelectionListener(selectionListener); - - _unsubscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER); - _unsubscribeButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - _unsubscribeButton.setText(UNSUBSCRIBE_BUTTON); - formData = new FormData(); - formData.top = new FormAttachment(label, 10); - formData.left = new FormAttachment(_subscribeButton, 10); - formData.width = 80; - _unsubscribeButton.setLayoutData(formData); - _unsubscribeButton.addSelectionListener(selectionListener); - - Label fixedLabel = _toolkit.createLabel(composite, ""); - formData = new FormData(); - formData.top = new FormAttachment(notificationNameCombo, 5); - formData.left = new FormAttachment(0, 10); - fixedLabel.setLayoutData(formData); - fixedLabel.setText(DESCRIPTION + " : "); - fixedLabel.setFont(ApplicationRegistry.getFont(FONT_BOLD)); - - descriptionLabel = _toolkit.createLabel(composite, ""); - formData = new FormData(); - formData.top = new FormAttachment(notificationNameCombo, 5); - formData.left = new FormAttachment(fixedLabel, 10); - formData.right = new FormAttachment(100); - descriptionLabel.setLayoutData(formData); - descriptionLabel.setText(" "); - descriptionLabel.setFont(ApplicationRegistry.getFont(FONT_ITALIC)); - } - - /** - * Creates clear buttin and refresh button - */ - protected void addButtons() - { - Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout(2, true)); - - // Add Clear Button - _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); - _clearButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.LEAD, SWT.TOP, true, false); - gridData.widthHint = 80; - _clearButton.setLayoutData(gridData); - _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - serverRegistry.clearNotifications(_mbean, ss.toList()); - refresh(); - } - }); - - // Add Refresh Button - _refreshButton = _toolkit.createButton(composite, BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); - _refreshButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - gridData = new GridData(SWT.TRAIL, SWT.TOP, true, false); - gridData.widthHint = 80; - _refreshButton.setLayoutData(gridData); - _refreshButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - refresh(); - } - }); - } - - @Override - public void refresh(ManagedBean mbean) - { - _mbean = mbean; - _notifications = null; - _table.deselectAll(); - _tableViewer.getTable().clearAll(); - - if (_mbean == null) - { - _tableViewer.getTable().clearAll(); - _subscribeButton.setEnabled(false); - _unsubscribeButton.setEnabled(false); - return; - } - - if (!doesMBeanSendsNotification()) - { - Control[] children = _form.getBody().getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].setVisible(false); - } - - String name = (_mbean.getName() != null) ? _mbean.getName() : _mbean.getType(); - _form.setText(name + " does not send any notification"); - return; - } - - Control[] children = _form.getBody().getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].setVisible(true); - } - - populateNotificationInfo(); - workerRunning = true; - _form.layout(true); - _form.getBody().layout(true, true); - } - - public void refresh() - { - _notifications = null; - _table.deselectAll(); - _tableViewer.getTable().clearAll(); - } - - /** - * Fills the notification information widgets for selected mbean - */ - private void populateNotificationInfo() - { - notificationNameCombo.removeAll(); - NotificationInfoModel[] items = MBeanUtility.getNotificationInfo(_mbean); - if (items.length > 1) - { - notificationNameCombo.add(SELECT_NOTIFICATIONNAME); - } - - for (int i = 0; i < items.length; i++) - { - notificationNameCombo.add(items[i].getName()); - notificationNameCombo.setData(items[i].getName(), items[i]); - } - notificationNameCombo.select(0); - - typesCombo.removeAll(); - typesCombo.add("Select Type", 0); - typesCombo.select(0); - typesCombo.setEnabled(false); - - populateNotificationType(notificationNameCombo.getItem(0)); - checkForEnablingButtons(); - } - - /** - * Checks and the enabing/disabling of buttons - */ - private void checkForEnablingButtons() - { - int nameIndex = notificationNameCombo.getSelectionIndex(); - int itemCount = notificationNameCombo.getItems().length; - if ((itemCount > 1) && (nameIndex == 0)) - { - _subscribeButton.setEnabled(false); - _unsubscribeButton.setEnabled(false); - descriptionLabel.setText(""); - return; - } - - int typeIndex = typesCombo.getSelectionIndex(); - itemCount = typesCombo.getItems().length; - if ((itemCount > 1) && (typeIndex == 0)) - { - _subscribeButton.setEnabled(false); - _unsubscribeButton.setEnabled(false); - return; - } - - String type = typesCombo.getItem(typeIndex); - String name = notificationNameCombo.getItem(nameIndex); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - - if (serverRegistry.hasSubscribedForNotifications(_mbean, name, type)) - { - _subscribeButton.setEnabled(false); - _unsubscribeButton.setEnabled(true); - } - else - { - _subscribeButton.setEnabled(true); - _unsubscribeButton.setEnabled(false); - } - } - - private boolean doesMBeanSendsNotification() - { - NotificationInfoModel[] items = MBeanUtility.getNotificationInfo(_mbean); - if (items == null || items.length == 0) - return false; - else - return true; - } - - /** - * Selection listener for subscribing or unsubscribing the notifications - */ - private class SelectionListenerImpl extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - Button source = (Button)e.getSource(); - String type = typesCombo.getItem(typesCombo.getSelectionIndex()); - String name = notificationNameCombo.getItem(notificationNameCombo.getSelectionIndex()); - if (source == _unsubscribeButton) - { - try - { - MBeanUtility.removeNotificationListener(_mbean, name, type); - } - catch(Exception ex) - { - MBeanUtility.handleException(ex); - } - } - else if (source == _subscribeButton) - { - try - { - MBeanUtility.createNotificationlistener(_mbean, name, type); - } - catch(Exception ex) - { - MBeanUtility.handleException(ex); - } - } - checkForEnablingButtons(); - } - } - - /** - * Selection listener class for the Notification Name. The notification type and description will be - * displayed accordingly - */ - private class ComboSelectionListener extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - if (_mbean == null) - return; - - Combo combo = (Combo)e.getSource(); - if (combo == notificationNameCombo) - { - String selectedItem = combo.getItem(combo.getSelectionIndex()); - populateNotificationType(selectedItem); - } - checkForEnablingButtons(); - } - } - - private void populateNotificationType(String notificationName) - { - NotificationInfoModel data = (NotificationInfoModel)notificationNameCombo.getData(notificationName); - if (data == null) - { - descriptionLabel.setText(""); - typesCombo.select(0); - typesCombo.setEnabled(false); - return; - } - descriptionLabel.setText(data.getDescription()); - typesCombo.removeAll(); - typesCombo.setItems(data.getTypes()); - if (typesCombo.getItemCount() > 1) - { - typesCombo.add(SELECT_NOTIFICATIONTYPE, 0); - } - typesCombo.select(0); - typesCombo.setEnabled(true); - } - - /** - * Updates the table with new notifications received from mbean server for the selected mbean - */ - protected void updateTableViewer() - { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - List<NotificationObject> newList = serverRegistry.getNotifications(_mbean); - if (newList == null) - return; - - _notifications = newList; - _tableViewer.setInput(_notifications); - _tableViewer.refresh(); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java deleted file mode 100644 index 1774209dae..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NumberVerifyListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; - -/** - * Implementation of VeryfyListener for numeric values - * @author Bhupendra Bhardwaj - */ -public class NumberVerifyListener implements VerifyListener -{ - public void verifyText(VerifyEvent event) - { - String string = event.text; - char [] chars = new char [string.length ()]; - string.getChars (0, chars.length, chars, 0); - for (int i=0; i<chars.length; i++) - { - if (!('0' <= chars [i] && chars [i] <= '9')) - { - event.doit = false; - return; - } - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java deleted file mode 100644 index 12f38f1c74..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java +++ /dev/null @@ -1,898 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.TabularDataSupport; - -import static org.apache.qpid.management.ui.Constants.*; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.OperationData; -import org.apache.qpid.management.ui.model.ParameterData; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.Form; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * Control class for the MBean operations tab. It creates the required widgets - * for the selected MBean. - * @author Bhupendra Bhardwaj - */ -public class OperationTabControl extends TabControl -{ - private static final int heightForAParameter = 30; - private static final int labelWidth = 30; - private static final int valueWidth = labelWidth + 25; - - private FormToolkit _toolkit; - private Form _form; - private OperationData _opData; - - private SelectionListener operationExecutionListener = new OperationExecutionListener(); - private SelectionListener refreshListener = new RefreshListener(); - private SelectionListener parameterSelectionListener = new ParameterSelectionListener(); - private SelectionListener booleanSelectionListener = new BooleanSelectionListener(); - private VerifyListener verifyListener = new VerifyListenerImpl(); - private KeyListener keyListener = new KeyListenerImpl(); - private KeyListener headerBindingListener = new HeaderBindingKeyListener(); - - private Composite _headerComposite = null; - private Composite _paramsComposite = null; - private Composite _resultsComposite = null; - private Button _executionButton = null; - - // for customized method in header exchange - private HashMap<Text, Text> headerBindingHashMap = null; - private String _virtualHostName = null; - - public OperationTabControl(TabFolder tabFolder, OperationData opData) - { - super(tabFolder); - _toolkit = new FormToolkit(_tabFolder.getDisplay()); - _form = _toolkit.createForm(_tabFolder); - _form.getBody().setLayout(new GridLayout()); - _opData = opData; - createComposites(); - setHeader(); - } - - /** - * Form area is devided in four parts: - * Header composite - displays operaiton information - * Patameters composite - displays parameters if there - * Button - operation execution button - * Results composite - displays results for operations, which have - * no parameters but have some return value - */ - private void createComposites() - { - // - _headerComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - _headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - List<ParameterData> params = _opData.getParameters(); - if (params != null && !params.isEmpty()) - { - _paramsComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - } - _executionButton = _toolkit.createButton(_form.getBody(), BUTTON_EXECUTE, SWT.PUSH | SWT.CENTER); - _executionButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData layoutData = new GridData(SWT.CENTER, SWT.TOP, true, false); - layoutData.verticalIndent = 20; - _executionButton.setLayoutData(layoutData); - - _resultsComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - layoutData.verticalIndent = 20; - _resultsComposite.setLayoutData(layoutData); - _resultsComposite.setLayout(new GridLayout()); - } - - /** - * @see TabControl#getControl() - */ - public Control getControl() - { - return _form; - } - - @Override - public void refresh(ManagedBean mbean) - { - _mbean = mbean; - _virtualHostName = _mbean.getVirtualHostName(); - - // Setting the form to be invisible. Just in case the mbean server connection - // is done and it takes time in getting the response, then the ui should be blank - // instead of having half the widgets displayed. - _form.setVisible(false); - - ViewUtility.disposeChildren(_paramsComposite); - createParameterWidgets(); - - // Set button text and add appropriate listener to button. - // If there are no parameters and it is info operation, then operation gets executed - // and result is displayed - List<ParameterData> params = _opData.getParameters(); - if (params != null && !params.isEmpty()) - { - setButton(BUTTON_EXECUTE); - } - else if (_opData.getImpact() == OPERATION_IMPACT_ACTION) - { - setButton(BUTTON_EXECUTE); - } - else if (_opData.getImpact() == OPERATION_IMPACT_INFO) - { - setButton(BUTTON_REFRESH); - executeAndShowResults(); - } - - _form.setVisible(true); - layout(); - } - - public void layout() - { - _form.layout(true); - _form.getBody().layout(true, true); - } - - /** - * populates the header composite, containing the operation name and description. - */ - private void setHeader() - { - _form.setText(ViewUtility.getDisplayText(_opData.getName())); - _headerComposite.setLayout(new GridLayout(2, false)); - //operation description - Label label = _toolkit.createLabel(_headerComposite, DESCRIPTION + " : "); - label.setFont(ApplicationRegistry.getFont(FONT_BOLD)); - label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false)); - - label = _toolkit.createLabel(_headerComposite, _opData.getDescription()); - label.setFont(ApplicationRegistry.getFont(FONT_NORMAL)); - label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, true, false)); - - _headerComposite.layout(); - } - - /** - * Creates the widgets for operation parameters if there are any - */ - private void createParameterWidgets() - { - List<ParameterData> params = _opData.getParameters(); - if (params == null || params.isEmpty()) - { - return; - } - - // Customised parameter widgets - if (_mbean.isExchange() && - EXCHANGE_TYPE_VALUES[2].equals(_mbean.getProperty(EXCHANGE_TYPE)) && - _opData.getName().equalsIgnoreCase(OPERATION_CREATE_BINDING)) - { - customCreateNewBinding(); - return; - } - // end of Customised parameter widgets - - _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - _paramsComposite.setLayout(new FormLayout()); - int parameterPositionOffset = 0; - for (ParameterData param : params) - { - boolean valueInCombo = false; - Label label = _toolkit.createLabel(_paramsComposite, ViewUtility.getDisplayText(param.getName())); - FormData formData = new FormData(); - if (params.indexOf(param) == 0) - { - parameterPositionOffset = 0; - } - else - { - parameterPositionOffset += heightForAParameter; - } - formData.top = new FormAttachment(0, parameterPositionOffset + 2); - formData.right = new FormAttachment(labelWidth); - label.setLayoutData(formData); - label.setToolTipText(param.getDescription()); - - formData = new FormData(); - formData.top = new FormAttachment(0, parameterPositionOffset); - formData.left = new FormAttachment(label, 5); - formData.right = new FormAttachment(valueWidth); - // this will contain the list of items, if the list is to be made available to choose from - // e.g. the list of exchanges - String[] items = null; - if (param.getName().equals(QUEUE)) - { - List<String> qList = ApplicationRegistry.getServerRegistry(_mbean).getQueueNames(_virtualHostName); - // Customization for AMQQueueMBean method OPERATION_MOVE_MESSAGES - if (_opData.getName().equals(OPERATION_MOVE_MESSAGES)) - { - qList.remove(_mbean.getName()); - } - // End of Customization - items = qList.toArray(new String[0]); - } - else if (param.getName().equals(EXCHANGE)) - { - items = ApplicationRegistry.getServerRegistry(_mbean).getExchangeNames(_virtualHostName); - } - else if (param.getName().equals(EXCHANGE_TYPE)) - { - items = EXCHANGE_TYPE_VALUES; - } - else if (isUserListParameter(param)) - { - List<String> list = ApplicationRegistry.getServerRegistry(_mbean).getUsernames(); - if (list != null && !list.isEmpty()) - { - items = list.toArray(new String[0]); - } - } - - if (items != null) - { - org.eclipse.swt.widgets.List _list = new org.eclipse.swt.widgets.List(_paramsComposite, SWT.BORDER | SWT.V_SCROLL); - int listSize = _form.getClientArea().height * 2 / 3; - int itemsHeight = items.length * (_list.getItemHeight() + 2); - // Set a min height for the list widget (set it to min 4 items) - if (items.length < 4) - { - itemsHeight = 4 * (_list.getItemHeight() + 2); - } - - listSize = (listSize > itemsHeight) ? itemsHeight : listSize; - parameterPositionOffset = parameterPositionOffset + listSize; - formData.bottom = new FormAttachment(0, parameterPositionOffset); - _list.setLayoutData(formData); - _list.setData(param); - _list.setItems(items); - _list.addSelectionListener(parameterSelectionListener); - valueInCombo = true; - } - else if (param.isBoolean()) - { - Button booleanButton = _toolkit.createButton(_paramsComposite, "", SWT.CHECK); - booleanButton.setLayoutData(formData); - booleanButton.setData(param); - booleanButton.addSelectionListener(booleanSelectionListener); - valueInCombo = true; - } - else - { - int style = SWT.NONE; - if (PASSWORD.equalsIgnoreCase(param.getName())) - { - style = SWT.PASSWORD; - } - Text text = _toolkit.createText(_paramsComposite, "", style); - formData = new FormData(); - formData.top = new FormAttachment(0, parameterPositionOffset); - formData.left = new FormAttachment(label, 5); - formData.right = new FormAttachment(valueWidth); - text.setLayoutData(formData); - // Listener to assign value to the parameter - text.addKeyListener(keyListener); - // Listener to verify if the entered key is valid - text.addVerifyListener(verifyListener); - text.setData(param); - } - - // display the parameter data type next to the text field - if (valueInCombo) - { - label = _toolkit.createLabel(_paramsComposite, ""); - } - else if (PASSWORD.equalsIgnoreCase(param.getName())) - { - label = _toolkit.createLabel(_paramsComposite, "(String)"); - } - else - { - String str = param.getType(); - - if (param.getType().lastIndexOf(".") != -1) - str = param.getType().substring(1 + param.getType().lastIndexOf(".")); - - label = _toolkit.createLabel(_paramsComposite, "(" + str + ")"); - } - formData = new FormData(); - formData.top = new FormAttachment(0, parameterPositionOffset); - formData.left = new FormAttachment(valueWidth, 5); - label.setLayoutData(formData); - } - } - - private boolean isUserListParameter(ParameterData param) - { - if (_mbean.isAdmin() && param.getName().equals(OPERATION_PARAM_USERNAME) - && !_opData.getName().equals(OPERATION_CREATEUSER)) - { - return true; - } - - return false; - } - - /** - * Creates customized dispaly for a method "CreateNewBinding" for Headers exchange - * - */ - private void customCreateNewBinding() - { - headerBindingHashMap = new HashMap<Text, Text>(); - - _paramsComposite.setLayout(new GridLayout()); - _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); - final ScrolledComposite scrolledComposite = new ScrolledComposite(_paramsComposite, SWT.BORDER | SWT.V_SCROLL); - scrolledComposite.setExpandHorizontal(true); - scrolledComposite.setExpandVertical(true); - GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, true); - scrolledComposite.setLayoutData(layoutData); - scrolledComposite.setLayout(new GridLayout()); - - final Composite composite = _toolkit.createComposite(scrolledComposite, SWT.NONE); - scrolledComposite.setContent(composite); - layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - layoutData.verticalIndent = 20; - composite.setLayoutData(layoutData); - composite.setLayout(new FormLayout()); - - List<ParameterData> params = _opData.getParameters(); - ParameterData param = params.get(0); - // Queue selection widget - Label label = _toolkit.createLabel(composite, ViewUtility.getDisplayText(param.getName())); - FormData formData = new FormData(); - formData.top = new FormAttachment(0, 2); - formData.right = new FormAttachment(labelWidth); - label.setLayoutData(formData); - label.setToolTipText(param.getDescription()); - - formData = new FormData(); - formData.top = new FormAttachment(0); - formData.left = new FormAttachment(label, 5); - formData.right = new FormAttachment(valueWidth); - - Combo combo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN); - List<String> qList = ApplicationRegistry.getServerRegistry(_mbean).getQueueNames(_virtualHostName); - combo.setItems(qList.toArray(new String[0])); - combo.add("Select Queue", 0); - combo.select(0); - combo.setLayoutData(formData); - combo.setData(param); - combo.addSelectionListener(parameterSelectionListener); - - // Binding creation widgets - createARowForCreatingHeadersBinding(composite, 1); - createARowForCreatingHeadersBinding(composite, 2); - createARowForCreatingHeadersBinding(composite, 3); - createARowForCreatingHeadersBinding(composite, 4); - createARowForCreatingHeadersBinding(composite, 5); - createARowForCreatingHeadersBinding(composite, 6); - createARowForCreatingHeadersBinding(composite, 7); - createARowForCreatingHeadersBinding(composite, 8); - - final Button addMoreButton = _toolkit.createButton(composite, "Add More", SWT.PUSH); - formData = new FormData(); - formData.top = new FormAttachment(0, heightForAParameter); - formData.left = new FormAttachment(70, 5); - addMoreButton.setLayoutData(formData); - addMoreButton.setData("rowCount", 8); - addMoreButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - int count = Integer.parseInt(addMoreButton.getData("rowCount").toString()); - createARowForCreatingHeadersBinding(composite, ++count); - addMoreButton.setData("rowCount", count); - scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - composite.layout(); - _form.layout(); - } - }); - - scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - composite.layout(); - } - - /** - * Adds a row for adding a binding for Headers Exchange. Used by the method, which creates the customized - * layout and widgest for Header's exchange method createNewBinding. - * @param parent composite - * @param rowCount - row number - */ - private void createARowForCreatingHeadersBinding(Composite parent, int rowCount) - { - Label key = _toolkit.createLabel(parent, "Name"); - FormData formData = new FormData(); - formData.top = new FormAttachment(0, rowCount * heightForAParameter + 2); - formData.right = new FormAttachment(15); - key.setLayoutData(formData); - - Text keyText = _toolkit.createText(parent, "", SWT.NONE); - formData = new FormData(); - formData.top = new FormAttachment(0, rowCount * heightForAParameter); - formData.left = new FormAttachment(key, 5); - formData.right = new FormAttachment(40); - keyText.setLayoutData(formData); - keyText.addKeyListener(headerBindingListener); - - Label value = _toolkit.createLabel(parent, "Value"); - formData = new FormData(); - formData.top = new FormAttachment(0, rowCount * heightForAParameter + 2); - formData.right = new FormAttachment(45); - value.setLayoutData(formData); - - Text valueText = _toolkit.createText(parent, "", SWT.NONE); - formData = new FormData(); - formData.top = new FormAttachment(0, rowCount * heightForAParameter); - formData.left = new FormAttachment(value, 5); - formData.right = new FormAttachment(70); - valueText.setLayoutData(formData); - valueText.addKeyListener(headerBindingListener); - - // Add these to the map, to retrieve the values while setting the parameter value - headerBindingHashMap.put(keyText, valueText); - } - - /** - * Sets text and listener for the operation execution button - * @param text - */ - private void setButton(String text) - { - _executionButton.setText(text); - _executionButton.removeSelectionListener(refreshListener); - _executionButton.removeSelectionListener(operationExecutionListener); - - if (BUTTON_EXECUTE.equals(text)) - { - _executionButton.addSelectionListener(operationExecutionListener); - } - else - { - _executionButton.addSelectionListener(refreshListener); - } - } - - /** - * displays the operation result in a pop-up window - * @param result - */ - private void populateResults(Object result) - { - Display display = Display.getCurrent(); - int width = 610; - int height = 400; - Shell shell = ViewUtility.createPopupShell(RESULT, width, height); - shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE)); - ViewUtility.populateCompositeWithData(_toolkit, shell, result); - - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - shell.dispose(); - } - - /** - * Clears the parameter values of the operation - */ - private void clearParameters() - { - List<ParameterData> params = _opData.getParameters(); - if (params != null && !params.isEmpty()) - { - for (ParameterData param : params) - { - param.setDefaultValue(); - } - } - } - - /** - * Clears the values entered by the user from parameter value widgets - * @param control - */ - private void clearParameterValues(Composite control) - { - if (control == null || (control.isDisposed())) - return; - - Control[] controls = control.getChildren(); - if (controls == null || controls.length == 0) - return; - - for (int i = 0; i < controls.length; i++) - { - if (controls[i] instanceof Combo) - ((Combo)controls[i]).select(0); - if (controls[i] instanceof org.eclipse.swt.widgets.List) - ((org.eclipse.swt.widgets.List)controls[i]).deselectAll(); - else if (controls[i] instanceof Text) - ((Text)controls[i]).setText(""); - else if (controls[i] instanceof Button) - ((Button)controls[i]).setSelection(false); - else if (controls[i] instanceof Composite) - clearParameterValues((Composite)controls[i]); - } - } - - /** - * Listener class for operation execution events - */ - private class OperationExecutionListener extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - List<ParameterData> params = _opData.getParameters(); - if (params != null && !params.isEmpty()) - { - for (ParameterData param : params) - { - if (param.getValue() == null || param.getValue().toString().length() == 0) - { - // Customized check, because for this parameter null is allowed - if (param.getName().equals(ATTRIBUTE_QUEUE_OWNER) && - _opData.getName().equals(OPERATION_CREATE_QUEUE)) - { - continue; - } - // End of custom code - - ViewUtility.popupInfoMessage(_form.getText(), "Please select the " + ViewUtility.getDisplayText(param.getName())); - return; - } - - // customized for passwords - String securityMechanism = ApplicationRegistry.getSecurityMechanism(); - if ((MECH_CRAMMD5.equals(securityMechanism)) && PASSWORD.equalsIgnoreCase(param.getName())) - { - try - { - param.setValue(ViewUtility.getMD5HashedCharArray(param.getValue())); - } - catch (Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - return; - } - } - // end of customization - } - } - - if (_opData.getImpact() == OPERATION_IMPACT_ACTION) - { - String bean = _mbean.getName() == null ? _mbean.getType() : _mbean.getName(); - int response = ViewUtility.popupConfirmationMessage(bean, "Do you want to " + _form.getText()+ " ?"); - if (response == SWT.YES) - { - executeAndShowResults(); - } - } - else - { - executeAndShowResults(); - } - - if (_mbean.isAdmin() && _opData.getName().equals(OPERATION_DELETEUSER)) - { - refresh(_mbean); - } - else - { - clearParameters(); - clearParameterValues(_paramsComposite); - } - } - } - - // Listener for the "Refresh" execution button - private class RefreshListener extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - executeAndShowResults(); - } - } - - /** - * Executres the operation, gets the result from server and displays to the user - */ - private void executeAndShowResults() - { - Object result = null; - try - { - result = MBeanUtility.execute(_mbean, _opData); - } - catch(Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - return; - } - - // Custom code for Admin mbean operation - /* These custome codes here are to make the GUI look more user friendly. - * Here we are adding the users to a list, which will be used to list username to be selected on - * pages like "delete user", "set password" instead of typing the username - */ - if (_mbean.isAdmin()) - { - if (_opData.getName().equals(OPERATION_VIEWUSERS)) - { - ApplicationRegistry.getServerRegistry(_mbean).setUserList(extractUserList(result)); - } - else if (_opData.getName().equals(OPERATION_DELETEUSER)) - { - List<String> list = ApplicationRegistry.getServerRegistry(_mbean).getUsernames(); - Object userName = _opData.getParameterValue(OPERATION_PARAM_USERNAME); - if ((list != null) && !list.isEmpty() && (userName != null)) - { - list.remove(userName); - ApplicationRegistry.getServerRegistry(_mbean).setUserList(list); - } - } - else if (_opData.getName().equals(OPERATION_CREATEUSER)) - { - List<String> list = ApplicationRegistry.getServerRegistry(_mbean).getUsernames(); - Object userName = _opData.getParameterValue(OPERATION_PARAM_USERNAME); - if ((list != null) && !list.isEmpty() && (userName != null)) - { - list.add(userName.toString()); - ApplicationRegistry.getServerRegistry(_mbean).setUserList(list); - } - } - } - // end of custom code - - // Some mbeans have only "type" and no "name". - String title = _mbean.getType(); - if (_mbean.getName() != null && _mbean.getName().length() != 0) - { - title = _mbean.getName(); - } - - if (_opData.isReturnTypeVoid()) - { - ViewUtility.popupInfoMessage(title, OPERATION_SUCCESSFUL); - } - else if (_opData.isReturnTypeBoolean()) - { - boolean success = Boolean.parseBoolean(result.toString()); - String message = success ? OPERATION_SUCCESSFUL : OPERATION_UNSUCCESSFUL; - ViewUtility.popupInfoMessage(title, message); - } - else if (_opData.getParameters() != null && !_opData.getParameters().isEmpty()) - { - populateResults(result); - } - else - { - ViewUtility.disposeChildren(_resultsComposite); - ViewUtility.populateCompositeWithData(_toolkit, _resultsComposite, result); - _resultsComposite.layout(); - _form.layout(); - } - - } - - private List<String> extractUserList(Object result) - { - if (!(result instanceof TabularDataSupport)) - { - return null; - } - - TabularDataSupport tabularData = (TabularDataSupport)result; - Collection<Object> records = tabularData.values(); - List<String> list = new ArrayList<String>(); - for (Object o : records) - { - CompositeData data = (CompositeData) o; - if (data.containsKey(USERNAME)) - { - list.add(data.get(USERNAME).toString()); - } - } - - return list; - } - - /** - * Listener class for the operation parameters widget - */ - private class ParameterSelectionListener extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - ParameterData parameter = (ParameterData)e.widget.getData(); - parameter.setValue(null); - if (e.widget instanceof Combo) - { - Combo combo = (Combo)e.widget; - if (combo.getSelectionIndex() > 0) - { - String item = combo.getItem(combo.getSelectionIndex()); - parameter.setValueFromString(item); - } - } - else if (e.widget instanceof org.eclipse.swt.widgets.List) - { - org.eclipse.swt.widgets.List list = (org.eclipse.swt.widgets.List)e.widget; - String[] selectedItems = list.getSelection(); - if (selectedItems.length > 0) - { - parameter.setValueFromString(selectedItems[0]); - } - } - } - } - - /** - * Listener class for boolean parameter widgets - */ - private class BooleanSelectionListener extends SelectionAdapter - { - public void widgetSelected(SelectionEvent e) - { - ParameterData parameter = (ParameterData)(e.widget.getData()); - if (e.widget instanceof Button) - { - Button button = (Button)e.widget; - parameter.setValue(button.getSelection()); - } - else if (e.widget instanceof Combo) - { - Combo combo = (Combo)e.widget; - String item = combo.getItem(combo.getSelectionIndex()); - parameter.setValueFromString(item); - } - } - } - - /** - * Listener class for the operation parameter value widget (Text field) - */ - private class KeyListenerImpl extends KeyAdapter - { - public void keyReleased(KeyEvent e) - { - if (!(e.widget instanceof Text)) - return; - - Text text = (Text)e.widget; - // Get the parameters widget and assign the text to the parameter - String strValue = text.getText(); - ParameterData parameter = (ParameterData)text.getData(); - try - { - parameter.setValueFromString(strValue); - } - catch(Exception ex) - { - // Exception occured in setting parameter value. - // ignore it. The value will not be assigned to the parameter - } - } - } - - /** - * Listener class for HeaderExchange's new binding widgets. Used when the new bindings are - * being created for Header's Exchange - */ - private class HeaderBindingKeyListener extends KeyAdapter - { - public void keyReleased(KeyEvent e) - { - ParameterData param = _opData.getParameters().get(1); - StringBuffer paramValue = new StringBuffer(); - for (Entry<Text, Text> entry : headerBindingHashMap.entrySet()) - { - - Text nameText = entry.getKey(); - String name = nameText.getText(); - Text valueText = entry.getValue(); - String value = valueText.getText(); - if ((name != null) && (name.length() != 0) && (value != null) && (value.length() != 0)) - { - if (paramValue.length() != 0) - { - paramValue.append(","); - } - paramValue.append(name + "=" + value); - } - } - - param.setValue(paramValue.toString()); - } - } - - /** - * Listener class for verifying the user input with parameter type - */ - private class VerifyListenerImpl implements VerifyListener - { - public void verifyText(VerifyEvent event) - { - ParameterData parameter = (ParameterData)event.widget.getData(); - String text = event.text; - char [] chars = new char [text.length ()]; - text.getChars(0, chars.length, chars, 0); - String type = parameter.getType(); - if (type.equals("int") || type.equals("java.lang.Integer") || - type.equals("long") || type.equals("java.lang.Long")) - { - for (int i=0; i<chars.length; i++) - { - if (!('0' <= chars [i] && chars [i] <= '9')) - { - event.doit = false; - return; - } - } - - } - } - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java deleted file mode 100644 index 31a0bc857b..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.views; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.jmx.MBeanUtility; -import org.apache.qpid.management.ui.model.AttributeData; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.TabFolder; - -/** - * Controller class, which takes care of displaying appropriate information and widgets for Queues. - * This allows user to select Queues and add those to the navigation view - */ -public class QueueTypeTabControl extends MBeanTypeTabControl -{ - private boolean _showTempQueues = false; - private Button _sortBySizeButton = null; - private Button _sortByConsumercountButton = null; - private Button _sortByNameButton = null; - private Button _showTempQueuesButton = null; - - private ComparatorImpl _sorterByAttribute = new ComparatorImpl(); - - // Map required for sorting queues based on attribute values - private Map<AttributeData, ManagedBean> _queueDepthMap = new LinkedHashMap<AttributeData, ManagedBean>(); - // Map used for sorting Queues based on consumer count - private Map<AttributeData, ManagedBean> _queueConsumerCountMap = new LinkedHashMap<AttributeData, ManagedBean>(); - - - public QueueTypeTabControl(TabFolder tabFolder) - { - super(tabFolder, Constants.QUEUE); - createWidgets(); - } - - protected void createWidgets() - { - createHeaderComposite(getFormComposite()); - createButtonsComposite(getFormComposite()); - createListComposite(); - } - - @Override - public void refresh() throws Exception - { - setLabelValues(); - selectDefaultSortingButton(); - populateList(); - layout(); - } - - /** - * populates the map with mbean name and the mbean object. - * @throws Exception - */ - protected void populateList() throws Exception - { - // map should be cleared before populating it with new values - getMBeansMap().clear(); - _queueDepthMap.clear(); - _queueConsumerCountMap.clear(); - - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - String[] items = null; - java.util.List<ManagedBean> list = null; - - // populate the map and list with appropriate mbeans - list = serverRegistry.getQueues(MBeanView.getVirtualHost()); - items = getQueueItems(list); - // sort the refreshed list in the selected order - if (_sortBySizeButton.getSelection()) - { - sortQueuesByQueueDepth(); - } - else if (_sortByConsumercountButton.getSelection()) - { - sortQueuesByConsumerCount(); - } - else - { - getListWidget().setItems(items); - } - } - - private void selectDefaultSortingButton() - { - _sortByNameButton.setSelection(true); - _sortBySizeButton.setSelection(false); - _sortByConsumercountButton.setSelection(false); - - _showTempQueues = false; - _showTempQueuesButton.setSelection(_showTempQueues); - } - - protected void createListComposite() - { - // Composite to contain the item list - Composite composite = getToolkit().createComposite(getFormComposite()); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - composite.setLayoutData(gridData); - GridLayout layout = new GridLayout(2, true); - layout.verticalSpacing = 0; - composite.setLayout(layout); - - createListComposite(composite); - - // Composite to contain buttons like - Sort by size - Composite _sortingComposite = getToolkit().createComposite(composite); - gridData = new GridData(SWT.FILL, SWT.FILL, true, true); - _sortingComposite.setLayoutData(gridData); - GridLayout gridLayout = new GridLayout(); - gridLayout.verticalSpacing = 20; - _sortingComposite.setLayout(gridLayout); - - Group sortingGroup = new Group(_sortingComposite, SWT.SHADOW_NONE); - sortingGroup.setBackground(_sortingComposite.getBackground()); - sortingGroup.setText(" Sort List By "); - sortingGroup.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); - gridData = new GridData(SWT.CENTER, SWT.TOP, true, false); - sortingGroup.setLayoutData(gridData); - sortingGroup.setLayout(new GridLayout()); - - _sortByNameButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_NAME, SWT.RADIO); - gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false); - _sortByNameButton.setLayoutData(gridData); - _sortByNameButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - try - { - // sort the stored list of items - java.util.List<String> list = new ArrayList<String>(getMBeansMap().keySet()); - Collections.sort(list); - getListWidget().setItems(list.toArray(new String[0])); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - - _sortBySizeButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_DEPTH, SWT.RADIO); - gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false); - _sortBySizeButton.setLayoutData(gridData); - _sortBySizeButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - try - { - // sort the stored list of items - sortQueuesByQueueDepth(); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - - _sortByConsumercountButton = getToolkit().createButton(sortingGroup, Constants.QUEUE_SORT_BY_CONSUMERCOUNT, SWT.RADIO); - gridData = new GridData(SWT.LEAD, SWT.CENTER, true, false); - _sortByConsumercountButton.setLayoutData(gridData); - _sortByConsumercountButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - try - { - sortQueuesByConsumerCount(); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - - _showTempQueuesButton = getToolkit().createButton(_sortingComposite, Constants.QUEUE_SHOW_TEMP_QUEUES, SWT.CHECK); - _showTempQueuesButton.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); - _showTempQueuesButton.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e) - { - Button button = (Button)e.widget; - _showTempQueues = button.getSelection(); - try - { - populateList(); - } - catch (Exception ex) - { - MBeanUtility.handleException(ex); - } - } - }); - } - - - private String[] getQueueItems(java.util.List<ManagedBean> list) throws Exception - { - if (list == null) - return new String[0]; - - // Sort the list. It will keep the mbeans in sorted order in the _queueMap, which is required for - // sorting the queue according to size etc - Collections.sort(list, getMBeanNameSorter()); - java.util.List<String> items = new ArrayList<String>();; - int i = 0; - for (ManagedBean mbean : list) - { - if ((!_showTempQueues && mbean.isTempQueue())) - { - continue; - } - AttributeData data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_DEPTH); - String value = mbean.getName() + " (" + data.getValue().toString() + " KB)"; - items.add(value); - //items[i] = mbean.getName() + " (" + value + " KB)"; - getMBeansMap().put(value, mbean); - _queueDepthMap.put(data, mbean); - data = MBeanUtility.getAttributeData(mbean, Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT); - _queueConsumerCountMap.put(data, mbean); - i++; - } - - return items.toArray(new String[0]); - } - - - private void sortQueuesByQueueDepth() - { - // Queues are already in the alphabetically sorted order in _queueMap, now sort for queueDepth - java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueDepthMap.keySet()); - Collections.sort(list, _sorterByAttribute); - - String[] items = new String[list.size()]; - int i = 0; - for (AttributeData data : list) - { - ManagedBean mbean = _queueDepthMap.get(data); - String value = data.getValue().toString(); - items[i++] = mbean.getName() + " (" + value + " KB)"; - } - getListWidget().setItems(items); - } - - private void sortQueuesByConsumerCount() - { - java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueConsumerCountMap.keySet()); - Collections.sort(list, _sorterByAttribute); - - String[] items = new String[list.size()]; - int i = 0; - for (AttributeData data : list) - { - ManagedBean mbean = _queueConsumerCountMap.get(data); - String value = data.getValue().toString(); - items[i++] = mbean.getName() + " (" + value + " )"; - } - getListWidget().setItems(items); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java deleted file mode 100644 index c13c92066c..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import java.util.ArrayList; - -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.model.OperationData; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.TabFolder; - -/** - * Abstract class for all the control classes of tabs. - * @author Bhupendra Bhardwaj - */ -public abstract class TabControl -{ - protected ManagedBean _mbean = null; - protected TabFolder _tabFolder = null; - - private static java.util.List<String> simpleTypes = new ArrayList<String>(); - - static - { - simpleTypes.add("java.math.BigDecimal"); - simpleTypes.add("java.math.BigInteger"); - simpleTypes.add("java.lang.Boolean"); - simpleTypes.add("java.lang.Byte"); - simpleTypes.add("java.lang.Character"); - simpleTypes.add("java.util.Date"); - simpleTypes.add("java.lang.Double"); - simpleTypes.add("java.lang.Float"); - simpleTypes.add("java.lang.Integer"); - simpleTypes.add("java.lang.Long"); - simpleTypes.add("javax.management.ObjectName"); - simpleTypes.add("java.lang.Short"); - simpleTypes.add("java.lang.String"); - simpleTypes.add("boolean"); - } - - public TabControl(TabFolder tabFolder) - { - _tabFolder = tabFolder; - } - - /** - * @return controller composite for the tab - */ - public Control getControl() - { - return null; - } - - public void refresh(ManagedBean mbean) - { - if (mbean == null) - { - refresh(); - } - } - - public void refresh() - { - - } - - public void refresh(ManagedBean mbean, OperationData opData) - { - - } - - /** - * Sets focus on a widget - */ - public void setFocus() - { - - } - - public boolean isSimpleType(Object data) - { - return simpleTypes.contains(data.getClass().getName()); - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java deleted file mode 100644 index 9545ed9876..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.qpid.management.ui.Constants; -import org.apache.qpid.management.ui.ManagedBean; -import org.apache.qpid.management.ui.ManagedObject; - -public class TreeObject -{ - private String _name; - private String _type; - private String _virtualHost; - private TreeObject _parent; - private List<TreeObject> _children = new ArrayList<TreeObject>(); - private ManagedObject _object; - - public TreeObject(String name, String type) - { - this._name = name; - this._type = type; - } - - public TreeObject(ManagedObject obj) - { - _name = obj.getName(); - if (_name == null && (obj instanceof ManagedBean)) - { - String[] types = ((ManagedBean)obj).getType().split("\\."); - _name = types[types.length - 1]; - } - this._type = Constants.MBEAN; - this._object = obj; - } - - public void addChild(TreeObject child) - { - _children.add(child); - } - - public void addChildren(List<TreeObject> subList) - { - _children.addAll(subList); - } - - public List<TreeObject> getChildren() - { - return _children; - } - - public void setChildren(List<TreeObject> children) - { - this._children = children; - } - - public void setName(String value) - { - _name = value; - } - - public String getName() - { - return _name; - } - public String getType() - { - return _type; - } - - public String getVirtualHost() - { - // To make it work with the broker with no virtual host implementation - return _virtualHost == null ? Constants.DEFAULT_VH : _virtualHost; - } - - public void setVirtualHost(String vHost) - { - _virtualHost = vHost; - } - - public ManagedObject getManagedObject() - { - return _object; - } - - public void setManagedObject(ManagedObject obj) - { - this._object = obj; - } - - public TreeObject getParent() - { - return _parent; - } - - public void setParent(TreeObject parent) - { - this._parent = parent; - - if (parent != null) - { - parent.addChild(this); - } - } -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java deleted file mode 100644 index be25707bd3..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/VHNotificationsTabControl.java +++ /dev/null @@ -1,483 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.management.ui.views; - -import static org.apache.qpid.management.ui.Constants.BUTTON_CLEAR; -import static org.apache.qpid.management.ui.Constants.BUTTON_REFRESH; -import static org.apache.qpid.management.ui.Constants.CONSOLE_IMAGE; -import static org.apache.qpid.management.ui.Constants.FONT_BUTTON; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.qpid.management.ui.ApplicationRegistry; -import org.apache.qpid.management.ui.ServerRegistry; -import org.apache.qpid.management.ui.model.NotificationObject; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.Form; -import org.eclipse.ui.forms.widgets.FormToolkit; - -public class VHNotificationsTabControl extends TabControl -{ - protected FormToolkit _toolkit; - protected Form _form; - protected Table _table = null; - protected TableViewer _tableViewer = null; - - protected Thread worker = null; - - protected List<NotificationObject> _notifications = null; - - private static final String COLUMN_OBJ = "Object Name"; - private static final String COLUMN_SEQ = "Sequence No"; - private static final String COLUMN_TIME = "TimeStamp"; - private static final String COLUMN_TYPE = "Type"; - private static final String COLUMN_MSG = "Notification Message"; - protected static final String[] _tableTitles = new String [] { - COLUMN_OBJ, - COLUMN_SEQ, - COLUMN_TIME, - COLUMN_TYPE, - COLUMN_MSG - }; - - protected Button _clearButton = null; - protected Button _refreshButton = null; - - public VHNotificationsTabControl(TabFolder tabFolder) - { - super(tabFolder); - _toolkit = new FormToolkit(_tabFolder.getDisplay()); - _form = _toolkit.createForm(_tabFolder); - GridLayout gridLayout = new GridLayout(); - gridLayout.marginWidth = 0; - gridLayout.marginHeight = 0; - _form.getBody().setLayout(gridLayout); - - worker = new Thread(new Worker()); - worker.start(); - } - - protected void createWidgets() - { - addButtons(); - createTableViewer(); - } - - /** - * @see TabControl#getControl() - */ - public Control getControl() - { - if (_table == null) - { - createWidgets(); - } - return _form; - } - - /** - * Creates clear buttin and refresh button - */ - protected void addButtons() - { - Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - composite.setLayout(new GridLayout(2, true)); - - // Add Clear Button - _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); - _clearButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - GridData gridData = new GridData(SWT.LEAD, SWT.TOP, true, false); - gridData.widthHint = 80; - _clearButton.setLayoutData(gridData); - _clearButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - //TODO : Get selected rows and clear those - IStructuredSelection ss = (IStructuredSelection)_tableViewer.getSelection(); - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - serverRegistry.clearNotifications(null, ss.toList()); - refresh(); - } - }); - - // Add Refresh Button - _refreshButton = _toolkit.createButton(composite, BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); - _refreshButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); - gridData = new GridData(SWT.TRAIL, SWT.TOP, true, false); - gridData.widthHint = 80; - _refreshButton.setLayoutData(gridData); - _refreshButton.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - refresh(); - } - }); - } - - /** - * Creates table to display notifications - */ - private void createTable() - { - _table = _toolkit.createTable(_form.getBody(), SWT.MULTI | SWT.FULL_SELECTION); - _table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - TableColumn column = new TableColumn(_table, SWT.NONE); - column.setText(_tableTitles[0]); - column.setWidth(100); - - column = new TableColumn(_table, SWT.NONE); - column.setText(_tableTitles[1]); - column.setWidth(100); - - column = new TableColumn(_table, SWT.NONE); - column.setText(_tableTitles[2]); - column.setWidth(130); - - column = new TableColumn(_table, SWT.NONE); - column.setText(_tableTitles[3]); - column.setWidth(100); - - column = new TableColumn(_table, SWT.NONE); - column.setText(_tableTitles[4]); - column.setWidth(500); - - _table.setHeaderVisible(true); - _table.setLinesVisible(true); - } - - /** - * Creates JFace viewer for the notifications table - */ - protected void createTableViewer() - { - createTable(); - _tableViewer = new TableViewer(_table); - //_tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - _tableViewer.setUseHashlookup(true); - _tableViewer.setContentProvider(new ContentProviderImpl()); - _tableViewer.setLabelProvider(new LabelProviderImpl()); - _tableViewer.setColumnProperties(_tableTitles); - /* - CellEditor[] cellEditors = new CellEditor[_tableTitles.length]; - TextCellEditor textEditor = new TextCellEditor(table); - cellEditors[0] = textEditor; - textEditor = new TextCellEditor(table); - cellEditors[1] = textEditor; - textEditor = new TextCellEditor(table); - cellEditors[2] = textEditor; - textEditor = new TextCellEditor(table); - cellEditors[3] = textEditor; - - // Assign the cell editors to the viewer - _tableViewer.setCellEditors(cellEditors); - _tableViewer.setCellModifier(new TableCellModifier()); - */ - - addTableListeners(); - - //_tableViewer.addSelectionChangedListener(new ); - - //_notificationDetails = new Composite(_tabControl, SWT.BORDER); - //_notificationDetails.setLayoutData(new GridData(GridData.FILL_BOTH)); - - //_tabControl.layout(); - //viewerComposite.layout(); - } - - /** - * Adds listeners to the viewer for displaying notification details - */ - protected void addTableListeners() - { - _tableViewer.addDoubleClickListener(new IDoubleClickListener() - { - Display display = null; - Shell shell = null; - public void doubleClick(DoubleClickEvent event) - { - display = Display.getCurrent(); - shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX | SWT.RESIZE); - shell.setText("Notification"); - shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE)); - - int x = display.getBounds().width; - int y = display.getBounds().height; - shell.setBounds(x/4, y/4, x/2, y/3); - StructuredSelection selection = (StructuredSelection)event.getSelection(); - createPopupContents((NotificationObject)selection.getFirstElement()); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - //If you create it, you dispose it. - shell.dispose(); - } - - private void createPopupContents(NotificationObject obj) - { - shell.setLayout(new GridLayout()); - - Composite parent = _toolkit.createComposite(shell, SWT.NONE); - parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - GridLayout layout = new GridLayout(4, true); - parent.setLayout(layout); - - // Object name record - Label key = _toolkit.createLabel(parent, COLUMN_OBJ, SWT.TRAIL); - GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false,1,1); - key.setLayoutData(layoutData); - Text value = _toolkit.createText(parent, obj.getSourceName(), SWT.BEGINNING | SWT.BORDER |SWT.READ_ONLY); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1)); - - // Sequence no record - key = _toolkit.createLabel(parent, COLUMN_SEQ, SWT.TRAIL); - layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false,1,1); - key.setLayoutData(layoutData); - value = _toolkit.createText(parent, ""+obj.getSequenceNo(), SWT.BEGINNING | SWT.BORDER |SWT.READ_ONLY); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1)); - - // Time row - key = _toolkit.createLabel(parent, COLUMN_TIME, SWT.TRAIL); - key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1)); - value = _toolkit.createText(parent, obj.getTimeStamp(), SWT.BEGINNING | SWT.BORDER | SWT.READ_ONLY); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1)); - - key = _toolkit.createLabel(parent, COLUMN_TYPE, SWT.TRAIL); - key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1)); - value = _toolkit.createText(parent, obj.getType(), SWT.BEGINNING | SWT.BORDER | SWT.READ_ONLY); - value.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false,3,1)); - - key = _toolkit.createLabel(parent, COLUMN_MSG, SWT.TRAIL); - key.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, true, false,1,1)); - value = _toolkit.createText(parent, obj.getMessage(), SWT.MULTI | SWT.WRAP| SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); - gridData.heightHint = 100; - value.setLayoutData(gridData); - } - }); - } - - public void refresh() - { - _notifications = null; - _table.deselectAll(); - _tableViewer.getTable().clearAll(); - - Control[] children = _form.getBody().getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].setVisible(true); - } - - workerRunning = true; - _form.layout(true); - _form.getBody().layout(true, true); - } - - /** - * Content provider class for the table viewer - */ - protected class ContentProviderImpl implements IStructuredContentProvider, INotificationViewer - { - public void inputChanged(Viewer v, Object oldInput, Object newInput) - { - - } - public void dispose() - { - - } - public Object[] getElements(Object parent) - { - return _notifications.toArray(new NotificationObject[0]); - } - public void addNotification(NotificationObject notification) - { - _tableViewer.add(notification); - } - - public void addNotification(List<NotificationObject> notificationList) - { - _tableViewer.add(notificationList.toArray(new NotificationObject[0])); - } - } - - /** - * Label provider for the table viewer - */ - protected class LabelProviderImpl implements ITableLabelProvider - { - List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>(); - public void addListener(ILabelProviderListener listener) - { - listeners.add(listener); - } - - public void dispose(){ - - } - - public Image getColumnImage(Object element, int columnIndex) - { - return null; - } - - public String getColumnText(Object element, int columnIndex) - { - String result = null; - NotificationObject t = (NotificationObject)element; - switch(columnIndex) - { - case 0 : - result = t.getSourceName(); - break; - case 1 : - result = String.valueOf(t.getSequenceNo()); - break; - case 2 : - result = String.valueOf(t.getTimeStamp()); - break; - case 3 : - result = t.getType(); - break; - case 4 : - result = t.getMessage(); - break; - default : - result = ""; - } - - return result; - } - - public boolean isLabelProperty(Object element, String property) - { - return false; - } - - public void removeListener(ILabelProviderListener listener) - { - listeners.remove(listener); - } - } // end of LabelProviderImpl - - protected boolean workerRunning = false; - protected void setWorkerRunning(boolean running) - { - workerRunning = running; - } - - /** - * Worker class which keeps looking if there are new notifications coming from server for the selected mbean - */ - private class Worker implements Runnable - { - public void run() - { - Display display = _tabFolder.getDisplay(); - while(true) - { - if (!workerRunning || display == null) - { - sleep(); - continue; - } - - display.syncExec(new Runnable() - { - public void run() - { - if (_form == null || _form.isDisposed()) - return; - setWorkerRunning(_form.isVisible()); - if (!workerRunning) return; - - updateTableViewer(); - } - }); - - sleep(); - } - } - - private void sleep() - { - try - { - Thread.sleep(2000); - } - catch(Exception ex) - { - - } - } - } - - /** - * Updates the table with new notifications received from mbean server for all mbeans - */ - protected void updateTableViewer() - { - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(MBeanView.getServer()); - List<NotificationObject> newList = serverRegistry.getNotifications(null); - if (newList == null) - return; - - _notifications = newList; - _tableViewer.setInput(_notifications); - _tableViewer.refresh(); - } - -} diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java deleted file mode 100644 index 4a441d3ae5..0000000000 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java +++ /dev/null @@ -1,979 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui.views; - -import org.apache.commons.codec.binary.Hex; -import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.SelectionAdapter; -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.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.swt.widgets.ScrollBar; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; - -import javax.management.openmbean.ArrayType; -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.CompositeDataSupport; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.TabularDataSupport; -import javax.management.openmbean.TabularType; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Set; - - -/** - * Utility Class for displaying OpenMbean data types by creating required SWT widgets - * @author Bhupendra Bhardwaj - */ -public class ViewUtility -{ - public static final String OP_NAME = "operation_name"; - public static final String OP_PARAMS = "parameters"; - public static final String PARAMS_TEXT = "text"; - - public static final String FIRST = "First"; - public static final String LAST = "Last"; - public static final String NEXT = "Next"; - public static final String PREV = "Previous"; - public static final String INDEX = "Index"; - - private static final Comparator tabularDataComparator = new TabularDataComparator(); - - private static List<String> SUPPORTED_ARRAY_DATATYPES = new ArrayList<String>(); - private static final int DEFAULT_CONTENT_SIZE = 198; - - static - { - SUPPORTED_ARRAY_DATATYPES.add("java.lang.String"); - SUPPORTED_ARRAY_DATATYPES.add("java.lang.Boolean"); - SUPPORTED_ARRAY_DATATYPES.add("java.lang.Character"); - SUPPORTED_ARRAY_DATATYPES.add("java.lang.Integer"); - SUPPORTED_ARRAY_DATATYPES.add("java.lang.Long"); - SUPPORTED_ARRAY_DATATYPES.add("java.lang.Double"); - SUPPORTED_ARRAY_DATATYPES.add("java.util.Date"); - } - - /** - * Populates the composite with given openmbean data type (TabularType or CompositeType) - * @param toolkit - * @param parent composite - * @param data open mbean data type(either composite type or tabular data type) - */ - public static void populateCompositeWithData(FormToolkit toolkit, Composite parent, Object data) - { - if (data instanceof TabularDataSupport) - { - ViewUtility.createTabularDataHolder(toolkit, parent, (TabularDataSupport) data); - } - else if (data instanceof CompositeDataSupport) - { - ViewUtility.populateCompositeWithCompositeData(toolkit, parent, (CompositeDataSupport) data); - } - } - - @SuppressWarnings("unchecked") - private static void createTabularDataHolder(FormToolkit toolkit, Composite parent, TabularDataSupport tabularData) - { - Composite composite = toolkit.createComposite(parent, SWT.BORDER); - GridLayout layout = new GridLayout(4, true); - layout.horizontalSpacing = 0; - layout.marginWidth = 0; - layout.marginHeight = 10; - layout.verticalSpacing = 10; - composite.setLayout(layout); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - Set entrySet = tabularData.entrySet(); - ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet); - if (list.size() == 0) - { - Text text = toolkit.createText(composite, " No records ", SWT.CENTER | SWT.SINGLE | SWT.READ_ONLY); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1); - text.setLayoutData(layoutData); - return; - } - - Collections.sort(list, tabularDataComparator); - - // Attach the tabular record to be retrieved and shown later when record is traversed - // using first/next/previous/last buttons - composite.setData(list); - - // Create button and the composite for CompositeData - Composite compositeDataHolder = createCompositeDataHolder(toolkit, composite, - tabularData.getTabularType().getRowType()); - - // display the first record - CompositeData data = (CompositeData) (list.get(0)).getValue(); - composite.setData(INDEX, 0); - populateCompositeWithCompositeData(toolkit, compositeDataHolder, data); - enableOrDisableTraversalButtons(composite); - } - - private static void enableOrDisableTraversalButtons(Composite composite) - { - int index = (Integer) composite.getData(INDEX); - int size = ((List) composite.getData()).size(); - - ((Button) composite.getData(FIRST)).setEnabled(true); - ((Button) composite.getData(PREV)).setEnabled(true); - ((Button) composite.getData(NEXT)).setEnabled(true); - ((Button) composite.getData(LAST)).setEnabled(true); - - if (index == 0) - { - ((Button) composite.getData(FIRST)).setEnabled(false); - ((Button) composite.getData(PREV)).setEnabled(false); - } - if (index == size - 1) - { - ((Button) composite.getData(NEXT)).setEnabled(false); - ((Button) composite.getData(LAST)).setEnabled(false); - } - } - - /** - * Sets up the given composite for holding a CompositeData. Create traversal buttons, label etc and - * creates a child Composite, which should be populated with the CompositeData - * @param toolkit - * @param dataHolder - * @param compositeType - * @return - */ - private static Composite createCompositeDataHolder(final FormToolkit toolkit, final Composite dataHolder, CompositeType compositeType) - { - String desc = compositeType.getDescription(); - Label description = toolkit.createLabel(dataHolder, desc, SWT.CENTER); - description.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false, 4, 1)); - // TODO nameLabel.setFont(font); - description.setText(desc); - - // Add traversal buttons - final Button firstRecordButton = toolkit.createButton(dataHolder, FIRST, SWT.PUSH); - GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_END); - layoutData.widthHint = 80; - firstRecordButton.setLayoutData(layoutData); - - final Button nextRecordButton = toolkit.createButton(dataHolder, NEXT, SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_END); - layoutData.widthHint = 80; - nextRecordButton.setLayoutData(layoutData); - - final Button previousRecordButton = toolkit.createButton(dataHolder, PREV, SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 80; - previousRecordButton.setLayoutData(layoutData); - - final Button lastRecordButton = toolkit.createButton(dataHolder, LAST, SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 80; - lastRecordButton.setLayoutData(layoutData); - - // Now create the composite, which will hold the CompositeData - final Composite composite = toolkit.createComposite(dataHolder, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.horizontalSpacing = layout.verticalSpacing = 0; - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); - - // Add button references. These references will be used when buttons - // are to enabled or disabled based of record index. e.g. for first record - // First and Previous buttons will be disabled. - dataHolder.setData(FIRST, firstRecordButton); - dataHolder.setData(NEXT, nextRecordButton); - dataHolder.setData(PREV, previousRecordButton); - dataHolder.setData(LAST, lastRecordButton); - - // Listener for the traversal buttons. When a button is clicked the respective - // CompositeData will be populated in the composite - SelectionListener listener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (!(e.widget instanceof Button)) - { - return; - } - - Button traverseButton = (Button) e.widget; - // Get the CompositeData respective to the button selected - CompositeData data = getCompositeData(dataHolder, traverseButton.getText()); - populateCompositeWithCompositeData(toolkit, composite, data); - enableOrDisableTraversalButtons(dataHolder); - } - }; - - firstRecordButton.addSelectionListener(listener); - nextRecordButton.addSelectionListener(listener); - previousRecordButton.addSelectionListener(listener); - lastRecordButton.addSelectionListener(listener); - - return composite; - } - - /** - * The CompositeData is set as data with the Composite and using the index, this method will - * return the corresponding CompositeData - * @param compositeHolder - * @param dataIndex - * @return the CompositeData respective to the index - */ - private static CompositeData getCompositeData(Composite compositeHolder, String dataIndex) - { - List objectData = (List) compositeHolder.getData(); - if (objectData == null || objectData.isEmpty()) - { - // TODO - } - - // Get the index of record to be shown. - int index = 0; - if (compositeHolder.getData(INDEX) != null) - { - index = (Integer) compositeHolder.getData(INDEX); - } - - if (FIRST.equals(dataIndex)) - { - index = 0; - } - else if (NEXT.equals(dataIndex)) - { - index = index + 1; - } - else if (PREV.equals(dataIndex)) - { - index = (index != 0) ? (index = index - 1) : index; - } - else if (LAST.equals(dataIndex)) - { - index = objectData.size() - 1; - } - - // Set the index being shown. - compositeHolder.setData(INDEX, index); - - return (CompositeData) ((Map.Entry) objectData.get(index)).getValue(); - } - - /** - * Populates the given composite with the CompositeData. Creates required widgets to hold the data types - * @param toolkit - * @param parent - * @param data CompositeData - */ - @SuppressWarnings("unchecked") - private static void populateCompositeWithCompositeData(FormToolkit toolkit, Composite parent, CompositeData data) - { - Control[] oldControls = parent.getChildren(); - for (int i = 0; i < oldControls.length; i++) - { - oldControls[i].dispose(); - } - - Composite compositeHolder = toolkit.createComposite(parent, SWT.NONE); - GridLayout layout = new GridLayout(4, false); - layout.horizontalSpacing = 10; - compositeHolder.setLayout(layout); - compositeHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - // ItemNames in composite data - List<String> itemNames = new ArrayList<String>(data.getCompositeType().keySet()); - - for (String itemName : itemNames) - { - OpenType itemType = data.getCompositeType().getType(itemName); - Label keyLabel = toolkit.createLabel(compositeHolder, itemName, SWT.TRAIL); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); - layoutData.minimumWidth = 70; - keyLabel.setLayoutData(layoutData); - - if (itemType.isArray()) - { - OpenType type = ((ArrayType) itemType).getElementOpenType(); - // If Byte array and mimetype is text, convert to text string - if (type.getClassName().equals(Byte.class.getName())) - { - String mimeType = null; - String encoding = null; - if (data.containsKey("MimeType")) - { - mimeType = (String) data.get("MimeType"); - } - if (data.containsKey("Encoding")) - { - encoding = (String) data.get("Encoding"); - } - - if (encoding == null || encoding.length() == 0) - { - encoding = Charset.defaultCharset().name(); - } - - if ("text/plain".equals(mimeType)) - { - convertByteArray(toolkit, compositeHolder, data, itemName, encoding); - } - else - { - handleBinaryMessageContent(toolkit, compositeHolder, data, itemName, encoding); - } - } - // If array of any other supported type, show as a list of String array - else if (SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName())) - { - convertArrayItemForDisplay(compositeHolder, data, itemName); - } - else - { - setNotSupportedDataType(toolkit, compositeHolder); - } - } - else if (itemType instanceof TabularType) - { - Composite composite = toolkit.createComposite(compositeHolder, SWT.NONE); - composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - createTabularDataHolder(toolkit, composite, (TabularDataSupport) data.get(itemName)); - } - else - { - Text valueText = toolkit.createText(compositeHolder, String.valueOf(data.get(itemName)), SWT.READ_ONLY | SWT.BORDER); - valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); - } - } - - // layout the composite after creating new widgets. - parent.layout(); - } //end of method - - - private static void convertByteArray(FormToolkit toolkit, Composite compositeHolder, CompositeData data, String itemName, String encoding) - { - Byte[] arrayItems = (Byte[]) data.get(itemName); - byte[] byteArray = new byte[arrayItems.length]; - - for (int i = 0; i < arrayItems.length; i++) - { - byteArray[i] = arrayItems[i]; - } - try - { - String textMessage = new String(byteArray, encoding); - - Text valueText = toolkit.createText(compositeHolder, textMessage, SWT.READ_ONLY | SWT.BORDER | - SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); - gridData.heightHint = 300; - valueText.setLayoutData(gridData); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - static Button _firstButton, _nextButton, _previousButton, _lastButton; - static Text _hexNumTextToEnd, _hexNumTextToStart; - - /** - * Creates widgets for object messages and populates the content in hexadecimal format. - * @param toolkit - * @param compositeHolder - * @param data - * @param itemName - * @param encoding - */ - private static void handleBinaryMessageContent(FormToolkit toolkit, Composite compositeHolder, CompositeData data, String itemName, String encoding) - { - final String thisEncoding = encoding; - final Byte[] arrayItems = (Byte[]) data.get(itemName); - final byte[] byteArray = new byte[arrayItems.length]; - - for (int i = 0; i < arrayItems.length; i++) - { - byteArray[i] = arrayItems[i]; - } - - try - { - //create a new composite to contain the widgets required to display object messages. - final Composite localComposite = toolkit.createComposite(compositeHolder, SWT.NONE); - localComposite.setData("currentBytePos", 0); - localComposite.setData("startingBytePos", 0); - GridLayout layout = new GridLayout(2, true); - layout.marginWidth = 0; - layout.marginHeight = 0; - localComposite.setLayout(layout); - localComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); - - int startContentSize = DEFAULT_CONTENT_SIZE; // This will fill the 18 rows of the standard size - - if (byteArray.length < DEFAULT_CONTENT_SIZE) - { - startContentSize = byteArray.length; - } - - //create a text to display the hexadecimal views of object messages, it takes more space than ascii view as a hex uses 2 chars - //and 1 space, while ascii only uses 1 char and 1 space. - final Text hexText = toolkit.createText(localComposite, - new String(displayByteFormat(localComposite, byteArray, startContentSize * 2, thisEncoding, "<<", true)), - SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); - gridData.widthHint = 144; //set to 222 if not using any fonts - gridData.heightHint = 200; - hexText.setLayoutData(gridData); - - final Text asciiText = toolkit.createText(localComposite, - new String(displayByteFormat(localComposite, byteArray, startContentSize * 2, thisEncoding, "<<", false)), - SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER); - - - gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); - gridData.widthHint = 52;//set to 98 if not using any fonts - gridData.heightHint = 200; - asciiText.setLayoutData(gridData); - - //use a monospaced font for a better layout - Font font = new Font(compositeHolder.getDisplay(), "Courier", 10, SWT.NORMAL); - hexText.setFont(font); - asciiText.setFont(font); - - final ScrollBar hexScrollBar = hexText.getVerticalBar(); - final ScrollBar asciiScrollBar = asciiText.getVerticalBar(); - - //create a sub composite to contain all the buttons - final Composite buttonComposite = toolkit.createComposite(localComposite, SWT.NONE); - layout = new GridLayout(7, false); - layout.marginWidth = 0; - buttonComposite.setLayout(layout); - buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); - - _firstButton = toolkit.createButton(buttonComposite, "<<", SWT.PUSH); - GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _firstButton.setLayoutData(layoutData); - _firstButton.setToolTipText("See the first n bytes"); - - _previousButton = toolkit.createButton(buttonComposite, "<", SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _previousButton.setLayoutData(layoutData); - _previousButton.setToolTipText("See the previous n bytes"); - _previousButton.setEnabled(false); - - _hexNumTextToStart = toolkit.createText(buttonComposite, "0"); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _hexNumTextToStart.setLayoutData(layoutData); - _hexNumTextToStart.setEditable(false); - - final Text hexNumText = toolkit.createText(buttonComposite, "" + startContentSize); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - hexNumText.setLayoutData(layoutData); - - _hexNumTextToEnd = toolkit.createText(buttonComposite, "" + (byteArray.length - startContentSize)); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _hexNumTextToEnd.setLayoutData(layoutData); - _hexNumTextToEnd.setEditable(false); - - _nextButton = toolkit.createButton(buttonComposite, ">", SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _nextButton.setLayoutData(layoutData); - _nextButton.setToolTipText("See the next n bytes"); - _nextButton.setEnabled(true); - - _lastButton = toolkit.createButton(buttonComposite, ">>", SWT.PUSH); - layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - layoutData.widthHint = 40; - _lastButton.setToolTipText("See the last n bytes"); - _lastButton.setLayoutData(layoutData); - - SelectionListener listener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - if (e.widget instanceof Button) - { - String numOfBytes = hexNumText.getText(); - try - { - int n = Integer.parseInt(numOfBytes); - - //Reset range display if user requests a large value - if (n > byteArray.length) - { - n = (byteArray.length > DEFAULT_CONTENT_SIZE) ? DEFAULT_CONTENT_SIZE : byteArray.length; - hexNumText.setText("" + n); - } - - //rest if the user requests 0 - if (n < 1) - { - n = DEFAULT_CONTENT_SIZE; - hexNumText.setText("" + n); - } - - Button button = (Button) e.widget; - hexText.setText(displayByteFormat(localComposite, byteArray, n * 2, thisEncoding, - button.getText(), true)); - asciiText.setText(displayByteFormat(localComposite, byteArray, n * 2, thisEncoding, - button.getText(), false)); - } - catch (NumberFormatException exp) - { - popupErrorMessage("Error", - "Please input the number of bytes you wish to look at"); - } - } - if (e.widget instanceof ScrollBar) - { - //synchronize the movements of the two scrollbars - ScrollBar sb = (ScrollBar) e.widget; - if (sb.getParent().equals(hexText)) - { - asciiScrollBar.setIncrement(sb.getIncrement()); - asciiScrollBar.setSelection(sb.getSelection()); - asciiText.setTopIndex(hexText.getTopIndex()); - } - else if (sb.getParent().equals(asciiText)) - { - hexScrollBar.setSelection(sb.getSelection()); - hexScrollBar.setIncrement(sb.getIncrement()); - hexText.setTopIndex(asciiText.getTopIndex()); - } - } - } - }; - localComposite.addControlListener(new ControlAdapter() - { - public void controlResized(ControlEvent e) - { - //if the control is resized, set different parameters to make a single line displays the same contents. - if (((GridLayout) localComposite.getLayout()).makeColumnsEqualWidth) - { - ((GridLayout) localComposite.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout) localComposite.getLayout()).numColumns = 2; - ((GridData) hexText.getLayoutData()).horizontalSpan = 1; - ((GridData) hexText.getLayoutData()).widthHint = 144; - ((GridData) asciiText.getLayoutData()).horizontalSpan = 1; - ((GridData) asciiText.getLayoutData()).widthHint = 52; - ((GridData) buttonComposite.getLayoutData()).horizontalSpan = 2; - } - else - { - ((GridLayout) localComposite.getLayout()).makeColumnsEqualWidth = true; - ((GridLayout) localComposite.getLayout()).numColumns = 42; //set to 47 if not using any fonts - ((GridData) hexText.getLayoutData()).horizontalSpan = 25; // set to 30 if not using any fonts - ((GridData) asciiText.getLayoutData()).horizontalSpan = 17; // set to 17 if not using any fonts - ((GridData) buttonComposite.getLayoutData()).horizontalSpan = 42; - } - } - }); - - _firstButton.addSelectionListener(listener); - _previousButton.addSelectionListener(listener); - _nextButton.addSelectionListener(listener); - _lastButton.addSelectionListener(listener); - hexScrollBar.addSelectionListener(listener); - asciiScrollBar.addSelectionListener(listener); - //f.dispose(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - /** - * Format object messages to have a hexadecimal view and a ascii view. - * @param numOfBytes - * @param encoding - * @return - */ - private static String displayByteFormat(Composite localComposite, byte[] byteArray, int numOfBytes, String encoding, String direction, boolean isHex) - { - final Hex hexeconder = new Hex(); - final byte[] encoded = hexeconder.encode(byteArray); - - int hexLength = byteArray.length * 2; - StringBuilder sb = new StringBuilder(); - int currentBytePos = (Integer) localComposite.getData("currentBytePos"); - int startingBytePos = (Integer) localComposite.getData("startingBytePos"); - - int strLength = 0; - int offset = 0; - String encStr; - if (isHex) - { - if (direction.equals("<<")) - { - strLength = (numOfBytes > hexLength) ? hexLength : numOfBytes; - offset = 0; - } - else if (direction.equals("<")) - { - strLength = (startingBytePos - numOfBytes < 0) ? startingBytePos - : numOfBytes; - offset = (startingBytePos - numOfBytes < 0) ? 0 - : startingBytePos - numOfBytes; - } - else if (direction.equals(">")) - { - strLength = (numOfBytes > (hexLength - currentBytePos)) ? hexLength - - currentBytePos - : numOfBytes; - offset = currentBytePos; - - } - else if (direction.equals(">>")) - { - strLength = (numOfBytes > hexLength) ? hexLength : numOfBytes; - offset = (hexLength - numOfBytes > 0) ? hexLength - numOfBytes - : 0; - } - else - { - strLength = hexLength; - offset = 0; - } - localComposite.setData("strLength", strLength); - localComposite.setData("currentBytePos", offset + strLength); - localComposite.setData("startingBytePos", offset); - - if (_lastButton != null && !_lastButton.isDisposed()) - { - //Set button state - _previousButton.setEnabled(offset != 0); - _nextButton.setEnabled(offset + strLength != hexLength); - - //set the text fields - _hexNumTextToStart.setText("" + offset / 2); - _hexNumTextToEnd.setText("" + (hexLength - (offset + strLength)) / 2); - } - } - - try - { - if (isHex) - { - encStr = new String(encoded, offset, strLength, encoding); - for (int c = 0; c < strLength; c++) - { - - sb.append(encStr.charAt(c)); - if (c % 2 == 1) - { - sb.append(" "); - } - - } - return sb.toString().toUpperCase(); - } - else - { - strLength = (Integer) localComposite.getData("strLength"); - sb = new StringBuilder(); - encStr = new String(byteArray, startingBytePos / 2, strLength / 2, encoding); - for (int c = 0; c < encStr.length(); c++) - { - char ch = encStr.charAt(c); - if (ch > 31 && ch < 127) - { - sb.append(ch); - } - else - { - sb.append("?"); - } - - sb.append(" "); - } - } - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - return sb.toString(); - } - - public static int popupInfoMessage(String title, String message) - { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_INFORMATION | SWT.OK); - messageBox.setMessage(message); - messageBox.setText(title); - int response = messageBox.open(); - - return response; - } - - public static int popupErrorMessage(String title, String message) - { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR | SWT.OK); - messageBox.setMessage(message); - messageBox.setText(title); - int response = messageBox.open(); - - return response; - } - - public static int popupConfirmationMessage(String title, String message) - { - MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(), - SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL); - messageBox.setMessage(message); - messageBox.setText(title); - int response = messageBox.open(); - - return response; - } - - public static void popupError(String title, String message, Throwable ex) - { - IStatus status = new Status(IStatus.ERROR, ApplicationWorkbenchAdvisor.PERSPECTIVE_ID, - IStatus.ERROR, ex.toString(), ex); - ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, message, status); - - } - - public static void popupError(String errorMsg) - { - Display display = Display.getCurrent(); - Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX); - shell.setText("Attribute"); - shell.setLayout(new GridLayout()); - int x = display.getBounds().width; - int y = display.getBounds().height; - int width = 500; - int height = 250; - shell.setBounds(x / 4, y / 4, width, height); - - Label label = new Label(shell, SWT.NONE); - label.setText(errorMsg); - label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - shell.dispose(); - } - - public static Shell createPopupShell(String title, int width, int height) - { - Display display = Display.getCurrent(); - Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | SWT.MAX); - shell.setText(title); - shell.setLayout(new GridLayout()); - int x = display.getBounds().width; - int y = display.getBounds().height; - shell.setBounds(x / 4, y / 4, width, height); - - return shell; - } - - /** - * Creates a List widget for displaying array of strings - * @param compositeHolder - * @param data - containing the array item value - * @param itemName - item name - */ - private static void convertArrayItemForDisplay(Composite compositeHolder, CompositeData data, String itemName) - { - Object[] arrayItems = (Object[]) data.get(itemName); - String[] items = new String[arrayItems.length]; - for (int i = 0; i < arrayItems.length; i++) - { - items[i] = String.valueOf(arrayItems[i]); - } - org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List(compositeHolder, - SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY); - list.setItems(items); - //list.setBackground(compositeHolder.getBackground()); - list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); - } - - private static void setNotSupportedDataType(FormToolkit toolkit, Composite compositeHolder) - { - Text valueText = toolkit.createText(compositeHolder, "--- Content can not be displayed ---", SWT.READ_ONLY); - valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); - } - - /** - * Converts the input string to displayable format by converting some character case or inserting space - * @param input - * @return formatted string - */ - public static String getDisplayText(String input) - { - StringBuffer result = new StringBuffer(input); - if (Character.isLowerCase(result.charAt(0))) - { - result.setCharAt(0, Character.toUpperCase(result.charAt(0))); - } - for (int i = 1; i < input.length(); i++) - { - if (Character.isUpperCase(result.charAt(i)) && !Character.isWhitespace(result.charAt(i - 1)) - && Character.isLowerCase(result.charAt(i - 1))) - { - result.insert(i, " "); - i++; - } - else if (Character.isLowerCase(result.charAt(i)) && Character.isWhitespace(result.charAt(i - 1))) - { - result.setCharAt(i, Character.toUpperCase(result.charAt(i))); - } - - } - - return result.toString(); - } - - /** - * Disposes the children of given Composite if not null and not already disposed - * @param parent composite - */ - public static void disposeChildren(Composite parent) - { - if (parent == null || parent.isDisposed()) - { - return; - } - - Control[] oldControls = parent.getChildren(); - for (int i = 0; i < oldControls.length; i++) - { - oldControls[i].dispose(); - } - } - - public static char[] getMD5HashedCharArray(Object text) throws NoSuchAlgorithmException, UnsupportedEncodingException - { - byte[] data = ((String) text).getBytes("utf-8"); - - MessageDigest md = MessageDigest.getInstance("MD5"); - - for (byte b : data) - { - md.update(b); - } - - byte[] digest = md.digest(); - - char[] byteArray = new char[digest.length]; - int index = 0; - for (byte b : digest) - { - byteArray[index++] = (char) b; - } - return byteArray; - } - - public static char[] getHash(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException - { - byte[] data = text.getBytes("utf-8"); - - MessageDigest md = MessageDigest.getInstance("MD5"); - - for (byte b : data) - { - md.update(b); - } - - byte[] digest = md.digest(); - - char[] hash = new char[digest.length]; - - int index = 0; - for (byte b : digest) - { - hash[index++] = (char) b; - } - - return hash; - } - - private static class TabularDataComparator implements java.util.Comparator<Map.Entry> - { - public int compare(Map.Entry data1, Map.Entry data2) - { - if (data1.getKey() instanceof List) - { - Object obj1 = ((List) data1.getKey()).get(0); - Object obj2 = ((List) data2.getKey()).get(0); - String str1 = obj1.toString(); - String str2 = obj2.toString(); - if (obj1 instanceof String) - { - return str1.compareTo(str2); - } - - try - { - return Long.valueOf(str1).compareTo(Long.valueOf(str2)); - } - catch (Exception ex) - { - return -1; - } - } - - return -1; - } - } -} diff --git a/java/management/eclipse-plugin/src/main/resources/.eclipseproduct b/java/management/eclipse-plugin/src/main/resources/.eclipseproduct deleted file mode 100644 index 28ee27ca17..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/.eclipseproduct +++ /dev/null @@ -1,23 +0,0 @@ -#Eclipse Product File
-#Fri Nov 03 14:47:54 GMT 2006
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-version=1.0-incubating-M2-SNAPSHOT
-name=Qpid Management Console
-id=org.apache.qpid.manager.gui.product
diff --git a/java/management/eclipse-plugin/src/main/resources/eclipse.exe b/java/management/eclipse-plugin/src/main/resources/eclipse.exe Binary files differdeleted file mode 100644 index 7826d1ed80..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/eclipse.exe +++ /dev/null diff --git a/java/management/eclipse-plugin/src/main/resources/eclipse.ini b/java/management/eclipse-plugin/src/main/resources/eclipse.ini deleted file mode 100644 index 6a4ecb5b5d..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/eclipse.ini +++ /dev/null @@ -1,4 +0,0 @@ --vmargs
--Xms40m
--Xmx256m
--Declipse.consoleLog=true
diff --git a/java/management/eclipse-plugin/src/main/resources/license.eclipse.txt b/java/management/eclipse-plugin/src/main/resources/license.eclipse.txt deleted file mode 100644 index da433e89f9..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/license.eclipse.txt +++ /dev/null @@ -1,88 +0,0 @@ -Eclipse Public License - v 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and -b) in the case of each subsequent Contributor: - -i) changes to the Program, and - -ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. - -2. GRANT OF RIGHTS - -a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. - -b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. - -c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. - -d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: - -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: - -i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. - -When the Program is made available in source code form: - -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the Program. - -Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. - - diff --git a/java/management/eclipse-plugin/src/main/resources/org.apache.commons.codec/org.apache.commons.codec_1.3.0.jar b/java/management/eclipse-plugin/src/main/resources/org.apache.commons.codec/org.apache.commons.codec_1.3.0.jar Binary files differdeleted file mode 100644 index ae60ce21b7..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/org.apache.commons.codec/org.apache.commons.codec_1.3.0.jar +++ /dev/null diff --git a/java/management/eclipse-plugin/src/main/resources/sasl/MANIFEST.MF b/java/management/eclipse-plugin/src/main/resources/sasl/MANIFEST.MF deleted file mode 100644 index d18b1a073d..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/sasl/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: jmx sasl Plug-in -Bundle-SymbolicName: jmxremote.sasl -Bundle-Version: 1.0.1 -Bundle-ClassPath: . -Bundle-Vendor: -Bundle-Localization: plugin diff --git a/java/management/eclipse-plugin/src/main/resources/startup.jar b/java/management/eclipse-plugin/src/main/resources/startup.jar Binary files differdeleted file mode 100644 index 2f26eceece..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/startup.jar +++ /dev/null diff --git a/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini b/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini deleted file mode 100644 index b5186ef073..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/unix/configuration/config.ini +++ /dev/null @@ -1,27 +0,0 @@ -###############################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-###############################################################################
-
-#Product Runtime Configuration File
-
-osgi.splashPath=platform:/base/plugins/org.apache.qpid.management.ui
-eclipse.product=org.apache.qpid.management.ui.product
-eclipse.application=org.apache.qpid.management.ui.application
-osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.motif.linux.x86,org.eclipse.swt.gtk.linux.x86_64,org.eclipse.swt.gtk.linux.x86,org.eclipse.swt.gtk.linux.ppc,org.eclipse.swt.motif.hpux.PA_RISC,org.eclipse.swt.gtk.solaris.sparc,org.eclipse.swt.motif.solaris.sparc,org.eclipse.swt.carbon.macocx,org.eclipse.ui,org.eclipse.ui.forms,org.eclipse.ui.workbench,org.apache.commons.codec
-osgi.bundles.defaultStartLevel=4
-eof=eof
diff --git a/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini b/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini deleted file mode 100644 index e287f0f4a9..0000000000 --- a/java/management/eclipse-plugin/src/main/resources/win32/configuration/config.ini +++ /dev/null @@ -1,26 +0,0 @@ -###############################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-###############################################################################
-
-#Product Runtime Configuration File
-
-osgi.splashPath=platform:/base/plugins/org.apache.qpid.management.ui
-eclipse.product=org.apache.qpid.management.ui.product
-eclipse.application=org.apache.qpid.management.ui.application
-osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.core.runtime@start,com.ibm.icu,org.apache.qpid.management.ui,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.jobs,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.swt,org.eclipse.swt.win32.win32.x86,org.eclipse.ui,org.eclipse.ui.forms,jmxremote.sasl,org.eclipse.ui.workbench,org.apache.commons.codec
-osgi.bundles.defaultStartLevel=4
diff --git a/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java b/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java deleted file mode 100644 index 64a5843953..0000000000 --- a/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.management.ui; - -import junit.framework.TestCase; -import org.apache.qpid.exchange.ExchangeDefaults; -import org.apache.qpid.framing.AMQShortString; -import org.apache.qpid.server.exchange.DestNameExchange; -import org.apache.qpid.server.management.AMQManagedObject; -import org.apache.qpid.server.queue.AMQQueue; -import org.apache.qpid.server.queue.AMQQueueMBean; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.registry.IApplicationRegistry; -import org.apache.qpid.server.virtualhost.VirtualHost; - -import javax.management.MBeanFeatureInfo; -import javax.management.MBeanInfo; -import java.util.ArrayList; -import java.util.List; - - -/** - * Test class to test if any change in the broker JMX code is affesting the management console - * There are some hardcoding of management feature names and parameter names to create a customized - * look in the console. - */ -public class ManagementConsoleTest extends TestCase -{ - private VirtualHost _virtualHost; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance(); - _virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test"); - } - - /** - * Test for AMQQueueMBean attribute and operation names, which are used in the management console - * @throws Exception - */ - public void testAMQQueueMBeanInfo() throws Exception - { - // If this test fails due to changes in the broker code, - // then the constants in the Constants.java shoule be updated accordingly - AMQQueue queue = new AMQQueue(new AMQShortString("testQueueForManagement"), false, null, false, _virtualHost); - AMQManagedObject mbean = new AMQQueueMBean(queue); - MBeanInfo mbeanInfo = mbean.getMBeanInfo(); - - List<String> operationNames = getNamesList(mbeanInfo.getOperations()); - assertTrue(operationNames.contains(Constants.OPERATION_MOVE_MESSAGES)); - - List<String> attributesList = getNamesList(mbeanInfo.getAttributes()); - assertTrue(attributesList.contains(Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT)); - assertTrue(attributesList.contains(Constants.ATTRIBUTE_QUEUE_DEPTH)); - } - - /** - * Test for Exchange MBean attribute and operation names, which are used in the management console - * @throws Exception - */ - public void testExchangeMBeanInfo() throws Exception - { - // If this test fails due to changes in the broker code, - // then the constants in the Constants.java shoule be updated accordingly - DestNameExchange exchange = new DestNameExchange(); - exchange.initialise(_virtualHost, ExchangeDefaults.DIRECT_EXCHANGE_NAME, false, true); - AMQManagedObject mbean = (AMQManagedObject)exchange.getManagedObject(); - MBeanInfo mbeanInfo = mbean.getMBeanInfo(); - - // Check for the Exchange Type property in the ObjectName - assertNotNull(mbean.getObjectName().getKeyProperty(Constants.EXCHANGE_TYPE)); - - // Check for operation names - List<String> operationNames = getNamesList(mbeanInfo.getOperations()); - assertTrue(operationNames.contains(Constants.OPERATION_CREATE_BINDING)); - } - - /** - * Test for VirtualHostManagerMBean features used in Management console for customizing the GUI - * @throws Exception - */ - public void testVirtualHostManagerMBeanInfo() throws Exception - { - AMQManagedObject mbean = (AMQManagedObject)_virtualHost.getManagedObject(); - assertTrue(mbean.getType().equals(Constants.VIRTUAL_HOST)); - } - - private List<String> getNamesList(MBeanFeatureInfo[] features) - { - List<String> names = new ArrayList<String>(); - for (MBeanFeatureInfo feature : features) - { - names.add(feature.getName()); - } - - return names; - } -} |
