IBM Books

Administration Guide


Usage Scenario

The code in the following example will:

  1. Update the actions of the SAMPLE Database (see "MySample.java")

  2. Update the actions of all Database objects (see "MyDatabaseActions.java")

  3. Add a new instance object (see "MyInstance.java")

  4. Update the actions of the DB2 instance (see "MyDB2.java")

  5. Update the actions of the Databases folder (see "MyDatabases.java")

  6. Update the actions of the SYSIBM.SYSPLAN table (see "MySYSPLAN.java")

  7. Add a new table object (see "MyTable.java")

  8. Update the actions of the DB_User object under the Application object (see "MyDBUser.java")

  9. Add a button to the Control Center toolbar (see "MyToolbarAction.java").

The main extension file is MyExtension.java. All the class files are stored in the plugin directory and are zipped up by the command:

   zip -r0 db2plug.zip plugin

The output db2plug.zip is then placed in the CLASSPATH or in the codebase directory depending whether the Control Center is running as an application or an applet.

MyExtension.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyExtension implements CCExtension
{
   public CCObject[] getObjects()
   {
      CCObject[] objs = new CCObject[10];
      objs[0] = new MySample();
      objs[1] = new MyDatabaseActions();
      objs[2] = new MyInstance();
      objs[3] = new MyDB2();
      objs[4] = new MyDatabases();
      objs[5] = new MySYSPLAN();
      objs[6] = new MyTable();
      objs[7] = new MyDBUser();
      return objs;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] actions = new CCAction[1];
      actions[0] = new MyToolbarAction();
      return actions;
   }
}

MySample.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MySample implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE";
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyDatabaseActions.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDatabaseActions implements CCObject
{
   public String getName()
   {
      return null;
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyDropAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyInstance.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyInstance implements CCObject
{
   public String getName()
   {
      return "LOCAL - MyInstance";
   }
 
   public int getType()
   {
      return INSTANCE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return true;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return null;
   }
 
}

MyDB2.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDB2 implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2";
   }
 
   public int getType()
   {
      return INSTANCE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[3];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      acts[2] = new MyCascadeAction();
      return acts;
   }
}

MyDatabases.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDatabases implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - Databases";
   }
 
   public int getType()
   {
      return DATABASE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[1];
      acts[0] = new MyCreateAction();
      return acts;
   }
 
}

MySYSPLAN.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MySYSPLAN implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE - SYSIBM - SYSPLAN";
   }
 
   public int getType()
   {
      return TABLE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyTable.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyTable implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - SAMPLE - SYSIBM - MyTable";
   }
 
   public int getType()
   {
      return TABLE;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return true;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyDBUser.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDBUser implements CCObject
{
   public String getName()
   {
      return "LOCAL - DB2 - TEST-DB Users";
   }
 
   public int getType()
   {
      return DB_USER;
   }
 
   public javax.swing.ImageIcon getIcon()
   {
      return null;
   }
 
   public boolean isNew()
   {
      return false;
   }
 
   public CCAction[] getActions()
   {
      CCAction[] acts = new CCAction[2];
      acts[0] = new MyAlterAction();
      acts[1] = new MyAction();
      return acts;
   }
 
}

MyToolbarAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
import javax.swing.*;
 
public class MyToolbarAction extends CCAction
{
   public MyToolbarAction()
   {
      super("MyToolbarAction");
   }
 
   public ImageIcon getIcon()
   {
      return <Your icon>;
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My action performed, object name = " +
                          objectName );
      return true;
   }
}

MyAlterAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyAlterAction extends CCAction
{
   public MyAlterAction()
   {
      super(0);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My alter action performed, object name = " +
                          objectName );
      return true;
   }
}

MyAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyAction extends CCAction
{
   public MyAction()
   {
      super("MyAction");
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My action performed, object name = " +
                          objectName );
      return true;
   }
}

MyDropAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyDropAction extends CCAction
{
   public MyDropAction()
   {
      super(1);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My drop action performed, object name = " +
                          objectName );
      return true;
   }
}

MyCascadeAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyCascadeAction extends CCAction
{
   public MyCascadeAction()
   {
      super(11,2);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My cascade action performed, object name = " +
                          objectName );
      return true;
   }
}

MyCreateAction.java

package plugin;
import com.ibm.db2.tools.cc.navigator.*;
 
public class MyCreateAction extends CCAction
{
   public MyCreateAction()
   {
      super(0);
   }
 
   public boolean actionPerformed(String objectName)
   {
      System.out.println( "My create action performed, object name = " +
                          objectName );
      return true;
   }
}


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]