Package edu.wpi.first.smartdashboard.util

Examples of edu.wpi.first.smartdashboard.util.StatefulDisplayElement


        elem.init();
        // TODO read layout properties from global map, by name, bypass
        // autolayout if found
        Properties props = null;
        if (elem instanceof StatefulDisplayElement) {
          StatefulDisplayElement isu = (StatefulDisplayElement) elem;
          props = isu.getProperties();

          System.out.println(isu.getRecord().getName() + ", "
              + isu.getRecord().getType() + ", "
//              + isu.getLayoutAllocation().point.getX() + ", "
//              + isu.getLayoutAllocation().point.getY() + ", "
              + isu.getSize().getWidth() + ", "
              + isu.getSize().getHeight()
              + isu.getProperties());

        }
       
        // initialized from IHSWidgets
        if (props != null && props.size()>0) {
View Full Code Here


          .getType());
      Properties props = getCustomWidgets().getWidgetProperties().get(r.getName());

      // default behavior, no file-based definition
      if (props == null ) {
      final StatefulDisplayElement elem = (StatefulDisplayElement) choices
          .get(0).newInstance();
      elem.setFieldName(r.getName());
      elem.setRecord(r);

      addField(elem);

      // System.out.println(r.getType()+","+elem.getFieldName());

      return elem;
      }
      else {
        // consult the properties table for the widget class name, otherwise use the first in the list.
        String widgetName = props.getProperty("jp");
        Class widgetClass = null;
        for (int i=0; i<choices.size(); i++) {
          Class clazz =  choices.get(i);
          if (clazz.getSimpleName().equalsIgnoreCase(widgetName)) {
            widgetClass = clazz;
          }
        }
        final StatefulDisplayElement elem = (StatefulDisplayElement)
            (widgetClass==null ? choices.get(0).newInstance() : widgetClass.newInstance());
        elem.setFieldName(r.getName());
        elem.setRecord(r);

        addField(elem);

        // System.out.println(r.getType()+","+elem.getFieldName());
View Full Code Here

      super(string);
      this.elementClass = elementClass;
    }

    public void actionPerformed(ActionEvent e) {
      final StatefulDisplayElement newElement;
      Record record = selectedElement.getRecord();
      final Point location = new Point(selectedElement.getLocation());
      selectedElement.disconnect();
      selectedElement.getLayoutAllocation().deallocate();
      selectedElement.getParent().remove(selectedElement);
      try {
        newElement = (StatefulDisplayElement) elementClass
            .newInstance();
      } catch (InstantiationException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE,
            null, ex);
        return;
      } catch (IllegalAccessException ex) {
        Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE,
            null, ex);
        return;
      }

      // final FormattedField newElement = new FormattedField();
      newElement.setFieldName(record.getName());
      newElement.setRecord(record);
      addField(newElement);
      // queue up request to set location so it happens after addField
      SwingUtilities.invokeLater(new Runnable() {

        public void run() {
          newElement.setLocation(location);
        }
      });
      record.addStateReceiver(newElement);
    }
View Full Code Here

TOP

Related Classes of edu.wpi.first.smartdashboard.util.StatefulDisplayElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.