-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add button-icon for union/intersection in the groups side panel #3954
Conversation
Fix display ofs state in preferences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the code looks good.
Of course, the icons have to be replaced by proper ones before merge. It would be nice if somehow can update fontawesomefx to include the most recent icons since there are other instances where newer icons are more suitable (see IconTheme
).
@@ -88,7 +90,7 @@ public final Node getContentPane() { | |||
/** | |||
* @return the header pane for this component | |||
*/ | |||
public final Node getHeader() { | |||
public Node getHeader() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of overriding this method, I would propose to create a new (overridable) method getHeaderButtons
that results additional header button to be displayed. In this way you ensure consistency as well as reduce code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a protected method for gettingAddtionalHeader buttons
buttonContainer.getChildren().addAll(up, down, close); | ||
BorderPane graphic = new BorderPane(); | ||
graphic.setCenter(icon.getGraphicNode()); | ||
BorderPane container = new BorderPane(); | ||
// container.setLeft(graphic); | ||
// container.setLeft(graphic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
boolean newState = !intersectionToggled; | ||
preferences.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, newState); | ||
|
||
BasePanel basePanel = frame.getCurrentBasePanel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the dependency on frame
and replace it by dialog service (which has a notify
method).
|
||
boolean intersectionSelected = prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS); | ||
//Looks odd, but the prefs store true for intersection and false for union | ||
if (intersectionSelected) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is hard to understand, I would propose to add a better named method to JabrefPreferences
. Moreover, the code is probably easier to understand if you add an enum for the different modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now introduced an enum with methods for setting/get the pref value
Additionally, the Icons are now directly added in the enum, so it should be easier to change them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would separate the group mode enum from the icon. The mode is something that can (in principle) be defined and used in the model/logic package thus I wouldn't mix it with something gui related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, however, this is purely a gui thing. My immediate thoughts were also about storing that in model, but it would provide any additional value. And this makes it easier to directly use the icon,
create enum with icons change booleans to enum remove duplicated code remove old prefs
@tobiasdiez Is this now okay? Then you could merge it with CO-Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've still some remarks, but these are very minor. You can directly merge after fixing them.
|
||
public abstract class SidePaneComponent { | ||
|
||
protected final SidePaneManager manager; | ||
protected final ToggleCommand toggleCommand; | ||
private final JabRefIcon icon; | ||
private final String title; | ||
protected final JabRefIcon icon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make them private again
public SidePaneComponent(SidePaneManager manager, JabRefIcon icon, String title) { | ||
this.manager = manager; | ||
this.icon = icon; | ||
this.title = title; | ||
this.toggleCommand = new ToggleCommand(this); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
container.setCenter(label); | ||
container.setRight(buttonContainer); | ||
container.getStyleClass().add("sidePaneComponentHeader"); | ||
|
||
return container; | ||
} | ||
|
||
protected Optional<Node> getAddtionalHeaderButtons() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just from the name of the method, I would have expected a list of buttons as the return value and not a single one. I think, supporting multiple buttons make sense and is not a big change overall.
return preferences.getGroupViewMode().getIcon().getGraphicNode(); | ||
} | ||
|
||
private Tooltip getUnionInterSectionToolTip() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Intersection" and "Tooltip"
@@ -20,15 +25,43 @@ | |||
public class GroupSidePane extends SidePaneComponent { | |||
|
|||
private final JabRefPreferences preferences; | |||
private final DialogService dialogService; | |||
private final Button intersectionUnionToggle = IconTheme.JabRefIcons.WWW.asButton(); | |||
private final Tooltip toggleUnion = new Tooltip(Localization.lang("Toogle union")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to have these tooltips as instance variables. I would simply inline them.
} | ||
|
||
private Node getUnionIntersectionGraphic() { | ||
return preferences.getGroupViewMode().getIcon().getGraphicNode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would extract these methods to a new class GroupViewModeViewModel
which gives you the graphic and the tooltip (constructor accepts the mode). In this way, you clearly separate everything ui-related from the actual model class.
@@ -193,7 +194,8 @@ | |||
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CA = "editorEMACSkeyBindingsRebindCA"; | |||
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CF = "editorEMACSkeyBindingsRebindCF"; | |||
public static final String GROUPS_DEFAULT_FIELD = "groupsDefaultField"; | |||
public static final String GROUP_INTERSECT_SELECTIONS = "groupIntersectSelections"; | |||
public static final String GROUP_INTERSECT_UNION_VIEW_MODE = "groupIntersectUnionViewModes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be private now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
…rsectionnew * upstream/maintable-beta: fix FX thread error on save database dlg Fix close confirmation Bring back special fields in menu Remove unused methods add search performance tweak from master
return headerbuttons as list
@tobiasdiez Fixed the issues you m entionend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few very minor things are remaining. Please merge directly after fixing them.
|
||
public static Tooltip getUnionIntersectionTooltip(GroupViewMode mode) { | ||
if (mode == GroupViewMode.UNION) { | ||
return new Tooltip(Localization.lang("Toogle intersection")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The texts seem to be interchanged by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it's right. As the tooltip should indicate what happens when you press the button,
If you are in union mode currently -> togle intersection
If you are in intersection mode -> toggle union
} | ||
|
||
public static Node getUnionIntersectionGraphic(GroupViewMode mode) { | ||
return mode.getIcon().getGraphicNode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you agree that a code similar to the above one for the tooltip is better than storing the icon directly in the groupviewmode
?
@@ -193,7 +194,8 @@ | |||
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CA = "editorEMACSkeyBindingsRebindCA"; | |||
public static final String EDITOR_EMACS_KEYBINDINGS_REBIND_CF = "editorEMACSkeyBindingsRebindCF"; | |||
public static final String GROUPS_DEFAULT_FIELD = "groupsDefaultField"; | |||
public static final String GROUP_INTERSECT_SELECTIONS = "groupIntersectSelections"; | |||
public static final String GROUP_INTERSECT_UNION_VIEW_MODE = "groupIntersectUnionViewModes"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
…rsectionnew * upstream/maintable-beta: (88 commits) set look and feel to windows, aqua or nimbus for swing in case fix import remove look and feel New translations JabRef_en.properties (French) (#4009) Fix Look and Feel related issues (#4002) Fix statement in changelog [WIP] Add Text File Export for "Find Unlinked Files" (#3979) Fix IEEE preview does not display month (#3983) Activate context menu on key press (#4004) Improve code layout Fix concurrent modification exception when adding entries to groups Fix build Typo Add fix Rename test Fix #3994 Duplicate unmodifiable list for sorting (#3996) Remove deprecated and unused method (#3993) Improvements around external file types (#3887) Migrate to native gradle test task (#3987) Do not run checkstyle as part of the gradle check task (#3985) ...
make prefs private
I fixed the remaining issues and I am going to merge this one now |
* Add button for union/intersection in the groups side panel Fix display ofs state in preferences * add method for getting addtionalHeaderButtons create enum with icons change booleans to enum remove duplicated code remove old prefs * remove uncommented code * fix checkstyle * Add group intersection and union icons * add tooltips for side pane and groups pane * Extract get graphics and tooltip to new class return headerbuttons as list * refactor and extract icon method to view model make prefs private
…drop * upstream/maintable-beta: (174 commits) Fix ACM fetcher import of entries (#4019) Reimplement tooltips for file and identifier columns (#4011) Add button-icon for union/intersection in the groups side panel (#3954) Update Dependencies (#4012) set look and feel to windows, aqua or nimbus for swing in case fix import remove look and feel New translations JabRef_en.properties (French) (#4009) Fix Look and Feel related issues (#4002) Fix statement in changelog [WIP] Add Text File Export for "Find Unlinked Files" (#3979) Fix IEEE preview does not display month (#3983) Activate context menu on key press (#4004) Improve code layout Fix concurrent modification exception when adding entries to groups Fix build Typo Add fix Rename test Fix #3994 Duplicate unmodifiable list for sorting (#3996) ... # Conflicts: # src/main/java/org/jabref/gui/actions/CleanupAction.java # src/main/java/org/jabref/gui/maintable/MainTable.java
Fixes #3269
Fix display of state for union/intersection in preferences
As we currently unfortunately don't have Icons for Set Intersection/Union
set-center
andset-all
https://materialdesignicons.com/icon/set-centerin the Material Design Font, I used the WWW and the twitter icon to demonstrate the purpose. @halirutan will then try to integrate the correoct icons in JabRef