Commit a08f4705 by Jessica Hawkwell

Working on setting up services, fixed 1 ui issue

1 parent 397cac7b
Pipeline #194 passed
in 18 seconds
......@@ -20,8 +20,7 @@ import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import me.felinewith.lang_toolkit.apps.langbuilder.util.UIHelper;
import me.felinewith.lang_toolkit.apps.langbuilder.window.WindowUnifiedListener;
import me.felinewith.lang_toolkit.library.IStrappedApp;
import me.felinewith.lang_toolkit.library.IStrappedPlugin;
......@@ -66,38 +65,25 @@ public final class LangBuilder implements IStrappedApp {
log = LogManager.getLogger();
boolean usingNimbus = false;
try {
for ( UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels() ) {
if ( info.getName().equals("Nimbus") ) {
UIManager.setLookAndFeel(info.getClassName());
usingNimbus = true;
}
}
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
UnsupportedLookAndFeelException ex) {
}
if ( !usingNimbus ) {
try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
UnsupportedLookAndFeelException ex) {
}
}
UIHelper.init();
//StringBuilder sb = new StringBuilder();
if ( log.isDebugEnabled() ) {
UIManager.getDefaults().entrySet().spliterator().forEachRemaining((t) -> {
StringBuilder sb;
sb = new StringBuilder();
sb.append(t.getKey());
/*if ( log.isDebugEnabled() ) {
UIManager.getDefaults().entrySet().forEach((t) -> {
StringBuilder sb = new StringBuilder("UID\t");
sb.append(t.getKey().toString());
sb.append("\t");
sb.append(t.getValue());
sb.append(t.getValue().toString());
log.debug(sb.toString());
});
}
log.debug(UIManager.getLookAndFeel().getName());
UIManager.getLookAndFeelDefaults().entrySet().forEach((t) -> {
StringBuilder sb = new StringBuilder("LAF\t");
sb.append(t.getKey().toString());
sb.append("\t");
sb.append(t.getValue().toString());
log.debug(sb.toString());
});
} // */
// configuration!
log.info("[Desktop] Setting up configuration...");
StringBuilder sb = new StringBuilder(System.getProperty("user.home"));
......@@ -240,7 +226,7 @@ public final class LangBuilder implements IStrappedApp {
button.addActionListener(new UnifiedListener() {
@Override public void handleEvent(ActionHandle action) {
int a = 0;
String t = plugin.getName();
String t = "plugin.".concat(plugin.getName());
Component c;
JPanel jp;
for ( a = 0; a < desktop.getTabCount(); a++ ) {
......
package me.felinewith.lang_toolkit.apps.langbuilder.util;
import java.util.Map.Entry;
import java.util.function.Consumer;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.InsetsUIResource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author jlhawkwell
*/
public class UIHelper {
private static Logger log;
public static void init() {
if ( log == null ) { log = LogManager.getLogger(); }
boolean usingNimbus = false;
try {
for ( UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels() ) {
if ( info.getName().equals("Nimbus") ) {
UIManager.setLookAndFeel(info.getClassName());
usingNimbus = true;
}
}
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
UnsupportedLookAndFeelException ex) {
}
if ( !usingNimbus ) {
try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
UnsupportedLookAndFeelException ex) {
}
}
//FontUIResource font = new FontUIResource("Allerta Regular", 0, 14);
setUIDefaults();
}
public static void runHelper(Consumer<? super Entry<Object, Object>> action) {
if ( log == null ) { log = LogManager.getLogger(); }
UIManager.getDefaults().entrySet().forEach(action);
UIManager.getLookAndFeelDefaults().entrySet().forEach(action);
}
private static void setUIDefaults() {
runHelper((t) -> {
if ( t.getValue() instanceof FontUIResource ) {
FontUIResource value = (FontUIResource) t.getValue();
FontUIResource font = new FontUIResource(value.getFontName(), value.getStyle(), value.getSize() + 2);
t.setValue(font);
if ( log.isDebugEnabled() ) { log.debug("Setting default font on ".concat(t.getKey().toString())); }
}
else if ( t.getKey().toString().startsWith("Label") && (t.getValue() instanceof InsetsUIResource) ) {
InsetsUIResource inset = (InsetsUIResource) t.getValue();
int i = 2;
inset.set(i, i, i, i);
t.setValue(inset);
}
});
}
private UIHelper() { log = LogManager.getLogger(); }
}
package me.felinewith.lang_toolkit.library;
/**
*
* @author jlhawkwell
*/
public interface ILangPlugin {
}
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.compile.on.save>none</netbeans.compile.on.save>
</properties>
</project-shared-configuration>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.felinewith.lang-toolkit.library</groupId>
<artifactId>libservices</artifactId>
<packaging>jar</packaging>
<name>LangBuilder Services</name>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2017</inceptionYear>
<description>Services for the LangBuilder Desktop.</description>
<parent>
<groupId>me.felinewith</groupId>
<artifactId>lang-toolkit</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>me.felinewith.lang-toolkit.library</groupId>
<artifactId>libbootstrap</artifactId>
</dependency>
</dependencies>
</project>
package me.felinewith.lang_toolkit.library;
import javax.swing.JComponent;
/**
*
* @author jlhawkwell
*/
public interface ILangService<T> {
public abstract void serviceInit();
public abstract void serviceInit(T t);
public abstract boolean canAttach();
public abstract void attachComponent(JComponent component);
}
package me.felinewith.lang_toolkit.library;
/**
*
* @author jlhawkwell
*/
public class LangServices {
}
<html>
<head>
<title>${page_title}</title>
</head>
<body>
<h2>${page_title}</h2>
<hr>
#include(${main_template})
</body>
</html>
......@@ -68,9 +68,11 @@ public class IPAHelper extends IStrappedPlugin {
@Override public void getActionCommand(String command) {
}
private JPanel textWrapper(String text) {
private JPanel textWrapper(String text) { return textWrapper(text, false); }
private JPanel textWrapper(String text, boolean boxLayout) {
JPanel panel = new JPanel();
panel.add(new JLabel(text));
if ( boxLayout ) { panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); }
return panel;
}
......@@ -81,11 +83,10 @@ public class IPAHelper extends IStrappedPlugin {
panel.add(textWrapper(""));
IPANames n;
for ( String c : cols ) {
panel.add(textWrapper(wordFix(c))); }
for ( String c : cols ) { panel.add(textWrapper(wordFix(c), true)); }
for ( String r : rows ) {
for ( String c : cols ) {
if ( cols[0].equals(c) ) { panel.add(textWrapper(wordFix(r))); }
if ( cols[0].equals(c) ) { panel.add(textWrapper(wordFix(r), true)); }
n = null;
try { n = IPANames.valueOf(c.concat("_").concat(r)); }
catch ( IllegalArgumentException ex ) {}
......@@ -113,18 +114,18 @@ public class IPAHelper extends IStrappedPlugin {
if ( background == null ) { panel.setBackground(Color.WHITE); }
else { panel.setBackground(background); }
JLabel left = new JLabel();
JLabel right = new JLabel();
JLabel left = new JLabel(" ");
JLabel right = new JLabel(" ");
JPanel pleft = new JPanel();
JPanel pright = new JPanel();
pleft.setBackground(panel.getBackground());
pright.setBackground(panel.getBackground());
pleft.add(left);
pright.add(right);
pleft.setBackground(panel.getBackground());
pright.setBackground(panel.getBackground());
if ( name.hasLeft()) { left.setText(name.getLeft()); }
if ( name.hasRight()) { right.setText(name.getRight()); }
......@@ -147,34 +148,27 @@ public class IPAHelper extends IStrappedPlugin {
rightTip.append(pt);
if ( name.hasLeft()) {
left.setName(name.toString());
pleft.addMouseListener(new Borderer(pleft));
pleft.setName(name.toString());
nameHelper(name, left, pleft);
if ( name.getLeft().equals("\u2297") ) { leftTip.append("\n(\u2297 = No known Unicode symbol)"); }
toolTipHelper(leftTip.toString(), left, pleft);
pleft.setBorder(BorderFactory.createLineBorder(panel.getBackground(), 2));
}
if ( name.hasRight()) {
right.setName(name.toString());
pright.addMouseListener(new Borderer(pright));
pright.setName(name.toString());
nameHelper(name, right, pright);
if ( name.getRight().equals("\u2297") ) { rightTip.append("\n(\u2297 = No known Unicode symbol)"); }
toolTipHelper(rightTip.toString(), right, pright);
pright.setBorder(BorderFactory.createLineBorder(panel.getBackground(), 2));
}
left.setHorizontalAlignment(JLabel.CENTER);
left.setHorizontalTextPosition(JLabel.CENTER);
right.setHorizontalAlignment(JLabel.CENTER);
right.setHorizontalTextPosition(JLabel.CENTER);
pleft.setBorder(BorderFactory.createLineBorder(panel.getBackground(), 2));
pright.setBorder(BorderFactory.createLineBorder(panel.getBackground(), 2));
if ( name.isBoth() ) {
panel.add(left);
left.addMouseListener(new Borderer(panel));
panel.setToolTipText(left.getToolTipText());
panel.addMouseListener(new Borderer(panel));
panel.setName(name.toString());
borderHelper(left, panel);
}
else {
if ( name.hasLeft() ) { borderHelper(left, pleft); }
if ( name.hasRight() ) { borderHelper(right, pright); }
panel.add(pleft);
panel.add(pright);
}
......@@ -184,30 +178,43 @@ public class IPAHelper extends IStrappedPlugin {
private String wordFix(String input) { return WordUtils.capitalize(input.replaceAll("_", " ").toLowerCase()); }
private void borderHelper(JLabel label, JPanel panel) {
if ( panel.getBorder() == null ) {
panel.setBorder(BorderFactory.createLineBorder(panel.getBackground()));
}
Borderer b = new Borderer(panel);
label.addMouseListener(b);
panel.addMouseListener(b);
}
private void nameHelper(IPANames name, JComponent... comps) {
for ( JComponent comp : comps ) { comp.setName(name.toString()); }
}
private void toolTipHelper(String toolTip, JComponent... comps) {
for ( JComponent comp : comps ) { comp.setToolTipText(toolTip);
//if ( comp instanceof JLabel ) { ((JLabel) comp).setToolTipText(toolTip); }
//if ( comp instanceof JPanel ) { ((JPanel) comp).setToolTipText(toolTip); }
}
for ( JComponent comp : comps ) { comp.setToolTipText(toolTip); }
}
private class Borderer implements MouseListener {
private JPanel p;
private final JPanel p;
private Border b;
public Borderer(JPanel panel) { p = panel; }
Borderer(JPanel panel) {
p = panel;
b = panel.getBorder();
}
@Override public void mouseClicked(MouseEvent e) {}
@Override public void mousePressed(MouseEvent e) {}
@Override public void mouseReleased(MouseEvent e) {}
@Override public void mouseEntered(MouseEvent e) {
b = p.getBorder();
p.setBorder(BorderFactory.createLineBorder(Color.ORANGE, 2));
if ( b.equals(p.getBorder()) ) {
b = p.getBorder();
p.setBorder(BorderFactory.createLineBorder(Color.ORANGE, 2));
}
}
@Override public void mouseExited(MouseEvent e) {
if ( e.getComponent() instanceof JLabel ) { return; }
p.setBorder(b);
}
@Override public void mouseExited(MouseEvent e) { p.setBorder(b); }
}
}
package me.felinewith.lang_toolkit.plugins.ipa_helper;
import java.util.ArrayList;
import org.apache.logging.log4j.LogManager;
/**
*
......@@ -182,6 +181,10 @@ public enum IPANames {
private IPANames(String voiced, String unvoiced, IPANameParts... ipaparts) {
v = voiced;
uv = unvoiced;
if ( (v != null) && v.equals("!?") ) { v = "\u2297"; }
if ( (uv != null) && uv.equals("!?") ) { uv = "\u2297"; }
if ( parts == null ) {
ArrayList<IPANameParts> list = new ArrayList<>();
IPANameParts ip;
......@@ -212,7 +215,6 @@ public enum IPANames {
catch ( IllegalArgumentException ex ) {}
}
}
LogManager.getLogger().warn(toString());
if ( !list.isEmpty() ) { parts = list.toArray(new IPANameParts[list.size()]); }
}
else { parts = ipaparts; }
......
......@@ -76,6 +76,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<modules>
<module>library/libbootstrap</module>
<module>library/liblangbuilder</module>
<module>library/libservices</module>
<module>apps/bootstrap</module>
<module>apps/langbuilder</module>
......@@ -177,6 +178,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<artifactId>liblangbuilder</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>me.felinewith.lang-toolkit.library</groupId>
<artifactId>libservices</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!