Commit 1a71db6d authored by Nico Mack's avatar Nico Mack

Implement About feature

parent b5599fe8
<html>
<h1>${Title}</h1>
<p>${Description}</p>
<p>Version : ${Version}</p>
<hr>
<h2>Installed Tulip Packages</h2>
<p>${Packages}</p>
</html>
\ No newline at end of file
BUILD_DATE=BuildDate
BUILD_NUMBER=BuildNumber
DESCRIPTION=Description
NAME=Name
TITLE=Title
PACKAGES=Packages
VERSION=Version
ABOUT_NODE=about
ACTIVATE_WITH_HANDLE_NODE=activateWithHandle
ALPHA_NODE=alpha
ANIMATED_PROPERTIES_ELEMENT=animatedProperties
......@@ -37,6 +38,7 @@ CURSORS_NODE=cursors
DEFAULT_NODE=default
DEFINING_SHAPE_NODE=definingShape
DELAY_NODE=delay
DESCRIPTION_NODE=description
DESELECTED_ELEMENT=deselected
DISPLAY_TIME_NODE=displayTime
DISTANCE_NODE=distance
......@@ -185,6 +187,7 @@ TULIP_NAMESPACE=lu.list.itis.dkd.tui
TYPE_NODE=type
UNIT_NODE=unit
UPPER_BOUND_NODE=upperBound
VERSION_NODE=version
VOLUME_NODE=volume
WIDGET_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.builder
WIDTH_NODE=width
......
<h3>${Name} - ${Version}</h3>
<p><i>(Build Date : ${BuildDate} | Build Number : ${BuildNumber})</i></p>
\ No newline at end of file
......@@ -68,7 +68,7 @@ public class StageManager {
public StageManager(Properties properties, Document bootstrap) throws BuildException {
TangibleInterfaceManager interfaceManager = new TangibleInterfaceManager(properties);
TangibleInterfaceManager interfaceManager = new TangibleInterfaceManager(properties, bootstrap);
stageMap.put(TANGIBLE_INTERFACE_STAGE_ID, interfaceManager);
StageSetBootstrapper stageSet = new StageSetBootstrapper(bootstrap);
......@@ -144,23 +144,6 @@ public class StageManager {
}
}
// ---------------------------------------------------------------------------
/**
* @param contents
*/
// ---------------------------------------------------------------------------
// public void setContent(Collection<Entry<String, Content>> contents) {
// if (contents != null) {
// for (Entry<String, Content> entry : contents) {
// Content content = entry.getValue();
// if (stageMap.containsKey(content.getStageId())) {
// stageMap.get(content.getStageId()).addToStage(entry.getKey(), content);
// }
// }
// }
// }
// ---------------------------------------------------------------------------
/**
* @param objects
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2016.
*
* This file is part of TULIP.
*
* TULIP is licensed under a dual-licensing scheme. For non-commercial purposes, the LGPL version 3,
* as stated below, is applicable. For all commercial purposes TULIP is licensed under a LIST
* proprietary license. Please contact LIST at tto@list.lu to obtain a commercial license.
*
* For all non-commercial purposes, TULIP is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 of the License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.utility;
import org.eclipse.osgi.util.NLS;
/**
* Auto-generated class for string externalization to be used to bundle all node names.
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.2
* @version 2.5.0
*/
@SuppressWarnings({"javadoc", "squid:S3008"})
public class About extends NLS {
private static final String BUNDLE_NAME = "about"; //$NON-NLS-1$
public static String BUILD_DATE;
public static String BUILD_NUMBER;
public static String DESCRIPTION;
public static String NAME;
public static String TITLE;
public static String PACKAGES;
public static String VERSION;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, About.class);
}
private About() {}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import org.eclipse.osgi.util.NLS;
public class Externalization extends NLS {
private static final String BUNDLE_NAME = "externalization"; //$NON-NLS-1$
public static String ABOUT_NODE;
public static String ACTIVATE_WITH_HANDLE_NODE;
public static String ALPHA_NODE;
public static String ANIMATED_PROPERTIES_ELEMENT;
......@@ -72,6 +73,7 @@ public class Externalization extends NLS {
public static String DEFAULT_NODE;
public static String DEFINING_SHAPE_NODE;
public static String DELAY_NODE;
public static String DESCRIPTION_NODE;
public static String DESELECTED_ELEMENT;
public static String DISPLAY_TIME_NODE;
public static String DISTANCE_NODE;
......@@ -220,6 +222,7 @@ public class Externalization extends NLS {
public static String TYPE_NODE;
public static String UNIT_NODE;
public static String UPPER_BOUND_NODE;
public static String VERSION_NODE;
public static String VOLUME_NODE;
public static String WIDGET_BUILDER_NAMESPACE;
public static String WIDTH_NODE;
......
......@@ -23,24 +23,21 @@ import lu.list.itis.dkd.tui.logging.OnScreenLogAppender;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.io.StringReader;
import java.net.URL;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
......@@ -48,6 +45,8 @@ import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.text.DefaultCaret;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
/**
* @author mack
......@@ -62,7 +61,7 @@ public class SplashScreen extends JPanel implements LogListener {
private BufferedImage logo;
private JTextArea log;
private JTextArea about;
private JEditorPane about;
private JScrollPane logScroller;
private JScrollPane aboutScroller;
private OnScreenLogAppender appender;
......@@ -76,7 +75,7 @@ public class SplashScreen extends JPanel implements LogListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SplashScreen.class.getSimpleName());
private static final String LOGO_PATH = "resources/TULIP.png"; //$NON-NLS-1$
private static final String COLUMN_SPECS = "5dlu, left:pref, 5dlu, 60dlu:grow, 5dlu"; //$NON-NLS-1$
private static final String COLUMN_SPECS = "5dlu, left:pref, 50dlu, 100dlu:grow, 5dlu"; //$NON-NLS-1$
private static final String ROW_SPECS = "5dlu, center:300dlu, 5dlu, top:pref:grow,5dlu"; //$NON-NLS-1$
// ---------------------------------------------------------------------------
......@@ -122,23 +121,32 @@ public class SplashScreen extends JPanel implements LogListener {
log.setColumns(columns);
log.setRows(rows);
about = new JTextArea();
about.setLineWrap(false);
about.setOpaque(false);
about.setForeground(Color.LIGHT_GRAY);
HTMLEditorKit htmlEditor = new HTMLEditorKit();
StyleSheet stylesheet = htmlEditor.getStyleSheet();
stylesheet.addRule("h1 { font-family: Arial, Helvetica Neue, Helvetica, sans-serif; color: #ffffff; font-size: 1.4em; text-align: left; font-style: bold; }"); //$NON-NLS-1$
stylesheet.addRule("h2 { font-family: Arial, Helvetica Neue, Helvetica, sans-serif; color: #ffffff; font-size: 1.2em; text-align: left; font-style: bold; }"); //$NON-NLS-1$
stylesheet.addRule("h3 { font-family: Arial, Helvetica Neue, Helvetica, sans-serif; color: #ffffff; font-size: 1.1em; text-align: left; font-style: bold; }"); //$NON-NLS-1$
stylesheet.addRule("p { font-family: Arial, Helvetica Neue, Helvetica, sans-serif; color: #b0b0b0; font-size: 1.0em; text-align: left; }"); //$NON-NLS-1$
about = new JEditorPane();
about.setContentType("text/html"); //$NON-NLS-1$
about.setEditorKit(htmlEditor);
about.setEditable(false);
about.setSize(new Dimension((screenWidth / 2), (int) (0.8 * screenHeight)));
about.setOpaque(false);
about.setDoubleBuffered(false);
Font aboutFont = new Font("Arial", Font.BOLD, 16);
metrics = about.getFontMetrics(aboutFont);
columns = (int) (screenWidth / 2 * (metrics.charWidth('A') * 1.4));
rows = (int) ((0.8 * screenHeight) / (2 * metrics.getHeight()));
about.setFont(aboutFont);
about.setColumns(columns);
about.setRows(rows);
// Font aboutFont = new Font("Arial", Font.BOLD, 16);
// metrics = about.getFontMetrics(aboutFont);
// columns = (int) (screenWidth / 2 * (metrics.charWidth('A') * 1.4));
// rows = (int) ((0.8 * screenHeight) / (2 * metrics.getHeight()));
// about.setFont(aboutFont);
// about.setColumns(columns);
// about.setRows(rows);
aboutScroller = new JScrollPane(about);
aboutScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
aboutScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
aboutScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
aboutScroller.setAutoscrolls(false);
aboutScroller.setOpaque(false);
aboutScroller.getViewport().setOpaque(false);
......@@ -147,38 +155,12 @@ public class SplashScreen extends JPanel implements LogListener {
appender = OnScreenLogAppender.getInstance("SplashScreen");
appender.addLogListener(this);
this.findAllTulipPackages();
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
private void findAllTulipPackages() {
Reflections reflections = new Reflections(Externalization.TULIP_NAMESPACE);
Set<Class<? extends TulipPackage>> tulipPackages = reflections.getSubTypesOf(TulipPackage.class);
TulipPackage instance = null;
for (Class<? extends TulipPackage> tulipPackage : tulipPackages) {
Constructor<TulipPackage> constructor;
try {
constructor = (Constructor<TulipPackage>) tulipPackage.getConstructor();
instance = constructor.newInstance();
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.error("Failed to instantiate tulip package {}!", tulipPackage.getSimpleName(), e); //$NON-NLS-1$
}
if (instance != null) {
StringBuilder builder = new StringBuilder(this.about.getText());
builder.append(instance).append("\n");
this.about.setText(builder.toString());
LOGGER.info("Tulip Package: {}", instance); //$NON-NLS-1$
}
}
}
// ---------------------------------------------------------------------------
......@@ -222,5 +204,12 @@ public class SplashScreen extends JPanel implements LogListener {
// ***************************************************************************
// ---------------------------------------------------------------------------
public void setAbout(String htmlContent) {
try {
about.read(new StringReader(htmlContent), null);
} catch (IOException exception) {
LOGGER.error("failed to update HTML content!", exception); //$NON-NLS-1$
}
}
}
......@@ -39,6 +39,7 @@ import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.builder.BaseWidgetBuilder;
import org.jdom2.Document;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
......@@ -55,8 +56,8 @@ import java.util.logging.Logger;
public class PositionChangeListenerTest {
/**
* Mock for the {@link PositionChangeListener} registering whether it was called and the
* parameter passed to it.
* Mock for the {@link PositionChangeListener} registering whether it was called and the parameter
* passed to it.
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.1
......@@ -145,8 +146,8 @@ public class PositionChangeListenerTest {
* @see TangibleInterfaceManager
*/
@SuppressWarnings("javadoc")
public TestTangibleInterfaceManager(Properties properties) {
super(properties);
public TestTangibleInterfaceManager(Properties properties, Document bootstrap) {
super(properties, bootstrap);
}
}
......
......@@ -39,6 +39,7 @@ import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.builder.BaseWidgetBuilder;
import org.jdom2.Document;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
......@@ -102,8 +103,8 @@ public class SpatialMatrixTest {
* @see TangibleInterfaceManager
*/
@SuppressWarnings("javadoc")
public TestTangibleInterfaceManager(Properties properties) {
super(properties);
public TestTangibleInterfaceManager(Properties properties, Document bootstrap) {
super(properties, bootstrap);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment