Skip to content

Commit

Permalink
Merge pull request #38 from evolvedbinary/feature/loading
Browse files Browse the repository at this point in the history
Set button to loading when fetching results
  • Loading branch information
adamretter authored Jan 10, 2024
2 parents f4f2a27 + f9e9916 commit a1329c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ private void restultsJTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FI
private void textChanged() {

// GATE Keeper
// reject if either fields have less than 4 chars
// reject if either fields have less than 3 chars
// this correspond to requestAutoComplete function as well
//TODO USE a constant for this value
if(selectionJTextField.getText().length() < 4) return;
if(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent() != null && dependentJTextField.getText().length() < 4) return;
if(selectionJTextField.getText().length() < 3) return;
if(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent() != null && dependentJTextField.getText().length() < 3) return;

// if we are already fetching results no need to do it again
if(runningState.compareAndSet(false, true)) {
Expand Down Expand Up @@ -395,6 +395,9 @@ public class LiveAutoComplete extends SwingWorker {
@Override
protected Object doInBackground() throws Exception {

fetchjButton.setText("Loading...");
fetchjButton.setEnabled(false);

DefaultTableModel model = (DefaultTableModel) restultsJTable.getModel();
// clear the old results
model.setRowCount(0);
Expand Down Expand Up @@ -441,6 +444,8 @@ protected Object doInBackground() throws Exception {
@Override
protected void done() {
// Update UI on EDT when the task is complete
fetchjButton.setText("Search...");
fetchjButton.setEnabled(true);
DefaultTableModel model = (DefaultTableModel) restultsJTable.getModel();

//populate with the new results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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) {
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 a1329c8

Please sign in to comment.