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 icon + color and description to groups #2612

Merged
merged 5 commits into from
Mar 6, 2017
Merged
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
Prev Previous commit
Next Next commit
Add color, description and icon in groups dialog
  • Loading branch information
tobiasdiez committed Mar 3, 2017
commit 5034747967f963ff59fb05eb37a155b59221c7dd
41 changes: 35 additions & 6 deletions src/main/java/org/jabref/gui/groups/GroupDialog.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,8 @@
import javax.swing.SwingConstants;
import javax.swing.event.CaretListener;

import javafx.scene.paint.Color;

import org.jabref.Globals;
import org.jabref.JabRefGUI;
import org.jabref.gui.Dialog;
@@ -80,6 +82,10 @@ class GroupDialog extends JDialog implements Dialog<AbstractGroup> {
Localization.lang("Refine supergroup: When selected, view entries contained in both this group and its supergroup"));
private final JRadioButton unionButton = new JRadioButton(
Localization.lang("Include subgroups: When selected, view entries contained in this group or its subgroups"));
private final JTextField colorField = new JTextField(GroupDialog.TEXTFIELD_LENGTH);
private final JTextField descriptionField = new JTextField(GroupDialog.TEXTFIELD_LENGTH);
private final JTextField iconField = new JTextField(GroupDialog.TEXTFIELD_LENGTH);

// for KeywordGroup
private final JTextField keywordGroupSearchField = new JTextField(GroupDialog.TEXTFIELD_LENGTH);
private final TextField keywordGroupSearchTerm = new TextField(FieldName.KEYWORDS, "", false);
@@ -209,7 +215,7 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) {
// create layout
FormLayout layoutAll = new FormLayout(
"right:pref, 4dlu, fill:600px, 4dlu, fill:pref",
"p, 3dlu, p, 3dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, "
"p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, "
+ "0dlu, p, 0dlu, p, 3dlu, p, 3dlu, "
+ "p, 3dlu, p, 3dlu, top:80dlu, 9dlu, p, 9dlu, p");

@@ -221,6 +227,18 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) {
builderAll.append(nameField);
builderAll.nextLine();
builderAll.nextLine();
builderAll.append(Localization.lang("Description"));
builderAll.append(descriptionField);
builderAll.nextLine();
builderAll.nextLine();
builderAll.append(Localization.lang("Color"));
builderAll.append(colorField);
builderAll.nextLine();
builderAll.nextLine();
builderAll.append(Localization.lang("Icon"));
builderAll.append(iconField);
builderAll.nextLine();
builderAll.nextLine();
builderAll.append(explicitRadioButton, 5);
builderAll.nextLine();
builderAll.nextLine();
@@ -339,6 +357,14 @@ public void actionPerformed(ActionEvent e) {
autoGroupPersonsField.getText().trim());
}
}
try {
resultingGroup.setColor(Color.valueOf(colorField.getText()));
} catch (IllegalArgumentException ex) {
// Ignore invalid color (we should probably notify the user instead...)
}
resultingGroup.setDescription(descriptionField.getText());
resultingGroup.setIconCode(iconField.getText());

dispose();
} catch (IllegalArgumentException exception) {
jabrefFrame.showMessage(exception.getLocalizedMessage());
@@ -349,6 +375,9 @@ public void actionPerformed(ActionEvent e) {
ItemListener itemListener = e -> updateComponents();

nameField.addCaretListener(caretListener);
colorField.addCaretListener(caretListener);
descriptionField.addCaretListener(caretListener);
iconField.addCaretListener(caretListener);
keywordGroupSearchField.addCaretListener(caretListener);
keywordGroupSearchTerm.addCaretListener(caretListener);
keywordGroupCaseSensitive.addItemListener(itemListener);
@@ -363,9 +392,13 @@ public void actionPerformed(ActionEvent e) {
explicitRadioButton.setSelected(true);
setContext(GroupHierarchyType.INDEPENDENT);
} else {
nameField.setText(editedGroup.getName());
colorField.setText(editedGroup.getColor().map(Color::toString).orElse(""));
descriptionField.setText(editedGroup.getDescription().orElse(""));
iconField.setText(editedGroup.getIconCode().orElse(""));

if (editedGroup.getClass() == WordKeywordGroup.class) {
WordKeywordGroup group = (WordKeywordGroup) editedGroup;
nameField.setText(group.getName());
keywordGroupSearchField.setText(group.getSearchField());
keywordGroupSearchTerm.setText(group.getSearchExpression());
keywordGroupCaseSensitive.setSelected(group.isCaseSensitive());
@@ -374,7 +407,6 @@ public void actionPerformed(ActionEvent e) {
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == RegexKeywordGroup.class) {
RegexKeywordGroup group = (RegexKeywordGroup) editedGroup;
nameField.setText(group.getName());
keywordGroupSearchField.setText(group.getSearchField());
keywordGroupSearchTerm.setText(group.getSearchExpression());
keywordGroupCaseSensitive.setSelected(group.isCaseSensitive());
@@ -383,18 +415,15 @@ public void actionPerformed(ActionEvent e) {
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == SearchGroup.class) {
SearchGroup group = (SearchGroup) editedGroup;
nameField.setText(group.getName());
searchGroupSearchExpression.setText(group.getSearchExpression());
searchGroupCaseSensitive.setSelected(group.isCaseSensitive());
searchGroupRegExp.setSelected(group.isRegularExpression());
searchRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == ExplicitGroup.class) {
nameField.setText(editedGroup.getName());
explicitRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());
} else if (editedGroup.getClass() == AutomaticKeywordGroup.class) {
nameField.setText(editedGroup.getName());
autoRadioButton.setSelected(true);
setContext(editedGroup.getHierarchicalContext());