Skip to content

Commit

Permalink
Merge pull request #12 from evolvedbinary/feature/filler
Browse files Browse the repository at this point in the history
[Feature] populate the UI text input values from XML
  • Loading branch information
adamretter authored Nov 1, 2023
2 parents a0ca347 + 8c69621 commit 6bf90f0
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 @@ -25,16 +25,18 @@
*/
public class newSuggestionForm extends javax.swing.JDialog {
private TeiCompleter teiCompleter;
private TeiCompleter.AutoCompleteContext autoCompleteContext;
private SuggestedAutocomplete suggestedAutocomplete = null;

private ArrayList<SuggestedAutocomplete> results = new ArrayList<>();

/**
* Creates new form JDialogForm
*/
public newSuggestionForm(java.awt.Frame parent, final TeiCompleter teiCompleter) {
public newSuggestionForm(java.awt.Frame parent, final TeiCompleter teiCompleter, final TeiCompleter.AutoCompleteContext autoCompleteContext) {
super(parent, ModalityType.DOCUMENT_MODAL);
this.teiCompleter = teiCompleter;
this.autoCompleteContext = autoCompleteContext;
initComponents();
customLabels();
}
Expand Down Expand Up @@ -336,12 +338,14 @@ public SuggestedAutocomplete getSuggestedAutocomplete() {
private void customLabels() {
if(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent() != null) {
dependentJLabel.setText(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getDependent().getLabel() + ":");
} else {
dependentJTextField.setText(autoCompleteContext.getDependentValue());
}else {
dependentJLabel.setVisible(false);
dependentJTextField.setVisible(false);
selectionJTextField.setPreferredSize(new Dimension(80, selectionJTextField.getHeight()));
}
selectionJLabel.setText(this.teiCompleter.getConfiguration().getAutoCompletes().get(0).getSelection().getLabel() + ":");
selectionJTextField.setText(autoCompleteContext.getSelectedValue());
}

public class LiveAutoComplete extends SwingWorker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public List<CIValue> filterAttributeValues(final List<CIValue> list, final WhatP
}
if(autoCompleteSuggestions != null && autoCompleteSuggestions.getSuggestions().size() == 0) {
// the value needs to be prefixed with a space character to bump it to the top of the list
list.add(new CustomCIValue(" Custom Entry...", this));
list.add(new CustomCIValue(" Custom Entry...", this, autoCompleteSuggestions.autoCompleteContext));
}

}
Expand Down Expand Up @@ -333,7 +333,7 @@ private String getAutoCompleteDependentXPath(final String elemXPath, final Depen
return elemXPath + "/" + dependent.getAttribute();
}

protected class AutoCompleteContext {
public class AutoCompleteContext {
private final String selectedValue;
@Nullable private final String dependentValue;

Expand Down Expand Up @@ -405,10 +405,12 @@ public List<CIValue> filterElementValues(final List<CIValue> list, final Context
*/
public class CustomCIValue extends CIValue {
private TeiCompleter teiCompleter;
private AutoCompleteContext autoCompleteContext;
private String suggestion;
public CustomCIValue(String s, final TeiCompleter teiCompleter) {
public CustomCIValue(String s, final TeiCompleter teiCompleter, final AutoCompleteContext autoCompleteContext) {
super(s);
this.teiCompleter = teiCompleter;
this.autoCompleteContext = autoCompleteContext;
}

@Override
Expand All @@ -426,7 +428,7 @@ private SuggestedAutocomplete promptUserForNewSuggestion() {
final KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
final Component comp = keyboardFocusManager.getFocusOwner();
final Frame parentFrame = getParentFrame(comp);
final newSuggestionForm newSuggestionForm = new newSuggestionForm(parentFrame, teiCompleter);
final newSuggestionForm newSuggestionForm = new newSuggestionForm(parentFrame, teiCompleter, autoCompleteContext);



Expand Down

0 comments on commit 6bf90f0

Please sign in to comment.