Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

A shortcut for reloading visualization files. #1190

Merged
merged 2 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ read the notes of the `Enso 2.0.0-alpha.1` release.
- [Added the ability to reposition visualisations.][1096] There is now an icon in the visualization
action bar that allows dragging the visualization. Once the visualization has been moved, there
appears another icon that will reset the position to the original position.
- [A shortcut for reloading visualization files.][1190] The visible visualizations must be switched
to another and switched back to see the effect.

[1096]: https://github.com/enso-org/ide/pull/1172
[1181]: https://github.com/enso-org/ide/pull/1181
[1190]: https://github.com/enso-org/ide/pull/1190
<br/>


Expand Down
1 change: 1 addition & 0 deletions docs/product/shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ further investigation.
| <kbd>ctrl</kbd> + <kbd>d</kbd> | Send test data to the selected node. |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>enter</kbd> | Push a hardcoded breadcrumb without navigating. |
| <kbd>ctrl</kbd> + <kbd>shift</kbd> + <kbd>arrow up</kbd> | Pop a breadcrumb without navigating. |
| <kbd>cmd</kbd> + <kbd>shift</kbd> + <kbd>alt</kbd> + <kbd>r</kbd> | Reload visualizations. To see the effect in the currently shown visualizations, you need to switch to another and switch back. |
1 change: 0 additions & 1 deletion src/rust/ensogl/lib/core/src/display/object/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,6 @@ mod tests {
fn visibility_test2() {
let node1 = Instance::<()>::new(Logger::new("node1"));
let node2 = Instance::<()>::new(Logger::new("node2"));
let node3 = Instance::<()>::new(Logger::new("node3"));
assert_eq!(node1.is_visible(),false);
node1.update(&());
assert_eq!(node1.is_visible(),false);
Expand Down
14 changes: 12 additions & 2 deletions src/rust/ide/src/ide/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ impl Integration {
}


// === Visualization Reload ===

frp::extend! { network
eval editor_outs.visualization_registry_reload_requested ([model](()) {
model.view.graph().reset_visualization_registry();
model.load_visualizations();
});
}


// === UI Actions ===

let inv = &invalidate.trigger;
Expand Down Expand Up @@ -398,7 +408,7 @@ impl Model {
,visualization,visualizations,project,node_view_by_expression};

this.init_project_name();
this.init_visualizations();
this.load_visualizations();
if let Err(err) = this.refresh_graph_view() {
error!(this.logger,"Error while initializing graph editor: {err}.");
}
Expand All @@ -408,7 +418,7 @@ impl Model {
this
}

fn init_visualizations(&self) {
fn load_visualizations(&self) {
let logger = self.logger.clone_ref();
let controller = self.visualization.clone_ref();
let graph_editor = self.view.graph().clone_ref();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ impl Registry {
/// Return a `Registry` pre-populated with default visualizations.
pub fn with_default_visualizations() -> Self {
let registry = Self::new();
registry.add(builtin::visualization::native::RawText::definition());
registry.try_add_java_script(builtin::visualization::java_script::scatter_plot_visualization());
registry.try_add_java_script(builtin::visualization::java_script::histogram_visualization());
registry.try_add_java_script(builtin::visualization::java_script::table_visualization());
registry.try_add_java_script(builtin::visualization::java_script::geo_map_visualization());
registry.add_default_visualizations();
registry
}

Expand Down Expand Up @@ -78,6 +74,21 @@ impl Registry {
self.path_map.borrow().get(path).cloned()
}

/// Remove all visualizations from registry
pub fn remove_all_visualizations(&self) {
self.path_map.borrow_mut().clear();
self.type_map.borrow_mut().clear();
}

/// Add default visualizations to the registry.
pub fn add_default_visualizations(&self) {
self.add(builtin::visualization::native::RawText::definition());
self.try_add_java_script(builtin::visualization::java_script::scatter_plot_visualization());
self.try_add_java_script(builtin::visualization::java_script::histogram_visualization());
self.try_add_java_script(builtin::visualization::java_script::table_visualization());
self.try_add_java_script(builtin::visualization::java_script::geo_map_visualization());
}

/// Return a default visualisation definition.
pub fn default_visualisation() -> visualization::Definition {
builtin::visualization::native::RawText::definition()
Expand Down
24 changes: 18 additions & 6 deletions src/rust/ide/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ ensogl::define_endpoints! {
register_visualization (Option<visualization::Definition>),
set_visualization_data ((NodeId,visualization::Data)),
enable_visualization (NodeId),

/// Remove from visualization registry all non-default visualizations.
reset_visualization_registry (),
/// Reload visualization registry
reload_visualization_registry(),
}

Output {
Expand Down Expand Up @@ -498,10 +503,11 @@ ensogl::define_endpoints! {
nodes_labels_visible (bool),


visualization_enabled (NodeId),
visualization_disabled (NodeId),
visualization_enable_fullscreen (NodeId),
visualization_preprocessor_changed ((NodeId,data::enso::Code)),
visualization_enabled (NodeId),
visualization_disabled (NodeId),
visualization_enable_fullscreen (NodeId),
visualization_preprocessor_changed ((NodeId,data::enso::Code)),
visualization_registry_reload_requested (),

on_visualization_select (Switch<NodeId>),
some_visualisation_selected (bool),
Expand Down Expand Up @@ -1833,6 +1839,7 @@ impl application::View for GraphEditor {
, (Press , "!node_editing" , "space" , "press_visualization_visibility")
// , (DoublePress , "!node_editing" , "space" , "double_press_visualization_visibility")
, (Release , "!node_editing" , "space" , "release_visualization_visibility")
, (Press , "", "cmd shift alt r" , "reload_visualization_registry")

// === Selection ===
, (Press , "" , "shift" , "enable_node_multi_select")
Expand Down Expand Up @@ -2764,11 +2771,16 @@ fn new_graph_editor(app:&Application) -> GraphEditor {

// === Register Visualization ===

def _register_visualization = inputs.register_visualization.map(f!([vis_registry](handle) {
eval inputs.register_visualization ([vis_registry](handle) {
if let Some(handle) = handle {
vis_registry.add(handle);
}
}));
});
eval inputs.reset_visualization_registry ([vis_registry](()) {
vis_registry.remove_all_visualizations();
vis_registry.add_default_visualizations();
});
out.source.visualization_registry_reload_requested <+ inputs.reload_visualization_registry;


// === Entering and Exiting Nodes ===
Expand Down