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

Add button-icon for union/intersection in the groups side panel #3954

Merged
merged 10 commits into from
May 6, 2018

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Apr 14, 2018

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 and set-all https://materialdesignicons.com/icon/set-center
in 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

grafik


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr changed the title Add button for union/intersection in the groups side panel Add button-icon for union/intersection in the groups side panel Apr 14, 2018
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 14, 2018
Copy link
Member

@tobiasdiez tobiasdiez left a 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() {
Copy link
Member

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.

Copy link
Member Author

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);
Copy link
Member

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();
Copy link
Member

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) {
Copy link
Member

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.

Copy link
Member Author

@Siedlerchr Siedlerchr Apr 15, 2018

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

Copy link
Member

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.

Copy link
Member Author

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,

@Siedlerchr
Copy link
Member Author

@tobiasdiez Is this now okay? Then you could merge it with CO-Authors

Copy link
Member

@tobiasdiez tobiasdiez left a 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;
Copy link
Member

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);

Copy link
Member

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() {
Copy link
Member

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() {
Copy link
Member

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"));
Copy link
Member

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();
Copy link
Member

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";
Copy link
Member

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?

Copy link
Member

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
@Siedlerchr
Copy link
Member Author

@tobiasdiez Fixed the issues you m entionend.

Copy link
Member

@tobiasdiez tobiasdiez left a 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"));
Copy link
Member

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.

Copy link
Member Author

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();
Copy link
Member

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";
Copy link
Member

Choose a reason for hiding this comment

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

?

@tobiasdiez tobiasdiez removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label May 2, 2018
…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)
  ...
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label May 5, 2018
@Siedlerchr
Copy link
Member Author

I fixed the remaining issues and I am going to merge this one now

@Siedlerchr Siedlerchr merged commit 8a8e09a into maintable-beta May 6, 2018
@Siedlerchr Siedlerchr deleted the unionintersectionnew branch May 6, 2018 10:30
florian-beetz pushed a commit that referenced this pull request May 8, 2018
* 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
Siedlerchr added a commit that referenced this pull request May 10, 2018
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants