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

Fix group edit dialog #5329

Merged
merged 1 commit into from
Sep 18, 2019
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ run {
"--add-exports", "javafx.graphics/com.sun.javafx.css=org.controlsfx.controls",
"--add-opens", "javafx.controls/javafx.scene.control.skin=org.controlsfx.controls",
"--add-opens", "javafx.graphics/javafx.scene=org.controlsfx.controls",
"--add-exports", "javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-opens", "javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-opens", "javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-opens", "javafx.graphics/com.sun.javafx.stage=com.jfoenix",
Expand Down
39 changes: 18 additions & 21 deletions src/main/java/org/jabref/gui/groups/GroupDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.groups.AbstractGroup;
import org.jabref.model.groups.AutomaticGroup;
import org.jabref.model.groups.AutomaticKeywordGroup;
import org.jabref.model.groups.AutomaticPersonsGroup;
import org.jabref.model.groups.ExplicitGroup;
Expand Down Expand Up @@ -336,7 +337,7 @@ groupName, getContext(),
}
} else if (texRadioButton.isSelected()) {
resultingGroup = TexGroup.create(groupName, getContext(),
Paths.get(texGroupFilePath.getText().trim()), new DefaultAuxParser(new BibDatabase()), Globals.getFileUpdateMonitor(), basePanel.getBibDatabaseContext().getMetaData());
Paths.get(texGroupFilePath.getText().trim()), new DefaultAuxParser(new BibDatabase()), Globals.getFileUpdateMonitor(), basePanel.getBibDatabaseContext().getMetaData());
}

resultingGroup.setColor(colorField.getValue());
Expand Down Expand Up @@ -376,6 +377,7 @@ groupName, getContext(),
editedGroup.getColor().ifPresent(colorField::setValue);
descriptionField.setText(editedGroup.getDescription().orElse(""));
iconField.setText(editedGroup.getIconName().orElse(""));
setContext(editedGroup.getHierarchicalContext());

if (editedGroup.getClass() == WordKeywordGroup.class) {
WordKeywordGroup group = (WordKeywordGroup) editedGroup;
Expand All @@ -384,28 +386,23 @@ groupName, getContext(),
keywordGroupCaseSensitive.setSelected(group.isCaseSensitive());
keywordGroupRegExp.setSelected(false);
keywordsRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == RegexKeywordGroup.class) {
RegexKeywordGroup group = (RegexKeywordGroup) editedGroup;
keywordGroupSearchField.setText(group.getSearchField().getName());
keywordGroupSearchTerm.setText(group.getSearchExpression());
keywordGroupCaseSensitive.setSelected(group.isCaseSensitive());
keywordGroupRegExp.setSelected(true);
keywordsRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == SearchGroup.class) {
SearchGroup group = (SearchGroup) editedGroup;
searchGroupSearchExpression.setText(group.getSearchExpression());
searchGroupCaseSensitive.setSelected(group.isCaseSensitive());
searchGroupRegExp.setSelected(group.isRegularExpression());
searchRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == ExplicitGroup.class) {
explicitRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == AutomaticKeywordGroup.class) {
} else if (editedGroup instanceof AutomaticGroup) {
autoRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());

if (editedGroup.getClass() == AutomaticKeywordGroup.class) {
AutomaticKeywordGroup group = (AutomaticKeywordGroup) editedGroup;
Expand All @@ -418,7 +415,6 @@ groupName, getContext(),
}
} else if (editedGroup.getClass() == TexGroup.class) {
texRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());

TexGroup group = (TexGroup) editedGroup;
texGroupFilePath.setText(group.getFilePath().toString());
Expand Down Expand Up @@ -588,7 +584,7 @@ private void updateComponents() {
if (okEnabled) {
setDescription(fromTextFlowToHTMLString(SearchDescribers.getSearchDescriberFor(
new SearchQuery(s1, isCaseSensitive(), isRegex()))
.getDescription()));
.getDescription()));

if (isRegex()) {
try {
Expand All @@ -615,9 +611,9 @@ private void updateComponents() {

private void openBrowseDialog() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(StandardFileType.AUX)
.withDefaultExtension(StandardFileType.AUX)
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
.addExtensionFilter(StandardFileType.AUX)
.withDefaultExtension(StandardFileType.AUX)
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> texGroupFilePath.setText(relativize(file.toAbsolutePath()).toString()));
}

Expand Down Expand Up @@ -672,21 +668,18 @@ private ArrayList<Node> createFormattedDescription(String descriptionHTML) {
Text textElement = new Text(bs);
textElement.setStyle("-fx-font-weight: bold");
nodes.add(textElement);

} else if (bs.matches("<i>[^<>]*</i>")) {

bs = bs.replaceAll("<i>|</i>", "");
Text textElement = new Text(bs);
textElement.setStyle("-fx-font-style: italic");
nodes.add(textElement);

} else if (bs.matches("<tt>[^<>]*</tt>|<kbd>[^<>]*</kbd>")) {

bs = bs.replaceAll("<tt>|</tt>|<kbd>|</kbd>", "");
Text textElement = new Text(bs);
textElement.setStyle("-fx-font-family: 'Courier New', Courier, monospace");
nodes.add(textElement);

} else {
nodes.add(new Text(bs));
}
Expand Down Expand Up @@ -724,12 +717,16 @@ private GroupHierarchyType getContext() {
}

private void setContext(GroupHierarchyType context) {
if (context == GroupHierarchyType.REFINING) {
intersectionButton.setSelected(true);
} else if (context == GroupHierarchyType.INCLUDING) {
unionButton.setSelected(true);
} else {
independentButton.setSelected(true);
switch (context) {
case INDEPENDENT:
independentButton.setSelected(true);
break;
case REFINING:
intersectionButton.setSelected(true);
break;
case INCLUDING:
unionButton.setSelected(true);
break;
}
}
}