Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package edu.wpi.grip.core.operations.network;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import edu.wpi.grip.core.operations.network.ros.MockROSManager;
import edu.wpi.grip.core.operations.network.ros.ROSNetworkPublisherFactory;

/**
* A mock of {@Link GRIPNetworkModule} for testing.
*/
public final class MockGRIPNetworkModule extends AbstractModule {
@Override
protected void configure() {
bind(MapNetworkPublisherFactory.class)
.annotatedWith(Names.named("ntManager"))
.to(MockMapNetworkPublisher.class);
bind(ROSNetworkPublisherFactory.class)
.annotatedWith(Names.named("rosManager"))
.to(MockROSManager.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package edu.wpi.grip.core.operations.network;


import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

@SuppressWarnings("PMD.UncommentedEmptyMethodBody")
public class MockMapNetworkPublisher<T> extends MapNetworkPublisher<T> {
public class MockMapNetworkPublisher<T> extends MapNetworkPublisher<T> implements MapNetworkPublisherFactory {

public MockMapNetworkPublisher() {
this(Collections.emptySet());
}

public MockMapNetworkPublisher(Set<String> keys) {
super(keys);
Expand Down Expand Up @@ -36,4 +40,9 @@ protected void publishNameChanged(Optional<String> oldName, String newName) {
public void close() {

}

@Override
public <T> MapNetworkPublisher<T> create(Set<String> keys) {
return new MockMapNetworkPublisher<>(keys);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package edu.wpi.grip.core.operations.network.ros;

public class MockROSManager implements ROSNetworkPublisherFactory {

@Override
public <C extends JavaToMessageConverter> ROSMessagePublisher create(C converter) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ROSPackageSanityTest extends AbstractPackageSanityTests {
public ROSPackageSanityTest() {
super();
ignoreClasses(c -> c.equals(ROSLoader.class));
ignoreClasses(c -> c.equals(ROSLoader.class) || c.equals(MockROSManager.class));
setDefault(JavaToMessageConverter.class, JavaToMessageConverter.BLOBS);
}
}
33 changes: 33 additions & 0 deletions ui/src/main/java/edu/wpi/grip/ui/AboutDialogController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package edu.wpi.grip.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;

import javax.inject.Inject;

public class AboutDialogController {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Inject
private Main main

@Inject
private Main main;

@FXML
private Label versionNumberLabel;

@FXML
void mousePressedDocumentationButton(MouseEvent event) {
main.getHostServices().showDocument("http://wpilib.screenstepslive.com/s/4485/m/50711");
}

@FXML
void mousePressedGithubButton(MouseEvent event) {
main.getHostServices().showDocument("https://github.com/WPIRoboticsProjects/GRIP");
}

@FXML
void initialize() {
assert versionNumberLabel != null : "fx:id=\"versionNumberText\" was not injected: check your FXML file 'AboutDialog.fxml'.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, should remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 4547ce4


versionNumberLabel.setText("Version " + edu.wpi.grip.core.Main.class.getPackage().getImplementationVersion());
}
}
22 changes: 22 additions & 0 deletions ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.SplitPane;
Expand All @@ -26,6 +27,8 @@
import javafx.scene.layout.Region;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.controlsfx.control.StatusBar;

import javax.inject.Inject;
Expand All @@ -49,6 +52,8 @@ public class MainWindowController {
@FXML
private Pane deployPane;
@FXML
private Pane aboutPane;
@FXML
private StatusBar statusBar;
@Inject
private EventBus eventBus;
Expand All @@ -65,6 +70,8 @@ public class MainWindowController {
@Inject
private Project project;

private Stage aboutDialogStage;

public void initialize() {
pipelineView.prefHeightProperty().bind(bottomPane.heightProperty());
statusBar.getLeftItems().add(startStoppableButtonFactory.create(pipelineRunner));
Expand Down Expand Up @@ -209,6 +216,21 @@ public void showProjectSettingsEditor() {
});
}

@FXML
public void showProjectAboutDialog() throws IOException {
if (aboutDialogStage == null) {
aboutDialogStage = new Stage();
aboutDialogStage.setScene(new Scene(aboutPane));
aboutDialogStage.initStyle(StageStyle.UTILITY);
aboutDialogStage.focusedProperty().addListener((observable, oldvalue, newvalue) -> {
if (oldvalue) {
aboutDialogStage.hide();
}
});
}
aboutDialogStage.show();
}

@FXML
public void quit() {
if (showConfirmationDialogAndWait()) {
Expand Down
93 changes: 93 additions & 0 deletions ui/src/main/resources/edu/wpi/grip/ui/AboutDialog.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<VBox fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="330.0" prefWidth="600.0" styleClass="about-window" stylesheets="@GRIP.css" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.wpi.grip.ui.AboutDialogController">
<children>
<Pane VBox.vgrow="ALWAYS" />
<HBox>
<children>
<Pane HBox.hgrow="ALWAYS" />
<ImageView fitHeight="156.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@icons/grip.png" />
</image>
</ImageView>
<Pane HBox.hgrow="ALWAYS" />
<VBox HBox.hgrow="ALWAYS">
<children>
<Label style="-fx-font-size: 64; -fx-font-weight: BOLD;" text="GRIP" />
<Label fx:id="versionNumberLabel" text="Version 0.0.0" />
<Pane VBox.vgrow="ALWAYS" />
<HBox>
<children>
<StackPane onMousePressed="#mousePressedGithubButton" styleClass="about-button">
<children>
<Label text="➔ Github">
<font>
<Font size="14.0" />
</font></Label>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<HBox.margin>
<Insets left="-3.0" />
</HBox.margin>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</StackPane>
</children>
</HBox>
<Pane VBox.vgrow="ALWAYS" />
<HBox>
<children>
<StackPane onMousePressed="#mousePressedDocumentationButton" styleClass="about-button">
<children>
<Label text="➔ ScreenSteps Documentation" />
</children>
<HBox.margin>
<Insets left="-3.0" />
</HBox.margin>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</StackPane>
</children>
</HBox>
</children>
</VBox>
<Pane HBox.hgrow="ALWAYS" />
</children>
</HBox>
<Pane VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets />
</VBox.margin>
</Pane>
<HBox>
<children>
<Pane HBox.hgrow="ALWAYS" />
<Label style="-fx-font-size: 12;" text="GRIP is licensed under a 3 Clause BSD License" textFill="#818181" />
<Pane HBox.hgrow="ALWAYS" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</HBox>
</children>
<stylesheets>
<URL value="@roboto/Roboto.css" />
Copy link
Member Author

@AustinShalit AustinShalit May 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (90) needs to be removed with #590.

<URL value="@GRIP.css" />
</stylesheets>
</VBox>
16 changes: 15 additions & 1 deletion ui/src/main/resources/edu/wpi/grip/ui/GRIP.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,18 @@ VBox.sockets {

.info-label {
-fx-font-weight: bold;
}
}

.about-window Label {
-fx-font-size: 14;
}

.about-button:hover {
-fx-background-color: gray;
-fx-background-radius: 12;
-fx-cursor: hand;
}

.about-button:hover Label {
-fx-text-fill: white;
}
18 changes: 18 additions & 0 deletions ui/src/main/resources/edu/wpi/grip/ui/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@
</graphic>
</MenuItem>
</Menu>
<Menu text="Help">
<MenuItem text="About" onAction="#showProjectAboutDialog">
<graphic>
<ImageView styleClass="menu-graphic">
<fitWidth>
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
</fitWidth>
<fitHeight>
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
</fitHeight>
<image>
<Image url="@icons/grip.png"/>
</image>
</ImageView>
</graphic>
</MenuItem>
</Menu>
</MenuBar>
<SplitPane dividerPositions="0.6" orientation="VERTICAL" VBox.vgrow="ALWAYS">
<items>
Expand All @@ -148,6 +165,7 @@
</children>
<fx:define>
<fx:include source="Deploy.fxml" fx:id="deployPane"/>
<fx:include source="AboutDialog.fxml" fx:id="aboutPane"/>
</fx:define>
<stylesheets>
<URL value="@roboto/Roboto.css"/>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/test/java/edu/wpi/grip/ui/MainWindowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.inject.util.Modules;
import edu.wpi.grip.core.*;
import edu.wpi.grip.core.events.OperationAddedEvent;
import edu.wpi.grip.core.operations.network.MockGRIPNetworkModule;
import edu.wpi.grip.core.sockets.InputSocket;
import edu.wpi.grip.core.sockets.OutputSocket;
import edu.wpi.grip.ui.util.DPIUtility;
Expand Down Expand Up @@ -39,7 +40,8 @@ public class MainWindowTest extends ApplicationTest {
public void start(Stage stage) throws Exception {
testModule.setUp();

Injector injector = Guice.createInjector(Modules.override(testModule).with(new GRIPUIModule()));
Injector injector = Guice.createInjector(
Modules.override(testModule, new MockGRIPNetworkModule()).with(new GRIPUIModule()));

final Parent root =
FXMLLoader.load(Main.class.getResource("MainWindow.fxml"), null, null, injector::getInstance);
Expand Down