/////////////////////////////////////////////////////////////////////// // // SimpleAddin.java : Provide a Java interface to the Simple add-in. // /////////////////////////////////////////////////////////////////////// // // Copyright © 1997-98 by the IBM Corporation. All Rights Reserved. // // Author: Angel L. Diaz aldiaz@us.ibm.com // Robert S. Sutor sutor@us.ibm.com // // IBM MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF // THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A // PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR // ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING OR MODIFYING // THIS SOFTWARE OR ITS DERIVATIVES. // /////////////////////////////////////////////////////////////////////// import java.awt.*; import java.applet.Applet; import ibm.techexplorer.techexplorer; import ibm.techexplorer.control.techexplorerControl; import ibm.techexplorer.axtchexp.AxTchExpRaw; public class SimpleAddin extends java.applet.Applet { Label simpleAddinLabel = null; Button addInInitialize = null; Button addInShutdown = null; Button addInEvaluate = null; TextField evalTextField = null; Panel simpleControlPanel = null; Panel buttonPanel = null; /* * techexplorer */ private techexplorer techexplorer = null; public void setPlugin( techexplorer obj ) { if ( obj instanceof techexplorer ) techexplorer = obj; } public void setControl( AxTchExpRaw obj ) { if ( obj instanceof AxTchExpRaw ) techexplorer = new techexplorerControl( obj ); } public void init() { simpleAddinLabel = new Label( "Simple add-in Control Panel : Not Loaded" ); addInInitialize = new Button( "Initialize" ); addInShutdown = new Button( "Shutdown" ); addInEvaluate = new Button( "Evaluate" ); buttonPanel = new Panel(); buttonPanel.setLayout(new GridLayout(1, 3)); buttonPanel.add(addInInitialize); buttonPanel.add(addInShutdown); buttonPanel.add(addInEvaluate); evalTextField = new TextField(); simpleControlPanel = new Panel(); simpleControlPanel.setLayout(new GridLayout(3,1) ); simpleControlPanel.add(simpleAddinLabel); simpleControlPanel.add(evalTextField); simpleControlPanel.add(buttonPanel); setLayout(new GridLayout(1, 1)); add(simpleControlPanel); } public void start() { if ( techexplorer == null ) System.out.println("SimpleAddin: start(): null techexplorer"); } public void stop() { } public void destroy() { // clean up non-java object techexplorer.gc(); } public boolean action(Event evt, Object arg) { if ( evt.target == addInInitialize ){ int nRval = techexplorer.addInInitialize( "application/x-simple-string" ); switch( nRval ) { case techexplorer.ADDIN_SUCCESS: simpleAddinLabel.setText( "Simple add-in Control Panel : Loaded" ); break; case techexplorer.ADDIN_ERROR_AVAILABLE: simpleAddinLabel.setText( "Simple add-in Control Panel : Simple add-in not available" ); break; case techexplorer.ADDIN_ERROR_LOAD: simpleAddinLabel.setText( "Simple add-in Control Panel : can not load Simple add-in dll" ); break; default: simpleAddinLabel.setText( "Simple add-in Control Panel : Not Loaded" ); break; } return true; } else if ( evt.target == addInShutdown ){ techexplorer.addInShutdown( "application/x-simple-string" ); simpleAddinLabel.setText( "Simple add-in Control Panel : Not Loaded" ); return true; } else if ( evt.target == addInEvaluate ){ if ( techexplorer.addInEvaluate( "application/x-simple-string", evalTextField.getText() ) != techexplorer.ADDIN_SUCCESS ) simpleAddinLabel.setText( "Simple add-in Control Panel : evaluate failed" ); return true; } else return false; } }