avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/instrument-client/src/test README.txt
Date Tue, 26 Mar 2002 11:32:24 GMT
leif        02/03/26 03:32:24

  Added:       instrument-client .cvsignore BUILDING.txt README.txt
                        ant.properties.sample build.xml project.properties
               instrument-client/example .cvsignore ant.properties.sample
                        build.xml
               instrument-client/example/bin client.bat client.sh
                        cpappend.bat
               instrument-client/src/java/org/apache/avalon/excalibur/instrument/client
                        AbstractInternalFrame.java DesktopPane.java
                        InstrumentClientFrame.java
                        InstrumentManagerConnection.java
                        InstrumentManagerConnectionListener.java
                        InstrumentManagerFrame.java
                        InstrumentSampleFrame.java LineChart.java Main.java
                        MenuBar.java
               instrument-client/src/test README.txt
  Log:
  Check in new instrument-client sub project.
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/instrument-client/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  build
  checkstyle.cache
  distributions
  dist
  excalibur-*
  *.el
  *.ipr
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/BUILDING.txt
  
  Index: BUILDING.txt
  ===================================================================
  
                 Building The Component
                 ======================
  
  In order to build a binary distribution version of the component from a 
  source  distribution,  you must have  a Java Development Kit (JDK)  for 
  version  1.1 (or  later)  downloaded  and  installed  (version  1.3.1 
  recommended), and do the following:
  
  (0) Download and Install a Java Development Kit
  
  * Download a Java Development Kit (JDK) release (version 1.1 or later) 
    from:
  
      http://java.sun.com/j2se/
  
  * Install the JDK according to the instructions included with the release.
  
  * Set an environment variable JAVA_HOME to the pathname of the directory
    into which you installed the JDK release.
  
  
  (1) Download and Install the Ant Binary Distribution
  
  * Download a binary distribution of Ant 1.4.1 from:
  
      http://jakarta.apache.org/builds/jakarta-ant/release/v1.4.1/bin/
  
    On a Windows platform, you will need:
      jakarta-ant-1.4.1-bin.zip
      jakarta-ant-1.4.1-optional.jar
  
    On a Unix platform, you will need:
      jakarta-ant-1.4.1-bin.tar.gz
      jakarta-ant-1.4.1-optional.jar
  
  * Unpack the binary distribution into a convenient location so that the
    Ant release resides in its own directory (conventionally named
    "jakarta-ant-1.4.1").  For the purposes of the remainder of this document,
    the symbolic name "${ant.home}" is used to refer to the full pathname of
    the release directory.
  
  * Copy the file "jakarta-ant-1.4.1-optional.jar", downloaded above, into
    the directory "${ant.home}/lib".  This makes available several Ant
    extension commands that are commonly required when building Jakarta
    based projects.
  
  * Modify the PATH environment variable to include directory
    "${ant.home}/bin" in its list.  This makes the "ant" command line script
    available, which will be used to actually perform the build.
  
  (2) Download and Install the JUnit Testing Package (OPTIONAL)
  
  NOTE: This is only required if you wish to run the unit tests for 
  this component
  
  * Download the JUnit unit test package (version 3.7 or later) from:
  
      http://www.junit.org/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  * Copy the file "junit.jar", downloaded above, into the directory 
    "${ant.home}/lib".  This makes available the unit testing tasks that are 
    commonly required when building Jakarta based projects.
  
  (3) Download and Install the JDepend 2.2, Dependency Analysis Package (OPTIONAL)
  
  NOTE: This is only required if you wish to run dependency analysis for 
  this component. 
  
  * Download the JDepend package (version 2.2 or later) from:
  
      http://www.clarkware.com/software/JDepend.html
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  * Copy the file "jdepend.jar", downloaded above, into the directory 
    "${ant.home}/lib".  This makes available the dependency analysis tasks.
  
  
  (4) Download and Install Checkstyle, 2.1 or later (OPTIONAL)
  
  NOTE: This is only required if you wish to generate reports regarding code style.
  
  * Download the Checkstyle package (version 2.1 or later) from:
  
      http://checkstyle.sourceforge.net/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  (5) Download and Install the Xalan, XSLT engine (OPTIONAL)
  
  NOTE: This is only required if you wish to generate reports for the dependency 
  analysis, checkstyle and unit testing results.
  
  * Download the Xalan package (version 2.3.1 or later) from:
  
      http://xml.apache.org/xalan-j/
  
  * Unpack the package into a convenient location so that it resides in its
    own subdirectory.
  
  * Copy the files "xalan.jar", and "xml-apis.jar", downloaded above, into 
    the directory "${ant.home}/lib".  This makes available the XSLT reporting
    capabilities.
  
  (6) Customize Build Properties For This Subproject
  
  Most Jakarta subprojects allow you to customize Ant properties (with default
  values defined in the "build.xml" file.  This is done by creating a text file
  named "ant.properties" in the source distribution directory (for property
  definitions local to this subproject) and/or your user home directory (for
  property definitions shared across subprojects).  You can use the included
  "ant.properties.sample" file as a starting point for this.
  
  External dependencies are satisfied by configuring appropriate values in your 
  ant.properties file.  The easiest way to satisfy these dependencies is to copy 
  the "ant.properties.sample" file (in the top-level directory) to "ant.properties", 
  and then edit it to suit your environment.  On Unix, this would be done as:
  
    cd @dist.name@
    cp ant.properties.sample ant.properties
    emacs ant.properties
  
  NOTE:  Be *sure* that you do not check "ant.properties" in to the CVS
  repository.  This file is local to your own development environment, and
  each developer will have their own version.
  
  (7) Build A Binary Distribution
  
  Open a command line shell, and issue the following commands:
  
    cd @dist.name@
    ant -projecthelp
  
  If everything is installed correctly, you should see a list of the Ant
  "targets" that represent different commands you might wish to build.  By
  convention, the "jar" target creates the jar of the component. To execute 
  it, type the following commands:
  
    cd @dist.name@
    ant jar
  
  This will create a jar in the @dist.name@/build/lib directory that contains 
  the component.
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/README.txt
  
  Index: README.txt
  ===================================================================
                 Avalons Excalibur Instrument
                 ----------------------------
  
  WARNING: Under Development--the API may change
  
  The instrument project provides an API for instrumenting
  components.
  
  Getting Started:
  ----------------
  
  If you downloaded a source release of the component then you 
  will need to build the component. Directions for building the 
  component are located in BUILDING.txt
  
  If you downloaded a binary release, or a release with both binary 
  and source then it is recomended you look over the documentation
  in docs/index.html - and then look into the examples/ directory
  for examples of the component in action.
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/ant.properties.sample
  
  Index: ant.properties.sample
  ===================================================================
  # -----------------------------------------------------------------------------
  # Component ant.properties.sample
  #
  # This is an example "ant.properties" file, used to customize the building of
  # the component for your local environment.  It defines the location of all
  # external modules that this component depend on.  Copy this file to
  # "ant.properties" in the source directory, and customize it as needed.
  #
  # The ant.properties values in this directory apply only to this component, and
  # override the defaults in ../ant.properties.
  #
  # $Id: ant.properties.sample,v 1.1 2002/03/26 11:32:23 leif Exp $
  # -----------------------------------------------------------------------------
  
  # --------------------------------------------------
  #      COMPONENT-SPECIFIC REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  # ----- Compile Control Flags -----
  build.debug=on
  build.optimize=off
  build.deprecation=off
  
  # ----- Base Directory in which all the packages are stored -----
  base.path=/opt
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  # ----- Avalon Framework -----
  avalon-framework.home=../../jakarta-avalon/build/lib
  avalon-framework.jar=${avalon-framework.home}/avalon-framework.jar
  
  # ----- Excalibur Instrument Manager -----
  excalibur-instrument-manager.home=../instrument-manager/build/lib
  excalibur-instrument-manager-client.jar=${excalibur-instrument-manager.home}/excalibur-instrument-manager-client-0.1.jar
  
  # ----- Altrmi -----
  commons-altrmi.home=../../jakarta-commons-sandbox/altrmi/dist
  commons-altrmi-client-impl.jar=${commons-altrmi.home}/commons-altrmi-client-impl.jar
  commons-altrmi-client-interfaces.jar=${commons-altrmi.home}/commons-altrmi-client-interfaces.jar
  commons-altrmi-common.jar=${commons-altrmi.home}/commons-altrmi-common.jar
  commons-altrmi-generator.jar=${commons-altrmi.home}/commons-altrmi-generator.jar
  
  # ----- JUnit Unit Test Suite, version 3.7 or later -----
  junit.home=${base.path}/junit3.7
  junit.lib=${junit.home}
  junit.jar=${junit.lib}/junit.jar
  
  
  
  # --------------------------------------------------
  #                OPTIONAL LIBRARIES
  # --------------------------------------------------
  
  # ----- Checkstyle, version 2.1 or later -----
  
  # Uncomment the 'do.checkstyle' flag property to enable checkstyle
  # do.checkstyle=
  checkstyle.home=${base.path}/checkstyle-2.1
  checkstyle.lib=${checkstyle.home}
  checkstyle.jar=${checkstyle.lib}/checkstyle-all-2.1.jar
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project name="Excalibur Instrument Client" default="main" basedir=".">
  
      <!-- load per-project properties -->
      <property file="project.properties"/>
  
      <!--
        Give user a chance to override without editing this file
        (and without typing -D each time he compiles it)
      -->
      <property file="ant.properties"/>
      <property file="../ant.properties"/>
      <property file="${user.home}/.ant.properties"/>
      
      <!-- Settings used to configure compile environment -->
      <property name="build.debug" value="on"/>
      <property name="build.optimize" value="off"/>
      <property name="build.deprecation" value="off"/>
      <property name="build.compress" value="false"/>
      <property name="junit.failonerror" value="false"/>
  
      <!-- location of intermediate products -->
      <property name="build.dir" value="build"/>
      <property name="build.lib" value="${build.dir}/lib"/>
      <property name="build.classes" value="${build.dir}/classes"/>
      <property name="build.genjava" value="${build.dir}/genjava"/>
      <property name="build.tests" value="${build.dir}/tests"/>
      <property name="build.reports" value="${build.dir}/reports"/>
  
      <!-- Set the properties for source directories -->
      <property name="src.dir" value="src"/>
      <property name="java.dir" value="${src.dir}/java"/>
      <property name="test.dir" value="${src.dir}/test"/>
  
      <!-- Set the properties for distribution directories -->
      <property name="dist.dir" value="dist"/>
      <property name="dist.javadocs" value="${dist.dir}/docs/api"/>
  
      <!-- property to specify name of zip/jar files -->
      <property name="dist.name" value="excalibur-${name}-${version}"/>
  
      <!-- property indicating directory where all distribution archives are placed -->
      <property name="dist.base" value="distributions"/>
  
      <!-- Classpath for product -->
      <path id="project.class.path">
          <pathelement path="${java.class.path}"/>
          <pathelement location="${build.classes}"/>
          <pathelement location="${avalon-framework.jar}"/>
          <pathelement location="${excalibur-instrument-manager-client.jar}"/>
          <pathelement location="${commons-altrmi-client-impl.jar}"/>
          <pathelement location="${commons-altrmi-client-interfaces.jar}"/>
          <pathelement location="${commons-altrmi-common.jar}"/>
          <pathelement location="${commons-altrmi-generator.jar}"/>
          <pathelement location="${junit.jar}"/>
          <pathelement location="${checkstyle.jar}"/>
      </path>
      
      <taskdef name="altrmiinterfaces"
          classname="org.apache.commons.altrmi.generator.ant.AltrmiInterfaceTask">
          <classpath refid="project.class.path" />
      </taskdef>
          
      <target name="main" depends="dist" description="Build the project"/>
      <target name="rebuild" depends="clean,main" description="Rebuild the project"/>
  
      <!-- Compiles the source code -->
      <target name="compile" description="Compiles the source code">
          <mkdir dir="${build.classes}"/>
  
          <!-- Compile all classes including the tests. -->
          <javac srcdir="${java.dir}"
              destdir="${build.classes}"
              debug="${build.debug}"
              optimize="${build.optimize}"
              deprecation="${build.deprecation}"
              target="1.2">
              <classpath refid="project.class.path" />
              <src path="${test.dir}"/>
              <include name="**/*.java"/>
          </javac>
  
          <!-- copy resources to same location as .class files -->
          <copy todir="${build.classes}">
              <fileset dir="${java.dir}">
                  <exclude name="**/*.java"/>
              </fileset>
          </copy>
  
          <copy todir="${build.classes}">
              <fileset dir="${test.dir}">
                  <exclude name="**/*.java"/>
              </fileset>
          </copy>
  
      </target>
      
      <!-- Generates the altrmi interfaces used by the client. -->
      <target name="altrmiinterfaces" depends="compile">
          <mkdir dir="${build.genjava}"/>
          
          <delete>
              <fileset dir="${build.genjava}" includes="AltrmiGenerated*.java"/>
          </delete>
          <delete>
              <fileset dir="${build.classes}" includes="AltrmiGenerated*.class"/>
          </delete>
          
          <altrmiinterfaces genname="InstrumentManagerClient"
              srcgendir="${build.genjava}" 
              classgendir="${build.classes}" 
              classesorinterfaces="org.apache.avalon.excalibur.instrument.manager.client.InstrumentManagerClient"
              additionalfacades="org.apache.avalon.excalibur.instrument.manager.client.InstrumentableDescriptor,org.apache.avalon.excalibur.instrument.manager.client.InstrumentDescriptor,org.apache.avalon.excalibur.instrument.manager.client.InstrumentSampleDescriptor">
              <classpath refid="project.class.path" />
              <!--classpath>
                  <pathelement location="${build.classes}"/>
              </classpath-->
          </altrmiinterfaces>        
      </target>
  
      <!-- Creates all the .jar file -->
      <target name="jar" depends="compile, altrmiinterfaces" description="Generates the jar files">
  
          <mkdir dir="${build.lib}"/>
  
          <jar jarfile="${build.lib}/${dist.name}.jar"
              basedir="${build.classes}"
              compress="${build.compress}">
              <exclude name="**/test/**"/>
              <zipfileset dir=".." prefix="META-INF/">
                  <include name="LICENSE.txt"/>
              </zipfileset>
          </jar>
      </target>
  
      <!-- Creates all the Javadocs -->
      <target name="javadocs" depends="compile" description="Generates the javadocs">
  
          <mkdir dir="${dist.javadocs}"/>
          <javadoc packagenames="org.apache.*"
              sourcepath="${java.dir}"
              destdir="${dist.javadocs}">
              <classpath refid="project.class.path" />
              <doclet name="com.sun.tools.doclets.standard.Standard">
                  <param name="-author"/>
                  <param name="-version"/>
                  <param name="-doctitle" value="${Name}"/>
                  <param name="-windowtitle" value="${Name} API"/>
                  <param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
                  <param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
                  <param name="-link" value="http://jakarta.apache.org/avalon/api/"/>
                  <param name="-bottom"
                      value="&quot;Copyright &#169; ${year} Apache Jakarta Project. All Rights Reserved.&quot;"/>
              </doclet>
          </javadoc>
      </target>
  
      <target name="test" depends="compile" description="Perform the unit tests">
          
          <echo message="Performing Unit Tests" />
          
          <mkdir dir="${build.tests}"/>
          
          <junit fork="true" 
                 haltonfailure="${junit.failonerror}"
                 printsummary="yes" 
                 dir="${build.tests}">
              <classpath refid="project.class.path"/>
  
              <formatter type="xml"/>    <!-- xml reports for junitreport -->
              <formatter type="plain"/>  <!-- text reports for humans     -->
  
              <batchtest todir="${build.tests}">
                  <fileset dir="${build.classes}">
                      <include name="**/test/*TestCase.class"/>
                      <exclude name="**/Abstract*"/>
                  </fileset>
              </batchtest>
          </junit>
          
      </target>
  
      <target name="test-reports" depends="test" description="Generate Reports for the unit tests">
          
          <mkdir dir="${build.reports}/junit"/>
          
          <junitreport todir="${build.reports}/junit">
              <fileset dir="${build.tests}">
                  <include name="TEST-*.xml"/>
              </fileset>
              <report format="frames" todir="${build.reports}/junit"/>
          </junitreport>
  
          <!-- Clean up the xml reports used by the junitreport task -->
          <!--
          <delete>
              <fileset dir="${build.tests}" includes="TEST-*.xml"/>
              <fileset dir="${build.tests}" includes="TESTS-*.xml"/>
          </delete>
          -->
          
      </target>
  
      <target name="jdepend" if="do.jdepend" description="Generate Dependency Analysis Report">
  
          <!-- this invocation of jdepend requires the CVS version of ant for the xml format -->
          <!-- thats why you are required to define do.jdepend property to generate the report -->
          <jdepend outputfile="${build.dir}/jdepend-results.xml" format="xml" fork="yes">
              <classpath refid="project.class.path"/>
              <sourcespath>
                  <pathelement location="src/java" />
              </sourcespath>
          </jdepend>
  
          <mkdir dir="${build.reports}/jdepend"/>
          <style in="${build.dir}/jdepend-results.xml" 
                 processor="trax" 
                 out="${build.reports}/jdepend/delete-me.txt" 
                 style="${ant.home}/etc/jdepend-frames.xsl"/>
      </target>
  
      <target name="checkstyle" if="do.checkstyle" description="Checkstyle">
      
          <!-- this invocation of checkstyle requires that checkstyle be downloaded and setup -->
          <!-- thats why you are required to define do.checkstyle property to generate the report -->
          <taskdef name="checkstyle"
              classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
              <classpath refid="project.class.path"/>
          </taskdef>
          <checkstyle
              lcurlyType="nl"
              lcurlyMethod="nl"
              lcurlyOther="nl"
              rcurly="ignore"
              allowProtected="false"
              allowPackage="false"
              allowNoAuthor="false"
              maxLineLen="100"
              maxMethodLen="100"
              maxConstructorLen="100"
              memberPattern="^m_[a-z][a-zA-Z0-9]*$"
              staticPattern="^c_[a-z][a-zA-Z0-9]*$"
              constPattern="(^c_[a-z][a-zA-Z0-9]*$)|([A-Z_]*$)"
              ignoreImportLen="true"
              allowTabs="false"
              javadocScope="protected"
              ignoreWhitespace="true"
              cacheFile="checkstyle.cache"
              failOnViolation="false"
              ignoreCastWhitespace="true">
              <fileset dir="${java.dir}">
                  <include name="**/*.java"/>
              </fileset>
              <formatter type="plain"/>
              <formatter type="xml" toFile="build/checkstyle-results.xml"/>
          </checkstyle>
      </target>
  
      <target name="checkstyle-report" 
              depends="checkstyle" 
              if="do.checkstyle" 
              description="Generate Checkstyle Report">
  
          <mkdir dir="${build.reports}/checkstyle"/>
          <style style="../tools/etc/checkstyle-frames.xsl" in="build/checkstyle-results.xml"
              out="${build.reports}/checkstyle/delete-me.html"/>
  
      </target>
  
      <!-- Creates the distribution -->
      <target name="dist" 
              depends="jar, test-reports, jdepend, checkstyle-report, javadocs" 
              description="Generates the jar files">
  
          <mkdir dir="${dist.dir}"/>
          <copy file="${build.lib}/${dist.name}.jar" todir="${dist.dir}"/>
          <copy file="../LICENSE.txt" todir="${dist.dir}"/>
          <copy file="../KEYS" todir="${dist.dir}"/>
  
          <mkdir dir="${dist.base}"/>
  
          <zip zipfile="${dist.base}/${dist.name}-bin.zip" compress="true">
              <zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
          </zip>
  
          <delete dir="${dist.dir}" />
  
      </target>
  
      <!-- Cleans up build and distribution directories -->
      <target name="clean" description="Cleans up the project">
          <delete file="checkstyle.cache"/>
          <delete dir="${build.dir}" />
          <delete dir="${dist.dir}" />
          <delete dir="test" /> <!-- unit testing output directory -->
          <delete>
              <fileset dir="." includes="**/*~" defaultexcludes="no"/>
          </delete>
      </target>
  
      <target name="real-clean" depends="clean" description="Cleans up the project, including distributions">
          <delete dir="${dist.base}" />
      </target>
  
  </project>
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/project.properties
  
  Index: project.properties
  ===================================================================
  name=instrument-client
  Name=Instrument Client
  version=0.1
  year=2002
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  lib
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/ant.properties.sample
  
  Index: ant.properties.sample
  ===================================================================
  # -----------------------------------------------------------------------------
  # Component ant.properties.sample
  #
  # This is an example "ant.properties" file, used to customize the building of
  # the component for your local environment.  It defines the location of all
  # external modules that this component depend on.  Copy this file to
  # "ant.properties" in the source directory, and customize it as needed.
  #
  # The ant.properties values in this directory apply only to this component, and
  # override the defaults in ../ant.properties.
  #
  # $Id: ant.properties.sample,v 1.1 2002/03/26 11:32:23 leif Exp $
  # -----------------------------------------------------------------------------
  
  # --------------------------------------------------
  #      COMPONENT-SPECIFIC REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  # ----- Compile Control Flags -----
  build.debug=on
  build.optimize=off
  build.deprecation=off
  
  # ----- Base Directory in which all the packages are stored -----
  base.path=/opt
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  # ----- Avalon Framework -----
  avalon-framework.home=../../../jakarta-avalon/build/lib
  avalon-framework.jar=${avalon-framework.home}/avalon-framework.jar
  
  # ----- Excalibur Instrument Manager -----
  excalibur-instrument-manager.home=../../instrument-manager/build/lib
  excalibur-instrument-manager-client.jar=${excalibur-instrument-manager.home}/excalibur-instrument-manager-client-0.1.jar
  
  # ----- Altrmi -----
  commons-altrmi.home=../../../jakarta-commons-sandbox/altrmi/dist
  commons-altrmi-client-impl.jar=${commons-altrmi.home}/commons-altrmi-client-impl.jar
  commons-altrmi-client-interfaces.jar=${commons-altrmi.home}/commons-altrmi-client-interfaces.jar
  commons-altrmi-common.jar=${commons-altrmi.home}/commons-altrmi-common.jar
  commons-altrmi-generator.jar=${commons-altrmi.home}/commons-altrmi-generator.jar
  
  # ----- JUnit Unit Test Suite, version 3.7 or later -----
  junit.home=${base.path}/junit3.7
  junit.lib=${junit.home}
  junit.jar=${junit.lib}/junit.jar
  
  
  
  # --------------------------------------------------
  #                OPTIONAL LIBRARIES
  # --------------------------------------------------
  
  # ----- Checkstyle, version 2.1 or later -----
  
  # Uncomment the 'do.checkstyle' flag property to enable checkstyle
  # do.checkstyle=
  checkstyle.home=${base.path}/checkstyle-2.1
  checkstyle.lib=${checkstyle.home}
  checkstyle.jar=${checkstyle.lib}/checkstyle-all-2.1.jar
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!-- ======================================================================= -->
  <!-- Container Example build file!                                           -->
  <!-- ======================================================================= -->
  
  <project name="instrument-client-example" default="main" basedir=".">
  
      <!--
        Give user a chance to override without editing this file
        (and without typing -D each time he compiles it)
      -->
      <property file="ant.properties"/>
      <property file="../ant.properties"/>
      <property file="${user.home}/.ant.properties"/>
      
      <!-- Directories build by ant -->
      <property name="lib.dir"               value="${basedir}/lib"/>
  
      <!-- =================================================================== -->
      <!-- Help on usage                                                       -->
      <!-- =================================================================== -->
      <target name="usage">
          <echo message="Use the -projecthelp option instead"/>
      </target>
      <target name="help" depends="usage"/>
  
      <!-- =================================================================== -->
      <!-- Help on usage                                                       -->
      <!-- =================================================================== -->
      <target name="collect-jars">
          <!-- Avalong Framework Jar -->
          <copy file="${avalon-framework.jar}"
              todir="${lib.dir}" preservelastmodified="yes"/>
          
          <!-- Instrument Manager Jars -->
          <copy file="${excalibur-instrument-manager-client.jar}"
              todir="${lib.dir}" preservelastmodified="yes"/>
          
          <!-- Altrmi Jars -->
          <copy file="${commons-altrmi-client-impl.jar}"
              todir="${lib.dir}" preservelastmodified="yes"/>
          <copy file="${commons-altrmi-client-interfaces.jar}"
              todir="${lib.dir}" preservelastmodified="yes"/>
          <copy file="${commons-altrmi-common.jar}"
              todir="${lib.dir}" preservelastmodified="yes"/>
          
          <!-- Instrument Client Jar -->
          <copy file="../build/lib/excalibur-instrument-client-0.1.jar"
              todir="${lib.dir}" preservelastmodified="yes"/>
      </target>
      
      <!-- =================================================================== -->
      <!-- Main target                                                         -->
      <!-- =================================================================== -->
      <target name="main" depends="collect-jars" description="build the runnable application">
      </target>
  
      <!-- =================================================================== -->
      <!-- Creates the javadocs archive.                                       -->
      <!-- =================================================================== -->
      <target name="javadocs" description="Generates javadoc documentation">
      </target>
  
      <!-- =================================================================== -->
      <!-- Cleans up compiled classes and generated XMLC source.               -->
      <!-- =================================================================== -->
      <target name="clean" description="cleans up the directory">
      </target>
  </project>
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/bin/client.bat
  
  Index: client.bat
  ===================================================================
  @echo off
  rem
  rem Example start script.
  rem
  rem Author: Leif Mortenson [leif@silveregg.co.jp]
  
  rem
  rem Determine if JAVA_HOME is set and if so then use it
  rem
  if not "%JAVA_HOME%"=="" goto found_java
  
  set EXAMPLE_JAVACMD=java
  goto file_locate
  
  :found_java
  set EXAMPLE_JAVACMD=%JAVA_HOME%\bin\java
  
  :file_locate
  
  rem
  rem Locate where the example is in filesystem
  rem
  if not "%OS%"=="Windows_NT" goto start
  
  rem %~dp0 is name of current script under NT
  set EXAMPLE_HOME=%~dp0
  
  rem : operator works similar to make : operator
  set EXAMPLE_HOME=%EXAMPLE_HOME:\bin\=%
  
  :start
  
  if not "%EXAMPLE_HOME%" == "" goto example_home
  
  echo.
  echo Warning: EXAMPLE_HOME environment variable is not set.
  echo   This needs to be set for Win9x as it's command prompt 
  echo   scripting bites
  echo.
  goto end
  
  :example_home
  rem
  rem build the runtime classpath
  rem
  set CP=
  
  
  set _LIBJARS=
  for %%i in (%EXAMPLE_HOME%\lib\*.jar) do call %EXAMPLE_HOME%\bin\cpappend.bat %%i
  if not "%_LIBJARS%" == "" goto run
  
  echo Unable to set CLASSPATH dynamically.
  goto end
  
  :run
  set CP=%CP%%_LIBJARS%
  
  rem Run the example application
  %EXAMPLE_JAVACMD% -Djava.compiler="NONE" -classpath "%CP%" org.apache.avalon.excalibur.instrument.client.Main %1 %2 %3 %4 %5 %6 %7 %8 %9
  
  :end
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/bin/client.sh
  
  Index: client.sh
  ===================================================================
  #!/bin/bash 
  #
  # Startup script.
  #
  
  #
  # Determine if JAVA_HOME is set and if so then use it
  #
  if [ -z "$JAVA_HOME" ] ;  then
    JAVA=`which java`
    if [ -z "$JAVA" ] ; then
      echo "Cannot find JAVA. Please set your PATH."
      exit 1
    fi
    JAVA_BINDIR=`dirname $JAVA`
    JAVA_HOME=$JAVA_BINDIR/..
  fi
  
  if [ "$JAVACMD" = "" ] ; then
     # it may be defined in env - including flags!!
     JAVACMD=$JAVA_HOME/bin/java
  fi
  
  EXAMPLE_HOME=..
  
  #
  # Build the runtime classpath
  #
  for i in ${EXAMPLE_HOME}/lib/*.jar ; do
      CP=${CP}:$i
  done
  
  #echo $CP
  
  # Run the example application
  $JAVACMD -classpath $CP org.apache.avalon.excalibur.instrument.client.Main $@
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/example/bin/cpappend.bat
  
  Index: cpappend.bat
  ===================================================================
  set _LIBJARS=%_LIBJARS%;%1
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/AbstractInternalFrame.java
  
  Index: AbstractInternalFrame.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.BorderLayout;
  import java.awt.Dimension;
  import javax.swing.JDesktopPane;
  import javax.swing.JInternalFrame;
  import javax.swing.JPanel;
  import javax.swing.event.InternalFrameEvent;
  import javax.swing.event.InternalFrameListener;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:23 $
   * @since 4.1
   */
  abstract class AbstractInternalFrame
      extends JInternalFrame
      implements InternalFrameListener
  {
      private InstrumentClientFrame m_frame;
      private JInternalFrame m_nextFrame;
      private boolean m_loaded;
  
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      AbstractInternalFrame( Configuration stateConfig,
                             boolean resizable,
                             boolean closable,
                             boolean maximizable,
                             boolean iconifiable,
                             InstrumentClientFrame frame )
      {
          super( "", resizable, closable, maximizable, iconifiable );
  
          m_frame = frame;
  
          // Look for the location and size of the frame.
          int x = stateConfig.getAttributeAsInteger( "x", getX() );
          int y = stateConfig.getAttributeAsInteger( "y", getY() );
          int width = stateConfig.getAttributeAsInteger( "width", getWidth() );
          int height = stateConfig.getAttributeAsInteger( "height", getHeight() );
          setLocation( x, y );
          setSize( width, height );
  
          // Look for the window state.
          try
          {
              if( stateConfig.getAttributeAsBoolean( "iconized", false ) )
              {
                  setIcon( true );
              }
              else if( stateConfig.getAttributeAsBoolean( "maximized", false ) )
              {
                  this.setMaximum( true );
              }
          }
          catch( java.beans.PropertyVetoException e )
          {
          }
  
          // Set the content pane so that it is the right color
          JPanel contentPane = new JPanel();
          contentPane.setLayout( new BorderLayout() );
          setContentPane( contentPane );
  
          addInternalFrameListener( this );
  
          m_loaded = true;
      }
  
      AbstractInternalFrame( String title,
                             boolean resizable,
                             boolean closable,
                             boolean maximizable,
                             boolean iconifiable,
                             InstrumentClientFrame frame )
      {
          super( title, resizable, closable, maximizable, iconifiable );
  
          m_frame = frame;
  
          // Set the content pane so that it is the right color
          JPanel contentPane = new JPanel();
          contentPane.setLayout( new BorderLayout() );
          setContentPane( contentPane );
  
          addInternalFrameListener( this );
  
          m_loaded = false;
      }
  
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      /**
       * Adds the frame to the desktop in a simple and dumb cascading format.
       */
      void addToDesktop( JDesktopPane desktop )
      {
          // Make sure that the size is valid
          Dimension maxSize = desktop.getSize();
          Dimension size = getSize();
          if( ( maxSize.width < size.width ) || ( maxSize.height < size.height ) )
          {
              setSize( new Dimension( Math.min( maxSize.width, size.width ),
                                      Math.min( maxSize.height, size.height ) ) );
              size = getSize();
          }
  
          if( !m_loaded )
          {
              // Position the frame
              int max = (int)Math.min( Math.ceil( ( maxSize.width - size.width ) / 20.0 ),
                                       Math.ceil( ( maxSize.height - size.height ) / 20.0 ) );
  
              JInternalFrame[] frames = desktop.getAllFrames();
              int pos;
              if( max > 0 )
              {
                  pos = ( frames.length % max ) * 20;
              }
              else
              {
                  pos = 0;
              }
              setLocation( pos, pos );
          }
  
          desktop.add( this );
      }
  
      void hideFrame()
      {
          setVisible( false );
          dispose();
      }
  
      public void updateUI()
      {
          super.updateUI();
  
          pack();
          setMinimumSize( getSize() );
      }
  
      /**
       * Allows subclasses to fill in configuration information.  At the least, they must set
       *  a type attribute.
       */
      abstract protected void getState( DefaultConfiguration stateConfig );
  
      final Configuration getState()
      {
          DefaultConfiguration stateConfig = new DefaultConfiguration( "inner-frame", "-" );
  
          // Save the location and size of the frame.
          stateConfig.setAttribute( "x", Integer.toString( getX() ) );
          stateConfig.setAttribute( "y", Integer.toString( getY() ) );
          stateConfig.setAttribute( "width", Integer.toString( getWidth() ) );
          stateConfig.setAttribute( "height", Integer.toString( getHeight() ) );
  
          // Save the window state.
          if( isIcon() )
          {
              stateConfig.setAttribute( "iconized", "true" );
          }
          else if( isMaximum() )
          {
              stateConfig.setAttribute( "maximized", "true" );
          }
  
          getState( stateConfig );
  
          return stateConfig;
      }
      
      protected InstrumentClientFrame getFrame()
      {
          return m_frame;
      }
  
      /*---------------------------------------------------------------
       * InternalFrameListener Methods
       *-------------------------------------------------------------*/
      public void internalFrameOpened( InternalFrameEvent event )
      {
      }
  
      public void internalFrameClosing( InternalFrameEvent event )
      {
          // Select the new top frame
          JDesktopPane desktop = m_frame.getDesktopPane();
          JInternalFrame[] frames = desktop.getAllFrames();
          // Find the first frame other than the one being hidden and select and move it to the front
          m_nextFrame = null;
          for( int i = 0; i < frames.length; i++ )
          {
              JInternalFrame frame = frames[ i ];
              if( frame != this )
              {
                  m_nextFrame = frame;
  
                  // Break out
                  i = frames.length;
              }
          }
      }
  
      public void internalFrameClosed( InternalFrameEvent event )
      {
          // On closing Swing will bring forward the window at the bottom,
          //	rather than the next window.  So we need to move it back and show the correct one.
          if( m_nextFrame != null )
          {
              // The getSelectedFrame method was added in JDK1.3, so it may not yet exist.
              // Cast this to our workaround DesktopPane to work around this.
              DesktopPane desktop = (DesktopPane)m_frame.getDesktopPane();
              JInternalFrame top = desktop.getSelectedFrame();
  
              if( top != null )
              {
                  if( top != m_nextFrame )
                  {
                      try
                      {
                          m_nextFrame.setSelected( true );
                          desktop.moveToFront( m_nextFrame );
                          desktop.moveToBack( top );
                      }
                      catch( java.beans.PropertyVetoException e )
                      {
                      }
                  }
              }
          }
      }
  
      public void internalFrameIconified( InternalFrameEvent event )
      {
      }
  
      public void internalFrameDeiconified( InternalFrameEvent event )
      {
          // Swing always activates a frame when it is deiconified, but it down't
          //  always move it to the front
          JDesktopPane desktop = m_frame.getDesktopPane();
          desktop.moveToFront( this );
      }
  
      public void internalFrameActivated( InternalFrameEvent event )
      {
      }
  
      public void internalFrameDeactivated( InternalFrameEvent event )
      {
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/DesktopPane.java
  
  Index: DesktopPane.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import javax.swing.JDesktopPane;
  import javax.swing.JInternalFrame;
  
  /**
   * This class was build to make it possible to use some of the JDK1.3
   *  features work in 1.2.2. Taken from JDK1.3 source to make it work.
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:23 $
   * @since 4.1
   */
  class DesktopPane extends JDesktopPane
  {
      private transient JInternalFrame selectedFrame = null;
  
      /**
       * Used to indicate you wish to see the entire contents of the item being
       * dragged inside the desktop pane.
       *
       * @see #OUTLINE_DRAG_MODE
       * @see #setDragMode
       */
      public static int LIVE_DRAG_MODE = 0;
  
      /**
       * Used to indicate you wish to see only an outline of the item being
       * dragged inside the desktop pane.
       *
       * @see #LIVE_DRAG_MODE
       * @see #setDragMode
       */
      public static int OUTLINE_DRAG_MODE = 1;
  
      private int dragMode = LIVE_DRAG_MODE;
  
      /**
       * Set the "dragging style" used by the desktop pane.  You may want to change
       * to one mode or another for performance or aesthetic reasons.
       *
       * @param dragMode the style of drag to use for items in the Desktop
       *
       * @beaninfo
       *        bound: true
       *  description: Dragging style for internal frame children.
       *         enum: LIVE_DRAG_MODE JDesktopPane.LIVE_DRAG_MODE
       *               OUTLINE_DRAG_MODE JDesktopPane.OUTLINE_DRAG_MODE
       */
      public void setDragMode( int dragMode )
      {
          /* if (!(dragMode == LIVE_DRAG_MODE || dragMode == OUTLINE_DRAG_MODE)) {
          throw new IllegalArgumentException("Not a valid drag mode");
          }*/
          firePropertyChange( "dragMode", this.dragMode, dragMode );
          this.dragMode = dragMode;
      }
  
      /**
       * Get the current "dragging style" used by the desktop pane.
       * @see #setDragMode
       */
      public int getDragMode()
      {
          return dragMode;
      }
  
      /** return the currently active JInternalFrame in this JDesktopPane, or
       * null if no JInternalFrame is currently active.
       *
       * @return the currently active JInternalFrame or null
       * @since 1.3
       */
      public JInternalFrame getSelectedFrame()
      {
          return selectedFrame;
      }
  
      /** set the currently active JInternalFrame in this JDesktopPane.
       *
       * @param f The internal frame that's currently selected
       * @since 1.3
       */
  
      public void setSelectedFrame( JInternalFrame f )
      {
          selectedFrame = f;
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/InstrumentClientFrame.java
  
  Index: InstrumentClientFrame.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.BorderLayout;
  import java.io.File;
  import java.util.HashMap;
  
  import javax.swing.JDesktopPane;
  import javax.swing.JFrame;
  import javax.swing.JInternalFrame;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.SwingUtilities;
  import javax.swing.border.BevelBorder;
  
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentableDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentSampleDescriptor;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:23 $
   * @since 4.1
   */
  class InstrumentClientFrame
      extends JFrame
      implements Runnable
  {
      private String m_title;
      
      private JDesktopPane m_desktopPane;
      private MenuBar m_menuBar;
  
      private File m_desktopFile;
      private File m_desktopFileDir;
      
      private HashMap m_connections = new HashMap();
      private InstrumentManagerConnection[] m_connectionArray;
  
      private Thread m_runner;
      
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      /**
       * Creates a new InstrumentClient frame.
       *
       * @param title The title for the frame.
       */
      InstrumentClientFrame( String title )
      {
          super();
  
          m_title = title;
          
          init();
  
          m_runner = new Thread( this, "InstrumentClientFrameRunner" );
          m_runner.start();
      }
      
      /*---------------------------------------------------------------
       * Runnable Methods
       *-------------------------------------------------------------*/
      public void run()
      {
          while( m_runner != null )
          {
              try
              {
                  try
                  {
                      Thread.sleep( 1000 );
                  }
                  catch( InterruptedException e )
                  {
                  }
                  
                  // Check on the status of all of the connections (Avoid synchronization)
                  InstrumentManagerConnection[] connectionArray = m_connectionArray;
                  if ( connectionArray == null )
                  {
                      connectionArray = updateInstrumentManagerConnectionArray();
                  }
                  for ( int i = 0; i < connectionArray.length; i++ )
                  {
                      InstrumentManagerConnection connection = connectionArray[i];
                      if ( connection.isClosed() )
                      {
                          // Connection is closed, try to open it.
                          connection.tryOpen();
                      }
                      else
                      {
                          // Make sure that the connection is still open
                          connection.ping();
                      }
                  }
  
                  // Update each of the ProfileSampleFrames.  This is kind of temporary
                  //  to get rid of the one thread per frame issue.
                  JInternalFrame[] frames = m_desktopPane.getAllFrames();
                  for( int i = 0; i < frames.length; i++ )
                  {
                      JInternalFrame frame = frames[ i ];
                      
                      if( frame instanceof InstrumentSampleFrame )
                      {
                          ( (InstrumentSampleFrame)frame ).update();
                      }
                  }
              }
              catch( Throwable t )
              {
                  // Should not get here, but we want to make sure that this never happens.
                  System.out.println( "Unexpected error caught in ProfilerFrame runner:" );
                  t.printStackTrace();
              }
          }
      }
      
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      private void init()
      {
          updateTitle();
  
          getContentPane().setLayout( new BorderLayout() );
  
          // Create a DesktopPane and place it in a BevelBorder
          m_desktopPane = new DesktopPane();
          JPanel dBorder = new JPanel();
          dBorder.setBorder( new BevelBorder( BevelBorder.LOWERED ) );
          dBorder.setLayout( new BorderLayout() );
          dBorder.add( m_desktopPane, BorderLayout.CENTER );
          getContentPane().add( dBorder, BorderLayout.CENTER );
  
          // Create a Menu Bar
          m_menuBar = new MenuBar( this );
          setJMenuBar( m_menuBar );
  
          setLocation( 50, 50 );
          setSize( 640, 480 );
      }
      
      private void updateTitle()
      {
          if( m_desktopFile == null )
          {
              setTitle( m_title );
          }
          else
          {
              setTitle( m_title + " - " + m_desktopFile.getAbsolutePath() );
          }
      }
      
      JDesktopPane getDesktopPane()
      {
          return m_desktopPane;
      }
      
      void closeAllFrames()
      {
          JInternalFrame[] frames = m_desktopPane.getAllFrames();
          for( int i = 0; i < frames.length; i++ )
          {
              frames[ i ].setVisible( false );
              frames[ i ].dispose();
          }
      }
      
      InstrumentManagerConnection[] getInstrumentManagerConnections()
      {
          // Avoid synchronization when possible.
          InstrumentManagerConnection[] array = m_connectionArray;
          if ( array == null )
          {
              array = updateInstrumentManagerConnectionArray();
          }
          return array;
      }
      
      private InstrumentManagerConnection[] updateInstrumentManagerConnectionArray()
      {
          synchronized (this)
          {
              InstrumentManagerConnection[] array =
                  new InstrumentManagerConnection[ m_connections.size() ];
              m_connections.values().toArray( array );
              m_connectionArray = array;
              return array;
          }
      }
      
      InstrumentManagerConnection getInstrumentManagerConnection( String host, int port )
      {
          String key = host + ":" + port;
          synchronized (m_connections)
          {
              return (InstrumentManagerConnection)m_connections.get( key );
          }
      }
      
      void openInstrumentManagerConnection( String host, int port )
      {
          String key = host + ":" + port;
          synchronized (m_connections)
          {
              InstrumentManagerConnection connection =
                  (InstrumentManagerConnection)m_connections.get( key );
              if ( connection == null )
              {
                  connection = new InstrumentManagerConnection( host, port );
                  m_connections.put( key, connection );
                  m_connectionArray = null;
                  
                  openInstrumentManagerConnectionFrame( connection );
                  
                  return;
              }
          }
          
          // If we get here show an error that the connection alreay exists.
          //  Must be done outside the synchronization block.
          showErrorDialog( "A connection to " + key + " already exists." );
      }
      
      void openInstrumentManagerConnectionFrame( final InstrumentManagerConnection connection )
      {
          SwingUtilities.invokeLater( new Runnable()
          {
              public void run()
              {
                  InstrumentManagerFrame frame = 
                      new InstrumentManagerFrame( connection, InstrumentClientFrame.this );
  
                  frame.addToDesktop( m_desktopPane );
                  frame.show();
              }
          } );
      }
      
      void openInstrumentSampleFrame( final InstrumentManagerConnection connection,
                                      final InstrumentableDescriptor instrumentableDescriptor,
                                      final InstrumentDescriptor instrumentDescriptor,
                                      final InstrumentSampleDescriptor instrumentSampleDescriptor )
      {
          SwingUtilities.invokeLater( new Runnable()
          {
              public void run()
              {
                  String sampleName = instrumentSampleDescriptor.getName();
                  InstrumentSampleFrame frame = new InstrumentSampleFrame( connection,
                      sampleName, InstrumentClientFrame.this );
  
                  frame.addToDesktop( m_desktopPane );
                  frame.show();
              }
          } );
      }
      
      private void showErrorDialog( String message )
      {
          JOptionPane.showMessageDialog( this,
                                         "<html><body><font color=\"black\">" + message + "</font>" +
                                         "</body></html>", m_title + " Error",
                                         JOptionPane.ERROR_MESSAGE );
      }
      
      private void showErrorDialog( String message, Throwable t )
      {
          JOptionPane.showMessageDialog( this,
                                         "<html><body><font color=\"black\">" + message + 
                                         "</font><br><br><font color=\"black\">Reason: " +
                                         t.getMessage() + "</font></body></html>",
                                         m_title + " Error", JOptionPane.ERROR_MESSAGE );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/InstrumentManagerConnection.java
  
  Index: InstrumentManagerConnection.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentManagerClient;
  
  import org.apache.commons.altrmi.client.AltrmiHostContext;
  import org.apache.commons.altrmi.client.AltrmiFactory;
  import org.apache.commons.altrmi.client.impl.socket.SocketObjectStreamHostContext;
  import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  import org.apache.commons.altrmi.common.AltrmiInvocationException;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  class InstrumentManagerConnection
  {
      private String m_host;
      private int m_port;
      private boolean m_closed;
      private AltrmiHostContext m_altrmiHostContext;
      private AltrmiFactory m_altrmiFactory;
      private InstrumentManagerClient m_manager;
      
      private ArrayList m_listeners = new ArrayList();
      
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      InstrumentManagerConnection( String host, int port )
      {
          m_host = host;
          m_port = port;
          m_closed = true;
      }
      
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      public String getHost()
      {
          return m_host;
      }
      
      public int getPort()
      {
          return m_port;
      }
      
      /**
       * Returns a title for the connection which can be used in frame titlesa
       *  and menus.  Reflects the connected status.
       */
      public String getTitle()
      {
          String description;
          synchronized(this)
          {
              if ( m_manager == null )
              {
                  description = "[Not Connected]";
              }
              else
              {
                  description = m_manager.getDescription();
              }
          }
          
          return description + " (" + m_host + ":" + m_port + ")";
      }
      
      public InstrumentManagerClient getInstrumentManagerClient()
      {
          return m_manager;
      }
      
      public void open() throws AltrmiConnectionException, IOException
      {
          synchronized (this)
          {
              m_altrmiHostContext = new SocketObjectStreamHostContext( m_host, m_port );
              m_altrmiFactory = new ClientClassAltrmiFactory( false );
              m_altrmiFactory.setHostContext( m_altrmiHostContext );
              
              System.out.println("Listing Published Objects At Server...");
              String[] listOfPublishedObjectsOnServer = m_altrmiFactory.list();
              for (int i = 0; i < listOfPublishedObjectsOnServer.length; i++) {
                  System.out.println("..[" + i + "]:" + listOfPublishedObjectsOnServer[i]);
              }
              
              m_manager = (InstrumentManagerClient)m_altrmiFactory.lookup(
                  "InstrumentManagerClient" );
              
              m_closed = false;
              
              // Notify the listeners.
              for ( Iterator iter = m_listeners.iterator(); iter.hasNext(); )
              {
                  ((InstrumentManagerConnectionListener)iter.next()).opened( m_host, m_port);
              }
          }
      }
      
      /**
       * Attempts to open the connection.  If it fails, it just leaves it closed.
       */
      public void tryOpen()
      {
          try
          {
              open();
          }
          catch ( AltrmiConnectionException e )
          {
          }
          catch ( IOException e )
          {
          }
      }
      
      public boolean isClosed()
      {
          return m_closed;
      }
      
      public void close()
      {
          synchronized (this)
          {
              if ( !m_closed )
              {
                  m_closed = true;
                  m_manager = null;
                  m_altrmiFactory.close();
                  m_altrmiFactory = null;
                  m_altrmiHostContext = null;
                  
                  // Notify the listeners.
                  for ( Iterator iter = m_listeners.iterator(); iter.hasNext(); )
                  {
                      ((InstrumentManagerConnectionListener)iter.next()).closed( m_host, m_port);
                  }
              }
          }
      }
      
      public void dispose()
      {
          synchronized (this)
          {
              if ( !isClosed() )
              {
                  close();
              }
              
              // Notify the listeners.
              for ( Iterator iter = m_listeners.iterator(); iter.hasNext(); )
              {
                  ((InstrumentManagerConnectionListener)iter.next()).disposed( m_host, m_port);
              }
          }
      }
      
      public void ping()
      {
          synchronized(this)
          {
              // Ping the server by requesting the manager's name
              if ( m_manager != null )
              {
                  try
                  {
                      String name = m_manager.getName();
                  }
                  catch ( AltrmiInvocationException e )
                  {
                      // Socket was closed.
                      close();
                  }
              }
          }
      }
      
      public void addInstrumentManagerConnectionListener( InstrumentManagerConnectionListener listener )
      {
          synchronized (this)
          {
              m_listeners.add( listener );
          }
      }
      
      public void removeInstrumentManagerConnectionListener( InstrumentManagerConnectionListener listener )
      {
          synchronized (this)
          {
              m_listeners.remove( listener );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/InstrumentManagerConnectionListener.java
  
  Index: InstrumentManagerConnectionListener.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  interface InstrumentManagerConnectionListener
  {
      /**
       * Called when the connection is opened.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      void opened( String host, int port );
      
      /**
       * Called when the connection is closed.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      void closed( String host, int port );
      
      /**
       * Called when the connection is disposed.  All references should be removed.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      void disposed( String host, int port );
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/InstrumentManagerFrame.java
  
  Index: InstrumentManagerFrame.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.Dimension;
  
  import javax.swing.event.InternalFrameEvent;
  
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentManagerClient;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  class InstrumentManagerFrame
      extends AbstractInternalFrame
      implements InstrumentManagerConnectionListener
  {
      public static final String FRAME_TYPE = "instrument-manager-frame";
      
      private InstrumentManagerConnection m_connection;
  
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      InstrumentManagerFrame( Configuration stateConfig,
                              InstrumentClientFrame frame )
          throws ConfigurationException
      {
          super( stateConfig, true, true, true, true, frame );
          
          String host = stateConfig.getAttribute( "host" );
          int port = stateConfig.getAttributeAsInteger( "port" );
          
          // Obtain the specified connection.  It should have already been created from the state.
          m_connection = getFrame().getInstrumentManagerConnection( host, port );
          if ( m_connection == null )
          {
              throw new ConfigurationException( 
                  "Could not locate an Instrument Manager Connection at " + host + ":" + port );
          }
          
          m_connection.addInstrumentManagerConnectionListener( this );
          
          init();
      }
  
      InstrumentManagerFrame( InstrumentManagerConnection connection,
                              InstrumentClientFrame frame )
      {
          super( "", true, true, true, true, frame );
          
          m_connection = connection;
          
          connection.addInstrumentManagerConnectionListener( this );
          
          init();
  
          setSize( new Dimension( 400, 400 ) );
      }
  
      /*---------------------------------------------------------------
       * AbstractInternalFrame Methods
       *-------------------------------------------------------------*/
      /**
       * Allows subclasses to fill in configuration information.  At the least, they must set
       *  a type attribute.
       */
      protected void getState( DefaultConfiguration stateConfig )
      {
          stateConfig.setAttribute( "type", FRAME_TYPE );
          stateConfig.setAttribute( "host", m_connection.getHost() );
          stateConfig.setAttribute( "port", Integer.toString( m_connection.getPort() ) );
      }
  
      /*---------------------------------------------------------------
       * InternalFrameListener Methods
       *-------------------------------------------------------------*/
      public void internalFrameClosed( InternalFrameEvent event )
      {
          m_connection.removeInstrumentManagerConnectionListener( this );
  
          super.internalFrameClosed( event );
      }
      
      /*---------------------------------------------------------------
       * InstrumentManagerConnectionListener Methods
       *-------------------------------------------------------------*/
      /**
       * Called when the connection is opened.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void opened( String host, int port )
      {
          // Status changed, so reinitialize the frame.
          init();
      }
      
      /**
       * Called when the connection is closed.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void closed( String host, int port )
      {
          // Status changed, so reinitialize the frame.
          init();
      }
      
      /**
       * Called when the connection is disposed.  All references should be removed.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void disposed( String host, int port )
      {
          hideFrame();
      }
  
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      private void setTitle()
      {
          setTitle( m_connection.getTitle() );
      }
  
      private void init()
      {
          setTitle();
  
          //getContentPane().add( m_lineChart );
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/InstrumentSampleFrame.java
  
  Index: InstrumentSampleFrame.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.Color;
  import java.awt.Dimension;
  import javax.swing.JLabel;
  import javax.swing.SwingConstants;
  import javax.swing.event.InternalFrameEvent;
  
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentableDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentManagerClient;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentSampleDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentSampleSnapshot;
  import org.apache.avalon.excalibur.instrument.manager.client.NoSuchInstrumentableException;
  import org.apache.avalon.excalibur.instrument.manager.client.NoSuchInstrumentException;
  import org.apache.avalon.excalibur.instrument.manager.client.NoSuchInstrumentSampleException;
  
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.configuration.DefaultConfiguration;
  
  import org.apache.commons.altrmi.common.AltrmiInvocationException;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  class InstrumentSampleFrame
      extends AbstractInternalFrame
      implements InstrumentManagerConnectionListener
  {
      public static final String FRAME_TYPE = "sample-frame";
  
      private InstrumentManagerConnection m_connection;
      private InstrumentableDescriptor m_instrumentableDescriptor;
      private InstrumentDescriptor m_instrumentDescriptor;
      private InstrumentSampleDescriptor m_instrumentSampleDescriptor;
      private String m_instrumentSampleName;
      private LineChart m_lineChart;
  
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      InstrumentSampleFrame( Configuration stateConfig,
                             InstrumentClientFrame frame )
          throws ConfigurationException
      {
          super( stateConfig, true, true, true, true, frame );
          
          String host = stateConfig.getAttribute( "host" );
          int port = stateConfig.getAttributeAsInteger( "port" );
          m_instrumentSampleName = stateConfig.getAttribute( "sample" );
          
          // Obtain the specified connection.  It should have already been created from the state.
          m_connection = getFrame().getInstrumentManagerConnection( host, port );
          if ( m_connection == null )
          {
              throw new ConfigurationException( 
                  "Could not locate an Instrument Manager Connection at " + host + ":" + port );
          }
          
          m_connection.addInstrumentManagerConnectionListener( this );
          
          init();
      }
  
      InstrumentSampleFrame( InstrumentManagerConnection connection,
                             String sampleName,
                             InstrumentClientFrame frame )
      {
          super( "", true, true, true, true, frame );
  
          m_connection = connection;
          m_instrumentSampleName = sampleName;
          
          connection.addInstrumentManagerConnectionListener( this );
  
          init();
  
          setSize( new Dimension( 600, 120 ) );
      }
  
      /*---------------------------------------------------------------
       * AbstractInternalFrame Methods
       *-------------------------------------------------------------*/
      /**
       * Allows subclasses to fill in configuration information.  At the least, they must set
       *  a type attribute.
       */
      protected void getState( DefaultConfiguration stateConfig )
      {
          stateConfig.setAttribute( "type", FRAME_TYPE );
          stateConfig.setAttribute( "host", m_connection.getHost() );
          stateConfig.setAttribute( "port", Integer.toString( m_connection.getPort() ) );
          stateConfig.setAttribute( "sample", m_instrumentSampleDescriptor.getName() );
      }
  
      /*---------------------------------------------------------------
       * InternalFrameListener Methods
       *-------------------------------------------------------------*/
      public void internalFrameClosed( InternalFrameEvent event )
      {
          m_connection.removeInstrumentManagerConnectionListener( this );
  
          super.internalFrameClosed( event );
      }
  
      /*---------------------------------------------------------------
       * InstrumentManagerConnectionListener Methods
       *-------------------------------------------------------------*/
      /**
       * Called when the connection is opened.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void opened( String host, int port )
      {
          // Status changed, so reinitialize the frame.
          init();
      }
      
      /**
       * Called when the connection is closed.  May be called more than once if 
       *  the connection to the InstrumentManager is reopened.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void closed( String host, int port )
      {
          // Status changed, so reinitialize the frame.
          init();
      }
      
      /**
       * Called when the connection is disposed.  All references should be removed.
       *
       * @param host Host of the connection.
       * @param host Port of the connection.
       */
      public void disposed( String host, int port )
      {
          hideFrame();
      }
  
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      /**
       * Sets the title of the frame.
       * <p>
       * Only called when synchronized.
       */
      private void setTitle()
      {
          String title;
          InstrumentManagerClient manager = m_connection.getInstrumentManagerClient();
          if ( manager == null )
          {
              title = m_connection.getTitle() + " : " + m_instrumentSampleName;
          }
          else
          {
              title = m_connection.getTitle() + " : " +
                  m_instrumentableDescriptor.getDescription() + " : " +
                  m_instrumentDescriptor.getDescription() + " : " +
                  m_instrumentSampleDescriptor.getDescription();
          }
  
          setTitle( title );
      }
  
      private void init()
      {
          synchronized (this)
          {
              // Clean out the content pane
              getContentPane().removeAll();
              
              InstrumentManagerClient manager = m_connection.getInstrumentManagerClient();
              if ( manager == null )
              {
                  // Not connected.
                  m_instrumentableDescriptor = null;
                  m_instrumentDescriptor = null;
                  m_instrumentSampleDescriptor = null;
                  
                  JLabel label = new JLabel( "Not Connected" );
                  label.setForeground( Color.red );
                  label.setHorizontalAlignment( SwingConstants.CENTER );
                  label.setVerticalAlignment( SwingConstants.CENTER );
                  
                  getContentPane().add( label );
              }
              else
              {
                  try
                  {
                      // Look up the descriptors.
                      try
                      {
                          m_instrumentableDescriptor =
                              manager.getInstrumentableDescriptor( m_instrumentSampleName );
                      }
                      catch ( NoSuchInstrumentableException e )
                      {
                          // Frame no longer valid.
                          hideFrame();
                          return;
                      }
                      try
                      {
                          m_instrumentDescriptor = m_instrumentableDescriptor.
                              getInstrumentDescriptor( m_instrumentSampleName );
                      }
                      catch ( NoSuchInstrumentException e )
                      {
                          // Frame no longer valid.
                          hideFrame();
                          return;
                      }
                      try
                      {
                          m_instrumentSampleDescriptor = m_instrumentDescriptor.
                              getInstrumentSampleDescriptor( m_instrumentSampleName );
                      }
                      catch ( NoSuchInstrumentSampleException e )
                      {
                          // Frame no longer valid.
                          hideFrame();
                          return;
                      }
                      
                      // Decide on a line interval based on the interval of the sample.
                      long interval = m_instrumentSampleDescriptor.getInterval();
                      int hInterval;
                      String format;
                      String detailFormat;
                      if( interval < 1000 )
                      {
                          // Once per 10 seconds.
                          hInterval = (int)( 10000 / interval );
                          format = "{2}:{3}:{4}";
                          detailFormat = "{0}/{1} {2}:{3}:{4}.{5}";
                      }
                      else if( interval < 60000 )
                      {
                          // Once per minute.
                          hInterval = (int)( 60000 / interval );
                          format = "{2}:{3}:{4}";
                          detailFormat = "{0}/{1} {2}:{3}:{4}";
                      }
                      else if( interval < 600000 )
                      {
                          // Once per 10 minutes
                          hInterval = (int)( 600000 / interval );
                          format = "{0}/{1} {2}:{3}";
                          detailFormat = "{0}/{1} {2}:{3}";
                      }
                      else if( interval < 3600000 )
                      {
                          // Once per hour.
                          hInterval = (int)( 3600000 / interval );
                          format = "{0}/{1} {2}:{3}";
                          detailFormat = "{0}/{1} {2}:{3}";
                      }
                      else if( interval < 86400000 )
                      {
                          // Once per day.
                          hInterval = (int)( 86400000 / interval );
                          format = "{0}/{1}";
                          detailFormat = "{0}/{1} {2}:{3}";
                      }
                      else
                      {
                          // Default to every 10 points.
                          hInterval = 10;
                          format = "{0}/{1} {2}:{3}";
                          detailFormat = "{0}/{1} {2}:{3}";
                      }
              
                      m_lineChart = new LineChart( hInterval,
                          m_instrumentSampleDescriptor.getInterval(), format, detailFormat, 20 );
              
                      getContentPane().add( m_lineChart );
                  }
                  catch ( AltrmiInvocationException e )
                  {
                      // Server went away, close the connection
                      m_connection.close();
                  }
              }
              
              // Set the title last so that the descriptors can be reloaded if necessary.
              setTitle();
          }
  
          update();
      }
  
      void update()
      {
          synchronized (this)
          {
              if (  m_instrumentSampleDescriptor != null )
              {
                  try
                  {
                      InstrumentSampleSnapshot snapshot = m_instrumentSampleDescriptor.getSnapshot();
              
                      int[] samples = snapshot.getSamples();
              
                      m_lineChart.setValues( samples, snapshot.getTime() );
                  }
                  catch ( AltrmiInvocationException e )
                  {
                      // Server went away, close the connection
                      m_connection.close();
                  }
              }
          }
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/LineChart.java
  
  Index: LineChart.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.FontMetrics;
  import java.awt.Graphics;
  import java.awt.Insets;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseListener;
  import java.awt.event.MouseMotionListener;
  import java.text.DecimalFormat;
  import java.text.MessageFormat;
  import java.util.Calendar;
  import java.util.Date;
  import javax.swing.JComponent;
  
  /**
   * Draws a nice pretty chart given a set of data.
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  
  /*
   * Disclaimer.  I know that this code is ugly.  It is taken from an old
   *  project and works. :-)
   */
  public class LineChart
      extends JComponent
      implements MouseListener, MouseMotionListener
  {
      private Color m_lineColor = Color.red;
      private Color m_lightLineColor = new Color( 255, 128, 128 );
      private Color m_lightGridColor = new Color( 192, 192, 192 );
      private Color m_darkGridColor = new Color( 128, 128, 128 );
      private Color m_frameColor = Color.black;
      private Color m_crossColor = Color.blue;
      private Color m_maskFrameColor = new Color( 128, 128, 255, 192 );
      private Color m_maskColor = new Color( 224, 224, 255, 192 );
  
      /** Number of sample points between vertical lines. */
      private int m_lineSampleInterval;
  
      /** The number of milliseconds represented by each data sample. */
      private long m_sampleInterval;
  
      /**
       * Format of the text which is displayed along the x (time) axis of the
       *  chart.
       */
      private String m_format;
  
      /**
       * Format of the text which is displayed over the component as
       *	the user moves the mouse over the line chart.
       */
      private String m_dFormat;
  
      /** Number of sample points to use when calculating the moving average. */
      private int m_averageWindow;
      /** Time of the last sample point. */
      private long m_time;
  
      /** Sample point data. */
      private int[] m_values;
  
      /** Moving average of the sample point data. */
      private float[] m_averageWindowValues;
  
      /** Minimum value in m_values. */
      private int m_min;
  
      /** Maximum value in m_values. */
      private int m_max;
  
      /** Integer number format. */
      private DecimalFormat m_intFormat = new DecimalFormat( "###,###,###,##0" );
  
      /** Decimal number format. */
      private DecimalFormat m_floatFormat = new DecimalFormat( "###,###,###,##0.00" );
  
      private boolean m_mouseOver;
      private boolean m_mousePressed;
      private int m_mouseX;
      private int m_mouseY;
  
      /*---------------------------------------------------------------
       * Constructor
       *-------------------------------------------------------------*/
      /**
       * @param lineSampleInterval The interval in data points at which to place vertical
       *	lines and labels along the x (time) axis.
       * @param sampleInterval The number of milliseconds represented by each data sample.
       * @param format Format of the text which is displayed along the x (time) axis of
       *	the chart.  The text will display the time of the line chart at a particular
       *	interval.  The text should take the format "{0}/{1} {2}:{3}:{4}.{5}" where {0} is
       *	replaced by the month, {1} by the day, {2} by the hour, {3} by the minute, {4}
       *	by the second, and {5} by the hundereths of a second.
       * @param detailFormat Format of the text which is displayed over the component as
       *	the user moves the mouse over the line chart.  The text will display the exact
       *	value of the line chart at a particular point.  The text should take the format
       *	"{0}/{1} {2}:{3}:{4}.{5}" where {0} is replaced by the month, {1} by the day,
       *  {2} by the hour, {3} by the minute, {4} by the second, and {5} by the hundereths
       *  of a second.
       * @param averageWindow Number of data points to do a moving average over when the
       *	mouse is pressed on the component.
       */
      public LineChart( int lineSampleInterval,
                        long sampleInterval,
                        String format,
                        String detailFormat,
                        int averageWindow )
      {
          m_lineSampleInterval = lineSampleInterval;
          m_sampleInterval = sampleInterval;
          m_format = format;
          m_dFormat = detailFormat;
          m_averageWindow = averageWindow;
  
          setBackground( Color.white );
          setValues( new int[ 0 ], System.currentTimeMillis() );
          addMouseListener( this );
          addMouseMotionListener( this );
      }
  
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      /**
       * Sets the data samples to be displayed by the line chart.
       *
       * @param values Array of data samples.
       * @param time The time of the start of the last sample point.
       */
      public void setValues( int[] values, long time )
      {
          int max = 0;
          int min = Integer.MAX_VALUE;
          for( int i = 0; i < values.length; i++ )
          {
              int v = values[ i ];
              if( v > max ) max = v;
              if( v < min ) min = v;
          }
          if( ( max - min ) < 10 )
          {
              max += ( ( 10 - ( max - min ) ) / 2 );
              min -= ( 10 - ( max - min ) );
          }
          if( min < 0 )
          {
              max += -min;
              min = 0;
          }
  
          float[] averageValues = new float[ values.length ];
          if( m_averageWindow > 1 )
          {
              int total = 0;
              for( int i = 0; i < values.length; i++ )
              {
                  total += values[ i ];
                  if( i >= m_averageWindow - 1 )
                  {
                      if( i >= m_averageWindow )
                      {
                          total -= values[ i - m_averageWindow ];
                      }
                      averageValues[ i ] = (float)total / m_averageWindow;
                  }
                  else
                  {
                      averageValues[ i ] = Float.MIN_VALUE;
                  }
              }
          }
  
          synchronized( this )
          {
              m_time = time;
              m_values = values;
              m_averageWindowValues = averageValues;
              m_min = min;
              m_max = max;
          }
  
          repaint();
      }
  
      private String getFormattedTime( Date dTime, boolean detailed )
      {
          Calendar calendar = Calendar.getInstance();
          calendar.setTime( dTime );
  
          int v;
          String month, day, hour, minute, second, hundreths;
  
          // Substitute the month
          v = calendar.get( Calendar.MONTH ) - Calendar.JANUARY + 1;
          if( v < 10 )
          {
              month = "0" + Integer.toString( v );
          }
          else
          {
              month = Integer.toString( v );
          }
  
          // Substitute the Day
          v = calendar.get( Calendar.DAY_OF_MONTH );
          if( v < 10 )
          {
              day = "0" + Integer.toString( v );
          }
          else
          {
              day = Integer.toString( v );
          }
  
          // Substitute the Hour
          v = calendar.get( Calendar.HOUR_OF_DAY );
          if( v < 10 )
          {
              hour = "0" + Integer.toString( v );
          }
          else
          {
              hour = Integer.toString( v );
          }
  
          // Substitute the Minute
          v = calendar.get( Calendar.MINUTE );
          if( v < 10 )
          {
              minute = "0" + Integer.toString( v );
          }
          else
          {
              minute = Integer.toString( v );
          }
  
          // Substitute the Second
          v = calendar.get( Calendar.SECOND );
          if( v < 10 )
          {
              second = "0" + Integer.toString( v );
          }
          else
          {
              second = Integer.toString( v );
          }
  
          // Substitute the Hudreths of a Second
          v = calendar.get( Calendar.MILLISECOND ) / 10;
          if( v < 10 )
          {
              hundreths = "0" + Integer.toString( v );
          }
          else
          {
              hundreths = Integer.toString( v );
          }
  
          String format;
          if( detailed )
          {
              format = MessageFormat.format( m_dFormat,
                                             new Object[]{month, day, hour, minute, second, hundreths} );
          }
          else
          {
              format = MessageFormat.format( m_format,
                                             new Object[]{month, day, hour, minute, second, hundreths} );
          }
          return format;
      }
  
      /**
       * Paints the component.
       *
       * @param g Graphics to paint the chart onto.
       */
      public synchronized void paintComponent( Graphics g )
      {
          Dimension size = getSize();
          Insets insets = getInsets();
  
          g.setColor( getBackground() );
          g.fillRect( insets.left, insets.top, size.width - insets.left - insets.right,
                      size.height - insets.top - insets.bottom );
  
          // Resolve the vertical interval
          int yLabelInterval = 1;
          while( ( m_max - m_min ) / yLabelInterval > 20 )
          {
              yLabelInterval *= 10;
          }
  
          FontMetrics fontMetrics = g.getFontMetrics();
          int maxYLabelWidth = fontMetrics.stringWidth( m_intFormat.format( m_max ) );
          int fontHeight = fontMetrics.getAscent();
          int fontHalfHeight = fontHeight / 2;
  
          int chartLeft = insets.left + maxYLabelWidth + 5;
          int chartTop = insets.top + 5;
          int chartWidth = size.width - chartLeft - insets.right - 1 - 5;
          int chartHeight = size.height - chartTop - insets.bottom - 1 - fontHeight;
  
          // Draw the horizontal grid (Left to Right lines)
          if( chartHeight > 0 )
          {
              int horizonalLineLabeledInterval = (int)Math.ceil(
                  (float)fontHeight / ( yLabelInterval * chartHeight / ( m_max - m_min ) ) );
              int horizontalLineNumber = 0;
              for( int i = ( (int)Math.ceil( (float)m_min / yLabelInterval ) ) * yLabelInterval;
                   i < m_max; i += yLabelInterval )
              {
                  // Calculate the location of the line on the y-axis.  Be careful of very large numbers
                  int y = chartTop + chartHeight -
                      (int)( (long)chartHeight * ( i - m_min ) / ( m_max - m_min ) );
  
                  if( horizontalLineNumber >= horizonalLineLabeledInterval )
                  {
                      horizontalLineNumber = 0;
                  }
                  if( horizontalLineNumber == 0 )
                  {
                      String lbl = m_intFormat.format( i );
                      g.setColor( m_frameColor );
                      g.drawString( lbl, chartLeft - 5 - fontMetrics.stringWidth( lbl ),
                                    y + fontHalfHeight );
  
                      g.setColor( m_darkGridColor );
                  }
                  else
                  {
                      g.setColor( m_lightGridColor );
                  }
                  horizontalLineNumber++;
  
                  if( chartWidth > 0 )
                  {
                      g.drawLine( chartLeft, y, chartLeft + chartWidth, y );
                  }
              }
          }
  
  
  
          // Draw the vertical grid (Top to Bottom lines)
          if( chartWidth > 0 )
          {
              // Figure out how wide a label is for formatting.
              String format = MessageFormat.format( m_format, new String[]{"00", "00", "00", "00"} );
              int fw = fontMetrics.stringWidth( format ) + 10;
  
              // Figure out what internal of lines we can place labels under.
              int verticalLineLabeledInterval;
              if( ( m_values.length > 0 ) && ( chartWidth > 0 ) )
              {
                  verticalLineLabeledInterval = (int)Math.ceil( (float)fw /
                                                                ( m_lineSampleInterval * chartWidth / ( m_values.length ) ) );
              }
              else
              {
                  verticalLineLabeledInterval = 1;
              }
  
              // Calculate a base time for drawing the vertical lines.
              long baseTime = ( ( m_time - m_values.length * m_sampleInterval ) /
                  ( m_sampleInterval * m_lineSampleInterval ) ) *
                  ( m_sampleInterval * m_lineSampleInterval );
  
              // Draw each of the lines.
              int verticalLineNumber = 0;
              for( int i = 0; i < m_values.length; i++ )
              {
                  long time = m_time - ( m_values.length - i - 1 ) * m_sampleInterval;
                  if( ( ( ( time - baseTime ) / m_sampleInterval ) % m_lineSampleInterval ) == 0 )
                  {
                      int x = chartLeft + i * chartWidth / ( m_values.length - 1 );
  
                      // Draw a label under the line if line should have a label.
                      if( ( verticalLineNumber >= verticalLineLabeledInterval ) ||
                          ( verticalLineNumber == 0 ) )
                      {
                          format = getFormattedTime( new Date( time ), false );
  
                          if( x - fontMetrics.stringWidth( format ) / 2 >= chartLeft )
                          {
                              g.setColor( m_frameColor );
                              g.drawString( format, x - fontMetrics.stringWidth( format ) / 2,
                                            chartTop + chartHeight + fontHeight );
  
                              g.setColor( m_darkGridColor );
                              verticalLineNumber = 1;
                          }
                          else
                          {
                              g.setColor( m_lightGridColor );
                          }
                      }
                      else
                      {
                          g.setColor( m_lightGridColor );
                          verticalLineNumber++;
                      }
  
                      // Draw the vertical line
                      if( chartHeight > 0 )
                      {
                          g.drawLine( x, chartTop, x, chartTop + chartHeight );
                      }
                  }
              }
          }
  
          if( ( chartWidth > 0 ) && ( chartHeight > 0 ) )
          {
              // Draw the frame
              g.setColor( m_frameColor );
              g.drawLine( chartLeft, chartTop, chartLeft, chartTop + chartHeight );
              g.drawLine( chartLeft, chartTop + chartHeight, chartLeft + chartWidth,
                          chartTop + chartHeight );
  
  
  
              // Draw the the values that make up the data of the chart.
              if( ( m_averageWindow > 0 ) && ( m_mousePressed ) )
              {
                  g.setColor( m_lightLineColor );
              }
              else
              {
                  g.setColor( m_lineColor );
              }
  
              int lastX = 0;
              int lastY = 0;
              for( int i = 0; i < m_values.length; i++ )
              {
                  // Calculate the location of the point on the x-axis.
                  int x = chartLeft + i * chartWidth / ( m_values.length - 1 );
  
                  // Calculate the location of the line on the y-axis.  Be careful of very large numbers
                  int y = chartTop + chartHeight -
                      (int)( (long)chartHeight * ( m_values[ i ] - m_min ) / ( m_max - m_min ) );
  
                  if( i > 0 )
                  {
                      g.drawLine( lastX, lastY, x, y );
                  }
  
                  lastX = x;
                  lastY = y;
              }
  
              // Draw the averaged values of the chart
              if( ( m_averageWindow > 0 ) && ( m_mousePressed ) )
              {
                  g.setColor( m_lineColor );
                  lastX = 0;
                  lastY = 0;
                  for( int i = m_averageWindow; i < m_averageWindowValues.length; i++ )
                  {
                      // Calculate the location of the point on the x-axis.
                      int x = chartLeft + i * chartWidth / ( m_averageWindowValues.length - 1 );
  
                      // Calculate the location of the line on the y-axis.  Be careful of very large
                      //  numbers.  The float value average valus makes this easy here.
                      int y = chartTop + chartHeight -
                          (int)( chartHeight * ( m_averageWindowValues[ i ] - m_min ) /
                          ( m_max - m_min ) );
  
                      if( i > m_averageWindow )
                      {
                          g.drawLine( lastX, lastY, x, y );
                      }
  
                      lastX = x;
                      lastY = y;
                  }
              }
  
              // Make the label visible if the user tracks over any part of the chart.
              if( ( m_mouseOver ) && ( m_mouseX >= chartLeft ) &&
                  ( m_mouseX <= chartLeft + chartWidth ) )
              {
                  // Figure out the index of the data point where the mouse is.
                  int index = (int)Math.round(
                      (float)( m_values.length - 1 ) * ( m_mouseX - chartLeft ) / chartWidth );
  
                  // Draw the label
                  int mouseDataPointX = 0;
                  int mouseDataPointY = 0;
                  String mouseDataPointValue = null;
                  long mouseDataPointTime = 0;
                  boolean showLabel = false;
  
                  if( ( m_averageWindow > 0 ) && ( m_mousePressed ) )
                  {
                      if( ( index >= m_averageWindow ) && ( index < m_averageWindowValues.length ) )
                      {
                          // Draw the label for the average data
  
                          // Calculate the location of the point on the x-axis.
                          mouseDataPointX = chartLeft + index * chartWidth /
                              ( m_averageWindowValues.length - 1 );
  
                          // Calculate the location of the line on the y-axis.  Be careful of very large
                          //  numbers.  The float value average valus makes this easy here.
                          mouseDataPointY = chartTop + chartHeight -
                              (int)( chartHeight * ( m_averageWindowValues[ index ] - m_min ) /
                              ( m_max - m_min ) );
  
                          // Round the average value to 2 decimal places.
                          mouseDataPointValue = m_floatFormat.format( m_averageWindowValues[ index ] );
  
                          // Get the time at the mouse data point
                          mouseDataPointTime = m_time -
                              ( m_averageWindowValues.length - index - 1 ) * m_sampleInterval;
  
                          showLabel = true;
                      }
                  }
                  else
                  {
                      if( ( index >= 0 ) && ( index < m_values.length ) )
                      {
                          // Draw the label for the regular data.
  
                          // Calculate the location of the point on the x-axis.
                          mouseDataPointX = chartLeft + index * chartWidth / ( m_values.length - 1 );
  
                          // Calculate the location of the line on the y-axis.  Be careful of very large
                          //  numbers.
                          mouseDataPointY = chartTop + chartHeight -
                              (int)( (long)chartHeight * ( m_values[ index ] - m_min ) /
                              ( m_max - m_min ) );
  
                          // Get the average value.
                          mouseDataPointValue = m_intFormat.format( m_values[ index ] );
  
                          // Get the time at the mouse data point
                          mouseDataPointTime = m_time - ( m_values.length - index - 1 ) *
                              m_sampleInterval;
  
                          showLabel = true;
                      }
                  }
  
                  if( showLabel )
                  {
                      // Draw a cross at the point being to be labeled.
                      g.setColor( m_crossColor );
                      g.drawLine( mouseDataPointX, chartTop, mouseDataPointX, chartTop + chartHeight );
                      g.drawLine( chartLeft, mouseDataPointY, chartLeft + chartWidth, mouseDataPointY );
  
                      // Get the text of the label
                      String mouseDataPointLabel = mouseDataPointValue + " : " +
                          getFormattedTime( new Date( mouseDataPointTime ), true );
                      int mouseDataPointLabelWidth = fontMetrics.stringWidth( mouseDataPointLabel );
                      int mouseDataPointLabelLeft;
                      int mouseDataPointLabelTop;
  
                      // If the point is near the edges of the chart, then it would run off the chart.
                      //  To avoid this, the label is moved around relative to the location of the cross.
                      //  Decide where it should go.
                      if( mouseDataPointX + 5 + mouseDataPointLabelWidth < chartLeft + chartWidth )
                      {
                          // Ok on the right
                          mouseDataPointLabelLeft = mouseDataPointX + 4;
                          if( mouseDataPointY + 5 + fontHeight < chartTop + chartHeight )
                          {
                              // Ok on the bottom
                              mouseDataPointLabelTop = mouseDataPointY + 4;
                          }
                          else
                          {
                              // Must go on the top
                              mouseDataPointLabelTop = mouseDataPointY - 4 - fontHeight;
                          }
                      }
                      else
                      {
                          // Must go on the left
                          mouseDataPointLabelLeft = mouseDataPointX - 4 - mouseDataPointLabelWidth;
                          if( mouseDataPointY + 5 + fontHeight < chartTop + chartHeight )
                          {
                              // Ok on the bottom
                              mouseDataPointLabelTop = mouseDataPointY + 4;
                          }
                          else
                          {
                              // Must go on the top
                              mouseDataPointLabelTop = mouseDataPointY - 4 - fontHeight;
                          }
                      }
  
                      // Draw an outline around the location of the label.
                      g.setColor( m_maskFrameColor );
                      g.drawRect( mouseDataPointLabelLeft - 1, mouseDataPointLabelTop - 1,
                                  mouseDataPointLabelWidth + 2, fontHeight + 2 );
  
                      // Draw the background of the label.  By default this is partly transparent and
                      //  looks better on top of the outline.
                      g.setColor( m_maskColor );
                      g.fillRect( mouseDataPointLabelLeft - 1, mouseDataPointLabelTop - 1,
                                  mouseDataPointLabelWidth + 2, fontHeight + 2 );
  
                      // Draw the text of the label.
                      g.setColor( m_crossColor );
                      g.drawString( mouseDataPointLabel, mouseDataPointLabelLeft,
                                    mouseDataPointLabelTop + fontHeight );
                  }
              }
          }
      }
  
      /*---------------------------------------------------------------
       * MouseListener Methods
       *-------------------------------------------------------------*/
      public void mouseClicked( MouseEvent event )
      {
      }
  
      public void mousePressed( MouseEvent event )
      {
          m_mousePressed = true;
      }
  
      public void mouseReleased( MouseEvent event )
      {
          m_mousePressed = false;
      }
  
      public void mouseEntered( MouseEvent event )
      {
          m_mouseOver = true;
          repaint();
      }
  
      public void mouseExited( MouseEvent event )
      {
          m_mouseOver = false;
          repaint();
      }
  
      /*---------------------------------------------------------------
       * MouseMotionListener Methods
       *-------------------------------------------------------------*/
      public void mouseDragged( MouseEvent event )
      {
          m_mouseX = event.getX();
          m_mouseY = event.getY();
          repaint();
      }
  
      public void mouseMoved( MouseEvent event )
      {
          m_mouseX = event.getX();
          m_mouseY = event.getY();
          repaint();
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/Main.java
  
  Index: Main.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  public class Main
  {
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      
      /*---------------------------------------------------------------
       * Main Method
       *-------------------------------------------------------------*/
      /**
       * Main method used to lauch an InstrumentClient application.
       */
      public static void main( String args[] )
      {
          InstrumentClientFrame client = new InstrumentClientFrame( "Instrument Client" );
          client.show();
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/java/org/apache/avalon/excalibur/instrument/client/MenuBar.java
  
  Index: MenuBar.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.instrument.client;
  
  import java.awt.event.ActionEvent;
  import java.util.Arrays;
  import java.util.Comparator;
  import javax.swing.AbstractAction;
  import javax.swing.Action;
  import javax.swing.JCheckBoxMenuItem;
  import javax.swing.JInternalFrame;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.event.MenuEvent;
  import javax.swing.event.MenuListener;
  
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentableDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentDescriptor;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentManagerClient;
  import org.apache.avalon.excalibur.instrument.manager.client.InstrumentSampleDescriptor;
  
  import org.apache.commons.altrmi.common.AltrmiInvocationException;
  
  /**
   *
   * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/03/26 11:32:24 $
   * @since 4.1
   */
  public class MenuBar
      extends JMenuBar
  {
      private InstrumentClientFrame m_frame;
      //private ProfilerManager m_profilerManager;
  
      private JMenu m_menuFile;
  
      private JMenu m_menuInstrumentManagers;
  
      private JMenu m_menuOptions;
      private JCheckBoxMenuItem m_menuItemShowUnconfigured;
  
      private JMenu m_menuWindow;
  
      private boolean m_showUnconfigured;
  
      /*---------------------------------------------------------------
       * Constructors
       *-------------------------------------------------------------*/
      MenuBar( InstrumentClientFrame frame/*, ProfilerManager profilerManager*/ )
      {
          m_frame = frame;
          //m_profilerManager = profilerManager;
  
          add( buildFileMenu() );
          add( buildInstrumentManagerMenu() );
          add( buildOptionsMenu() );
          add( buildWindowMenu() );
      }
  
      /*---------------------------------------------------------------
       * Methods
       *-------------------------------------------------------------*/
      private JMenu buildFileMenu()
      {
          m_menuFile = new JMenu( "File" );
          m_menuFile.setMnemonic( 'F' );
  
          // Clear
          Action newAction = new AbstractAction( "New" )
          {
              public void actionPerformed( ActionEvent event )
              {
                  //m_frame.fileNew();
              }
          };
          JMenuItem newItem = new JMenuItem( newAction );
          newItem.setMnemonic( 'N' );
          m_menuFile.add( newItem );
  
          // Open
          Action openAction = new AbstractAction( "Open ..." )
          {
              public void actionPerformed( ActionEvent event )
              {
                  //m_frame.fileOpen();
              }
          };
          JMenuItem open = new JMenuItem( openAction );
          open.setMnemonic( 'O' );
          m_menuFile.add( open );
  
          // Save
          Action saveAction = new AbstractAction( "Save" )
          {
              public void actionPerformed( ActionEvent event )
              {
                  //m_frame.fileSave();
              }
          };
          JMenuItem save = new JMenuItem( saveAction );
          save.setMnemonic( 'S' );
          m_menuFile.add( save );
  
          // Save As
          Action saveAsAction = new AbstractAction( "Save As ..." )
          {
              public void actionPerformed( ActionEvent event )
              {
                  //m_frame.fileSaveAs();
              }
          };
          JMenuItem saveAs = new JMenuItem( saveAsAction );
          saveAs.setMnemonic( 'A' );
          m_menuFile.add( saveAs );
  
          return m_menuFile;
      }
  
      private JMenu buildInstrumentManagerMenu()
      {
          m_menuInstrumentManagers = new JMenu( "Instrument Managers" );
          m_menuInstrumentManagers.setMnemonic( 'I' );
  
          m_menuInstrumentManagers.addMenuListener( new MenuListener()
          {
              public void menuSelected( MenuEvent event )
              {
                  rebuildInstrumentManagersMenu();
              }
  
              public void menuDeselected( MenuEvent event )
              {
              }
  
              public void menuCanceled( MenuEvent event )
              {
              }
          } );
  
          return m_menuInstrumentManagers;
      }
      
      private void rebuildInstrumentManagersMenu()
      {
          m_menuInstrumentManagers.removeAll();
          
          // Add Connect menu item
          Action connectAction = new AbstractAction( "Connect to Instrument Manager..." )
          {
              public void actionPerformed( ActionEvent event )
              {
                  // For now, skip the dialog
                  m_frame.openInstrumentManagerConnection( "localhost", 15555 );
              }
          };
          
          JMenuItem connectItem = new JMenuItem( connectAction );
          connectItem.setMnemonic( 'C' );
          m_menuInstrumentManagers.add( connectItem );
          
          // Add links to the connections
          InstrumentManagerConnection[] connections = m_frame.getInstrumentManagerConnections();
          if ( connections.length > 0 )
          {
              m_menuInstrumentManagers.addSeparator();
              
              for ( int i = 0; i < connections.length; i++ )
              {
                  InstrumentManagerConnection connection = connections[i];
                  
                  Action action = new AbstractAction( connection.getTitle() )
                  {
                      public void actionPerformed( ActionEvent event )
                      {
                      }
                  };
                  action.putValue( "InstrumentManagerConnection", connection );
                  
                  JMenu menu = new JMenu( action );
  
                  // Set up a Listener to handle the selected event.
                  menu.addMenuListener( new MenuListener()
                  {
                      public void menuSelected( MenuEvent event )
                      {
                          JMenu menu = (JMenu)event.getSource();
                          Action action = menu.getAction();
                          
                          rebuildInstrumentManagerMenu(
                              menu, (InstrumentManagerConnection)action.getValue(
                              "InstrumentManagerConnection" ) );
                      }
  
                      public void menuDeselected( MenuEvent event )
                      {
                      }
  
                      public void menuCanceled( MenuEvent event )
                      {
                      }
                  } );
  
                  m_menuInstrumentManagers.add( menu );
              }
          }
      }
  
      private void rebuildInstrumentManagerMenu( JMenu managerMenu,
                                                 InstrumentManagerConnection connection )
      {
          managerMenu.removeAll();
          
          boolean showAll = m_menuItemShowUnconfigured.getState();
          
          Action detailAction = new AbstractAction( "Details..." )
          {
              public void actionPerformed( ActionEvent event )
              {
                  JMenuItem item = (JMenuItem)event.getSource();
                  Action action = item.getAction();
                  
                  m_frame.openInstrumentManagerConnectionFrame(
                      (InstrumentManagerConnection)action.getValue( "connection" ) );
              }
          };
          detailAction.putValue( "connection", connection );
          
          JMenuItem detailItem = new JMenuItem( detailAction );
          detailItem.setMnemonic( 'D' );
          managerMenu.add( detailItem );
          
          try
          {
              InstrumentManagerClient manager = connection.getInstrumentManagerClient();
              
              if ( manager != null )
              {
                  managerMenu.addSeparator();
                  
                  InstrumentableDescriptor[] descriptors = manager.getInstrumentableDescriptors();
                  
                  for( int i = 0; i < descriptors.length; i++ )
                  {
                      InstrumentableDescriptor descriptor = descriptors[ i ];
          
                      if( showAll || descriptor.isConfigured() )
                      {
                          String description = descriptor.getDescription();
          
                          Action action = new AbstractAction( description )
                          {
                              public void actionPerformed( ActionEvent event )
                              {
                              }
                          };
                          action.putValue( "InstrumentManagerConnection", connection );
                          action.putValue( "InstrumentableDescriptor", descriptor );
          
                          JMenu menu = new JMenu( action );
          
                          // Set up a Listener to handle the selected event.
                          menu.addMenuListener( new MenuListener()
                          {
                              public void menuSelected( MenuEvent event )
                              {
                                  JMenu menu = (JMenu)event.getSource();
                                  Action action = menu.getAction();
                                  
                                  rebuildInstrumentableMenu(
                                      menu,
                                      (InstrumentManagerConnection)action.getValue(
                                          "InstrumentManagerConnection" ),
                                      (InstrumentableDescriptor)action.getValue(
                                          "InstrumentableDescriptor" ) );
                              }
          
                              public void menuDeselected( MenuEvent event )
                              {
                              }
          
                              public void menuCanceled( MenuEvent event )
                              {
                              }
                          } );
          
                          managerMenu.add( menu );
                      }
                  }
              }
          }
          catch ( AltrmiInvocationException e )
          {
              // Something went wrong, so close the connection.
              connection.close();
          }
      }
  
      private void rebuildInstrumentableMenu( JMenu instrumentableMenu,
                                              InstrumentManagerConnection connection,
                                              InstrumentableDescriptor instrumentableDescriptor )
      {
          instrumentableMenu.removeAll();
  
          boolean showAll = m_menuItemShowUnconfigured.getState();
          
          try
          {
              InstrumentDescriptor[] descriptors =
                  instrumentableDescriptor.getInstrumentDescriptors();
              
              for( int i = 0; i < descriptors.length; i++ )
              {
                  InstrumentDescriptor descriptor = descriptors[ i ];
      
                  if( showAll || descriptor.isConfigured() )
                  {
                      String description = descriptor.getDescription();
      
                      Action action = new AbstractAction( description )
                      {
                          public void actionPerformed( ActionEvent event )
                          {
                          }
                      };
                      action.putValue( "InstrumentManagerConnection", connection );
                      action.putValue( "InstrumentableDescriptor", instrumentableDescriptor );
                      action.putValue( "InstrumentDescriptor", descriptor );
      
                      JMenu menu = new JMenu( action );
      
                      // Set up a Listener to handle the selected event.
                      menu.addMenuListener( new MenuListener()
                      {
                          public void menuSelected( MenuEvent event )
                          {
                              JMenu menu = (JMenu)event.getSource();
                              Action action = menu.getAction();
                              
                              rebuildInstrumentMenu(
                                  menu,
                                  (InstrumentManagerConnection)action.getValue(
                                      "InstrumentManagerConnection" ),
                                  (InstrumentableDescriptor)action.getValue(
                                      "InstrumentableDescriptor" ),
                                  (InstrumentDescriptor)action.getValue(
                                      "InstrumentDescriptor" ) );
                          }
      
                          public void menuDeselected( MenuEvent event )
                          {
                          }
      
                          public void menuCanceled( MenuEvent event )
                          {
                          }
                      } );
      
                      instrumentableMenu.add( menu );
                  }
              }
          }
          catch ( AltrmiInvocationException e )
          {
              // Something went wrong, so close the connection.
              connection.close();
          }
      }
  
      private void rebuildInstrumentMenu( JMenu instrumentMenu,
                                          InstrumentManagerConnection connection,
                                          InstrumentableDescriptor instrumentableDescriptor,
                                          InstrumentDescriptor instrumentDescriptor )
      {
          instrumentMenu.removeAll();
  
          boolean showAll = m_menuItemShowUnconfigured.getState();
          
          try
          {
              InstrumentSampleDescriptor[] descriptors =
                  instrumentDescriptor.getInstrumentSampleDescriptors();
              
              for( int i = 0; i < descriptors.length; i++ )
              {
                  InstrumentSampleDescriptor descriptor = descriptors[ i ];
      
                  if( showAll || descriptor.isConfigured() )
                  {
                      String description = descriptor.getDescription();
      
                      Action action = new AbstractAction( description )
                      {
                          public void actionPerformed( ActionEvent event )
                          {
                              JMenuItem menu = (JMenuItem)event.getSource();
                              Action action = menu.getAction();
                              
                              m_frame.openInstrumentSampleFrame(
                                  (InstrumentManagerConnection)action.getValue(
                                      "InstrumentManagerConnection" ),
                                  (InstrumentableDescriptor)action.getValue(
                                      "InstrumentableDescriptor" ),
                                  (InstrumentDescriptor)action.getValue(
                                      "InstrumentDescriptor" ),
                                  (InstrumentSampleDescriptor)action.getValue(
                                      "InstrumentSampleDescriptor" ) );
                          }
                      };
                      action.putValue( "InstrumentManagerConnection", connection );
                      action.putValue( "InstrumentableDescriptor", instrumentableDescriptor );
                      action.putValue( "InstrumentDescriptor", instrumentDescriptor );
                      action.putValue( "InstrumentSampleDescriptor", descriptor );
      
                      JMenuItem item = new JMenuItem( action );
      
                      instrumentMenu.add( item );
                  }
              }
          }
          catch ( AltrmiInvocationException e )
          {
              // Something went wrong, so close the connection.
              connection.close();
          }
      }
  
      /*
      private void rebuildProfilePointMenu( JMenu profilePointMenu,
                                            ProfilableDescriptor profilableDescriptor,
                                            ProfilePointDescriptor profilePointDescriptor )
      {
          profilePointMenu.removeAll();
  
          ProfileSampleDescriptor[] profileSampleDescriptors = profilePointDescriptor.getProfileSampleDescriptors();
  
          Comparator comp = new Comparator()
          {
              public int compare( Object o1, Object o2 )
              {
                  return ( (ProfileSampleDescriptor)o1 ).getDescription().
                      compareTo( ( (ProfileSampleDescriptor)o2 ).getDescription() );
              }
  
              public boolean equals( Object obj )
              {
                  return false;
              }
          };
          Arrays.sort( profileSampleDescriptors, comp );
  
          for( int i = 0; i < profileSampleDescriptors.length; i++ )
          {
              ProfileSampleDescriptor profileSampleDescriptor = profileSampleDescriptors[ i ];
  
              String profileSampleName = profileSampleDescriptor.getDescription();
  
              Action action = new AbstractAction( profileSampleName )
              {
                  public void actionPerformed( ActionEvent event )
                  {
                      JMenuItem menu = (JMenuItem)event.getSource();
                      Action action = menu.getAction();
  
                      m_frame.openProfileSampleFrame(
                          (ProfilableDescriptor)action.getValue( "profilableDescriptor" ),
                          (ProfilePointDescriptor)action.getValue( "profilePointDescriptor" ),
                          (ProfileSampleDescriptor)action.getValue( "profileSampleDescriptor" ) );
                  }
              };
              action.putValue( "profilableDescriptor", profilableDescriptor );
              action.putValue( "profilePointDescriptor", profilePointDescriptor );
              action.putValue( "profileSampleDescriptor", profileSampleDescriptor );
  
              JMenuItem item = new JMenuItem( action );
  
              profilePointMenu.add( item );
          }
      }
      */
  
      private JMenu buildOptionsMenu()
      {
          m_menuOptions = new JMenu( "Options" );
          m_menuOptions.setMnemonic( 'O' );
  
          // Show Unconfigured Profilables option
          m_menuItemShowUnconfigured =
              new JCheckBoxMenuItem( "Show Unconfigured Profilables", false );
          m_menuOptions.add( m_menuItemShowUnconfigured );
  
          return m_menuOptions;
      }
  
      private JMenu buildWindowMenu()
      {
          m_menuWindow = new JMenu( "Window" );
          m_menuWindow.setMnemonic( 'W' );
  
          m_menuWindow.addMenuListener( new MenuListener()
          {
              public void menuSelected( MenuEvent event )
              {
                  rebuildWindowMenu();
              }
  
              public void menuDeselected( MenuEvent event )
              {
              }
  
              public void menuCanceled( MenuEvent event )
              {
              }
          } );
  
          return m_menuWindow;
      }
  
      private void rebuildWindowMenu()
      {
          m_menuWindow.removeAll();
  
          // Close All menu choice
          Action closeAllAction = new AbstractAction( "Close All" )
          {
              public void actionPerformed( ActionEvent event )
              {
                  m_frame.closeAllFrames();
              }
          };
  
          JMenuItem closeAll = new JMenuItem( closeAllAction );
          closeAll.setMnemonic( 'o' );
          m_menuWindow.add( closeAll );
  
  
          // List up all of the visible frames.
          JInternalFrame[] frames = m_frame.getDesktopPane().getAllFrames();
  
          if( frames.length > 0 )
          {
              m_menuWindow.addSeparator();
          }
  
          for( int i = 0; i < frames.length; i++ )
          {
              String label = ( i + 1 ) + " " + frames[ i ].getTitle();
              Action action = new AbstractAction( label )
              {
                  public void actionPerformed( ActionEvent event )
                  {
                      JMenuItem menu = (JMenuItem)event.getSource();
                      Action action = menu.getAction();
  
                      JInternalFrame frame = (JInternalFrame)action.getValue( "frame" );
                      try
                      {
                          if( frame.isIcon() )
                          {
                              // Restore the frame
                              frame.setIcon( false );
                          }
                          frame.setSelected( true );
                          m_frame.getDesktopPane().moveToFront( frame );
                      }
                      catch( java.beans.PropertyVetoException e )
                      {
                      }
                  }
              };
              action.putValue( "frame", frames[ i ] );
  
              JMenuItem item = new JMenuItem( action );
              m_menuWindow.add( item );
  
              if( i < 10 )
              {
                  item.setMnemonic( (char)( '1' + i ) );
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/instrument-client/src/test/README.txt
  
  Index: README.txt
  ===================================================================
  No tests yet.
  This file keeps the directory here until they are added.
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message