Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.moonshineproject.plugin {
- import com.moonshineproject.GlobalEventDispatcher;
- import com.moonshineproject.IDEModel;
- import com.moonshineproject.plugin.console.view.ConsoleModeEvent;
- import flash.events.EventDispatcher;
- import flash.utils.Dictionary;
- import flash.utils.getQualifiedClassName;
- import no.doomsday.console.ConsoleUtil;
- import com.moonshineproject.plugin.console.ConsoleOutputter;
- public class PluginBase extends ConsoleOutputter implements IPlugin
- {
- protected namespace console;
- override public function get name():String { throw new Error("You need to give a unique name.") }
- public function get author():String { return "N/A"; }
- public function get description():String { return "A plugin base that plugins can extend to gain easier access to some functionality."; }
- /**
- * ensures if the plugin will be activated by default when the plugin
- * is loaded for the first time (without settings xml file written)
- * */
- public function get activatedByDefault():Boolean { return true; }
- console static var commands:Dictionary = new Dictionary(true);
- console static var mode:String = "";
- protected var dispatcher:EventDispatcher = GlobalEventDispatcher.getInstance();
- protected var model:IDEModel = IDEModel.getInstance();
- protected var _activated:Boolean = false;
- public function get activated():Boolean
- {
- return _activated;
- }
- public function activate():void
- {
- this.
- ConsoleUtil.addSystemMessage("Plugin Activation : "+name+" ["+getQualifiedClassName(this).split("::")[1]+"]");
- _activated = true;
- }
- public function deactivate():void
- {
- ConsoleUtil.addSystemMessage("Plugin DeActivation : "+name+" ["+getQualifiedClassName(this).split("::")[1]+"]");
- _activated = false;
- }
- public function PluginBase() {}
- // Console command functions
- protected function registerCommand(commandName:String, callback:Function):void
- {
- console::commands[commandName] = callback;
- }
- protected function unregisterCommand(commandName:String):void
- {
- console::commands[commandName] = null;
- delete console::commands[commandName];
- }
- protected function enterConsoleMode(newMode:String):void
- {
- console::mode = newMode;
- dispatcher.dispatchEvent(new ConsoleModeEvent(ConsoleModeEvent.CHANGE, newMode));
- }
- protected function exitConsoleMode():void
- {
- console::mode = "";
- dispatcher.dispatchEvent(new ConsoleModeEvent(ConsoleModeEvent.CHANGE, ""));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement