Go to Post Come on how can you not be excited about IRI! - richardp [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 19-01-2013, 17:01
jonbuckley33 jonbuckley33 is offline
Registered User
FRC #1014
 
Join Date: Jan 2013
Location: United States
Posts: 2
jonbuckley33 is an unknown quantity at this point
Custom SmartDashboard Widget

I have been trying to get a basic custom widget working on the SmartDashboard for a couple weeks now, but I've gotten very lost in the changes they've made in the API since 2012. Right now, I am just trying to create a widget that reads and writes to its associated NetworkTable (it's being created from a putData(Subsystem s) call). However, I am not able to read or write from the NetworkTable through any diplomatic means. I've tried extending Widget and AbstractTableWidget, with no luck on either. I don't even get a setValue() method call or a valueChanged() call.

If anyone has created their own widget on SmartDashboard for 2013 code, please help!
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2013, 20:06
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Custom SmartDashboard Widget

I haven't made a widget personally, but the people who made SmartDashboard have made quite a few! Here's CheckBox from the SmartDashboard source code:
Code:
package edu.wpi.first.smartdashboard.gui.elements;

import edu.wpi.first.smartdashboard.gui.elements.bindings.AbstractValueWidget;
import javax.swing.*;

import edu.wpi.first.smartdashboard.properties.*;
import edu.wpi.first.smartdashboard.types.*;

/**
 * Implements a simple text box UI element with a name label.
 * @author pmalmsten
 */
public class CheckBox extends AbstractValueWidget {

    public static final DataType[] TYPES = {DataType.BOOLEAN};

    public final BooleanProperty editable = new BooleanProperty(this, "Editable", true);
    
    private EditableBooleanValueCheckBox valueField;

    public void init() {
        setResizable(false);

        setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

        valueField = new EditableBooleanValueCheckBox(getFieldName());

        add(valueField);
    }

    @Override
    public void propertyChanged(Property property) {
        if (property == editable) {
            valueField.setEnabled(editable.getValue());
        }
    }
}
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2013, 20:06
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Custom SmartDashboard Widget

AbstractTableWidget is fairly easy to get started with, because it binds NetworkTables variables to your objects of type StringTableField, NumberTableField, BooleanTableField or BooleanTableCheckBox. You don't need to write any NetworkTables code. The sending data and receiving data happens automatically if there is a change.

I found it helpful to look at how the PIDEditor was implemented in SmartDashboard.

I made a few extensions that extended PIDEditor. You can see them here: http://forums.usfirst.org/showthread.php?t=20437
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi