Skip to content

Commit

Permalink
Merge pull request #11 from evolvedbinary/fix/depency
Browse files Browse the repository at this point in the history
[fix] remove dependency on optional attribute
  • Loading branch information
adamretter authored Oct 31, 2023
2 parents 0094a19 + e72fa9a commit a0ca347
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void textChanged() {
// this correspond to requestAutoComplete function as well
//TODO USE a constant for this value
if(selectionJTextField.getText().length() < 4) return;
if(dependentJTextField.getText().length() < 4) return;
if(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent() != null && dependentJTextField.getText().length() < 4) return;

// if we are already fetching results no need to do it again
if(runningState.compareAndSet(false, true)) {
Expand All @@ -333,8 +333,14 @@ public SuggestedAutocomplete getSuggestedAutocomplete() {
return suggestedAutocomplete;
}

private void customLabels() {
dependentJLabel.setText(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent().getLabel() + ":");
private void customLabels() {
if(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent() != null) {
dependentJLabel.setText(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent().getLabel() + ":");
} else {
dependentJLabel.setVisible(false);
dependentJTextField.setVisible(false);
selectionJTextField.setPreferredSize(new Dimension(80, selectionJTextField.getHeight()));
}
selectionJLabel.setText(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getSelection().getLabel() + ":");
}

Expand All @@ -351,14 +357,14 @@ protected Object doInBackground() throws Exception {
model.removeRow(i);
}

// Introduce a delay of 300 milliseconds
// Introduce a delay of 100 milliseconds
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// Handle interruption if necessary
}

// get the text field values after the cooldown
// get the text field values after the cool down
selection = selectionJTextField.getText();
dependent = dependentJTextField.getText();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected final AutoCompleteSuggestions<AutoComplete> getAutoCompleteSuggestions
public List<CIValue> requestAutoComplete(final AutoComplete autoComplete, final String selection, @Nullable final String dependent) {
final Authentication.AuthenticationType authenticationType = autoComplete.getRequestInfo().getAuthentication() == null ? null : autoComplete.getRequestInfo().getAuthentication().getAuthenticationType();
//TODO USE a constant for this value
if(selection.length() > 3 && dependent.length() > 3) {
if(selection.length() > 3) {
final Suggestions suggestions = getClient(authenticationType).getSuggestions(autoComplete.getRequestInfo(), selection, dependent, autoComplete.getResponseAction());
final List<CIValue> results = new ArrayList<>();
for(final Suggestion suggestion : suggestions.getSuggestion()) {
Expand Down

0 comments on commit a0ca347

Please sign in to comment.