Initial checkin of unified hierarchy of WPILib 2015

This commit is contained in:
Brad Miller
2013-12-15 18:30:16 -05:00
commit 3178911eef
1560 changed files with 410007 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Network_Tables_2.0"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java-table-viewer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,59 @@
<!--
Table Viewer Build Script
Tasks:
- compile: Compiles the code.
- jar: Makes the runnable jar file.
- clean: Cleans up the project.
-->
<project name="Java TableMyProject Viewer" default="jar" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src.dir" location="src"/>
<property name="build.dir" location="build"/>
<property name="lib.dir" location="lib"/>
<property name="dist.dir" location="dist/tools"/>
<property name="revision" value="rUNVERSIONED"/>
<path id="external.jars">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<path id="project.classpath">
<pathelement location="${src.dir}"/>
<path refid="external.jars" />
</path>
<target name="init">
</target>
<target name="compile" description="compile the source " >
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}"/>
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src.dir}" destdir="${build.dir}"
includeAntRuntime="no"
includeJavaRuntime="no"
classpathref="project.classpath"/>
</target>
<target name="jar" depends="compile" description="generate the distribution" >
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist.dir}/TableViewer-${revision}.jar" basedir="${build.dir}">
<zipgroupfileset dir="lib/" includes="*.jar" />
<manifest>
<attribute name="Main-Class" value="edu.wpi.first.table_viewer.TableViewer"/>
</manifest>
</jar>
</target>
<target name="clean" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
</project>

View File

@@ -0,0 +1,4 @@
libs.CopyLibs.classpath=\
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.CopyLibs.displayName=CopyLibs Task
libs.CopyLibs.prop-version=1.0

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="NetworkTableViewer" default="default" basedir=".">
<description>Builds, tests, and runs the project NetworkTableViewer.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="NetworkTableViewer-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
nbbuild.xml.data.CRC32=e55bf502
nbbuild.xml.script.CRC32=9f7b6a03
nbbuild.xml.stylesheet.CRC32=28e38971@1.56.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=e55bf502
nbproject/build-impl.xml.script.CRC32=97404a04
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46

View File

@@ -0,0 +1,76 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=NetworkTableViewer
application.vendor=Sam
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
buildfile=nbbuild.xml
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/NetworkTableViewer.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.java-table-viewer-src=src
file.reference.networktables-desktop.jar=..\\NetworkTableViewer\\lib\\networktables-desktop.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.networktables-desktop.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.7
javac.target=1.7
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=edu.wpi.first.table_viewer.TableViewer
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=x-IBM33722
src.dir=${file.reference.java-table-viewer-src}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>NetworkTableViewer</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots/>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>

View File

@@ -0,0 +1,24 @@
package edu.wpi.first.table_viewer;
import java.io.*;
public class ConstantPutTest {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
/*DebugNetworkTableTransactionPool pool;
NetworkTableServer client = new NetworkTableServer(SocketStreams.newStreamProvider(1735), new DefaultThreadManager(), pool=new DebugNetworkTableTransactionPool());
boolean x = true;
long start = System.currentTimeMillis();
while(true){
client.putBoolean("my key", x=!x);
if(System.currentTimeMillis()-start>10000)
break;
}
pool.print();*/
}
}

View File

@@ -0,0 +1,18 @@
package edu.wpi.first.table_viewer;
import java.util.Arrays;
import javax.swing.tree.DefaultTreeCellRenderer;
public class DefaultNetworkTablesValueRenderer extends DefaultTreeCellRenderer {
public void setValue(Object value) {
if (value == null) {
setText("null");
} else if (value instanceof Object[]) {
setText(Arrays.toString((Object[]) value));
} else {
setText(value.toString());
}
}
}

View File

@@ -0,0 +1,66 @@
package edu.wpi.first.table_viewer;
import java.util.*;
import javax.swing.table.*;
import edu.wpi.first.wpilibj.networktables2.*;
import edu.wpi.first.wpilibj.tables.*;
public class NetworkTableTableModel extends AbstractTableModel implements ITableListener {
private final NetworkTableNode node;
public NetworkTableTableModel(NetworkTableNode node) {
this.node = node;
node.addTableListener(this, true);
}
private final List<String> keys = new ArrayList<String>();
@Override
public void valueChanged(ITable source, String key, Object value, boolean isNew) {
if(isNew){
keys.add(key);
fireTableRowsInserted(keys.size()-1, keys.size()-1);
}
else{
int row = keys.indexOf(key);
fireTableRowsUpdated(row, row);
}
}
@Override
public int getRowCount() {
return keys.size();
}
@Override
public int getColumnCount() {
return 3;
}
@Override
public String getColumnName(int column){
if(column==0)
return "Key";
if(column==1)
return "Value";
return "Sequence Number";
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if(columnIndex==0)
return keys.get(rowIndex);
try {
if(columnIndex==1)
return node.getValue(keys.get(rowIndex));
return (int)node.getEntryStore().getEntry(keys.get(rowIndex)).getSequenceNumber();
} catch (TableKeyNotDefinedException e) {
return null;
}
}
}

View File

@@ -0,0 +1,14 @@
package edu.wpi.first.table_viewer;
public class TableViewer {
/**
* @param args
*/
public static void main(String[] args) {
TableViewerModePrompt prompt = new TableViewerModePrompt();
prompt.setVisible(true);
}
}

View File

@@ -0,0 +1,37 @@
package edu.wpi.first.table_viewer;
import edu.wpi.first.table_viewer.tree.NetworkTableTree;
import java.awt.*;
import javax.swing.*;
import edu.wpi.first.wpilibj.networktables2.*;
import edu.wpi.first.wpilibj.tables.*;
public class TableViewerFrame extends JFrame implements IRemoteConnectionListener {
private final JLabel statusLabel;
private final NetworkTableTree tree;
public TableViewerFrame(NetworkTableNode node) {
super(node.toString());
setDefaultCloseOperation(EXIT_ON_CLOSE);
add(statusLabel = new JLabel(), BorderLayout.NORTH);
node.addConnectionListener(this, true);
tree = new NetworkTableTree(node);
add(new JScrollPane(tree));
setSize(600, 600);
}
@Override
public void connected(IRemote remote) {
statusLabel.setText("Connected");
}
@Override
public void disconnected(IRemote remote) {
statusLabel.setText("Disconnected");
}
}

View File

@@ -0,0 +1,107 @@
package edu.wpi.first.table_viewer;
import java.awt.*;
import java.awt.event.*;
import java.util.prefs.Preferences;
import javax.swing.*;
import edu.wpi.first.wpilibj.networktables2.*;
import edu.wpi.first.wpilibj.networktables2.client.*;
import edu.wpi.first.wpilibj.networktables2.server.*;
import edu.wpi.first.wpilibj.networktables2.stream.*;
public class TableViewerModePrompt extends JDialog implements ActionListener {
private JTextField hostField;
private JButton launchClientButton, launchServerButton;
private JButton cancelButton;
private Preferences prefs;
public TableViewerModePrompt() {
setTitle("Preferences");
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
setBackground(Color.white);
} catch (Exception e) {
e.printStackTrace();
}
prefs = Preferences.userNodeForPackage(getClass());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JPanel contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
setContentPane(contentPane);
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = 1;
c.gridy = 1;
add(new JLabel("Host: "), c);
c.gridx = 1;
String host;
try {
host = prefs.get("host", "localhost");
} catch (NullPointerException e) {
host = "localhost";
}
add(hostField = new JTextField(host), c);
hostField.addActionListener(this);
hostField.setColumns(20);
c.gridx = 0;
c.gridy = 3;
c.gridwidth = 2;
JPanel buttonPanel = new JPanel();
buttonPanel.add(launchClientButton = new JButton("Start client"));
launchClientButton.addActionListener(this);
buttonPanel.add(launchServerButton = new JButton("Start server"));
launchServerButton.addActionListener(this);
buttonPanel.add(cancelButton = new JButton("Cancel"));
cancelButton.addActionListener(this);
add(buttonPanel, c);
setSize(320, 120);
setMinimumSize(getSize());
pack();
}
public String getHost() {
return hostField.getText();
}
public int getPort() {
return 1735;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() != cancelButton) {
try {
NetworkTableNode node = null;
if (e.getSource() == launchServerButton) {//server
IOStreamProvider streamProvider = SocketStreams.newStreamProvider(getPort());
node = new NetworkTableServer(streamProvider);
prefs.put("host", "");
} else if (e.getSource() == launchClientButton) {
String host = getHost();
IOStreamFactory streamFactory = SocketStreams.newStreamFactory(host, getPort());
NetworkTableClient client = new NetworkTableClient(streamFactory);
client.reconnect();
node = client;
prefs.put("host", host);
}
TableViewerFrame frame = new TableViewerFrame(node);
frame.setVisible(true);
dispose();
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getClass() + ": " + ex.getMessage(), "Error creating table node", JOptionPane.ERROR_MESSAGE);
}
} else {
System.exit(0);
}
}
}

View File

@@ -0,0 +1,38 @@
package edu.wpi.first.table_viewer;
import java.io.*;
import edu.wpi.first.wpilibj.networktables2.client.*;
import edu.wpi.first.wpilibj.networktables2.stream.*;
public class TestClient {
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException {
IOStreamFactory streamFactory = SocketStreams.newStreamFactory("10.1.90.2", 1735);
NetworkTableClient client = new NetworkTableClient(streamFactory);
client.reconnect();
long last = System.currentTimeMillis();
int num = 40;
String[] keys = new String[num];
for(int i = 0; i<num; ++i)
keys[i] = "MyClientKey"+i;
for(int i = 0; true; ++i){
for(int j = 0; j<num; ++j)
client.putBoolean(keys[j], i%2==0);
//server.putNumber("Time", System.currentTimeMillis()-last);
last = System.currentTimeMillis();
Thread.sleep(20);
}
}
}

View File

@@ -0,0 +1,37 @@
package edu.wpi.first.table_viewer;
import java.io.*;
import edu.wpi.first.wpilibj.networktables.*;
public class TestServer {
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException {
NetworkTable server = NetworkTable.getTable("SmartDashboard");
//IOStreamProvider streamProvider = SocketStreams.newStreamProvider(1735);
//NetworkTableServer server = new NetworkTableServer(streamProvider, new DefaultThreadManager(), new NetworkTableTransactionPool());
long last = System.currentTimeMillis();
int num = 40;
String[] keys = new String[num];
for(int i = 0; i<num; ++i)
keys[i] = "MyKey"+i;
for(int i = 0; true; ++i){
for(int j = 0; j<num; ++j)
server.putBoolean(keys[j], i%2==0);
//server.putNumber("Time", System.currentTimeMillis()-last);
last = System.currentTimeMillis();
Thread.sleep(20);
}
}
}

View File

@@ -0,0 +1,54 @@
package edu.wpi.first.table_viewer;
import java.io.*;
import edu.wpi.first.wpilibj.networktables.*;
public class TestTableServer {
static int numVars = 40;
static {
try {
NetworkTable.setServerMode();
NetworkTable.initialize();
} catch (IOException ex) {
ex.printStackTrace();
}
}
static NetworkTable table = NetworkTable.getTable("SmartDashboard");
static String[] vars = new String[numVars];
static {
for (int i = 0; i < numVars; i++) {
vars[i] = "Variable" + i;
}
}
static boolean value = false;
static int counter = 0;
static long loop;
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException,
InterruptedException {
while (true) {
counter++;
value = !value;
loop = System.currentTimeMillis();
for (int v = 0; v < numVars; v++) {
table.putBoolean(vars[v], value);
}
loop = System.currentTimeMillis() - loop;
try {
Thread.sleep(20 - loop);
} catch (Exception e) {
}
}
}
}

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="keyLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="keyField" max="32767" attributes="0"/>
</Group>
<Component id="jScrollPane1" alignment="0" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="140" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="1" groupAlignment="1" max="-2" attributes="0">
<Component id="removeRowButton" pref="97" max="32767" attributes="0"/>
<Component id="addRowButton" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="okayButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="keyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="keyField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="112" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="addRowButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="removeRowButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okayButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="keyLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Trebuchet MS" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Array name"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="keyField">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="keyFieldActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="valueTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="2" rowCount="4">
<Column editable="true" title="Value" type="java.lang.String"/>
<Column editable="true" title="Type" type="java.lang.Object"/>
</Table>
</Property>
<Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
<TableColumnModel selectionModel="0">
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
<Title/>
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
<Title/>
<Editor/>
<Renderer/>
</Column>
</TableColumnModel>
</Property>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="false" resizingAllowed="true"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="removeRowButton">
<Properties>
<Property name="text" type="java.lang.String" value="Remove row"/>
<Property name="toolTipText" type="java.lang.String" value="Remove the selected row"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeRowButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="addRowButton">
<Properties>
<Property name="text" type="java.lang.String" value="Add row"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[20, 20]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addRowButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,201 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.wpilibj.networktables2.type.ArrayData;
import edu.wpi.first.wpilibj.networktables2.type.ArrayEntryType;
import edu.wpi.first.wpilibj.networktables2.type.DefaultEntryTypes;
import edu.wpi.first.wpilibj.networktables2.type.NetworkTableEntryType;
import edu.wpi.first.wpilibj.tables.ITable;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Sam
*/
public class AddArrayDialog extends IAddValueDialog {
private JComboBox typeEditor = new JComboBox(new String[]{"Boolean", "Number", "String", "Object"});
public AddArrayDialog(ITable table) {
super(table);
initComponents();
setMinimumSize(getSize());
valueTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(typeEditor));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
keyLabel = new javax.swing.JLabel();
keyField = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
valueTable = new javax.swing.JTable();
cancelButton = new javax.swing.JButton();
okayButton = new javax.swing.JButton();
removeRowButton = new javax.swing.JButton();
addRowButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
keyLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
keyLabel.setText("Array name");
keyField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
keyFieldActionPerformed(evt);
}
});
valueTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Value", "Type"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Object.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
valueTable.getTableHeader().setReorderingAllowed(false);
jScrollPane1.setViewportView(valueTable);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
okayButton.setText("OK");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
removeRowButton.setText("Remove row");
removeRowButton.setToolTipText("Remove the selected row");
removeRowButton.setPreferredSize(new java.awt.Dimension(20, 20));
removeRowButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeRowButtonActionPerformed(evt);
}
});
addRowButton.setText("Add row");
addRowButton.setPreferredSize(new java.awt.Dimension(20, 20));
addRowButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addRowButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(keyLabel)
.addGap(18, 18, 18)
.addComponent(keyField))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 140, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(removeRowButton, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.addComponent(addRowButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(okayButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(keyLabel)
.addComponent(keyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(addRowButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(removeRowButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton)
.addComponent(okayButton)))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void keyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_keyFieldActionPerformed
private void addRowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addRowButtonActionPerformed
((DefaultTableModel) valueTable.getModel()).insertRow(valueTable.getSelectedRow() + 1, new Object[]{null, null});
}//GEN-LAST:event_addRowButtonActionPerformed
private void removeRowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeRowButtonActionPerformed
try {
((DefaultTableModel) valueTable.getModel()).removeRow(valueTable.getSelectedRow());
} catch (ArrayIndexOutOfBoundsException e) {
((DefaultTableModel) valueTable.getModel()).removeRow(valueTable.getModel().getRowCount() - 1);
}
}//GEN-LAST:event_removeRowButtonActionPerformed
private void okayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okayButtonActionPerformed
try {
dispose();
} catch (Exception e) {
e.printStackTrace();
}
}//GEN-LAST:event_okayButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addRowButton;
private javax.swing.JButton cancelButton;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField keyField;
private javax.swing.JLabel keyLabel;
private javax.swing.JButton okayButton;
private javax.swing.JButton removeRowButton;
private javax.swing.JTable valueTable;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="trueFalseGroup">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="keyLabel" min="-2" pref="130" max="-2" attributes="0"/>
<Component id="keyField" pref="140" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="trueButton" linkSize="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="okayButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="falseButton" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="keyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="keyField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="trueButton" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="falseButton" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="okayButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="trueButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="trueFalseGroup"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="True"/>
</Properties>
</Component>
<Component class="javax.swing.JToggleButton" name="falseButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="trueFalseGroup"/>
</Property>
<Property name="text" type="java.lang.String" value="False"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="falseButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="keyField">
</Component>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="keyLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Trebuchet MS" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Variable name:"/>
</Properties>
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator1">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Trebuchet MS" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Value:"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,161 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.wpilibj.tables.ITable;
/**
*
* @author Sam
*/
public class AddBooleanDialog extends IAddValueDialog {
/**
* Creates new form AddBooleanDialog
*/
public AddBooleanDialog(ITable table) {
super(table);
setTitle("Add Boolean");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
trueFalseGroup = new javax.swing.ButtonGroup();
trueButton = new javax.swing.JToggleButton();
falseButton = new javax.swing.JToggleButton();
keyField = new javax.swing.JTextField();
okayButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
keyLabel = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
trueFalseGroup.add(trueButton);
trueButton.setSelected(true);
trueButton.setText("True");
trueFalseGroup.add(falseButton);
falseButton.setText("False");
falseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
falseButtonActionPerformed(evt);
}
});
okayButton.setText("OK");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
keyLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
keyLabel.setText("Variable name:");
jLabel1.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
jLabel1.setText("Value:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(keyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(keyField, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(trueButton)
.addComponent(jLabel1)))
.addComponent(jSeparator1)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(okayButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton))
.addComponent(falseButton, javax.swing.GroupLayout.Alignment.TRAILING))))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {falseButton, trueButton});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(keyLabel)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(keyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(trueButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(falseButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(okayButton)
.addComponent(cancelButton))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {falseButton, trueButton});
pack();
}// </editor-fold>//GEN-END:initComponents
private void falseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_falseButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_falseButtonActionPerformed
private void okayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okayButtonActionPerformed
// TODO add your handling code here:
if(keyField.getText().isEmpty()) {
return;
}
table.putBoolean(keyField.getText(), trueButton.isSelected());
dispose();
}//GEN-LAST:event_okayButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JToggleButton falseButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField keyField;
private javax.swing.JLabel keyLabel;
private javax.swing.JButton okayButton;
private javax.swing.JToggleButton trueButton;
private javax.swing.ButtonGroup trueFalseGroup;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="valueLabel" max="32767" attributes="0"/>
<Component id="keyLabel" max="32767" attributes="0"/>
</Group>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="valueField" max="32767" attributes="0"/>
<Component id="keyField" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="67" max="32767" attributes="0"/>
<Component id="okayButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="keyLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="keyField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="valueLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="valueField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="okayButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="keyField">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="keyFieldActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="valueField">
</Component>
<Component class="javax.swing.JLabel" name="keyLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Trebuchet MS" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Variable name"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="valueLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Trebuchet MS" size="12" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Value"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,136 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.wpilibj.tables.ITable;
/**
*
* @author Sam
*/
public class AddNumberDialog extends IAddValueDialog {
public AddNumberDialog(ITable table) {
super(table);
setTitle("Add number");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
keyField = new javax.swing.JTextField();
valueField = new javax.swing.JTextField();
keyLabel = new javax.swing.JLabel();
valueLabel = new javax.swing.JLabel();
okayButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
keyField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
keyFieldActionPerformed(evt);
}
});
keyLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
keyLabel.setText("Variable name");
valueLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
valueLabel.setText("Value");
okayButton.setText("OK");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(valueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(keyLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(valueField)
.addComponent(keyField)))
.addGroup(layout.createSequentialGroup()
.addGap(0, 67, Short.MAX_VALUE)
.addComponent(okayButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(keyLabel)
.addComponent(keyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valueLabel)
.addComponent(valueField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(okayButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void keyFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_keyFieldActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
private void okayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okayButtonActionPerformed
// TODO add your handling code here:
try {
table.putNumber(keyField.getText(), Double.parseDouble(valueField.getText()));
dispose();
} catch (NumberFormatException e) {
}
}//GEN-LAST:event_okayButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JTextField keyField;
private javax.swing.JLabel keyLabel;
private javax.swing.JButton okayButton;
private javax.swing.JTextField valueField;
private javax.swing.JLabel valueLabel;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,136 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.wpilibj.tables.ITable;
/**
*
* @author Sam
*/
public class AddStringDialog extends IAddValueDialog {
public AddStringDialog(ITable table) {
super(table);
setTitle("Add string");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
keyField = new javax.swing.JTextField();
valueField = new javax.swing.JTextField();
keyLabel = new javax.swing.JLabel();
valueLabel = new javax.swing.JLabel();
okayButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
keyField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
keyFieldActionPerformed(evt);
}
});
keyLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
keyLabel.setText("Variable name");
valueLabel.setFont(new java.awt.Font("Trebuchet MS", 1, 12)); // NOI18N
valueLabel.setText("Value");
okayButton.setText("OK");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(valueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(keyLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(valueField)
.addComponent(keyField)))
.addGroup(layout.createSequentialGroup()
.addGap(0, 67, Short.MAX_VALUE)
.addComponent(okayButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(keyLabel)
.addComponent(keyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(valueLabel)
.addComponent(valueField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(okayButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void keyFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
private void okayButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
table.putNumber(keyField.getText(), Double.parseDouble(valueField.getText()));
dispose();
} catch (NumberFormatException e) {
}
}
// Variables declaration - do not modify
private javax.swing.JButton cancelButton;
private javax.swing.JTextField keyField;
private javax.swing.JLabel keyLabel;
private javax.swing.JButton okayButton;
private javax.swing.JTextField valueField;
private javax.swing.JLabel valueLabel;
// End of variables declaration
}

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="trueFalseGroup">
</Component>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="trueButton" max="32767" attributes="0"/>
<Component id="okayButton" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="60" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="falseButton" max="32767" attributes="0"/>
<Component id="cancelButton" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="trueButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="falseButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="okayButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="trueButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection component="trueFalseGroup" type="bean"/>
</Property>
<Property name="text" type="java.lang.String" value="True"/>
</Properties>
</Component>
<Component class="javax.swing.JToggleButton" name="falseButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection component="trueFalseGroup" type="bean"/>
</Property>
<Property name="text" type="java.lang.String" value="False"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,111 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.table_viewer.tree.LeafNode;
/**
*
* @author Sam
*/
public class EditBooleanDialog extends javax.swing.JDialog {
private final LeafNode leaf;
public EditBooleanDialog(LeafNode leaf) {
super();
this.leaf = leaf;
initComponents();
trueButton.setSelected(Boolean.getBoolean(leaf.getValue()));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
trueFalseGroup = new javax.swing.ButtonGroup();
okayButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
trueButton = new javax.swing.JToggleButton();
falseButton = new javax.swing.JToggleButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
okayButton.setText("OK");
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
trueFalseGroup.add(trueButton);
trueButton.setText("True");
trueFalseGroup.add(falseButton);
falseButton.setText("False");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(trueButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(okayButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(falseButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cancelButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(trueButton)
.addComponent(falseButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(okayButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void okayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okayButtonActionPerformed
// TODO add your handling code here:
leaf.setTableValue(trueButton.isSelected());
dispose();
}//GEN-LAST:event_okayButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// TODO add your handling code here:
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JToggleButton falseButton;
private javax.swing.JButton okayButton;
private javax.swing.JToggleButton trueButton;
private javax.swing.ButtonGroup trueFalseGroup;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="editorLabel" min="-2" pref="84" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="208" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
<Component id="editorLabel" min="-2" pref="27" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="okButton" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="inputField">
<Properties>
<Property name="columns" type="int" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="2" type="code"/>
</Property>
<Property name="rows" type="int" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="1" type="code"/>
</Property>
<Property name="text" type="java.lang.String" value="Double"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="editorLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Change value:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="okButton">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,124 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.table_viewer.tree.TableEntryData;
import edu.wpi.first.table_viewer.tree.LeafNode;
import edu.wpi.first.table_viewer.*;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JDialog;
/**
*
* @author Sam
*/
public class EditNumberDialog extends JDialog {
private LeafNode leaf;
public EditNumberDialog(LeafNode leaf) {
super();
setTitle("Edit Number");
this.leaf = leaf;
initComponents();
inputField.setText(((TableEntryData) leaf.getUserObject()).getValue());
setResizable(false);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
inputField = new javax.swing.JTextArea();
editorLabel = new javax.swing.JLabel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
inputField.setColumns(2);
inputField.setRows(1);
inputField.setText("Double");
jScrollPane1.setViewportView(inputField);
editorLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
editorLabel.setText("Change value:");
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cancelButton))
.addGroup(layout.createSequentialGroup()
.addComponent(editorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(editorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(okButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
try {
leaf.setTableValue(Double.parseDouble(inputField.getText()));
dispose();
} catch (NumberFormatException e) {
inputField.setForeground(Color.red);
inputField.setFont(inputField.getFont().deriveFont(Font.BOLD));
}
}//GEN-LAST:event_okButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JLabel editorLabel;
private javax.swing.JTextArea inputField;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,119 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.table_viewer.tree.TableEntryData;
import edu.wpi.first.table_viewer.tree.LeafNode;
import edu.wpi.first.table_viewer.*;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JDialog;
/**
*
* @author Sam
*/
public class EditStringDialog extends JDialog {
private LeafNode leaf;
public EditStringDialog(LeafNode leaf) {
super();
setTitle("Edit String");
this.leaf = leaf;
initComponents();
inputField.setText(((TableEntryData) leaf.getUserObject()).getValue());
setResizable(false);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
inputField = new javax.swing.JTextArea();
editorLabel = new javax.swing.JLabel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
inputField.setColumns(2);
inputField.setRows(1);
inputField.setText("Double");
jScrollPane1.setViewportView(inputField);
editorLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
editorLabel.setText("Change value:");
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(okButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cancelButton))
.addGroup(layout.createSequentialGroup()
.addComponent(editorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(editorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(okButton)
.addComponent(cancelButton))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
leaf.setTableValue(inputField.getText());
dispose();
}
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
dispose();
}
// Variables declaration - do not modify
private javax.swing.JButton cancelButton;
private javax.swing.JLabel editorLabel;
private javax.swing.JTextArea inputField;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton okButton;
// End of variables declaration
}

View File

@@ -0,0 +1,23 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.dialog;
import edu.wpi.first.wpilibj.tables.ITable;
import javax.swing.JDialog;
/**
*
* @author Sam
*/
public abstract class IAddValueDialog extends JDialog {
protected ITable table;
public IAddValueDialog(ITable table) {
super();
this.table = table;
}
}

View File

@@ -0,0 +1,57 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.tree;
import edu.wpi.first.wpilibj.tables.ITable;
import java.awt.Menu;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JPopupMenu;
/**
*
* @author Sam
*/
public class BranchNode extends ITableNode {
private Map<String, ITableNode> entries = new HashMap<>();
public BranchNode(ITable table) {
this(table, "NetworkTables");
}
public BranchNode(ITable table, String name) {
super(table, name, true);
table.addTableListener(this, true);
table.addSubTableListener(this);
setAllowsChildren(true);
}
@Override
public void valueChanged(ITable source, String key, Object value, boolean isNew) {
if (isNew && !entries.containsKey(key)) {
if (value.toString().startsWith("NetworkTable: /")) {
String tableName = value.toString().substring(source.toString().length() + 1);
BranchNode branch = new BranchNode(source.getSubTable(tableName), key);
this.add(branch);
entries.put(key, branch);
} else {
LeafNode leaf = new LeafNode(source, key, value);
this.add(leaf);
entries.put(key, leaf);
}
}
}
@Override
public boolean isLeaf() {
return false;
}
@Override
public JPopupMenu getMenu() {
return menu;
}
}

View File

@@ -0,0 +1,72 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.tree;
import edu.wpi.first.table_viewer.dialog.AddBooleanDialog;
import edu.wpi.first.table_viewer.dialog.AddNumberDialog;
import edu.wpi.first.table_viewer.dialog.AddStringDialog;
import edu.wpi.first.wpilibj.tables.ITable;
import edu.wpi.first.wpilibj.tables.ITableListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
/**
*
* @author Sam
*/
public abstract class ITableNode extends DefaultMutableTreeNode implements ITableListener {
protected JPopupMenu menu = new JPopupMenu();
protected static DefaultTreeModel treeModel;
public static void setTree(JTree tree) {
treeModel = (DefaultTreeModel) tree.getModel();
}
public ITableNode(final ITable table, Object userObject, boolean allowsChildren) {
super(userObject, allowsChildren);
JMenuItem addBoolean = new JMenuItem("Add boolean"),
addNumber = new JMenuItem("Add number"),
addString = new JMenuItem("Add string");
addBoolean.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AddBooleanDialog(table).setVisible(true);
}
});
addNumber.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AddNumberDialog(table).setVisible(true);
}
});
addString.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AddStringDialog(table).setVisible(true);
}
});
menu.add(addBoolean);
menu.add(addNumber);
menu.add(addString);
}
@Override
public abstract boolean isLeaf();
public abstract JPopupMenu getMenu();
}

View File

@@ -0,0 +1,84 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.tree;
import edu.wpi.first.table_viewer.dialog.EditBooleanDialog;
import edu.wpi.first.table_viewer.dialog.EditNumberDialog;
import edu.wpi.first.table_viewer.dialog.EditStringDialog;
import edu.wpi.first.wpilibj.tables.ITable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
/**
*
* @author Sam
*/
public class LeafNode extends ITableNode {
private ITable table;
private String key;
private boolean insertedEdit = false;
public LeafNode(ITable table, String key, Object value) {
super(table, new TableEntryData(key, value), false);
table.addTableListener(key, this, true);
this.table = table;
this.key = key;
}
public String getKey() {
return key;
}
public String getValue() {
return ((TableEntryData) userObject).getValue();
}
public String getType() {
return ((TableEntryData) userObject).getType();
}
public void setTableValue(Object newValue) {
table.putValue(key, newValue);
}
@Override
public boolean isLeaf() {
return true;
}
@Override
public void valueChanged(ITable source, String key, Object value, boolean isNew) {
setUserObject(new TableEntryData(key, value));
treeModel.reload(this);
}
@Override
public JPopupMenu getMenu() {
if (!insertedEdit) {
JMenuItem editorItem = new JMenuItem("Edit");
editorItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (getType().equals("BOOLEAN")) {
new EditBooleanDialog(LeafNode.this).setVisible(true);
} else if (getType().equals("NUMBER")) {
new EditNumberDialog(LeafNode.this).setVisible(true);
} else if (getType().equals("STRING")) {
new EditStringDialog(LeafNode.this).setVisible(true);
}
}
});
menu.add(editorItem, 0);
menu.add(new JSeparator(), 1);
insertedEdit = true;
}
return menu;
}
}

View File

@@ -0,0 +1,86 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.tree;
import edu.wpi.first.table_viewer.dialog.EditBooleanDialog;
import edu.wpi.first.table_viewer.dialog.EditNumberDialog;
import edu.wpi.first.table_viewer.dialog.EditStringDialog;
import edu.wpi.first.wpilibj.networktables.NetworkTableProvider;
import edu.wpi.first.wpilibj.networktables2.NetworkTableNode;
import edu.wpi.first.wpilibj.tables.ITable;
import edu.wpi.first.wpilibj.tables.ITableListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultTreeModel;
/**
*
* @author Sam
*/
public class NetworkTableTree extends JTree implements ITableListener {
private final BranchNode rootNode;
public NetworkTableTree(NetworkTableNode node) {
super();
ITable table = new NetworkTableProvider(node).getRootTable();
ITableNode.setTree(this);
rootNode = new BranchNode(table);
table.addTableListener(this, true);
table.addSubTableListener(this);
((DefaultTreeModel) this.getModel()).setRoot(rootNode);
MouseAdapter ml = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int selRow = getRowForLocation(e.getX(), e.getY());
if (SwingUtilities.isRightMouseButton(e)) {
int row = getClosestRowForLocation(e.getX(), e.getY());
setSelectionRow(row);
handleRightClick(e.getX(), e.getY());
}
if (selRow != -1) {
if (e.getClickCount() == 2) {
handleDoubleClick();
}
}
}
};
addMouseListener(ml);
}
private void handleDoubleClick() {
ITableNode selectedNode = ((ITableNode) getSelectionPath().getLastPathComponent());
if (selectedNode instanceof LeafNode) {
if (((LeafNode) selectedNode).getType().equalsIgnoreCase("number")) {
new EditNumberDialog((LeafNode) selectedNode).setVisible(true);
} else if (((LeafNode) selectedNode).getType().equalsIgnoreCase("string")) {
new EditStringDialog((LeafNode) selectedNode).setVisible(true);
} else if (((LeafNode) selectedNode).getType().equalsIgnoreCase("boolean")) {
new EditBooleanDialog((LeafNode) selectedNode).setVisible(true);
}
}
}
private void handleRightClick(int x, int y) {
ITableNode selectedNode = ((ITableNode) getSelectionPath().getLastPathComponent());
System.out.println("Right click at [" + x + "," + y + "] on node " + selectedNode);
JPopupMenu m = selectedNode.getMenu();
m.show(this, x, y);
}
@Override
public void valueChanged(ITable source, String key, Object value, boolean isNew) {
System.out.println(key + " changed to " + value);
((DefaultTreeModel) this.getModel()).reload();
}
}

View File

@@ -0,0 +1,93 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.table_viewer.tree;
import edu.wpi.first.wpilibj.networktables2.type.NumberArray;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Sam
*/
public class TableEntryData {
private Object key, value, type;
public TableEntryData(String key, Object value) {
this.key = key;
try {
this.value = new ArrayWrapper(value);
} catch (Exception ex) {
if (value instanceof Number) {
DecimalFormat format = new DecimalFormat("#.#####");
String dblVal = format.format((double) value);
this.value = dblVal;
} else {
this.value = value;
}
}
this.type = typeFromValue(value);
}
public String getKey() {
return key.toString();
}
public String getValue() {
return value.toString();
}
public String getType() {
return type.toString();
}
@Override
public String toString() {
return key + space + value + space + type;
}
private final String space = " ";
private String typeFromValue(Object value) {
String valueClassName = value.getClass().toString().substring(value.getClass().toString().lastIndexOf(".") + 1);
switch (valueClassName.toLowerCase()) {
case "boolean":
return "BOOLEAN";
case "double":
return "NUMBER";
case "string":
return "STRING";
case "object;": // the semicolon is required to catch arrays
return "ARRAY";
default:
return valueClassName.toUpperCase();
}
}
private class ArrayWrapper {
private Object[] array;
ArrayWrapper(Object array) throws Exception {
if (array instanceof Object[]) {
this.array = (Object[]) array;
} else {
throw new RuntimeException();
}
}
@Override
public String toString() {
String arrStr = Arrays.toString(array);
if (arrStr.length() > 2) {
return arrStr.substring(1, arrStr.length() - 1);
} else {
return "Empty";
}
}
}
}