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

Set button to loading when fetching results #38

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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