public class MyApplication extends AbstractMDIApplication { public MyApplication { super("My Application"); pluginsDir = new File(System.getProperty("user.dir")); this.addCustomAction("AddFile", MDIPluginsCustomActionType.SINGLE_PLUGIN); // register plugins in the plugins directory (same as main application jar directory) this.registerPlugins(); // create the menus with the Application menu factory mfactory = new SimpleMenuFactory(); super.preparePanels(4, true, true, mfactory); this.setSize(500, 500); } }
public class OpenFilePlugin extends AbstractMDIPlugin { public OpenFilePlugin() { } @Override public boolean supportCustomAction(String actionName) { return actionName.equals("AddImage"); } }
true
, it means that it declares that it did something with the data:DefaultMutableTreeNode
and looks for Plugins to add sub-nodes to this node:DefaultMutableTreeNode theNode = new DefaultMutableTreeNode"TheNode"); executeCustomAction("AddFile", theNode);Then we can have in our Plugin:
public class OpenFilePlugin extends AbstractMDIPlugin { public OpenFilePlugin() { } @Override public boolean supportCustomAction(String actionName) { return actionName.equals("AddFile"); } @Override public boolean executeCustomAction(String actionName, Object... arguments) { DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) arguments[0]; DefaultMutableTreeNode node = new DefaultMutableTreeNode("Child Node"); theNode.add(node); return true; } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences