Commit 0caeb225 authored by Vincent van Beveren's avatar Vincent van Beveren

continued on messagepane

started on integrated help
parent a894b977
/* CSS31_ style sheet for the output of Docutils HTML writers. */
/* Rules for easy reading and pre-defined style variants. */
/* */
/* :Author: Günter Milde, based on html4css1.css by David Goodger */
/* :Id: $Id: plain.css 7952 2016-07-26 18:15:59Z milde $ */
/* :Copyright: © 2015 Günter Milde. */
/* :License: Released under the terms of the `2-Clause BSD license`_, */
/* in short: */
/* */
/* Copying and distribution of this file, with or without modification, */
/* are permitted in any medium without royalty provided the copyright */
/* notice and this notice are preserved. */
/* */
/* This file is offered as-is, without any warranty. */
/* */
/* .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause */
/* .. _CSS3: http://www.w3.org/TR/CSS3 */
/* Document Structure */
/* ****************** */
/* "page layout" */
body {
padding: 0 5%;
margin: 8px 0;
}
div.document {
line-height:1.3;
counter-reset: table;
/* counter-reset: figure; */
/* avoid long lines --> better reading */
/* OTOH: lines should not be too short because of missing hyphenation, */
max-width: 50em;
margin: auto;
font-family: sans-serif;
}
/* Sections */
/* Transitions */
hr.docutils {
width: 80%;
margin-top: 1em;
margin-bottom: 1em;
clear: both;
}
/* Paragraphs */
/* ========== */
/* vertical space (parskip) */
p, ol, ul, dl,
div.line-block,
table{
margin-top: 0.5em;
margin-bottom: 0.5em;
}
h1, h2, h3, h4, h5, h6,
dl > dd {
margin-bottom: 0.5em;
}
/* Lists */
/* ========== */
/* Definition Lists */
dl > dd p:first-child { margin-top: 0; }
/* :last-child is not part of CSS 2.1 (introduced in CSS 3) */
/* dl > dd p:last-child { margin-bottom: 0; } */
/* lists nested in definition lists */
/* :only-child is not part of CSS 2.1 (introduced in CSS 3) */
dd > ul:only-child, dd > ol:only-child { padding-left: 1em; }
/* Description Lists */
/* styled like in most dictionaries, encyclopedias etc. */
dl.description > dt {
font-weight: bold;
clear: left;
float: left;
margin: 0;
padding: 0;
padding-right: 0.5em;
}
/* Field Lists */
/* example for custom field-name width */
dl.field-list.narrow > dd {
margin-left: 5em;
}
/* run-in: start field-body on same line after long field names */
dl.field-list.run-in > dd p {
display: block;
}
/* Bibliographic Fields */
/* generally, bibliographic fields use special definition list dl.docinfo */
/* but dedication and abstract are placed into "topic" divs */
div.abstract p.topic-title {
text-align: center;
}
div.dedication {
margin: 2em 5em;
text-align: center;
font-style: italic;
}
div.dedication p.topic-title {
font-style: normal;
}
/* Citations */
dl.citation dt.label {
font-weight: bold;
}
span.fn-backref {
font-weight: normal;
}
/* Text Blocks */
/* ============ */
/* Literal Blocks */
pre.literal-block, pre.doctest-block,
pre.math, pre.code {
margin-left: 1.5em;
margin-right: 1.5em
}
/* Block Quotes */
blockquote,
div.topic {
margin-left: 1.5em;
margin-right: 1.5em
}
blockquote > table,
div.topic > table {
margin-top: 0;
margin-bottom: 0;
}
blockquote p.attribution,
div.topic p.attribution {
text-align: right;
margin-left: 20%;
}
/* Tables */
/* ====== */
/* th { vertical-align: bottom; } */
table tr { text-align: left; }
/* "booktabs" style (no vertical lines) */
table.booktabs {
border: 0;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.booktabs * {
border: 0;
}
table.booktabs th {
border-bottom: thin solid;
}
/* numbered tables (counter defined in div.document) */
table.numbered > caption:before {
counter-increment: table;
content: "Table " counter(table) ": ";
font-weight: bold;
}
/* Explicit Markup Blocks */
/* ====================== */
/* Footnotes and Citations */
/* ----------------------- */
/* line on the left */
dl.footnote {
padding-left: 1ex;
border-left: solid;
border-left-width: thin;
}
/* Directives */
/* ---------- */
/* Body Elements */
/* ~~~~~~~~~~~~~ */
/* Images and Figures */
/* let content flow to the side of aligned images and figures */
.figure.align-left,
img.align-left,
object.align-left {
display: block;
clear: left;
float: left;
margin-right: 1em
}
.figure.align-right,
img.align-right,
object.align-right {
display: block;
clear: right;
float: right;
margin-left: 1em
}
/* Stop floating sidebars, images and figures at section level 1,2,3 */
h1, h2, h3 { clear: both; }
/* Sidebar */
/* Move into the margin. In a layout with fixed margins, */
/* it can be moved into the margin completely. */
div.sidebar {
width: 30%;
max-width: 26em;
margin-left: 1em;
margin-right: -5.5%;
background-color: #ffffee ;
}
/* Code */
pre.code, code { background-color: #eeeeee }
pre.code .ln { color: gray; } /* line numbers */
/* basic highlighting: for a complete scheme, see */
/* http://docutils.sourceforge.net/sandbox/stylesheets/ */
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
/* Math */
/* styled separately (see math.css for math-output=HTML) */
/* Epigraph */
/* Highlights */
/* Pull-Quote */
/* Compound Paragraph */
/* Container */
/* can be styled in a custom stylesheet */
/* Document Header and Footer */
div.footer, div.header {
clear: both;
font-size: smaller;
}
/* Inline Markup */
/* ============= */
/* Emphasis */
/* em */
/* Strong Emphasis */
/* strong */
/* Interpreted Text */
/* span.interpreted */
/* Title Reference */
/* cite */
/* Inline Literals */
/* possible values: normal, nowrap, pre, pre-wrap, pre-line */
/* span.docutils.literal { white-space: pre-wrap; } */
/* Hyperlink References */
a { text-decoration: none; }
/* External Targets */
/* span.target.external */
/* Internal Targets */
/* span.target.internal */
/* Footnote References */
/* a.footnote-reference */
/* Citation References */
/* a.citation-reference */
----------
SaFariPark
----------
SaFariPark is the software tool to use with MultiSFP
SaFariPark
----------
SaFariPark is the software tool to use with MultiSFP
......@@ -101,12 +101,16 @@ public class DDMI extends DDMIGroup {
public boolean verifyChecksums(DDMIContext ctx) {
boolean allOk = true;
for (DataSource ds : _dataSources.values())
{
if (!ds.isValid(ctx)) continue;
if (!ds.verifyChecksums(ctx)) return false;
if (!ds.verifyChecksums(ctx)) {
allOk = false;
}
}
return true;
return allOk;
}
public void updateChecksums(DDMIContext ctx) {
......
......@@ -194,7 +194,7 @@ public abstract class DataSource {
{
if (!c.check(ctx)) {
LOG.warning(String.format("Checksum for source=%s, start=%d, end=%d, at=%d, does not check out", this, c.start, c.end, c.offset));
LOG.warning(String.format("Checksum for source=%s, start=%d, end=%d, at=%d, does not check out", this.getId(), c.start, c.end, c.offset));
return false;
}
}
......
......@@ -31,7 +31,7 @@ public class PageDataSource extends DataSource {
private void selectPage(DDMIContext ctx)
{
LOG.info("Selecting page " + _pageNo);
LOG.fine("Selecting page " + _pageNo);
if (_parent.getPageSelect() == -1)
throw new RuntimeException("Parent has no page select!");
......
......@@ -121,9 +121,9 @@ public class VirtualI2CLink implements I2CLink {
_eeprom[i + 68] = i < serialBytes.length ? serialBytes[i] : 0x20;
}
_eeprom[63] = SFPUtils.checkSum(_eeprom, 0, 63);
_eeprom[95] = SFPUtils.checkSum(_eeprom, 64, 31);
_diag[95] = SFPUtils.checkSum(_diag, 0, 95);
//_eeprom[63] = SFPUtils.checkSum(_eeprom, 0, 63);
//_eeprom[95] = SFPUtils.checkSum(_eeprom, 64, 31);
//_diag[95] = SFPUtils.checkSum(_diag, 0, 95);
}
......
......@@ -42,7 +42,7 @@ public class I2C extends BusBase {
{
super(mpsse);
LOG.setLevel(Level.FINE);
// LOG.setLevel(Level.FINE);
mpsse.switchMode(0);
// configure clock speed
......@@ -52,7 +52,7 @@ public class I2C extends BusBase {
// set pull down on ports AD0 1 and 2
mpsse.setDrive0Only(0x7);
}
LOG.setLevel(Level.FINE);
// LOG.setLevel(Level.FINE);
LOG.fine(String.format("I2C initialized on MPSSE %s, myId=%08x", mpsse, System.identityHashCode(this)));
}
......
......@@ -5,6 +5,9 @@ import java.util.Set;
import javax.inject.Inject;
import nl.nikhef.safaripark.extra.BaseMessage;
import nl.nikhef.safaripark.extra.Message;
import nl.nikhef.safaripark.extra.MessagePane;
import nl.nikhef.safaripark.extra.Module;
import nl.nikhef.sfp.SFPDevice;
import nl.nikhef.sfp.SFPManager;
......@@ -18,6 +21,7 @@ public class AppContext {
public final ContextCache ctxCache;
private final Set<Module> _locks = new HashSet();
private MessagePane _msgPane;
@Inject
public AppContext(SFPManager sfpMgr, DDMILoader ddmiLdr, OverlayManager ovlMgr) {
......@@ -47,4 +51,17 @@ public class AppContext {
_locks.remove(m);
}
public void setMessagePane(MessagePane msgPane)
{
_msgPane = msgPane;
}
public MessagePane getMessagePane() {
return _msgPane;
}
}
......@@ -26,6 +26,8 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import nl.nikhef.safaripark.devmgr.BaySelectionListener;
import nl.nikhef.safaripark.extra.BaseMessage;
import nl.nikhef.safaripark.extra.Message;
import nl.nikhef.sfp.SFPDevice;
import nl.nikhef.sfp.ddmi.DDMI;
import nl.nikhef.sfp.ddmi.DDMIContext;
......@@ -44,14 +46,14 @@ public class ModuleManager implements BaySelectionListener
private JRadioButton _extendedhex;
private DDMI _ddmi;
private ContextCache _ctxCache;
private DDMIContext _ctx;
private String _moduleName;
private DateFormat _fileDateFormat = new SimpleDateFormat("yyMMdd_HHmmss");
private AppContext _appCtx;
public ModuleManager(Action binExport, AppContext appCtx)
{
_ctxCache = appCtx.ctxCache;
_appCtx = appCtx;
_binExport = binExport;
_binExport.setEnabled(false);
_dirChooser = new JFileChooser();
......@@ -88,21 +90,57 @@ public class ModuleManager implements BaySelectionListener
try {
if (dev.isModulePresent(bay))
{
_ctx = _ctxCache.getContextFor(dev, bay);
_ctx = _appCtx.ctxCache.getContextFor(dev, bay);
_moduleName = dev.getModuleName(bay);
_binExport.setEnabled(true);
widthdrawChecksum();
checkChecksums();
} else {
_ctx = null;
_binExport.setEnabled(false);
widthdrawChecksum();
}
} catch (IOException e) {
_ctx = null;
_binExport.setEnabled(false);
widthdrawChecksum();
}
}
private class CheckSumMessage extends BaseMessage
{
public CheckSumMessage() {
super("<html>Checksum for selected module does not check out, see Logging window for details.<br/><b>Note:</b> This could also occur if an incompatible overlay is loaded</html>", "Fix");
}
@Override
public void runOperation() {
_ctx.updateChecksums();
}
}
private Message _checksumMessage;
public void checkChecksums()
{
if (!_ctx.verifyChecksums()) {
_checksumMessage = new CheckSumMessage();
_appCtx.getMessagePane().addMessage(_checksumMessage);
}
}
private void widthdrawChecksum() {
if (_checksumMessage != null) {
_appCtx.getMessagePane().widthdrawMessage(_checksumMessage);
}
}
public void exportBinary(Component parent)
{
if ((_dirChooser.showDialog(parent, "Select") != JFileChooser.APPROVE_OPTION))
......
package nl.nikhef.safaripark;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Toolkit;
......@@ -26,6 +27,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFrame;
......@@ -49,8 +51,11 @@ import nl.nikhef.safaripark.devmgr.DeviceManager;
import nl.nikhef.safaripark.dolly.DollyModel;
import nl.nikhef.safaripark.dolly.DollyPanel;
import nl.nikhef.safaripark.editpane.EditPane;
import nl.nikhef.safaripark.extra.BaseMessage;
import nl.nikhef.safaripark.extra.ExtendedAbstractAction;
import nl.nikhef.safaripark.extra.GuiUtils;
import nl.nikhef.safaripark.extra.Message;
import nl.nikhef.safaripark.extra.MessagePane;
import nl.nikhef.safaripark.extra.StatefulTask;
import nl.nikhef.safaripark.monitor.Monitor;
import nl.nikhef.safaripark.res.Resources;
......@@ -100,6 +105,30 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
_modMgr.exportBinary(SaFariPark.this);
}
};
private Message _msg;
private Action _help = new ExtendedAbstractAction("Help", Resources.getIcon("help"), "Loads the manual") {
@Override
public void actionPerformed(ActionEvent e) {
File f = new File("multisfp.pdf");
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().open(f);
f = null;
} catch (Exception ex) {
}
}
if (f != null) {
if (_msg == null) {
_msg = new BaseMessage("Help can not be opened, please open manually at " + f.getAbsolutePath());
}
_appCtx.getMessagePane().addMessage(_msg);
}
}
};
private StatefulTask _task;
......@@ -135,6 +164,7 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
_status = new StatusBar();
_modMgr = new ModuleManager(_saveBinary, appCtx);
_devMgr.addDeviceSelectedListener(_modMgr);
_appCtx.setMessagePane(_messagePane);
DollyModel dm = new DollyModel(appCtx.ctxCache);
appCtx.sfpMgr.addSFPProviderListener(dm);
_dp = new DollyPanel(appCtx.ddmiLdr, dm, this);
......@@ -223,6 +253,8 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
tb.setFloatable(false);
tb.add(_selectOverlays);
tb.add(_saveBinary);
tb.add(Box.createHorizontalGlue());
tb.add(_help);
GuiUtils.toolbarTextButtions(tb);
add(tb, BorderLayout.NORTH);
......@@ -392,7 +424,6 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
public void run() {
_tabEdit.initEditor(_appCtx.ddmiLdr);
_timer.start();
}
});
......
......@@ -128,18 +128,7 @@ public class EditPane extends JPanel {
if (dev.isModulePresent(bay)) {
DDMIContext ctx = _ctxCache.getContextFor(dev, bay);
_ctx.setContext(ctx);
if (!_ctx.getContext().verifyChecksums()) {
if (JOptionPane.showConfirmDialog(this,
"One or more checksums on the device are not valid\n" +
"Recalculate checksums and write to eeprom?","Checksum failure",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
_ctx.getContext().updateChecksums();
}
}
_reload.setEnabled(true);
} else {
_ctx.setContext(null);
......
package nl.nikhef.safaripark.extra;
public class BaseMessage implements Message {
private final boolean _hasOperation;
private final String _messageText;
private final String _operationText;
public BaseMessage(String messageText) {
_hasOperation = false;
_messageText = messageText;
_operationText = null;
}
public BaseMessage(String messageText, String operationText) {
_hasOperation = true;
_messageText = messageText;
_operationText = operationText;
}
@Override
public String getMessage() {
return _messageText;
}
@Override
public boolean hasOperation() {
return _hasOperation;
}
@Override
public String getOperationText() {
return _operationText;
}
@Override
public void runOperation() {
}
@Override
public void repelOperation() {
}
}
package nl.nikhef.safaripark.extra;
/**
*
* @author vincentb
*
*/
public interface Message {
public String getMessage();
public boolean hasOperation();
public String getOperationText();
public void runOperation();
public void repelOperation();
}
package nl.nikhef.safaripark;
package nl.nikhef.safaripark.extra;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.Queue;
import javax.swing.BorderFactory;
import javax.swing.JButton;
......@@ -11,17 +15,19 @@ import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
public class MessagePane extends JPanel {
public class MessagePane extends JPanel implements ActionListener {
private static final Color NOTE_YELLOW = new Color(255, 255, 192);
private static final Color NOTE_YELLOW = new Color(255, 255, 220);
private JLabel _message;
private JButton _action;
private JButton _close;
private Queue<Message> _messages = new LinkedList<Message>();
public MessagePane() {
Border outside = BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK);
Border inside = BorderFactory.createEmptyBorder(4, 4, 4, 4);
Border inside = BorderFactory.createEmptyBorder(2, 4, 2, 4);
setBorder(BorderFactory.createCompoundBorder(outside, inside));
setBackground(NOTE_YELLOW);
......@@ -34,6 +40,8 @@ public class MessagePane extends JPanel {
JPanel btnPane = new JPanel();
btnPane.setOpaque(false);
_action = new JButton(" Fix! ");
_action.setOpaque(false);
_action.addActionListener(this);
_close = new JButton("x");
_close.setFont(_close.getFont().deriveFont(Font.BOLD));
Border bevel = BorderFactory.createBevelBorder(BevelBorder.RAISED);
......@@ -46,11 +54,56 @@ public class MessagePane extends JPanel {
_close.setOpaque(true);
_close.setBackground(Color.RED);
_close.setForeground(Color.WHITE);
_close.addActionListener(this);
btnPane.add(_action);
btnPane.add(_close);
add(btnPane, BorderLayout.EAST);
setVisible(false);
}
public void addMessage(Message m)
{
if (_messages.contains(m)) return;
_messages.add(m);
updateQueue();
}
public void widthdrawMessage(Message m)
{
_messages.remove(m);
updateQueue();
}
private void updateQueue() {
if (_messages.size() > 0) {
Message m = _messages.peek();
_message.setText(m.getMessage());
if (m.hasOperation()) {
_action.setText(m.getOperationText());
_action.setVisible(true);
} else {
_action.setVisible(false);
}
setVisible(true);
} else {
setVisible(false);
}
}
@Override
public void actionPerformed(ActionEvent e)
{
Message m = _messages.poll();
assert(m != null);
if (e.getSource() == _action) {
m.runOperation();
} else if (e.getSource() == _close) {
m.repelOperation();
}
updateQueue();
}
}
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