add permanent refresh button enabled when tags are updated

This commit is contained in:
jmillman 2016-05-04 12:23:23 -04:00
parent dfce250309
commit c98658f88e
2 changed files with 200 additions and 160 deletions

View File

@ -1,79 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import jfxtras.scene.control.*?>
<?import org.controlsfx.control.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.MenuButton?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import jfxtras.scene.control.LocalDateTimeTextField?>
<?import org.controlsfx.control.SegmentedButton?>
<fx:root prefHeight="-1.0" prefWidth="-1.0" type="javafx.scene.layout.BorderPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<fx:root prefHeight="-1.0" prefWidth="-1.0" type="javafx.scene.layout.BorderPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<top>
<ToolBar fx:id="toolBar" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<HBox alignment="CENTER" BorderPane.alignment="CENTER">
<children>
<Label fx:id="visualizationModeLabel">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
<font>
<Font name="System Bold" size="14.0" />
</font>
</Label>
<org.controlsfx.control.SegmentedButton maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity">
<buttons>
<ToggleButton fx:id="countsToggle" alignment="TOP_LEFT" mnemonicParsing="false" selected="true">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/chart_bar.png" />
</image>
</ImageView>
</graphic>
<HBox BorderPane.alignment="CENTER">
<children>
<ToolBar fx:id="toolBar" prefWidth="200.0" HBox.hgrow="ALWAYS">
<items>
<HBox alignment="CENTER" BorderPane.alignment="CENTER">
<children>
<Label fx:id="visualizationModeLabel">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
<font>
<Font name="System Bold" size="16.0" />
<Font name="System Bold" size="14.0" />
</font>
</ToggleButton>
<ToggleButton fx:id="detailsToggle" alignment="CENTER_RIGHT" layoutX="74.0" mnemonicParsing="false" selected="false">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true" rotate="0.0" smooth="true" style="-fx-background-color:white;" x="2.0" y="1.0">
<image>
<Image url="@../images/20140521121247760_easyicon_net_32_colorized.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="16.0" />
</font>
</ToggleButton>
</buttons>
</Label>
</org.controlsfx.control.SegmentedButton>
</children>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
<BorderPane.margin>
<Insets left="10.0" />
</BorderPane.margin>
</HBox>
<Separator orientation="VERTICAL" />
<Button fx:id="snapShotButton" mnemonicParsing="false">
<graphic>
<org.controlsfx.control.SegmentedButton maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity">
<buttons>
<ToggleButton fx:id="countsToggle" alignment="TOP_LEFT" mnemonicParsing="false" selected="true">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/chart_bar.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="16.0" />
</font>
</ToggleButton>
<ToggleButton fx:id="detailsToggle" alignment="CENTER_RIGHT" layoutX="74.0" mnemonicParsing="false" selected="false">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" mouseTransparent="true" pickOnBounds="true" preserveRatio="true" rotate="0.0" smooth="true" style="-fx-background-color:white;" x="2.0" y="1.0">
<image>
<Image url="@../images/20140521121247760_easyicon_net_32_colorized.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold" size="16.0" />
</font>
</ToggleButton>
</buttons>
</org.controlsfx.control.SegmentedButton>
</children>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
<BorderPane.margin>
<Insets left="10.0" />
</BorderPane.margin>
</HBox>
</items>
</ToolBar>
<ToolBar maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<items>
<Separator orientation="VERTICAL" />
<Button fx:id="snapShotButton" mnemonicParsing="false">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/image.png" />
</image>
</ImageView>
</graphic>
</Button>
<Separator halignment="LEFT" maxWidth="1.7976931348623157E308" orientation="VERTICAL" />
<Button fx:id="refreshButton" alignment="CENTER_RIGHT" mnemonicParsing="false" text="Refresh">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../images/image.png" />
</image>
<image>
<Image url="@../images/arrow-circle-double-135.png" />
</image>
</ImageView>
</graphic>
</Button>
<Separator orientation="VERTICAL" />
</items>
</ToolBar>
</graphic>
</Button>
</items>
</ToolBar>
</children>
</HBox>
</top>
<bottom>
<VBox maxHeight="-Infinity">

View File

@ -29,6 +29,7 @@ import java.util.function.Supplier;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
@ -158,13 +159,15 @@ final public class VisualizationPanel extends BorderPane {
@FXML
private Button snapShotButton;
@FXML
private Button refreshButton;
@FXML
private Label visualizationModeLabel;
/**
* wraps contained visualization so that we can show notifications over it.
*/
private final NotificationPane notificationPane = new NotificationPane();
private final ReadOnlyBooleanWrapper needsRefresh = new ReadOnlyBooleanWrapper(false);
private final TimeLineController controller;
private final FilteredEventsModel filteredEvents;
@ -190,7 +193,7 @@ final public class VisualizationPanel extends BorderPane {
/**
* hides the notification pane on any event
*/
private final InvalidationListener zoomListener = any -> notificationPane.hide();
private final InvalidationListener zoomListener = any -> setNeedsRefresh(false);
/**
* listen to change in end time picker and push to controller
@ -279,6 +282,7 @@ final public class VisualizationPanel extends BorderPane {
//configure snapshor button / action
ActionUtils.configureButton(new SaveSnapshotAsReport(controller, VisualizationPanel.this), snapShotButton);
ActionUtils.configureButton(new Refresh(), refreshButton);
/////configure start and end pickers
startLabel.setText(Bundle.VisualizationPanel_startLabel_text());
@ -357,60 +361,68 @@ final public class VisualizationPanel extends BorderPane {
detailsToggle.setSelected(true);
break;
}
}
private synchronized void setVisualization(final AbstractVisualizationPane<?, ?, ?, ?> newViz) {
Platform.runLater(() -> {
synchronized (VisualizationPanel.this) {
if (visualization != null) {
toolBar.getItems().removeAll(visualization.getSettingsNodes());
visualization.dispose();
}
if (visualization != null) {
toolBar.getItems().removeAll(visualization.getSettingsNodes());
visualization.dispose();
}
visualization = newViz;
visualization.update();
toolBar.getItems().addAll(newViz.getSettingsNodes());
visualization = newViz;
visualization.update();
toolBar.getItems().addAll(newViz.getSettingsNodes());
notificationPane.setContent(visualization);
if (visualization instanceof DetailViewPane) {
Platform.runLater(() -> {
((DetailViewPane) visualization).setHighLightedEvents(eventsTree.getSelectedEvents());
eventsTree.setDetailViewPane((DetailViewPane) visualization);
});
}
visualization.hasEvents.addListener((observable, oldValue, newValue) -> {
if (newValue == false) {
notificationPane.setContent(
new StackPane(visualization,
new Region() {
{
setBackground(new Background(new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY)));
setOpacity(.3);
}
},
new NoEventsDialog(() -> notificationPane.setContent(visualization))));
} else {
notificationPane.setContent(visualization);
}
notificationPane.setContent(visualization);
if (visualization instanceof DetailViewPane) {
Platform.runLater(() -> {
((DetailViewPane) visualization).setHighLightedEvents(eventsTree.getSelectedEvents());
eventsTree.setDetailViewPane((DetailViewPane) visualization);
});
}
visualization.hasEvents.addListener((observable, oldValue, newValue) -> {
if (newValue == false) {
notificationPane.setContent(
new StackPane(visualization,
new Region() {
{
setBackground(new Background(new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY)));
setOpacity(.3);
}
},
new NoEventsDialog(() -> notificationPane.setContent(visualization))));
} else {
notificationPane.setContent(visualization);
}
});
});
setNeedsRefresh(false);
}
@Subscribe
@NbBundle.Messages("VisualizationPanel.tagsAddedOrDeleted=Tags have been created and/or deleted. The visualization may not be up to date.")
public void handleTimeLineTagEvent(TagsUpdatedEvent event) {
Platform.runLater(() -> {
notificationPane.setCloseButtonVisible(false);
notificationPane.getActions().setAll(new Refresh());
notificationPane.show(Bundle.VisualizationPanel_tagsAddedOrDeleted(), new ImageView(INFORMATION));
});
setNeedsRefresh(true);
}
@Subscribe
public void handleRefreshRequestedEvent(RefreshRequestedEvent event) {
Platform.runLater(notificationPane::hide);
setNeedsRefresh(false);
}
private void setNeedsRefresh(Boolean needsRefresh) {
Platform.runLater(() -> {
VisualizationPanel.this.needsRefresh.set(needsRefresh);
if (needsRefresh) {
notificationPane.show(Bundle.VisualizationPanel_tagsAddedOrDeleted(), new ImageView(INFORMATION));
} else {
notificationPane.hide();
}
});
}
synchronized private void refreshHistorgram() {
@ -669,6 +681,7 @@ final public class VisualizationPanel extends BorderPane {
setGraphic(new ImageView(REFRESH));
setEventHandler(actionEvent -> filteredEvents.refresh());
disabledProperty().bind(needsRefresh.not());
}
}
}