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 { ...@@ -219,61 +219,65 @@ public final class LangBuilder implements IStrappedApp {
plugins.put(plugin.getName(), plugin); plugins.put(plugin.getName(), plugin);
boolean needShowWindow = true; }
if ( plugin.hasButton() ) {
JButton button = plugin.getButton(); @Override public void start() {
plugins.forEach((name, plugin) -> {
button.addActionListener(new UnifiedListener() { final String t = "plugin.".concat(name);
@Override public void handleEvent(ActionHandle action) {
int a = 0; boolean needShowWindow = true;
String t = "plugin.".concat(plugin.getName()); if ( plugin.hasButton() ) {
Component c; JButton button = plugin.getButton();
JPanel jp;
for ( a = 0; a < desktop.getTabCount(); a++ ) { button.addActionListener(new UnifiedListener() {
log.debug("Tab Index: ".concat(String.valueOf(a))); @Override public void handleEvent(ActionHandle action) {
c = desktop.getComponentAt(a); int a = 0;
if ( c == null ) { String t = "plugin.".concat(plugin.getName());
log.error("Component at ".concat(String.valueOf(a)).concat(" does not exist!")); Component c;
} JPanel jp;
else if (c instanceof JPanel) { for ( a = 0; a < desktop.getTabCount(); a++ ) {
jp = (JPanel) c; log.debug("Tab Index: ".concat(String.valueOf(a)));
log.debug(jp.getName()); c = desktop.getComponentAt(a);
if ( t.equals(jp.getName()) ) { if ( c == null ) {
desktop.setSelectedIndex(a); log.error("Component at ".concat(String.valueOf(a)).concat(" does not exist!"));
return; }
else if (c instanceof JPanel) {
jp = (JPanel) c;
log.debug(jp.getName());
if ( t.equals(jp.getName()) ) {
desktop.setSelectedIndex(a);
return;
}
} }
} }
}
if ( plugin.hasWindow() ) { if ( plugin.hasWindow() ) {
jp = plugin.getPanel(); jp = plugin.getPanel();
jp.setName(t); jp.setName(t);
desktop.addTab(plugin.getDisplayName(), jp); 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.pack();
jFrame.setVisible(true); jFrame.setVisible(true);
} }
} }
package me.felinewith.lang_toolkit.library; package me.felinewith.lang_toolkit.library;
import org.apache.commons.configuration2.Configuration;
/** /**
* *
* @author jlhawkwell * @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; package me.felinewith.lang_toolkit.library;
import javax.swing.JComponent; import javax.swing.JComponent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* *
* @author jlhawkwell * @author jlhawkwell
*/ */
public interface ILangService<T> { public abstract class ILangService<T> {
public abstract void serviceInit(); protected Logger log;
public void serviceInit() { log = LogManager.getLogger(); }
public abstract void serviceInit(T t); public abstract void serviceInit(T t);
public abstract boolean canAttach(); 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!