1 22 23 package org.gjt.sp.jedit; 24 25 import javax.swing.JMenuItem ; 26 import java.util.*; 27 import org.gjt.sp.jedit.browser.VFSBrowser; 28 import org.gjt.sp.jedit.gui.OptionsDialog; 29 import org.gjt.sp.jedit.menu.EnhancedMenu; 30 31 235 public abstract class EditPlugin 236 { 237 275 public void start() {} 276 278 305 public void stop() {} 307 314 public boolean usePluginHome() 315 { 316 return false; 317 } 318 319 326 public final String getPluginHome() 327 { 328 return pluginHome; 329 } 331 339 public String getClassName() 340 { 341 return getClass().getName(); 342 } 344 349 public PluginJAR getPluginJAR() 350 { 351 return jar; 352 } 354 362 public final JMenuItem createMenuItems() 363 { 364 if(this instanceof Broken) 365 return null; 366 367 String menuItemName = jEdit.getProperty("plugin." + 368 getClassName() + ".menu-item"); 369 if(menuItemName != null) 370 return GUIUtilities.loadMenuItem(menuItemName); 371 372 String menuProperty = "plugin." + getClassName() + ".menu"; 373 String codeProperty = "plugin." + getClassName() + ".menu.code"; 374 if(jEdit.getProperty(menuProperty) != null 375 || jEdit.getProperty(codeProperty) != null) 376 { 377 String pluginName = jEdit.getProperty("plugin." + 378 getClassName() + ".name"); 379 return new EnhancedMenu(menuProperty,pluginName); 380 } 381 382 return null; 383 } 385 394 public final JMenuItem createBrowserMenuItems() 395 { 396 if(this instanceof Broken) 397 return null; 398 399 String menuItemName = jEdit.getProperty("plugin." + 400 getClassName() + ".browser-menu-item"); 401 if(menuItemName != null) 402 { 403 return GUIUtilities.loadMenuItem( 404 VFSBrowser.getActionContext(), 405 menuItemName, 406 false); 407 } 408 409 String menuProperty = "plugin." + getClassName() + ".browser-menu"; 410 if(jEdit.getProperty(menuProperty) != null) 411 { 412 String pluginName = jEdit.getProperty("plugin." + 413 getClassName() + ".name"); 414 return new EnhancedMenu(menuProperty,pluginName, 415 VFSBrowser.getActionContext()); 416 } 417 418 return null; 419 } 421 423 428 public void createMenuItems(Vector menuItems) {} 430 435 public void createOptionPanes(OptionsDialog optionsDialog) {} 437 439 PluginJAR jar; 441 445 String pluginHome; 446 448 455 public static class Broken extends EditPlugin 456 { 457 public String getClassName() 458 { 459 return clazz; 460 } 461 462 Broken(PluginJAR jar, String clazz) 464 { 465 this.jar = jar; 466 this.clazz = clazz; 467 } 468 469 private String clazz; 471 } 473 480 public static class Deferred extends EditPlugin 481 { 482 public String getClassName() 483 { 484 return clazz; 485 } 486 487 Deferred(PluginJAR jar, String clazz) 489 { 490 this.jar = jar; 491 this.clazz = clazz; 492 } 493 494 EditPlugin loadPluginClass() 495 { 496 return null; 497 } 498 499 public String toString() 500 { 501 return "Deferred[" + clazz + "]"; 502 } 503 504 private String clazz; 506 } } 508 | Popular Tags |