1 package org.enhydra.kelp.jdev; 2 import oracle.ide.Ide; 3 import oracle.ide.addin.Addin; 4 import java.lang.String ; 5 import oracle.ide.util.MenuSpec; 6 import oracle.ide.addin.Context; 7 import javax.swing.Icon ; 8 import java.net.URL ; 9 import javax.swing.ImageIcon ; 10 import oracle.ide.addin.Wizard; 11 import javax.swing.JMenuItem ; 12 import oracle.ide.IdeAction; 13 import oracle.ide.addin.Controller; 14 import oracle.ide.ContextMenu; 15 import oracle.ide.addin.ContextMenuListener; 16 import javax.swing.JOptionPane ; 17 18 public class EnhydraAppWizard implements Addin, Wizard, Controller{ 20 private static JMenuItem contextMenuItem = null; 21 22 public static final int ENHYDRA_APP_WIZARD_ID = Ide.newCmd("org.enhydra.kelp.jdev.EnhydraAppWizard.ENHYDRA_APP_WIZARD_ID"); 24 private final static String GALLERY_ICON = "/media/gallery_16x16.gif"; 25 26 private JMenuItem menuItem = null; 27 private Icon _icon; 28 29 public EnhydraAppWizard() 30 { 31 } 32 33 public void initialize() 34 { 35 } 38 39 public void shutdown() 40 { 41 } 43 44 public float version() 45 { 46 return 1.0f; 48 } 49 50 public float ideVersion() 51 { 52 return Ide.IDE_VERSION; 53 } 54 55 public boolean canShutdown() 56 { 57 return true; 58 } 59 60 public String getName() 61 { 62 return "EnhydraAppWizard"; 63 } 64 65 public String getMenuLabel() 66 { 67 return null; 68 } 69 70 public MenuSpec getMenuSpecification() 71 { 72 return null; 73 } 74 75 public boolean isAvailable(Context context) 76 { 77 return true; 78 } 79 80 public Icon getIcon() 81 { 82 if (_icon == null) 83 { 84 URL url = getClass().getResource(GALLERY_ICON); 85 if (url != null) 86 { 87 _icon = new ImageIcon (url); 88 } 89 } 90 return _icon; 91 } 92 93 public boolean invoke(Context context, String [] params) 94 { 95 if (Ide.getActiveWorkspace() != null) 97 { 98 System.out.println("Current Workspace : " + Ide.getActiveWorkspace().getShortLabel()); 99 new RealWizard(context); 100 } 101 else 102 { 103 JOptionPane.showMessageDialog(null, 104 "Please select a Workspace", 105 "Ooops", 106 JOptionPane.WARNING_MESSAGE); 107 } 108 return true; 109 } 110 111 private Icon loadIcon(String iconName) 112 { 113 URL url = getClass().getResource(iconName); 114 Icon icon = null; 115 if (url != null) 116 { 117 icon = new ImageIcon (url); 118 } 119 return icon; 120 } 121 122 private JMenuItem createMenu_ENHYDRA_APP_WIZARD_ID(String iconName, String menuLabel, int mnemonic) 123 { 124 String cmdClass = null; 126 String category = null; 128 Icon icon = loadIcon(iconName); 130 Object data = null; 132 boolean enabled = true; 134 135 IdeAction action; 136 action = IdeAction.get(ENHYDRA_APP_WIZARD_ID, cmdClass, menuLabel, category, new Integer (mnemonic), icon, data, enabled); 138 action.setController(this); 140 JMenuItem menuItem = Ide.getMenubar().createMenuItem(action); 142 return menuItem; 143 } 144 145 public Controller supervisor() 146 { 147 return null; 148 } 149 150 public boolean handleEvent(IdeAction action, Context context) 151 { 152 final int cmdId = action.getCommandId(); 153 if (cmdId == org.enhydra.kelp.jdev.EnhydraAppWizard.ENHYDRA_APP_WIZARD_ID) 154 { 155 invoke(context, null); 156 return true; 157 } 158 return false; 159 } 160 161 public boolean update(IdeAction action, Context context) 162 { 163 final int cmdId = action.getCommandId(); 164 if (cmdId == org.enhydra.kelp.jdev.EnhydraAppWizard.ENHYDRA_APP_WIZARD_ID) 165 { 166 action.setEnabled(is_ENHYDRA_APP_WIZARD_ID_Available(context)); 167 return true; 168 } 169 return false; 170 } 171 172 private boolean is_ENHYDRA_APP_WIZARD_ID_Available(Context context) 173 { 174 return true; 176 } 177 178 public void checkCommands(Context action, Controller controller) 179 { 180 } 183 184 } | Popular Tags |