Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new method areListenersPaused() to interface SelectionModel #324

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/main/java/org/mastodon/adapter/SelectionModelAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,10 @@ public void pauseListeners()
{
selection.pauseListeners();
}

@Override
public boolean areListenersPaused()
{
return selection.areListenersPaused();
}
}
6 changes: 6 additions & 0 deletions src/main/java/org/mastodon/model/DefaultSelectionModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,10 @@ public void pauseListeners()
{
emitEvents = false;
}

@Override
public boolean areListenersPaused()
{
return !emitEvents;
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/mastodon/model/SelectionModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ public interface SelectionModel< V extends Vertex< E >, E extends Edge< V > >
public void resumeListeners();

public void pauseListeners();

boolean areListenersPaused();
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public void pauseListeners()
selection.pauseListeners();
}

@Override
public boolean areListenersPaused()
{
return selection.areListenersPaused();
}

@Override
public boolean isSelected( final BV vertex )
{
Expand Down Expand Up @@ -123,9 +129,15 @@ public boolean isSelected( final BE edge )
@Override
public void setSelected( final BV vertex, final boolean selected )
{
selection.pauseListeners();
setVertexSelected( vertex, selected );
selection.resumeListeners();
boolean areListenersPaused = selection.areListenersPaused();
if ( areListenersPaused )
setVertexSelected( vertex, selected );
else
{
selection.pauseListeners();
setVertexSelected( vertex, selected );
selection.resumeListeners();
}
}

private boolean setVertexSelected( final BV branchVertex, final boolean selected )
Expand Down
Loading