-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial version for autocompletion in text fields and text areas
- Loading branch information
1 parent
a315933
commit f5d3a5a
Showing
12 changed files
with
379 additions
and
62 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
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
17 changes: 17 additions & 0 deletions
17
src/main/java/link/biosmarcel/baka/filter/IncompleteQueryException.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,17 @@ | ||
package link.biosmarcel.baka.filter; | ||
|
||
import java.util.List; | ||
|
||
public class IncompleteQueryException extends RuntimeException { | ||
public final boolean empty; | ||
public final String token; | ||
public final List<String> options; | ||
|
||
public IncompleteQueryException(final boolean empty, | ||
final String token, | ||
final List<String> options) { | ||
this.empty = empty; | ||
this.token = token; | ||
this.options = options; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,29 @@ | ||
package link.biosmarcel.baka.filter; | ||
|
||
import org.jspecify.annotations.Nullable; | ||
|
||
public enum Operator { | ||
EQ, | ||
NOT_EQ, | ||
HAS, | ||
LT, | ||
LT_EQ, | ||
GT, | ||
GT_EQ, | ||
EQ("="), | ||
NOT_EQ("!="), | ||
HAS("has"), | ||
LT("<"), | ||
LT_EQ("<="), | ||
GT(">"), | ||
GT_EQ(">="); | ||
|
||
public final String text; | ||
|
||
Operator(final String text) { | ||
this.text = text; | ||
} | ||
|
||
public static @Nullable Operator match(final String text) { | ||
for (final var operator : Operator.values()) { | ||
if (operator.text.equalsIgnoreCase(text)) { | ||
return operator; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/link/biosmarcel/baka/view/AutocompleteField.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,28 @@ | ||
package link.biosmarcel.baka.view; | ||
|
||
import javafx.scene.control.TextField; | ||
import javafx.scene.control.TextInputControl; | ||
import javafx.scene.control.skin.TextFieldSkin; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
public class AutocompleteField extends AutocompleteInput { | ||
public AutocompleteField(Function<String, List<String>> autocompleteGenerator) { | ||
super(autocompleteGenerator); | ||
} | ||
|
||
@Override | ||
void positionPopup() { | ||
final var textFieldBounds = input.getBoundsInParent(); | ||
completionList.setTranslateY(textFieldBounds.getMaxY()); | ||
|
||
final var caretBounds = ((TextFieldSkin) input.getSkin()).getCharacterBounds(input.getCaretPosition()); | ||
completionList.setTranslateX(textFieldBounds.getMinX() + caretBounds.getMinX()); | ||
} | ||
|
||
@Override | ||
TextInputControl createInput() { | ||
return new TextField(); | ||
} | ||
} |
Oops, something went wrong.