net.sf.swtaddons_0.1.1_bin_src

16:39:18.674 INFO  jd.cli.Main - Decompiling net.sf.swtaddons_0.1.1_bin_src.jar
package net.sf.swtaddons.autocomplete;

import org.eclipse.jface.fieldassist.IContentProposal;

final class AutocompleteContentProposalProvider$1
  implements IContentProposal
{
  AutocompleteContentProposalProvider$1(AutocompleteContentProposalProvider paramAutocompleteContentProposalProvider, String paramString) {}
  
  public String getContent()
  {
    return val$proposal;
  }
  
  public String getDescription()
  {
    return null;
  }
  
  public String getLabel()
  {
    return null;
  }
  
  public int getCursorPosition()
  {
    return val$proposal.length();
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;

public class AutocompleteContentProposalProvider
  implements IContentProposalProvider
{
  protected String[] proposals = null;
  
  public AutocompleteContentProposalProvider(String[] proposals)
  {
    this.proposals = proposals;
  }
  
  public IContentProposal[] getProposals(String contents, int position)
  {
    List contentProposals = getMatchingProposals(proposals, contents);
    return (IContentProposal[])contentProposals.toArray(new IContentProposal[contentProposals.size()]);
  }
  
  public void setProposals(String[] items)
  {
    proposals = items;
  }
  
  protected List getMatchingProposals(String[] proposals, String contents)
  {
    List contentProposals = new ArrayList();
    String[] matchingProposals = matches(proposals, contents);
    for (int i = 0; i < matchingProposals.length; i++)
    {
      final String proposal = matchingProposals[i];
      contentProposals.add(new IContentProposal()
      {
        public String getContent()
        {
          return proposal;
        }
        
        public String getDescription()
        {
          return null;
        }
        
        public String getLabel()
        {
          return null;
        }
        
        public int getCursorPosition()
        {
          return proposal.length();
        }
      });
    }
    return contentProposals;
  }
  
  private String[] matches(String[] items, String prefix)
  {
    List matches = new ArrayList();
    for (int i = 0; i < items.length; i++) {
      if (startsWithIgnoreCase(items[i], prefix)) {
        matches.add(items[i]);
      }
    }
    return (String[])matches.toArray(new String[matches.size()]);
  }
  
  private boolean startsWithIgnoreCase(String string, String prefix)
  {
    return string.toLowerCase().startsWith(prefix.toLowerCase());
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete;

public class AutocompleteInputContentProposalProvider
  extends AutocompleteContentProposalProvider
{
  public AutocompleteInputContentProposalProvider(String[] proposals)
  {
    super(proposals);
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.AutocompleteInputContentProposalProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete;

import java.util.List;
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;

public class AutocompleteSelectorContentProposalProvider
  extends AutocompleteContentProposalProvider
{
  private Control control = null;
  
  public AutocompleteSelectorContentProposalProvider(String[] proposals, Combo combo)
  {
    super(proposals);
    control = combo;
  }
  
  public AutocompleteSelectorContentProposalProvider(String[] proposals, Text text)
  {
    super(proposals);
    control = text;
  }
  
  public IContentProposal[] getProposals(String contents, int position)
  {
    List contentProposals = getMatchingProposals(proposals, contents);
    if (contentProposals.size() == 0) {
      if ((control instanceof Text)) {
        contentProposals = getContentProposals((Text)control);
      } else if ((control instanceof Combo)) {
        contentProposals = getContentProposals((Combo)control);
      }
    }
    return (IContentProposal[])contentProposals.toArray(new IContentProposal[contentProposals.size()]);
  }
  
  private List getContentProposals(Combo combo)
  {
    combo.setText(combo.getText().substring(0, combo.getText().length() - 1));
    combo.setSelection(new Point(combo.getText().length(), combo.getText().length()));
    return getMatchingProposals(proposals, combo.getText());
  }
  
  private List getContentProposals(Text text)
  {
    text.setText(text.getText().substring(0, text.getText().length() - 1));
    text.setSelection(new Point(text.getText().length(), text.getText().length()));
    return getMatchingProposals(proposals, text.getText());
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.AutocompleteSelectorContentProposalProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete;

import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;

public abstract class AutocompleteWidget
{
  protected AutocompleteContentProposalProvider provider = null;
  protected ContentProposalAdapter adapter = null;
  
  protected char[] getAutoactivationChars()
  {
    String lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
    String uppercaseLetters = lowercaseLetters.toUpperCase();
    String numbers = "0123456789";
    
    String delete = new String(new char[] { '\b' });
    String allChars = lowercaseLetters + uppercaseLetters + numbers + delete;
    return allChars.toCharArray();
  }
  
  protected KeyStroke getActivationKeystroke()
  {
    return KeyStroke.getInstance(new Integer(262144).intValue(), new Integer(32).intValue());
  }
  
  protected abstract AutocompleteContentProposalProvider getContentProposalProvider(String[] paramArrayOfString);
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.AutocompleteWidget
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.combo;

import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Combo;

final class AutocompleteCombo$ProposalUpdateFocusListener
  implements FocusListener
{
  private AutocompleteCombo$ProposalUpdateFocusListener(AutocompleteCombo paramAutocompleteCombo) {}
  
  public void focusGained(FocusEvent e)
  {
    AutocompleteCombo.access$0(this$0).setProposals(this$0.combo.getItems());
  }
  
  public void focusLost(FocusEvent e) {}
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.combo.AutocompleteCombo.ProposalUpdateFocusListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.combo;

import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import net.sf.swtaddons.autocomplete.AutocompleteWidget;
import org.eclipse.jface.fieldassist.ComboContentAdapter;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Combo;

public abstract class AutocompleteCombo
  extends AutocompleteWidget
{
  private final class ProposalUpdateFocusListener
    implements FocusListener
  {
    private ProposalUpdateFocusListener() {}
    
    public void focusGained(FocusEvent e)
    {
      AutocompleteCombo.access$0(AutocompleteCombo.this).setProposals(combo.getItems());
    }
    
    public void focusLost(FocusEvent e) {}
  }
  
  protected Combo combo = null;
  
  public AutocompleteCombo(Combo aCombo)
  {
    combo = aCombo;
    if (combo != null)
    {
      combo.addFocusListener(new ProposalUpdateFocusListener(null));
      
      provider = getContentProposalProvider(combo.getItems());
      adapter = new ContentProposalAdapter(combo, new ComboContentAdapter(), provider, getActivationKeystroke(), getAutoactivationChars());
      adapter.setProposalAcceptanceStyle(2);
    }
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.combo.AutocompleteCombo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.combo;

import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import net.sf.swtaddons.autocomplete.AutocompleteInputContentProposalProvider;
import org.eclipse.swt.widgets.Combo;

public class AutocompleteComboInput
  extends AutocompleteCombo
{
  public AutocompleteComboInput(Combo combo)
  {
    super(combo);
  }
  
  protected AutocompleteContentProposalProvider getContentProposalProvider(String[] proposals)
  {
    return new AutocompleteInputContentProposalProvider(proposals);
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.combo.AutocompleteComboInput
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.combo;

import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Combo;

final class AutocompleteComboSelector$UpdateProposalListFocusListener
  implements FocusListener
{
  private AutocompleteComboSelector$UpdateProposalListFocusListener(AutocompleteComboSelector paramAutocompleteComboSelector) {}
  
  public void focusGained(FocusEvent e) {}
  
  public void focusLost(FocusEvent e)
  {
    Combo theCombo = (Combo)e.getSource();
    List items = Arrays.asList(theCombo.getItems());
    if (!items.contains(theCombo.getText())) {
      theCombo.select(0);
    }
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.combo.AutocompleteComboSelector.UpdateProposalListFocusListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.combo;

import java.util.Arrays;
import java.util.List;
import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import net.sf.swtaddons.autocomplete.AutocompleteSelectorContentProposalProvider;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.widgets.Combo;

public class AutocompleteComboSelector
  extends AutocompleteCombo
{
  private final class UpdateProposalListFocusListener
    implements FocusListener
  {
    private UpdateProposalListFocusListener() {}
    
    public void focusGained(FocusEvent e) {}
    
    public void focusLost(FocusEvent e)
    {
      Combo theCombo = (Combo)e.getSource();
      List items = Arrays.asList(theCombo.getItems());
      if (!items.contains(theCombo.getText())) {
        theCombo.select(0);
      }
    }
  }
  
  public AutocompleteComboSelector(Combo aCombo)
  {
    super(aCombo);
    aCombo.addFocusListener(new UpdateProposalListFocusListener(null));
  }
  
  protected AutocompleteContentProposalProvider getContentProposalProvider(String[] proposals)
  {
    return new AutocompleteSelectorContentProposalProvider(proposals, combo);
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.combo.AutocompleteComboSelector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.text;

import net.sf.swtaddons.autocomplete.AutocompleteWidget;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.swt.widgets.Text;

public abstract class AutocompleteText
  extends AutocompleteWidget
{
  protected Text text = null;
  
  public AutocompleteText(Text text, String[] selectionItems)
  {
    if (text != null)
    {
      this.text = text;
      provider = getContentProposalProvider(selectionItems);
      adapter = new ContentProposalAdapter(text, new TextContentAdapter(), provider, getActivationKeystroke(), getAutoactivationChars());
      adapter.setProposalAcceptanceStyle(2);
    }
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.text.AutocompleteText
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.text;

import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import net.sf.swtaddons.autocomplete.AutocompleteInputContentProposalProvider;
import org.eclipse.swt.widgets.Text;

public class AutocompleteTextInput
  extends AutocompleteText
{
  public AutocompleteTextInput(Text text, String[] selectionItems)
  {
    super(text, selectionItems);
  }
  
  protected AutocompleteContentProposalProvider getContentProposalProvider(String[] proposals)
  {
    return new AutocompleteInputContentProposalProvider(proposals);
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.text.AutocompleteTextInput
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package net.sf.swtaddons.autocomplete.text;

import net.sf.swtaddons.autocomplete.AutocompleteContentProposalProvider;
import net.sf.swtaddons.autocomplete.AutocompleteSelectorContentProposalProvider;
import org.eclipse.swt.widgets.Text;

public class AutocompleteTextSelector
  extends AutocompleteText
{
  public AutocompleteTextSelector(Text text, String[] selectionItems)
  {
    super(text, selectionItems);
  }
  
  protected AutocompleteContentProposalProvider getContentProposalProvider(String[] proposals)
  {
    return new AutocompleteSelectorContentProposalProvider(proposals, text);
  }
}

/* Location:
 * Qualified Name:     net.sf.swtaddons.autocomplete.text.AutocompleteTextSelector
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd