The code in the following example will:
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.
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }
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; } }