1
package org.herac.tuxguitar.gui.system.plugins.base;
3
import org.eclipse.swt.events.TypedEvent;
4
import org.herac.tuxguitar.gui.TuxGuitar;
5
import org.herac.tuxguitar.gui.actions.Action;
6
import org.herac.tuxguitar.gui.tools.custom.TGCustomTool;
7
import org.herac.tuxguitar.gui.tools.custom.TGCustomToolManager;
9
public abstract class TGToolItemPlugin extends TGPluginAdapter{
11
private boolean loaded;
12
private TGCustomTool tool;
13
private TGCustomToolAction toolAction;
15
protected abstract String getItemName();
17
protected abstract void doAction();
20
String name = getItemName();
21
this.tool = new TGCustomTool(name,name);
22
this.toolAction = new TGCustomToolAction(this.tool.getName());
29
protected void addPlugin(){
31
TuxGuitar.instance().getActionManager().addAction(this.toolAction);
32
TGCustomToolManager.instance().addCustomTool(this.tool);
33
TuxGuitar.instance().getItemManager().createMenu();
38
protected void removePlugin(){
40
TGCustomToolManager.instance().removeCustomTool(this.tool);
41
TuxGuitar.instance().getActionManager().removeAction(this.tool.getAction());
42
TuxGuitar.instance().getItemManager().createMenu();
47
public void setEnabled(boolean enabled) {
55
protected class TGCustomToolAction extends Action{
57
public TGCustomToolAction(String name) {
58
super(name, AUTO_LOCK | AUTO_UNLOCK | AUTO_UPDATE | KEY_BINDING_AVAILABLE);
61
protected int execute(TypedEvent e) {
b'\\ No newline at end of file'