Skip to content

Commit 72bf8e2

Browse files
committed
Revert "Puncture the bloat balloon (wpilibsuite#807)"
This reverts commit cdd5e7a.
1 parent 0745a52 commit 72bf8e2

File tree

23 files changed

+369
-246
lines changed

23 files changed

+369
-246
lines changed

api/src/main/java/edu/wpi/first/shuffleboard/api/components/SourceTreeTable.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ public class SourceTreeTable<S extends SourceEntry, V> extends TreeTableView<S>
4444
private final ObjectProperty<SourceType> sourceType = new SimpleObjectProperty<>(this, "sourceType", null);
4545

4646
private final TreeTableColumn<S, String> keyColumn = new TreeTableColumn<>("Name");
47-
private final TreeTableColumn<S, V> infoColumn = new TreeTableColumn<>("Info");
47+
private final TreeTableColumn<S, V> valueColumn = new TreeTableColumn<>("Value");
4848

4949
/**
5050
* Creates a new source tree table. It comes pre-populated with a key and a value column.
5151
*/
5252
public SourceTreeTable() {
5353
keyColumn.prefWidthProperty().bind(widthProperty().divide(2).subtract(2));
54-
infoColumn.prefWidthProperty().bind(widthProperty().divide(2).subtract(2));
54+
valueColumn.prefWidthProperty().bind(widthProperty().divide(2).subtract(2));
5555

5656
keyColumn.setCellValueFactory(
5757
f -> new ReadOnlyStringWrapper(getEntryForCellData(f).getViewName()));
58-
infoColumn.setCellValueFactory(
59-
f -> new ReadOnlyObjectWrapper(getEntryForCellData(f).getInfo()));
58+
valueColumn.setCellValueFactory(
59+
f -> new ReadOnlyObjectWrapper(getEntryForCellData(f).getValueView()));
6060
Label placeholder = new Label("No data available");
6161
setPlaceholder(placeholder);
6262

63-
getColumns().addAll(keyColumn, infoColumn);
63+
getColumns().addAll(keyColumn, valueColumn);
6464
}
6565

6666
/**

api/src/main/java/edu/wpi/first/shuffleboard/api/dnd/DataFormats.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public final class DataFormats {
3333
*/
3434
public static final DataFormat source = new DataFormat(APP_PREFIX + "/data-source");
3535

36+
/**
37+
* The data format for widget type names (string).
38+
*/
39+
public static final DataFormat widgetType = new DataFormat(APP_PREFIX + "/widget-type");
40+
3641
/**
3742
* The data format for components that do not exist inside a tile.
3843
*/

api/src/main/java/edu/wpi/first/shuffleboard/api/sources/SourceEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ default String getViewName() {
3030
Object getValue();
3131

3232
/**
33-
* Gets an object used to display information about the source. Implementers are encouraged to
33+
* Gets an object used to display the value of the source this entry represents. Implementers are encouraged to
3434
* sharpen the return type
3535
*/
36-
Object getInfo();
36+
Object getValueView();
3737

3838
}

api/src/main/java/edu/wpi/first/shuffleboard/api/sources/SourceTypes.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import edu.wpi.first.shuffleboard.api.data.DataType;
44
import edu.wpi.first.shuffleboard.api.data.DataTypes;
55
import edu.wpi.first.shuffleboard.api.sources.recording.TimestampedData;
6+
import edu.wpi.first.shuffleboard.api.util.PropertyUtils;
67
import edu.wpi.first.shuffleboard.api.util.Registry;
78

8-
import javafx.collections.ListChangeListener;
9+
import org.fxmisc.easybind.EasyBind;
910

1011
import java.util.HashMap;
1112
import java.util.Map;
1213
import java.util.Objects;
14+
import java.util.Optional;
1315

1416
import javafx.beans.InvalidationListener;
1517
import javafx.collections.FXCollections;
@@ -47,25 +49,11 @@ public SourceTypes() {
4749
register(Static);
4850

4951
typeNames.addListener((InvalidationListener) __ -> {
50-
typeNames
51-
.stream()
52+
Optional<ObservableList<String>> names = typeNames.stream()
5253
.map(this::forName)
5354
.map(SourceType::getAvailableSourceUris)
54-
.forEach(observableUriList -> {
55-
observableUriList.addListener((ListChangeListener<? super String>) c -> {
56-
while (c.next()) {
57-
if (c.wasAdded()) {
58-
for (String uri : c.getAddedSubList()) {
59-
if (!allUris.contains(uri)) {
60-
allUris.add(uri);
61-
}
62-
}
63-
} else if (c.wasRemoved()) {
64-
allUris.removeAll(c.getRemoved());
65-
}
66-
}
67-
});
68-
});
55+
.reduce(PropertyUtils::combineLists);
56+
names.ifPresent(l -> EasyBind.listBind(allUris, l));
6957
});
7058
}
7159

api/src/main/java/edu/wpi/first/shuffleboard/api/sources/recording/Recorder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
import edu.wpi.first.shuffleboard.api.DashboardMode;
44
import edu.wpi.first.shuffleboard.api.data.DataType;
5+
import edu.wpi.first.shuffleboard.api.data.DataTypes;
56
import edu.wpi.first.shuffleboard.api.properties.AtomicBooleanProperty;
67
import edu.wpi.first.shuffleboard.api.sources.DataSource;
8+
import edu.wpi.first.shuffleboard.api.sources.SourceType;
9+
import edu.wpi.first.shuffleboard.api.sources.SourceTypes;
710
import edu.wpi.first.shuffleboard.api.sources.recording.serialization.Serializer;
811
import edu.wpi.first.shuffleboard.api.sources.recording.serialization.Serializers;
912
import edu.wpi.first.shuffleboard.api.util.ShutdownHooks;
@@ -132,6 +135,14 @@ public void start() {
132135
startTime = Instant.now();
133136
firstSave = true;
134137
recording = new Recording();
138+
// Record initial conditions
139+
SourceTypes.getDefault().getItems().stream()
140+
.map(SourceType::getAvailableSources)
141+
.forEach(sources -> sources.forEach((id, value) -> {
142+
DataTypes.getDefault().forJavaType(value.getClass())
143+
.map(t -> new TimestampedData(id, t, value, 0L))
144+
.ifPresent(recording::append);
145+
}));
135146
}
136147
setRunning(true);
137148
}

api/src/main/java/edu/wpi/first/shuffleboard/api/widget/SingleSourceWidget.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import edu.wpi.first.shuffleboard.api.data.IncompatibleSourceException;
44
import edu.wpi.first.shuffleboard.api.sources.DataSource;
5+
56
import javafx.beans.property.ObjectProperty;
67
import javafx.beans.property.Property;
78
import javafx.beans.property.SimpleObjectProperty;
8-
import javafx.collections.ListChangeListener;
99

1010
/**
1111
* A partial implementation of {@code Widget} that only has a single source.
@@ -14,36 +14,6 @@ public abstract class SingleSourceWidget extends AbstractWidget {
1414

1515
protected final ObjectProperty<DataSource> source = new SimpleObjectProperty<>(this, "source", DataSource.none());
1616

17-
/**
18-
* Instantiates a new single source widget. This automatically registers listeners to make the
19-
* {@link #source} and {@link #sources} properties stay in sync such that both properties will
20-
* have the same, single data source object.
21-
*/
22-
public SingleSourceWidget() {
23-
// Bidirectional binding to make the sources list act like a single-element wrapper around
24-
// the source property
25-
source.addListener((__, oldSource, newSource) -> sources.setAll(newSource));
26-
27-
sources.addListener(new ListChangeListener<DataSource>() {
28-
@Override
29-
public void onChanged(Change<? extends DataSource> c) {
30-
while (c.next()) {
31-
if (c.wasAdded()) {
32-
var added = c.getAddedSubList();
33-
if (!added.isEmpty()) {
34-
var addedSource = added.get(0);
35-
if (addedSource != source.get()) {
36-
source.set(addedSource);
37-
}
38-
}
39-
} else if (c.wasRemoved()) {
40-
source.set(DataSource.none());
41-
}
42-
}
43-
}
44-
});
45-
}
46-
4717
@Override
4818
public final void addSource(DataSource source) throws IncompatibleSourceException {
4919
if (getDataTypes().contains(source.getDataType())) {

api/src/main/resources/edu/wpi/first/shuffleboard/api/base.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@
261261
-fx-stroke-width: 0.25em;
262262
}
263263

264+
/*******************************************************************************
265+
* *
266+
* Widget Gallery *
267+
* *
268+
******************************************************************************/
269+
.widget-gallery .item {
270+
-fx-border-width: 2;
271+
-fx-border-color: -swatch-200;
272+
-fx-border-insets: 5;
273+
-fx-background-insets: 5;
274+
-fx-alignment: center;
275+
-fx-cursor: hand;
276+
}
277+
264278
/*******************************************************************************
265279
* *
266280
* Property sheet *

api/src/test/java/edu/wpi/first/shuffleboard/api/components/SourceTreeTableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Object getValue() {
8686
}
8787

8888
@Override
89-
public Object getInfo() {
89+
public Object getValueView() {
9090
return uri;
9191
}
9292

app/src/main/java/edu/wpi/first/shuffleboard/app/LeftDrawerController.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
import edu.wpi.first.shuffleboard.api.util.FxUtils;
77
import edu.wpi.first.shuffleboard.api.util.StringUtils;
88
import edu.wpi.first.shuffleboard.api.widget.Component;
9+
import edu.wpi.first.shuffleboard.api.widget.Components;
910
import edu.wpi.first.shuffleboard.app.components.InteractiveSourceTree;
11+
import edu.wpi.first.shuffleboard.app.components.WidgetGallery;
1012
import edu.wpi.first.shuffleboard.app.plugin.PluginLoader;
1113

1214
import com.google.common.collect.ArrayListMultimap;
1315
import com.google.common.collect.Multimap;
1416

15-
import javafx.scene.control.ScrollPane;
1617
import org.controlsfx.glyphfont.FontAwesome;
1718
import org.controlsfx.glyphfont.Glyph;
1819
import org.controlsfx.glyphfont.GlyphFont;
@@ -21,6 +22,7 @@
2122

2223
import java.util.Comparator;
2324
import java.util.function.Consumer;
25+
import java.util.stream.Collectors;
2426

2527
import javafx.animation.KeyFrame;
2628
import javafx.animation.KeyValue;
@@ -34,6 +36,7 @@
3436
import javafx.geometry.Pos;
3537
import javafx.scene.control.Accordion;
3638
import javafx.scene.control.Labeled;
39+
import javafx.scene.control.TabPane;
3740
import javafx.scene.control.TextField;
3841
import javafx.scene.control.TitledPane;
3942
import javafx.scene.control.Tooltip;
@@ -55,10 +58,12 @@ public final class LeftDrawerController {
5558
@FXML
5659
private Pane root;
5760
@FXML
58-
private ScrollPane sourceContainer;
61+
private TabPane tabs;
5962
@FXML
6063
private Accordion sourcesAccordion;
6164
@FXML
65+
private WidgetGallery widgetGallery;
66+
@FXML
6267
private Pane handle;
6368
@FXML
6469
private Labeled expandContractButton;
@@ -76,8 +81,7 @@ private void initialize() {
7681
listenToPluginChanges(plugin);
7782
setup(plugin);
7883
});
79-
sourceContainer.maxWidthProperty().bind(root.widthProperty().subtract(handle.widthProperty()));
80-
sourceContainer.minWidthProperty().bind(root.widthProperty().subtract(handle.widthProperty()));
84+
tabs.maxWidthProperty().bind(root.widthProperty().subtract(handle.widthProperty()));
8185
sourcesAccordion.getPanes().sort(Comparator.comparing(TitledPane::getText));
8286
PluginLoader.getDefault().getKnownPlugins().addListener((ListChangeListener<Plugin>) c -> {
8387
while (c.next()) {
@@ -169,16 +173,23 @@ private void setup(Plugin plugin) {
169173
sourcesAccordion.setExpandedPane(titledPane);
170174
}
171175
});
176+
177+
// Add widgets to the gallery as well
178+
widgetGallery.setWidgets(Components.getDefault().allWidgets().collect(Collectors.toList()));
172179
});
173180
}
174181

175182
/**
176-
* Removes all traces from a plugin from the left drawer.
183+
* Removes all traces from a plugin from the left drawer. Source trees will be removed and all widgets
184+
* defined by the plugin will be removed from the gallery.
177185
*/
178186
private void tearDown(Plugin plugin) {
179187
// Remove the source panes
180188
sourcesAccordion.getPanes().removeAll(sourcePanes.removeAll(plugin));
181189
FXCollections.sort(sourcesAccordion.getPanes(), Comparator.comparing(TitledPane::getText));
190+
191+
// Remove widgets from the gallery
192+
widgetGallery.setWidgets(Components.getDefault().allWidgets().collect(Collectors.toList()));
182193
}
183194

184195
@FXML

app/src/main/java/edu/wpi/first/shuffleboard/app/MainWindowController.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package edu.wpi.first.shuffleboard.app;
22

3-
import com.google.common.base.Stopwatch;
43
import edu.wpi.first.shuffleboard.api.plugin.Plugin;
54
import edu.wpi.first.shuffleboard.api.prefs.Category;
65
import edu.wpi.first.shuffleboard.api.sources.recording.Recorder;
@@ -22,7 +21,6 @@
2221
import edu.wpi.first.shuffleboard.app.sources.recording.Playback;
2322
import edu.wpi.first.shuffleboard.app.tab.TabInfoRegistry;
2423

25-
import java.util.concurrent.TimeUnit;
2624
import org.fxmisc.easybind.EasyBind;
2725

2826
import java.awt.Desktop;
@@ -253,15 +251,7 @@ public void load() throws IOException {
253251
* @throws IOException if the file could not be read from
254252
*/
255253
public void load(File saveFile) throws IOException {
256-
var timer = Stopwatch.createStarted();
257254
setDashboard(saveFileHandler.load(saveFile));
258-
log.info(
259-
"Loaded save file "
260-
+ saveFile.getAbsolutePath()
261-
+ " in "
262-
+ timer.elapsed(TimeUnit.MILLISECONDS)
263-
+ " milliseconds"
264-
);
265255
}
266256

267257
@FXML

0 commit comments

Comments
 (0)