Commit b71bdb6e by Jessica Hawkwell

Merge branch 'dev-desktop' into 'master'

done lots of work, all that's needed is the welcome window content, and some UI tweaks

Closes #2

See merge request !3
2 parents b55921a7 bf9ac58a
<?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>
......@@ -18,6 +18,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
......
......@@ -9,6 +9,7 @@ import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import me.felinewith.lang_toolkit.apps.bootstrap.util.LoaderHelper;
import org.apache.commons.configuration2.Configuration;
/**
*
......@@ -89,12 +90,15 @@ public class BootstrapApp {
// start it up
app.preStart(args);
Configuration config = app.getConfig();
// check plugins
if ( !plugins.isEmpty() ) {
// register all the plugins
Iterator<IStrappedPlugin> itp = plugins.values().iterator();
while ( itp.hasNext() ) {
plug = itp.next();
plug.init(config);
app.registerPlugin(plug);
}
}
......
......@@ -139,10 +139,10 @@ public class BootstrapClassLoader extends ClassLoader
File f;
// FAST failure for certain groups
String[] fail = {"java/", "javax/", "com/sun", "sun/", "jdk/"};
/*String[] fail = {"java/", "javax/", "com/sun", "sun/", "jdk/"};
for ( String s : fail ) {
if ( path.startsWith(s) ) { return null; }
}
} // */
// FAST search
if ( !maps.isEmpty() )
{
......
package me.felinewith.lang_toolkit.apps.bootstrap;
import org.apache.commons.configuration2.Configuration;
/**
*
* @author jlhawkwell
*/
public interface IStrappedApp {
public void preStart(String[] args);
public Configuration getConfig();
public void registerPlugin(IStrappedPlugin plugin);
public void start();
}
package me.felinewith.lang_toolkit.apps.bootstrap;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import org.apache.commons.configuration2.Configuration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* Plug-in interface for a bootstrapped app.
* @author jlhawkwell
*/
public interface IStrappedPlugin {
public String getName();
public abstract class IStrappedPlugin {
public boolean hasButton();
public boolean hasToolBar();
public boolean hasWindow();
protected Logger log;
protected Configuration config;
public JButton getButton();
public JToolBar getToolBar();
public JFrame getFrame();
protected JButton jButton;
protected JToolBar jToolBar;
protected JPanel jPanel;
public IStrappedPlugin() {}
/**
* Initializer for the plug-in. Must be overridden, there are three
* class variables in the plug-in which you may populate here if your
* plug-in should only have a single instance of each.
*
* The three local variables are:
* <ul>
* <li>{@link JButton} {@code jButton}</li>
* <li>{@link JToolBar} {@code jToolBar}</li>
* <li>{@link JInternalFrame} {@code jInternalFrame}</li>
* </ul>
*/
public abstract void init();
/**
* First-time initializer for the plug-in.
* @param configuration Commons Configuration object for settings storage
*/
public final void init(Configuration configuration) {
if ( configuration == null ) { throw new NullPointerException("Configuration object cannot be null!"); }
if ( config != null ) { return; }
config = configuration;
log = LogManager.getLogger();
}
/**
* The name of the plug-in. This is only used in referencing and will not be shown to the user.
* @return Name of plug-in.
*/
public abstract String getName();
/**
* The display name of the plug-in. This is shown to the user.
* @return Display name of plug-in.
*/
public abstract String getDisplayName();
/**
* Determines if the object has a {@link JButton}
* @return {@code true} if {@code jButton} is not {@code null}
*/
public boolean hasButton() { return (jButton != null); }
/**
* Determines if the object has a {@link JToolBar}
* @return {@code true} if {@code jToolBar } is not {@code null}
*/
public boolean hasToolBar() { return (jToolBar != null); }
/**
* Determines if the object has a {@link JPanel}
* @return {@code true} if {@code jPanel} is not {@code null}
*/
public boolean hasWindow() { return (jPanel != null); }
/**
* By default, this provides the {@link JButton} created in the constructor.
* It may be overridden if a new {@link JButton} should be created on every call.
* @return The stored or created (if overridden) {@link JButton}
*/
public JButton getButton() { return jButton; }
/**
* By default, this provides the {@link JToolBar} created in the constructor.
* It may be overridden if a new {@link JToolBar} should be created on every call.
* @return The stored or created (if overridden) {@link JToolBar}
*/
public JToolBar getToolBar() { return jToolBar; }
/**
* By default, this provides the {@link JPanel} created in the constructor.
* It may be overridden if a new {@link JPanel} should be created on every call.
* @return The stored or created (if overridden) {@link JPanel}
*/
public JPanel getPanel() { return jPanel; }
}
......@@ -34,11 +34,19 @@ public class Log4jConfig extends ConfigurationFactory {
addAttribute("pattern", "%d{UNIX_MILLIS} [%style{%t}{cyan}/%style{%c{1}}{yellow}] %highlight{%-5level}: %msg%n%throwable"));
appenderBuilder.add(builder.newFilter("MarkerFilter", Filter.Result.DENY,
Filter.Result.NEUTRAL).addAttribute("marker", "FLOW"));
builder.add(appenderBuilder);
builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG).
/*builder.add(builder.newLogger("org.apache.logging.log4j", Level.DEBUG).
add(builder.newAppenderRef("Stdout")).
addAttribute("additivity", false));
addAttribute("additivity", false)); // */
/*AppenderComponentBuilder appenderBuilderHtml = builder.newAppender("html", "CONSOLE").
addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
appenderBuilderHtml.add(builder.newLayout("PatternLayout").
addAttribute("pattern", "%d{UNIX_MILLIS} [%style{%t}{cyan}/%style{%c{1}}{yellow}] %highlight{%-5level}: %msg%n%throwable"));
appenderBuilderHtml.add(builder.newFilter("MarkerFilter", Filter.Result.DENY,
Filter.Result.NEUTRAL).addAttribute("marker", "FLOW"));
builder.add(appenderBuilder); // */
builder.add(builder.newRootLogger(Level.ERROR).add(builder.newAppenderRef("Stdout")));
return builder.build();
}
......
<?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>
<org-netbeans-modules-whitelist.whitelist-oracle>false</org-netbeans-modules-whitelist.whitelist-oracle>
</properties>
</project-shared-configuration>
......@@ -23,6 +23,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</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>
......
......@@ -10,8 +10,8 @@ import java.awt.Point;
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
......@@ -38,7 +38,7 @@ import org.apache.logging.log4j.Logger;
*
* @author jlhawkwell
*/
public class LangBuilder implements IStrappedApp {
public final class LangBuilder implements IStrappedApp {
private String[] args;
private HashMap<String, IStrappedPlugin> plugins;
......@@ -48,8 +48,10 @@ public class LangBuilder implements IStrappedApp {
private JSplitPane jSplitPane;
private JScrollPane jScrollPane;
private JTree jTree;
private JDesktopPane jDesktopPane;
private JTabbedPane desktop;
private Configuration config;
private DesktopMenu desktopMenu;
private Logger log;
......@@ -60,11 +62,38 @@ public class LangBuilder implements IStrappedApp {
log = LogManager.getLogger();
try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
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) {
}
}
//StringBuilder sb = new StringBuilder();
if ( log.isDebugEnabled() ) {
UIManager.getDefaults().entrySet().spliterator().forEachRemaining((t) -> {
StringBuilder sb;
sb = new StringBuilder();
sb.append(t.getKey());
sb.append("\t");
sb.append(t.getValue());
log.debug(sb.toString());
});
}
// configuration!
log.info("[Desktop] Setting up configuration...");
StringBuilder sb = new StringBuilder(System.getProperty("user.home"));
......@@ -107,19 +136,20 @@ public class LangBuilder implements IStrappedApp {
unifiedListener = new WindowUnifiedListener(jFrame, config);
// TODO: toolbar menu
jTabbedPane = new JTabbedPane(JTabbedPane.TOP);
jTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
JToolBar toolBar = new JToolBar("LangBuilder Desktop", JToolBar.HORIZONTAL);
toolBar.setFloatable(false);
DesktopMenu tdm = new DesktopMenu(toolBar, unifiedListener);
BoxLayout bl = new BoxLayout(toolBar, BoxLayout.X_AXIS);
desktopMenu = new DesktopMenu(toolBar, unifiedListener);
tdm.addButton("New", "new", null, "16x16/actions/document-new.png");
tdm.addButton("Load", "load", null, "16x16/actions/document-open.png");
tdm.addButton("Save", "save", null, "16x16/actions/document-save.png");
tdm.addButton("Save As", "saveas", null, "16x16/actions/document-save-as.png");
tdm.addButton("Exit", "exit", null, "16x16/actions/system-log-out.png");
desktopMenu.addButton("New", "new", null, "16x16/actions/document-new.png");
desktopMenu.addButton("Load", "load", null, "16x16/actions/document-open.png");
desktopMenu.addButton("Save", "save", null, "16x16/actions/document-save.png");
desktopMenu.addButton("Save As", "saveas", null, "16x16/actions/document-save-as.png");
desktopMenu.addButton("Exit", "exit", null, "16x16/actions/system-log-out.png");
desktopMenu.addSeparator();
URL u = this.getClass().getResource("/org/freedesktop/tango/16x16/places/user-desktop.png");
jTabbedPane.addTab("LangBuilder Desktop", new ImageIcon(u), toolBar);
......@@ -132,10 +162,10 @@ public class LangBuilder implements IStrappedApp {
jScrollPane = new JScrollPane(jTree,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jDesktopPane = new JDesktopPane();
desktop = new JTabbedPane(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT);
jSplitPane.setLeftComponent(jScrollPane);
jSplitPane.setRightComponent(jDesktopPane);
jSplitPane.setRightComponent(desktop);
jFrame.add(jSplitPane, BorderLayout.CENTER);
// set component names
......@@ -143,7 +173,7 @@ public class LangBuilder implements IStrappedApp {
jTabbedPane.setName("window.menu");
jSplitPane.setName("window.splitter");
jTree.setName("window.tree");
jDesktopPane.setName("window.desktop");
desktop.setName("window.desktop");
// configure the window
......@@ -185,30 +215,39 @@ public class LangBuilder implements IStrappedApp {
);
jSplitPane.setDividerLocation(config.getInt("window.splitter.dividerLocation", sx / 8));
Component[] comps = {jFrame, jTabbedPane, jSplitPane, jTree, jDesktopPane};
for ( Component c : comps ) { ListenAttach.attach(c, unifiedListener, "addWindowFocusListener"); }
/*jFrame.addWindowListener(unifiedListener);
jFrame.addWindowStateListener(unifiedListener);
jTabbedPane.addChangeListener(unifiedListener);
Component[] comps = {jFrame, jTabbedPane, jSplitPane, jTree, desktop};
jFrame.addComponentListener(unifiedListener);
jTabbedPane.addComponentListener(unifiedListener);
jSplitPane.addComponentListener(unifiedListener);
jTree.addComponentListener(unifiedListener);
jDesktopPane.addComponentListener(unifiedListener);
jFrame.addPropertyChangeListener(unifiedListener);
jTabbedPane.addPropertyChangeListener(unifiedListener);
jSplitPane.addPropertyChangeListener(unifiedListener);
jTree.addPropertyChangeListener(unifiedListener);
jDesktopPane.addPropertyChangeListener(unifiedListener); // */
for ( Component c : comps ) { ListenAttach.attach(c, unifiedListener,
"addWindowFocusListener", "addComponentListener"); }
}
@Override public Configuration getConfig() { return config; }
@Override public void registerPlugin(IStrappedPlugin plugin) {
plugin.init();
plugins.put(plugin.getName(), plugin);
StringBuilder sb = new StringBuilder(plugin.getName());
sb.append("\t");
sb.append(plugin.hasButton());
sb.append("\t");
sb.append(plugin.hasToolBar());
sb.append("\t");
sb.append(plugin.hasWindow());
log.debug(sb.toString());
boolean needShowWindow = true;
if ( plugin.hasButton() ) {
desktopMenu.addButton(plugin.getButton());
needShowWindow = false;
}
if ( plugin.hasToolBar() ) {
jTabbedPane.addTab(plugin.getDisplayName(), plugin.getToolBar());
needShowWindow = false;
}
if ( needShowWindow && plugin.hasWindow() ) { desktop.addTab(plugin.getDisplayName(), plugin.getPanel()); }
}
@Override public void start() {
......
package me.felinewith.lang_toolkit.apps.langbuilder.ui;
import java.awt.BorderLayout;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import me.felinewith.lang_toolkit.apps.bootstrap.IStrappedPlugin;
/**
*
* @author jlhawkwell
*/
public class WelcomeWindow extends IStrappedPlugin {
private JEditorPane viewer;
@Override public void init() {
jPanel = new JPanel();
jPanel.setLayout(new BorderLayout());
viewer = new JEditorPane();
jPanel.add(viewer);
/*JScrollPane jScrollPane = new JScrollPane(
viewer, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jInternalFrame.add(jScrollPane); // */
viewer.setContentType("text/html; charset=UTF-8");
viewer.setEditable(false);
}
@Override public String getName() { return "WelconeWindow"; }
@Override public String getDisplayName() { return "Welcome!"; }
}
......@@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
......@@ -63,7 +64,13 @@ public class DesktopMenu {
b.setName(name);
if ( toolTip != null ) { if ( !toolTip.isEmpty() ) { b.setToolTipText(toolTip); } }
if ( icon != null ) { b.setIcon(icon); }
addComponent(b);
addComponent(b.getName(), b, true);
}
public void addButton(JButton button) {
if ( button.getName() == null ) { return; }
addComponent(button.getName(), button, false);
}
public void addSeparator() { toolBar.addSeparator(); }
......@@ -71,27 +78,35 @@ public class DesktopMenu {
public void addComponent(Component component) {
if ( component.getName() == null ) { return; }
addComponent(component.getName(), component);
addComponent(component.getName(), component, false);
}
public void addComponent(String name, Component component) {
public void addComponent(String name, Component component) { addComponent(name, component, false); }
private void addComponent(String name, Component component, boolean addListens) {
tbItems.put(name, component);
toolBar.add(name, component);
if ( al == null ) { return; }
try {
Method m = component.getClass().getMethod("addActionListener", ActionListener.class);
m.invoke(component, al);
}
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {}
try {
Method m = component.getClass().getMethod("setActionCommand", String.class);
m.invoke(component, name);
if ( component instanceof JButton ) {
((JButton) component).setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
((JButton) component).setBorderPainted(true);
} // */
if ( addListens ) {
try {
Method m = component.getClass().getMethod("addActionListener", ActionListener.class);
m.invoke(component, al);
}
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {}
try {
Method m = component.getClass().getMethod("setActionCommand", String.class);
m.invoke(component, name);
}
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {}
}
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {}
}
public Component getComponent(String name) { return tbItems.get(name); }
......
......@@ -58,13 +58,15 @@ public class WindowUnifiedListener extends UnifiedListener {
if ( className.equals("JSplitPane") ) {
switch ( action.getName() ) {
case "dividerLocation": saveHelper(action); return;
default: super.handleProperty(action);
default: return;
}
}
super.handleProperty(action);
}
@Override public void handleEvent(ActionHandle action) {
if ( !log.isDebugEnabled() ) { return; }
StringBuilder sb = new StringBuilder("[");
sb.append(action.getActionSource().toString());
sb.append("/");
......
app=me.felinewith.lang_toolkit.apps.langbuilder.LangBuilder
langbuilder.welcome=me.felinewith.lang_toolkit.apps.langbuilder.ui.WelcomeWindow
<?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>
......@@ -131,7 +131,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
......@@ -181,11 +180,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>clean test package install</defaultGoal>
<defaultGoal>test package install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -306,6 +306,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<configuration>
<!-- configLocation>https://dev.vocasystem.net/checkstyle.xml</configLocation -->
</configuration>
<reportSets>
<reportSet>
<id>parent</id>
<inherited>false</inherited>
<configuration>
<skip>true</skip>
</configuration>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -323,7 +332,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<splitindex>true</splitindex>
<detectLinks>true</detectLinks>
<nodeprecated>true</nodeprecated>
<stylesheet>maven</stylesheet>
<quiet>true</quiet>
</configuration>
</plugin>
<plugin>
......
......@@ -21,7 +21,7 @@
</custom>
<version position="right" />
<publishDate position="right" format="yyyy-mm-dd'T'HH:mm:ssZ" />
<publishDate position="right" format="yyyy-MM-dd'T'HH:mm:ssZ" />
<!-- poweredBy>
<logo name="VOCASystem.Net" href="https://dev.vocasystem.net/" alt="VOCASystem.Net"
......@@ -33,6 +33,7 @@
<item name="${this.name}" href="${this.url}" />
</breadcrumbs>
<menu ref="parent" inherit="top" />
<menu ref="modules" inherit="bottom" />
<menu name="Project Information" ref="reports" inherit="bottom" />
</body>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!