Skip to content

Commit

Permalink
3189 fix group renaming (#4470)
Browse files Browse the repository at this point in the history
* change row name if group name changed

* fix group renaming via property

* set formatting when set group name

* delete comments

* fix to string method

* Fix move to group always moves first entry (#4457)

* Fix move to group always moves first entry

* clarify comment a bit better

* Update archunit from 0.9.1 -> 0.9.2

* change row name if group name changed

* fix group renaming via property

* set formatting when set group name

* delete comments

* fix to string method

* fix group renaming

* revert GroupTreeView

* revert GroupTreeViewModel

* revert Group Dialog

* make binding with group name via formatting

* fix textGroupParsing

* revert group tree view model

* revert groupNodeViewModel

* fix code style
  • Loading branch information
Ali96kz authored and tobiasdiez committed Nov 23, 2018
1 parent 5479070 commit 944d3c9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/main/java/org/jabref/model/groups/AbstractGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.Objects;
import java.util.Optional;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color;

import org.jabref.model.entry.BibEntry;
Expand All @@ -18,7 +20,7 @@ public abstract class AbstractGroup implements SearchMatcher {
/**
* The group's name.
*/
protected final String name;
protected final StringProperty name = new SimpleStringProperty();
/**
* The hierarchical context of the group.
*/
Expand All @@ -29,14 +31,14 @@ public abstract class AbstractGroup implements SearchMatcher {
protected Optional<String> iconName = Optional.empty();

protected AbstractGroup(String name, GroupHierarchyType context) {
this.name = name;
this.name.setValue(name);
this.context = Objects.requireNonNull(context);
}

@Override
public String toString() {
return "AbstractGroup{" +
"name='" + name + '\'' +
"name='" + name.getValue() + '\'' +
", context=" + context +
", color=" + color +
", isExpanded=" + isExpanded +
Expand All @@ -54,13 +56,13 @@ public boolean equals(Object other) {
return false;
}
AbstractGroup that = (AbstractGroup) other;
return Objects.equals(this.name, that.name) && Objects.equals(this.description, that.description)
return Objects.equals(this.name.getValue(), that.name.getValue()) && Objects.equals(this.description, that.description)
&& Objects.equals(this.context, that.context);
}

@Override
public int hashCode() {
return Objects.hash(name, description, context);
return Objects.hash(name.getValue(), description, context);
}

public Optional<Color> getColor() {
Expand Down Expand Up @@ -122,6 +124,10 @@ public GroupHierarchyType getHierarchicalContext() {
* Returns this group's name, e.g. for display in a list/tree.
*/
public final String getName() {
return name.getValue();
}

public StringProperty nameProperty() {
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public String getField() {

@Override
public AbstractGroup deepCopy() {
return new AutomaticKeywordGroup(this.name, this.context, field, this.keywordDelimiter, keywordHierarchicalDelimiter);
return new AutomaticKeywordGroup(this.name.getValue(), this.context, field, this.keywordDelimiter, keywordHierarchicalDelimiter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public int hashCode() {

@Override
public AbstractGroup deepCopy() {
return new AutomaticPersonsGroup(this.name, this.context, this.field);
return new AutomaticPersonsGroup(this.name.getValue(), this.context, this.field);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/groups/ExplicitGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<String> getLegacyEntryKeys() {

@Override
public int hashCode() {
return Objects.hash(name, context, legacyEntryKeys, iconName, color, description, isExpanded);
return Objects.hash(name.getValue(), context, legacyEntryKeys, iconName, color, description, isExpanded);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/groups/TexGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean isDynamic() {
@Override
public AbstractGroup deepCopy() {
try {
return new TexGroup(name, context, filePath, auxParser, fileMonitor);
return new TexGroup(name.getValue(), context, filePath, auxParser, fileMonitor);
} catch (IOException ex) {
// This should never happen because we were able to monitor the file just fine until now
LOGGER.error("Problem creating copy of group", ex);
Expand Down

0 comments on commit 944d3c9

Please sign in to comment.