Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sfp-plus-i2c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
sfp-plus-i2c
Commits
8546282b
Commit
8546282b
authored
Mar 17, 2017
by
Vincent van Beveren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added overlay manager
parent
f1fe12db
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
200 additions
and
21 deletions
+200
-21
DDMI.java
sw/jsfp/src/nl/nikhef/sfp/ddmi/DDMI.java
+17
-17
maxim_ds1856m.xml
sw/safaripark/overlays/maxim_ds1856m.xml
+0
-0
Config.java
sw/safaripark/src/nl/nikhef/safaripark/Config.java
+8
-0
OverlayManager.java
sw/safaripark/src/nl/nikhef/safaripark/OverlayManager.java
+102
-0
SaFariPark.java
sw/safaripark/src/nl/nikhef/safaripark/SaFariPark.java
+18
-0
JCheckBoxList.java
...aripark/src/nl/nikhef/safaripark/extra/JCheckBoxList.java
+53
-0
Monitor.java
sw/safaripark/src/nl/nikhef/safaripark/monitor/Monitor.java
+0
-3
books.png
sw/safaripark/src/nl/nikhef/safaripark/res/books.png
+0
-0
emblem-notice.png
sw/safaripark/src/nl/nikhef/safaripark/res/emblem-notice.png
+0
-0
ValueSelectionPane.java
...park/src/nl/nikhef/safaripark/vsp/ValueSelectionPane.java
+2
-1
No files found.
sw/jsfp/src/nl/nikhef/sfp/ddmi/DDMI.java
View file @
8546282b
...
...
@@ -2,6 +2,7 @@ package nl.nikhef.sfp.ddmi;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -20,23 +21,8 @@ public class DDMI extends DDMIGroup {
private
Map
<
String
,
DataSource
>
_dataSources
=
new
HashMap
<
String
,
DataSource
>();
private
Map
<
String
,
DDMIElement
>
_elementIdCache
=
new
HashMap
<
String
,
DDMIElement
>();
private
static
final
DDMI
_SINGLETON
;
private
static
DDMI
_SINGLETON
;
static
{
DDMILoader
loader
=
new
DDMILoader
();
LOG
.
info
(
"Loading internal DDMI description from "
+
DDMI_XML
);
// , DDMI.class.getResource(MAXIM_XML)
try
{
loader
.
load
(
DDMI
.
class
.
getResource
(
DDMI_XML
));
}
catch
(
XMLStreamException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
_SINGLETON
=
loader
.
getDDMI
();
}
public
DDMI
()
{
}
...
...
@@ -57,7 +43,21 @@ public class DDMI extends DDMIGroup {
}
public
static
final
void
initSingleton
(
URL
[]
overlays
)
{
DDMILoader
loader
=
new
DDMILoader
();
LOG
.
info
(
"Loading internal DDMI description from "
+
DDMI_XML
);
// , DDMI.class.getResource(MAXIM_XML)
try
{
loader
.
load
(
DDMI
.
class
.
getResource
(
DDMI_XML
),
overlays
);
}
catch
(
XMLStreamException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
_SINGLETON
=
loader
.
getDDMI
();
}
public
static
final
DDMI
getDefault
()
{
return
_SINGLETON
;
...
...
sw/
jsfp/src/nl/nikhef/sfp/ddmi/desc
/maxim_ds1856m.xml
→
sw/
safaripark/overlays
/maxim_ds1856m.xml
View file @
8546282b
File moved
sw/safaripark/src/nl/nikhef/safaripark/Config.java
0 → 100644
View file @
8546282b
package
nl
.
nikhef
.
safaripark
;
import
java.util.prefs.Preferences
;
public
class
Config
{
public
static
final
Preferences
PREFS
=
Preferences
.
userNodeForPackage
(
Config
.
class
);
}
sw/safaripark/src/nl/nikhef/safaripark/OverlayManager.java
0 → 100644
View file @
8546282b
package
nl
.
nikhef
.
safaripark
;
import
java.awt.Component
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.prefs.Preferences
;
import
javax.swing.DefaultListModel
;
import
javax.swing.JCheckBox
;
import
javax.swing.JLabel
;
import
javax.swing.JOptionPane
;
import
javax.swing.JScrollPane
;
import
javax.swing.SwingConstants
;
import
nl.nikhef.safaripark.extra.JCheckBoxList
;
import
nl.nikhef.safaripark.res.Resources
;
public
class
OverlayManager
{
public
static
final
OverlayManager
SINGLETON
=
new
OverlayManager
();
private
Map
<
String
,
Boolean
>
_overlays
=
new
HashMap
<
String
,
Boolean
>();
private
File
_overlayDir
;
private
Preferences
_prefs
=
Config
.
PREFS
.
node
(
"overlays"
);
public
void
scanDirectory
(
File
dir
)
{
_overlayDir
=
dir
;
String
[]
files
=
_overlayDir
.
list
(
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
return
name
.
endsWith
(
".xml"
);
}
});
for
(
String
file
:
files
)
{
_overlays
.
put
(
file
,
_prefs
.
getBoolean
(
file
,
false
));
}
}
public
URL
[]
getOverlays
()
{
List
<
URL
>
lst
=
new
ArrayList
<
URL
>();
for
(
Map
.
Entry
<
String
,
Boolean
>
entries
:
_overlays
.
entrySet
())
{
if
(!
entries
.
getValue
())
continue
;
try
{
lst
.
add
(
new
File
(
_overlayDir
,
entries
.
getKey
()).
toURI
().
toURL
());
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
}
}
return
lst
.
toArray
(
new
URL
[
lst
.
size
()]);
}
public
void
showDialog
(
Component
parent
)
{
DefaultListModel
<
JCheckBox
>
cblm
=
new
DefaultListModel
<
JCheckBox
>();
for
(
Map
.
Entry
<
String
,
Boolean
>
entries
:
_overlays
.
entrySet
())
{
cblm
.
addElement
(
new
JCheckBox
(
entries
.
getKey
(),
entries
.
getValue
()));
}
JCheckBoxList
cbl
=
new
JCheckBoxList
(
cblm
);
JScrollPane
jsp
=
new
JScrollPane
(
cbl
);
Component
[]
comp
=
new
Component
[]
{
jsp
,
new
JLabel
(
"Changes to overlays require a restart to be applied"
,
Resources
.
getIcon
(
"emblem-notice"
),
SwingConstants
.
CENTER
)
};
if
(
JOptionPane
.
showOptionDialog
(
parent
,
comp
,
"Select overlays to load"
,
JOptionPane
.
OK_CANCEL_OPTION
,
JOptionPane
.
PLAIN_MESSAGE
,
null
,
null
,
null
)
!=
JOptionPane
.
OK_OPTION
)
{
return
;
}
for
(
int
i
=
0
;
i
<
cblm
.
getSize
();
i
++)
{
JCheckBox
cb
=
cblm
.
getElementAt
(
i
);
_overlays
.
put
(
cb
.
getText
(),
cb
.
isSelected
());
_prefs
.
putBoolean
(
cb
.
getText
(),
cb
.
isSelected
());
}
}
}
sw/safaripark/src/nl/nikhef/safaripark/SaFariPark.java
View file @
8546282b
...
...
@@ -8,6 +8,7 @@ import java.awt.event.ActionListener;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowListener
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Map.Entry
;
import
java.util.logging.Level
;
...
...
@@ -33,8 +34,10 @@ import nl.nikhef.safaripark.devmgr.BaySelectionListener;
import
nl.nikhef.safaripark.devmgr.DeviceManager
;
import
nl.nikhef.safaripark.editpane.EditPane
;
import
nl.nikhef.safaripark.monitor.Monitor
;
import
nl.nikhef.safaripark.res.Resources
;
import
nl.nikhef.sfp.SFPDevice
;
import
nl.nikhef.sfp.SFPManager
;
import
nl.nikhef.sfp.ddmi.DDMI
;
@SuppressWarnings
(
"serial"
)
public
class
SaFariPark
extends
JFrame
implements
BaySelectionListener
,
WindowListener
,
DeferredListener
{
...
...
@@ -55,10 +58,24 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
private
Timer
_timer
;
private
int
_scanForNewDevices
=
SCAN_DEVICE_DELAY
;
private
Action
_selectOverlays
=
new
ExtendedAbstractAction
(
"Select overlays"
,
Resources
.
getIcon
(
"books"
),
"Select which SFP+ overlays to load"
)
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
OverlayManager
.
SINGLETON
.
showDialog
(
SaFariPark
.
this
);
}
};
public
SaFariPark
()
{
SINGLETON
=
this
;
OverlayManager
.
SINGLETON
.
scanDirectory
(
new
File
(
"overlays"
));
DDMI
.
initSingleton
(
OverlayManager
.
SINGLETON
.
getOverlays
());
setLayout
(
new
BorderLayout
());
setTitle
(
"SaFariPark"
);
setSize
(
640
,
480
);
...
...
@@ -113,6 +130,7 @@ public class SaFariPark extends JFrame implements BaySelectionListener, WindowLi
private
void
makeToolbar
()
{
JToolBar
tb
=
new
JToolBar
();
tb
.
add
(
_selectOverlays
);
add
(
tb
,
BorderLayout
.
NORTH
);
}
...
...
sw/safaripark/src/nl/nikhef/safaripark/extra/JCheckBoxList.java
0 → 100644
View file @
8546282b
package
nl
.
nikhef
.
safaripark
.
extra
;
import
java.awt.Component
;
import
javax.swing.*
;
import
javax.swing.border.*
;
import
java.awt.event.*
;
@SuppressWarnings
(
"serial"
)
public
class
JCheckBoxList
extends
JList
<
JCheckBox
>
{
protected
static
Border
noFocusBorder
=
new
EmptyBorder
(
1
,
1
,
1
,
1
);
public
JCheckBoxList
()
{
setCellRenderer
(
new
CellRenderer
());
addMouseListener
(
new
MouseAdapter
()
{
public
void
mousePressed
(
MouseEvent
e
)
{
int
index
=
locationToIndex
(
e
.
getPoint
());
if
(
index
!=
-
1
)
{
JCheckBox
checkbox
=
(
JCheckBox
)
getModel
().
getElementAt
(
index
);
checkbox
.
setSelected
(!
checkbox
.
isSelected
());
repaint
();
}
}
});
setSelectionMode
(
ListSelectionModel
.
SINGLE_SELECTION
);
}
public
JCheckBoxList
(
ListModel
<
JCheckBox
>
model
){
this
();
setModel
(
model
);
}
protected
class
CellRenderer
implements
ListCellRenderer
<
JCheckBox
>
{
public
Component
getListCellRendererComponent
(
JList
<?
extends
JCheckBox
>
list
,
JCheckBox
value
,
int
index
,
boolean
isSelected
,
boolean
cellHasFocus
)
{
JCheckBox
checkbox
=
value
;
//Drawing checkbox, change the appearance here
checkbox
.
setBackground
(
isSelected
?
getSelectionBackground
()
:
getBackground
());
checkbox
.
setForeground
(
isSelected
?
getSelectionForeground
()
:
getForeground
());
checkbox
.
setEnabled
(
isEnabled
());
checkbox
.
setFont
(
getFont
());
checkbox
.
setFocusPainted
(
false
);
checkbox
.
setBorderPainted
(
true
);
checkbox
.
setBorder
(
isSelected
?
UIManager
.
getBorder
(
"List.focusCellHighlightBorder"
)
:
noFocusBorder
);
return
checkbox
;
}
}
}
\ No newline at end of file
sw/safaripark/src/nl/nikhef/safaripark/monitor/Monitor.java
View file @
8546282b
...
...
@@ -6,7 +6,6 @@ import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileWriter
;
import
java.io.PrintWriter
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
...
...
@@ -21,8 +20,6 @@ import javax.swing.JSpinner;
import
javax.swing.JTable
;
import
javax.swing.JToolBar
;
import
javax.swing.SpinnerListModel
;
import
javax.swing.SpinnerModel
;
import
javax.swing.SpinnerNumberModel
;
import
javax.swing.Timer
;
import
javax.swing.UIManager
;
import
javax.swing.event.ChangeEvent
;
...
...
sw/safaripark/src/nl/nikhef/safaripark/res/books.png
0 → 100644
View file @
8546282b
1.27 KB
sw/safaripark/src/nl/nikhef/safaripark/res/emblem-notice.png
0 → 100644
View file @
8546282b
1.18 KB
sw/safaripark/src/nl/nikhef/safaripark/vsp/ValueSelectionPane.java
View file @
8546282b
...
...
@@ -34,6 +34,7 @@ import javax.swing.UnsupportedLookAndFeelException;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeModel
;
import
nl.nikhef.safaripark.Config
;
import
nl.nikhef.safaripark.ExtendedAbstractAction
;
import
nl.nikhef.safaripark.res.Resources
;
import
nl.nikhef.sfp.ddmi.DDMI
;
...
...
@@ -256,7 +257,7 @@ public class ValueSelectionPane extends JPanel implements ItemListener {
tree
.
setModel
(
new
DefaultTreeModel
(
_root
));
Preferences
p
=
Preferences
.
userNodeForPackage
(
ValueSelectionPane
.
class
);
Preferences
p
=
Config
.
PREFS
.
node
(
"vsp"
);
_presets
=
p
.
node
(
name
);
Vector
<
String
>
options
=
new
Vector
<
String
>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment