Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.moonshineproject.plugin {
  2.     import com.moonshineproject.GlobalEventDispatcher;
  3.     import com.moonshineproject.IDEModel;
  4.     import com.moonshineproject.plugin.console.view.ConsoleModeEvent;
  5.    
  6.     import flash.events.EventDispatcher;
  7.     import flash.utils.Dictionary;
  8.     import flash.utils.getQualifiedClassName;
  9.    
  10.     import no.doomsday.console.ConsoleUtil;
  11.     import com.moonshineproject.plugin.console.ConsoleOutputter;
  12.    
  13.     public class PluginBase extends ConsoleOutputter implements IPlugin
  14.     {
  15.         protected namespace console;
  16.        
  17.         override public function get name():String          { throw new Error("You need to give a unique name.") }
  18.         public function get author():String         { return "N/A"; }
  19.         public function get description():String    { return "A plugin base that plugins can extend to gain easier access to some functionality."; }
  20.        
  21.         /**
  22.          * ensures if the plugin will be activated by default when the plugin
  23.          * is loaded for the first time (without settings xml file written)
  24.          * */
  25.         public function get activatedByDefault():Boolean { return true; }
  26.        
  27.         console static var commands:Dictionary = new Dictionary(true);
  28.         console static var mode:String = "";
  29.  
  30.         protected var dispatcher:EventDispatcher = GlobalEventDispatcher.getInstance();
  31.         protected var model:IDEModel = IDEModel.getInstance();
  32.        
  33.         protected var _activated:Boolean = false;
  34.         public function get activated():Boolean
  35.         {
  36.             return _activated;
  37.         }
  38.        
  39.         public function activate():void
  40.         {          
  41.         this.
  42.             ConsoleUtil.addSystemMessage("Plugin Activation : "+name+" ["+getQualifiedClassName(this).split("::")[1]+"]");
  43.             _activated = true;
  44.         }
  45.         public function deactivate():void
  46.         {
  47.             ConsoleUtil.addSystemMessage("Plugin DeActivation : "+name+" ["+getQualifiedClassName(this).split("::")[1]+"]");
  48.             _activated = false;
  49.         }
  50.        
  51.        
  52.         public function PluginBase() {}
  53.        
  54.         // Console command functions
  55.         protected function registerCommand(commandName:String, callback:Function):void
  56.         {
  57.             console::commands[commandName] = callback;
  58.         }
  59.        
  60.         protected function unregisterCommand(commandName:String):void
  61.         {
  62.             console::commands[commandName] = null;
  63.             delete console::commands[commandName];
  64.         }
  65.        
  66.         protected function enterConsoleMode(newMode:String):void
  67.         {
  68.             console::mode = newMode;
  69.             dispatcher.dispatchEvent(new ConsoleModeEvent(ConsoleModeEvent.CHANGE, newMode));
  70.         }
  71.        
  72.         protected function exitConsoleMode():void
  73.         {
  74.             console::mode = "";
  75.             dispatcher.dispatchEvent(new ConsoleModeEvent(ConsoleModeEvent.CHANGE, ""));
  76.         }
  77.        
  78.        
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement