public SmartDashboardXMLReader(string fileName) { base.\u002Ector(); SmartDashboardXMLReader dashboardXmlReader = this; this.widgets = (List) new ArrayList(); this.subsystems = (Map) new HashMap(); this.hiddenFields = (List) new ArrayList(); this.properties = (Map) new HashMap(); this.finishedReading = false; this.self = this; this.self = this; new SmartDashboardXMLReader.ReaderThread(this, fileName).start(); }
public virtual void load(string path) { try { SmartDashboardXMLReader dashboardXmlReader = new SmartDashboardXMLReader(path); System.get_out().println(new StringBuilder().append("\nLoading from \t").append(path).toString()); List xmlWidgets = dashboardXmlReader.getXMLWidgets(); int num = xmlWidgets.size(); while (num > 0) { System.get_out().println("Loading SmartDashboard widgets...."); XMLWidget xmlWidget = (XMLWidget) xmlWidgets.get(num - 1); DisplayElement element1 = xmlWidget.convertToDisplayElement(); if (element1 is Widget) { Widget element2 = (Widget) element1; if (Robot.getTable().containsKey(element2.getFieldName())) { object obj = Robot.getTable().getValue(element2.getFieldName()); DataType type = DataType.getType(obj); if (DisplayElementRegistry.supportsType(Object.instancehelper_getClass((object) element2), type)) this.smartDashboardPanel.setField(element2.getFieldName(), element2, type, obj, element2.getSavedLocation()); } else this.smartDashboardPanel.setField(element2.getFieldName(), element2, xmlWidget.getType(), (object) null, element2.getSavedLocation()); } else if (element1 is StaticWidget) this.smartDashboardPanel.addElement(element1, xmlWidget.getLocation()); num += -1; } Iterator iterator1 = dashboardXmlReader.getSubsystems().keySet().iterator(); label_11: while (iterator1.hasNext()) { XMLWidget subsystem1 = (XMLWidget) iterator1.next(); System.get_out().println(new StringBuilder().append("\nLoading \"").append(subsystem1.getField()).append("\"").toString()); LWSubsystem lwSubsystem = (LWSubsystem) subsystem1.convertToDisplayElement(); LWSubsystem subsystem2 = lwSubsystem; if (Robot.getLiveWindow().containsKey(lwSubsystem.getFieldName())) { object obj = Robot.getTable().getValue(lwSubsystem.getFieldName()); DataType type = DataType.getType(obj); if (DisplayElementRegistry.supportsType(Object.instancehelper_getClass((object) lwSubsystem), type)) this.liveWindowPanel.setField(lwSubsystem.getFieldName(), (Widget) lwSubsystem, type, obj, lwSubsystem.getSavedLocation()); } else this.liveWindowPanel.setField(lwSubsystem.getFieldName(), (Widget) lwSubsystem, lwSubsystem.getType(), (object) null, lwSubsystem.getSavedLocation()); Iterator iterator2 = dashboardXmlReader.getSubwidgetMap(subsystem1).values().iterator(); while (true) { if (iterator2.hasNext()) { XMLWidget xmlWidget = (XMLWidget) iterator2.next(); System.get_out().println(new StringBuilder().append("Adding subcomponent \"").append(xmlWidget.getField()).append("\"").toString()); AbstractTableWidget abstractTableWidget = (AbstractTableWidget) xmlWidget.convertToDisplayElement(); ITable subTable = Robot.getLiveWindow().getSubTable(subsystem2.getFieldName()).getSubTable(abstractTableWidget.getFieldName()); DataType type = DataType.getType((object) subTable); subsystem2.addWidget((Widget) abstractTableWidget); abstractTableWidget.setField(abstractTableWidget.getFieldName(), (Widget) abstractTableWidget, type, (object) subTable, subsystem2, abstractTableWidget.getSavedLocation()); ((Component) subsystem2).setSize(((JComponent) subsystem2).getPreferredSize()); } else goto label_11; } } Iterator iterator3 = dashboardXmlReader.getHiddenFields().iterator(); while (iterator3.hasNext()) this.smartDashboardPanel.removeField((string) iterator3.next()); Map properties = this.prefs.getProperties(); Iterator iterator4 = dashboardXmlReader.getProperties().entrySet().iterator(); while (iterator4.hasNext()) { Map.Entry entry = (Map.Entry) iterator4.next(); ((Property) properties.get(entry.getKey())).setValue(entry.getValue()); } ((Component) this).repaint(); } catch (FileNotFoundException ex) { } }
public static void setLoaded(SmartDashboardXMLReader XMLreader) { LWSubsystem.reader = XMLreader; }