1 package com.neuronrobotics.sdk.ui;
3 import gnu.io.NativeResource;
5 import java.awt.GraphicsEnvironment;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.awt.event.WindowAdapter;
9 import java.awt.event.WindowEvent;
11 import javax.swing.JButton;
12 import javax.swing.JDialog;
13 import javax.swing.JOptionPane;
14 import javax.swing.JPanel;
15 import javax.swing.JTabbedPane;
16 import javax.swing.LookAndFeel;
18 import net.miginfocom.swing.MigLayout;
20 import com.neuronrobotics.sdk.common.BowlerAbstractConnection;
21 import com.neuronrobotics.sdk.common.BowlerAbstractDevice;
22 import com.neuronrobotics.sdk.common.ConfigManager;
23 import com.neuronrobotics.sdk.common.Log;
24 import com.neuronrobotics.sdk.dyio.DyIOCommunicationException;
25 import com.neuronrobotics.sdk.serial.SerialConnection;
26 import com.neuronrobotics.sdk.util.OsInfoUtil;
59 private LookAndFeel
laf;
75 connectBtn.addActionListener(
new ActionListener() {
77 public void actionPerformed(ActionEvent arg0) {
81 }
catch(Exception e) {
82 JOptionPane.showMessageDialog(
null,
"Error connecting with the given connection.",
"Connection Error", JOptionPane.ERROR_MESSAGE);
90 cancelBtn.addActionListener(
new ActionListener() {
92 public void actionPerformed(ActionEvent arg0) {
98 refresh =
new JButton(
"Refresh");
99 refresh.addActionListener(
new ActionListener() {
101 public void actionPerformed(ActionEvent arg0) {
107 panel =
new JPanel(
new MigLayout(
"",
118 setTitle(
"Connection Information");
126 addWindowFocusListener(
new WindowAdapter() {
127 public void windowGainedFocus(WindowEvent e) {
132 setAlwaysOnTop(
true);
147 }
catch(Exception ex){
153 Log.
error(
"This is not a java 8 compliant system, removing the serial, bluetooth and usb connections");
179 setLocationRelativeTo(
null);
193 JOptionPane.showMessageDialog(
null,
"Unable to create connection.",
"Invalid Connection", JOptionPane.ERROR_MESSAGE);
222 Log.
info(
"Select connection:");
225 Log.
info(
"No connection selected...");
228 Log.
info(
"setting connection");
234 String m =
"The DyIO has not reported back to the library. \nCheck your connection and ensure you are attempting to talk to a DyIO, not another Bowler Device\nThis program will now exit.";
235 JOptionPane.showMessageDialog(
null, m,
"DyIO Not Responding"+e1.getMessage(), JOptionPane.ERROR_MESSAGE);
237 }
catch(Exception e) {
239 JOptionPane.showMessageDialog(
null, e.getMessage(),
"DyIO Connection problem ", JOptionPane.ERROR_MESSAGE);
242 Log.
info(
"Attempting to ping");
248 JOptionPane.showMessageDialog(
null,
"No device on that port",
"", JOptionPane.ERROR_MESSAGE);
261 if(!GraphicsEnvironment.isHeadless()) {
267 if(System.getProperty(
"nrdk.config.file") ==
null) {
290 if(System.getProperty(
"nrdk.config.file") ==
null) {
299 if(System.getProperty(
"nrdk.config.file") ==
null) {
void setConnection(BowlerAbstractConnection connection)
static BowlerAbstractConnection loadDefaultConnection(String filename)
static void info(String message)
static void error(String message)
void loadDefaultConnections()
JTabbedPane connectionPanels
static BowlerAbstractConnection getHeadlessConnection(String config)
SerialConnection connection
void addConnectionPanel(AbstractConnectionPanel panel)
static final long serialVersionUID
BowlerAbstractConnection getConnection()
static BowlerAbstractConnection promptConnection()
static boolean getBowlerDevice(BowlerAbstractDevice dev)
static BowlerAbstractConnection promptConnection(AbstractConnectionPanel panel)
static boolean getBowlerDevice(BowlerAbstractDevice dev, AbstractConnectionPanel panel)
static ImageIcon getIcon(String path)