-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* force author, title and year text areas to be single line text field using text formatter * consider 'institution' as a field, that should contain only one line * create EditorTextField and use that control for author, institution, year and title * pass JournalAbbrevRepo instead of Loader and Prefs * code review fixes - move SINGLE_LINE_FIELDS list to InternalBibtexFields class - rename hasSingleLine var to isSingleLine
- Loading branch information
1 parent
9ae2b40
commit f9799d4
Showing
14 changed files
with
183 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/jabref/gui/fieldeditors/ContextMenuAddable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jabref.gui.fieldeditors; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
import javafx.scene.control.MenuItem; | ||
|
||
public interface ContextMenuAddable { | ||
/** | ||
* Adds the given list of menu items to the context menu. The usage of {@link Supplier} prevents that the menus need | ||
* to be instantiated at this point. They are populated when the user needs them which prevents many unnecessary | ||
* allocations when the main table is just scrolled with the entry editor open. | ||
*/ | ||
void addToContextMenu(final Supplier<List<MenuItem>> items); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.jabref.gui.fieldeditors; | ||
|
||
import java.net.URL; | ||
import java.util.List; | ||
import java.util.ResourceBundle; | ||
import java.util.function.Supplier; | ||
|
||
import javafx.fxml.Initializable; | ||
import javafx.scene.control.ContextMenu; | ||
import javafx.scene.control.MenuItem; | ||
import javafx.scene.input.KeyCode; | ||
import javafx.scene.input.KeyEvent; | ||
|
||
import com.sun.javafx.scene.control.skin.TextFieldSkin; | ||
|
||
public class EditorTextField extends javafx.scene.control.TextField implements Initializable, ContextMenuAddable { | ||
|
||
public EditorTextField() { | ||
this(""); | ||
} | ||
|
||
public EditorTextField(final String text) { | ||
super(text); | ||
|
||
setMinHeight(1); | ||
setMinWidth(200); | ||
|
||
// Should behave as a normal text field with respect to TAB behaviour | ||
addEventFilter(KeyEvent.KEY_PRESSED, event -> { | ||
if (event.getCode() == KeyCode.TAB) { | ||
TextFieldSkin skin = (TextFieldSkin) getSkin(); | ||
if (event.isShiftDown()) { | ||
// Shift + Tab > previous text area | ||
skin.getBehavior().traversePrevious(); | ||
} else { | ||
if (event.isControlDown()) { | ||
// Ctrl + Tab > insert tab | ||
skin.getBehavior().callAction("InsertTab"); | ||
} else { | ||
// Tab > next text area | ||
skin.getBehavior().traverseNext(); | ||
} | ||
} | ||
event.consume(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void addToContextMenu(final Supplier<List<MenuItem>> items) { | ||
TextFieldSkin customContextSkin = new TextFieldSkin(this) { | ||
@Override | ||
public void populateContextMenu(ContextMenu contextMenu) { | ||
super.populateContextMenu(contextMenu); | ||
contextMenu.getItems().addAll(0, items.get()); | ||
} | ||
}; | ||
setSkin(customContextSkin); | ||
} | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
// not needed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/org/jabref/gui/fieldeditors/contextmenu/ClearField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.