Commit 54367d6b by Jessica Hawkwell

Minor simplification, adding services support

1 parent a08f4705
Pipeline #195 passed
in 17 seconds
......@@ -219,61 +219,65 @@ public final class LangBuilder implements IStrappedApp {
plugins.put(plugin.getName(), plugin);
boolean needShowWindow = true;
if ( plugin.hasButton() ) {
JButton button = plugin.getButton();
button.addActionListener(new UnifiedListener() {
@Override public void handleEvent(ActionHandle action) {
int a = 0;
String t = "plugin.".concat(plugin.getName());
Component c;
JPanel jp;
for ( a = 0; a < desktop.getTabCount(); a++ ) {
log.debug("Tab Index: ".concat(String.valueOf(a)));
c = desktop.getComponentAt(a);
if ( c == null ) {
log.error("Component at ".concat(String.valueOf(a)).concat(" does not exist!"));
}
else if (c instanceof JPanel) {
jp = (JPanel) c;
log.debug(jp.getName());
if ( t.equals(jp.getName()) ) {
desktop.setSelectedIndex(a);
return;
}
@Override public void start() {
plugins.forEach((name, plugin) -> {
final String t = "plugin.".concat(name);
boolean needShowWindow = true;
if ( plugin.hasButton() ) {
JButton button = plugin.getButton();
button.addActionListener(new UnifiedListener() {
@Override public void handleEvent(ActionHandle action) {
int a = 0;
String t = "plugin.".concat(plugin.getName());
Component c;
JPanel jp;
for ( a = 0; a < desktop.getTabCount(); a++ ) {
log.debug("Tab Index: ".concat(String.valueOf(a)));
c = desktop.getComponentAt(a);
if ( c == null ) {
log.error("Component at ".concat(String.valueOf(a)).concat(" does not exist!"));
}
else if (c instanceof JPanel) {
jp = (JPanel) c;
log.debug(jp.getName());
if ( t.equals(jp.getName()) ) {
desktop.setSelectedIndex(a);
return;
}
}
}
}
if ( plugin.hasWindow() ) {
jp = plugin.getPanel();
jp.setName(t);
desktop.addTab(plugin.getDisplayName(), jp);
if ( plugin.hasWindow() ) {
jp = plugin.getPanel();
jp.setName(t);
desktop.addTab(plugin.getDisplayName(), jp);
}
}
}
});
});
desktopMenu.addButton(button);
needShowWindow = false;
}
if ( plugin.hasToolBar() ) {
JToolBar jt = plugin.getToolBar();
jt.setName(t);
jTabbedPane.addTab(plugin.getDisplayName(), jt);
needShowWindow = false;
}
if ( needShowWindow && plugin.hasWindow() ) {
JPanel jp = plugin.getPanel();
jp.setName(t);
desktop.addTab(plugin.getDisplayName(), jp);
}
});
desktopMenu.addButton(button);
needShowWindow = false;
}
if ( plugin.hasToolBar() ) {
JToolBar jt = plugin.getToolBar();
jt.setName("plugin.".concat(plugin.getName()));
jTabbedPane.addTab(plugin.getDisplayName(), jt);
needShowWindow = false;
}
if ( needShowWindow && plugin.hasWindow() ) {
JPanel jp = plugin.getPanel();
jp.setName("plugin.".concat(plugin.getName()));
desktop.addTab(plugin.getDisplayName(), jp);
}
}
@Override public void start() {
jFrame.pack();
jFrame.setVisible(true);
}
}
package me.felinewith.lang_toolkit.library;
import org.apache.commons.configuration2.Configuration;
/**
*
* @author jlhawkwell
*/
public interface ILangPlugin {
public abstract class ILangPlugin {
protected Configuration project;
public abstract int hasFile();
public abstract String getFileName();
}
package me.felinewith.lang_toolkit.library;
import javax.swing.JComponent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author jlhawkwell
*/
public interface ILangService<T> {
public abstract void serviceInit();
public abstract class ILangService<T> {
protected Logger log;
public void serviceInit() { log = LogManager.getLogger(); }
public abstract void serviceInit(T t);
public abstract boolean canAttach();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!