org-netbeans-spi-quicksearch

16:40:19.221 INFO  jd.cli.Main - Decompiling org-netbeans-spi-quicksearch.jar
package org.netbeans.modules.quicksearch;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;

class AbstractQuickSearchComboBar$1
  implements DocumentListener
{
  AbstractQuickSearchComboBar$1(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void insertUpdate(DocumentEvent paramDocumentEvent)
  {
    textChanged();
  }
  
  public void removeUpdate(DocumentEvent paramDocumentEvent)
  {
    textChanged();
  }
  
  public void changedUpdate(DocumentEvent paramDocumentEvent)
  {
    textChanged();
  }
  
  private void textChanged()
  {
    if (this$0.command.isFocusOwner()) {
      this$0.displayer.maybeEvaluate(this$0.command.getText());
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

class AbstractQuickSearchComboBar$2
  extends FocusAdapter
{
  AbstractQuickSearchComboBar$2(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void focusLost(FocusEvent paramFocusEvent)
  {
    AbstractQuickSearchComboBar.access$000(this$0, paramFocusEvent);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

class AbstractQuickSearchComboBar$3
  extends FocusAdapter
{
  AbstractQuickSearchComboBar$3(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void focusGained(FocusEvent paramFocusEvent)
  {
    AbstractQuickSearchComboBar.access$100(this$0, paramFocusEvent);
  }
  
  public void focusLost(FocusEvent paramFocusEvent)
  {
    AbstractQuickSearchComboBar.access$200(this$0, paramFocusEvent);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

class AbstractQuickSearchComboBar$4
  extends KeyAdapter
{
  AbstractQuickSearchComboBar$4(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void keyPressed(KeyEvent paramKeyEvent)
  {
    AbstractQuickSearchComboBar.access$300(this$0, paramKeyEvent);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

class AbstractQuickSearchComboBar$5
  extends MouseAdapter
{
  AbstractQuickSearchComboBar$5(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void mouseClicked(MouseEvent paramMouseEvent)
  {
    this$0.displayer.explicitlyInvoked();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

class AbstractQuickSearchComboBar$6
  implements Runnable
{
  AbstractQuickSearchComboBar$6(AbstractQuickSearchComboBar paramAbstractQuickSearchComboBar) {}
  
  public void run()
  {
    this$0.displayer.invoke();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.ref.WeakReference;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.ListModel;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;
import org.openide.windows.TopComponent.Registry;

public abstract class AbstractQuickSearchComboBar
  extends JPanel
  implements ActionListener
{
  private static final String CATEGORY = "cat";
  QuickSearchPopup displayer = new QuickSearchPopup(this);
  WeakReference<TopComponent> caller;
  Color origForeground;
  protected final KeyStroke keyStroke;
  protected JTextComponent command;
  
  public AbstractQuickSearchComboBar(KeyStroke paramKeyStroke)
  {
    keyStroke = paramKeyStroke;
    
    initComponents();
    
    setShowHint(true);
    
    command.getDocument().addDocumentListener(new DocumentListener()
    {
      public void insertUpdate(DocumentEvent paramAnonymousDocumentEvent)
      {
        textChanged();
      }
      
      public void removeUpdate(DocumentEvent paramAnonymousDocumentEvent)
      {
        textChanged();
      }
      
      public void changedUpdate(DocumentEvent paramAnonymousDocumentEvent)
      {
        textChanged();
      }
      
      private void textChanged()
      {
        if (command.isFocusOwner()) {
          displayer.maybeEvaluate(command.getText());
        }
      }
    });
  }
  
  public KeyStroke getKeyStroke()
  {
    return keyStroke;
  }
  
  protected abstract JTextComponent createCommandField();
  
  protected abstract JComponent getInnerComponent();
  
  private void initComponents()
  {
    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setMaximumSize(new Dimension(200, Integer.MAX_VALUE));
    setName("Form");
    setOpaque(false);
    addFocusListener(new FocusAdapter()
    {
      public void focusLost(FocusEvent paramAnonymousFocusEvent)
      {
        AbstractQuickSearchComboBar.this.formFocusLost(paramAnonymousFocusEvent);
      }
    });
    command = createCommandField();
    command.setToolTipText(NbBundle.getMessage(AbstractQuickSearchComboBar.class, "AbstractQuickSearchComboBar.command.toolTipText", new Object[] { "(" + SearchResultRender.getKeyStrokeAsText(keyStroke) + ")" }));
    command.setName("command");
    command.addFocusListener(new FocusAdapter()
    {
      public void focusGained(FocusEvent paramAnonymousFocusEvent)
      {
        AbstractQuickSearchComboBar.this.commandFocusGained(paramAnonymousFocusEvent);
      }
      
      public void focusLost(FocusEvent paramAnonymousFocusEvent)
      {
        AbstractQuickSearchComboBar.this.commandFocusLost(paramAnonymousFocusEvent);
      }
    });
    command.addKeyListener(new KeyAdapter()
    {
      public void keyPressed(KeyEvent paramAnonymousKeyEvent)
      {
        AbstractQuickSearchComboBar.this.commandKeyPressed(paramAnonymousKeyEvent);
      }
    });
    command.addMouseListener(new MouseAdapter()
    {
      public void mouseClicked(MouseEvent paramAnonymousMouseEvent)
      {
        displayer.explicitlyInvoked();
      }
    });
  }
  
  private void formFocusLost(FocusEvent paramFocusEvent)
  {
    displayer.setVisible(false);
  }
  
  private void commandKeyPressed(KeyEvent paramKeyEvent)
  {
    if (paramKeyEvent.getKeyCode() == 40)
    {
      displayer.selectNext();
      paramKeyEvent.consume();
    }
    else if (paramKeyEvent.getKeyCode() == 38)
    {
      displayer.selectPrev();
      paramKeyEvent.consume();
    }
    else if (paramKeyEvent.getKeyCode() == 10)
    {
      paramKeyEvent.consume();
      invokeSelectedItem();
    }
    else if (paramKeyEvent.getKeyCode() == 27)
    {
      returnFocus(true);
      displayer.clearModel();
    }
    else if ((paramKeyEvent.getKeyCode() == 121) && (paramKeyEvent.isShiftDown()))
    {
      maybeShowPopup(null);
    }
  }
  
  public void invokeSelectedItem()
  {
    JList localJList = displayer.getList();
    ResultsModel.ItemResult localItemResult = (ResultsModel.ItemResult)localJList.getSelectedValue();
    if (localItemResult != null)
    {
      Runnable localRunnable = localItemResult.getAction();
      if ((localRunnable instanceof CategoryResult))
      {
        CategoryResult localCategoryResult = (CategoryResult)localRunnable;
        evaluateCategory(localCategoryResult.getCategory(), true);
        return;
      }
    }
    if (localJList.getModel().getSize() > 0)
    {
      returnFocus(false);
      
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          displayer.invoke();
        }
      });
    }
  }
  
  private void returnFocus(boolean paramBoolean)
  {
    displayer.setVisible(false);
    if (caller != null)
    {
      TopComponent localTopComponent = (TopComponent)caller.get();
      if (localTopComponent != null)
      {
        localTopComponent.requestActive();
        localTopComponent.requestFocus();
        return;
      }
    }
    if (paramBoolean) {
      KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
    }
  }
  
  private void commandFocusLost(FocusEvent paramFocusEvent)
  {
    displayer.setVisible(false);
    setShowHint(true);
  }
  
  private void commandFocusGained(FocusEvent paramFocusEvent)
  {
    caller = new WeakReference(TopComponent.getRegistry().getActivated());
    setShowHint(false);
    if (CommandEvaluator.isCatTemporary())
    {
      CommandEvaluator.setCatTemporary(false);
      CommandEvaluator.setEvalCat(null);
    }
  }
  
  protected void maybeShowPopup(MouseEvent paramMouseEvent)
  {
    if ((paramMouseEvent != null) && (!SwingUtilities.isLeftMouseButton(paramMouseEvent))) {
      return;
    }
    JPopupMenu localJPopupMenu = new JPopupMenu();
    ProviderModel.Category localCategory1 = null;
    if (!CommandEvaluator.isCatTemporary()) {
      localCategory1 = CommandEvaluator.getEvalCat();
    }
    JRadioButtonMenuItem localJRadioButtonMenuItem1 = new JRadioButtonMenuItem(NbBundle.getMessage(getClass(), "LBL_AllCategories"), localCategory1 == null);
    
    localJRadioButtonMenuItem1.addActionListener(this);
    localJPopupMenu.add(localJRadioButtonMenuItem1);
    for (ProviderModel.Category localCategory2 : ProviderModel.getInstance().getCategories()) {
      if (!"Recent".equals(localCategory2.getName()))
      {
        JRadioButtonMenuItem localJRadioButtonMenuItem2 = new JRadioButtonMenuItem(localCategory2.getDisplayName(), localCategory2 == localCategory1);
        localJRadioButtonMenuItem2.putClientProperty("cat", localCategory2);
        localJRadioButtonMenuItem2.addActionListener(this);
        localJPopupMenu.add(localJRadioButtonMenuItem2);
      }
    }
    localJPopupMenu.show(getInnerComponent(), 0, getInnerComponent().getHeight() - 1);
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    JRadioButtonMenuItem localJRadioButtonMenuItem = (JRadioButtonMenuItem)paramActionEvent.getSource();
    CommandEvaluator.setEvalCat((ProviderModel.Category)localJRadioButtonMenuItem.getClientProperty("cat"));
    CommandEvaluator.setCatTemporary(false);
    
    setShowHint(!command.isFocusOwner());
  }
  
  public void evaluateCategory(ProviderModel.Category paramCategory, boolean paramBoolean)
  {
    CommandEvaluator.setEvalCat(paramCategory);
    CommandEvaluator.setCatTemporary(paramBoolean);
    displayer.maybeEvaluate(command.getText());
  }
  
  public void setNoResults(boolean paramBoolean)
  {
    if ((command == null) || (origForeground == null)) {
      return;
    }
    if (command.getForeground().equals(command.getDisabledTextColor())) {
      return;
    }
    command.setForeground(paramBoolean ? Color.RED : origForeground);
  }
  
  private void setShowHint(boolean paramBoolean)
  {
    if (origForeground == null) {
      origForeground = command.getForeground();
    }
    if (paramBoolean)
    {
      command.setForeground(command.getDisabledTextColor());
      ProviderModel.Category localCategory = CommandEvaluator.getEvalCat();
      if ((localCategory != null) && (!CommandEvaluator.isCatTemporary())) {
        command.setText(getHintText(localCategory));
      } else {
        command.setText(getHintText(null));
      }
    }
    else
    {
      command.setForeground(origForeground);
      command.setText("");
    }
  }
  
  private String getHintText(ProviderModel.Category paramCategory)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    if (paramCategory != null) {
      localStringBuilder.append(NbBundle.getMessage(AbstractQuickSearchComboBar.class, "MSG_DiscoverabilityHint2", paramCategory.getDisplayName()));
    } else {
      localStringBuilder.append(NbBundle.getMessage(AbstractQuickSearchComboBar.class, "MSG_DiscoverabilityHint"));
    }
    localStringBuilder.append(" (");
    localStringBuilder.append(SearchResultRender.getKeyStrokeAsText(keyStroke));
    localStringBuilder.append(")");
    
    return localStringBuilder.toString();
  }
  
  public void requestFocus()
  {
    super.requestFocus();
    command.requestFocus();
  }
  
  public JTextComponent getCommand()
  {
    return command;
  }
  
  public int getBottomLineY()
  {
    return getInnerComponent().getY() + getInnerComponent().getHeight();
  }
  
  static Color getComboBorderColor()
  {
    Color localColor = UIManager.getColor(Utilities.isWindows() ? "Nb.ScrollPane.Border.color" : "TextField.shadow");
    
    return localColor != null ? localColor : getPopupBorderColor();
  }
  
  static Color getPopupBorderColor()
  {
    Color localColor = UIManager.getColor("controlShadow");
    return localColor != null ? localColor : Color.GRAY;
  }
  
  static Color getTextBackground()
  {
    Color localColor = UIManager.getColor("TextPane.background");
    if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
      localColor = UIManager.getColor("NbExplorerView.background");
    }
    return localColor != null ? localColor : Color.WHITE;
  }
  
  static Color getResultBackground()
  {
    return getTextBackground();
  }
  
  static Color getCategoryTextColor()
  {
    Color localColor = UIManager.getColor("textInactiveText");
    if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
      localColor = UIManager.getColor("Table.foreground");
    }
    return localColor != null ? localColor : Color.DARK_GRAY;
  }
  
  protected int computePrefWidth()
  {
    FontMetrics localFontMetrics = command.getFontMetrics(command.getFont());
    ProviderModel localProviderModel = ProviderModel.getInstance();
    int i = 0;
    for (ProviderModel.Category localCategory : localProviderModel.getCategories()) {
      if (!"Recent".equals(localCategory.getName())) {
        i = Math.max(i, localFontMetrics.stringWidth(getHintText(localCategory)));
      }
    }
    return Math.min(350, i);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AbstractQuickSearchComboBar
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.util.List;
import javax.swing.KeyStroke;
import org.netbeans.spi.quicksearch.SearchRequest;
import org.netbeans.spi.quicksearch.SearchResponse;

public abstract class Accessor
{
  public static Accessor DEFAULT;
  
  public abstract SearchRequest createRequest(String paramString, List<? extends KeyStroke> paramList);
  
  public abstract SearchResponse createResponse(CategoryResult paramCategoryResult, SearchRequest paramSearchRequest);
  
  static
  {
    Class localClass = SearchRequest.class;
    try
    {
      Class.forName(localClass.getName(), true, localClass.getClassLoader());
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      if (!$assertionsDisabled) {
        throw new AssertionError(localClassNotFoundException);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.Accessor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import javax.swing.JPopupMenu;

class AquaQuickSearchComboBar$1$1
  implements Runnable
{
  AquaQuickSearchComboBar$1$1(AquaQuickSearchComboBar.1 param1) {}
  
  public void run()
  {
    this$1.val$dummy.setVisible(false);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AquaQuickSearchComboBar.1.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;

class AquaQuickSearchComboBar$1
  implements PopupMenuListener
{
  AquaQuickSearchComboBar$1(AquaQuickSearchComboBar paramAquaQuickSearchComboBar, JPopupMenu paramJPopupMenu) {}
  
  public void popupMenuWillBecomeVisible(PopupMenuEvent paramPopupMenuEvent)
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        val$dummy.setVisible(false);
      }
    });
  }
  
  public void popupMenuWillBecomeInvisible(PopupMenuEvent paramPopupMenuEvent) {}
  
  public void popupMenuCanceled(PopupMenuEvent paramPopupMenuEvent) {}
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AquaQuickSearchComboBar.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class AquaQuickSearchComboBar$2
  implements ActionListener
{
  AquaQuickSearchComboBar$2(AquaQuickSearchComboBar paramAquaQuickSearchComboBar) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    this$0.maybeShowPopup(null);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AquaQuickSearchComboBar.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.Dimension;
import javax.swing.JTextField;

final class AquaQuickSearchComboBar$DynamicWidthTF
  extends JTextField
{
  private Dimension prefWidth;
  
  private AquaQuickSearchComboBar$DynamicWidthTF(AquaQuickSearchComboBar paramAquaQuickSearchComboBar) {}
  
  public Dimension getPreferredSize()
  {
    if (prefWidth == null)
    {
      Dimension localDimension = super.getPreferredSize();
      prefWidth = new Dimension(this$0.computePrefWidth(), height);
    }
    return prefWidth;
  }
  
  public Dimension getMinimumSize()
  {
    return getPreferredSize();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AquaQuickSearchComboBar.DynamicWidthTF
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.text.JTextComponent;

public class AquaQuickSearchComboBar
  extends AbstractQuickSearchComboBar
{
  public AquaQuickSearchComboBar(KeyStroke paramKeyStroke)
  {
    super(paramKeyStroke);
    
    setLayout(new BorderLayout());
    add(command, "Center");
  }
  
  protected JTextComponent createCommandField()
  {
    DynamicWidthTF localDynamicWidthTF = new DynamicWidthTF(null);
    final JPopupMenu localJPopupMenu = new JPopupMenu();
    localJPopupMenu.addPopupMenuListener(new PopupMenuListener()
    {
      public void popupMenuWillBecomeVisible(PopupMenuEvent paramAnonymousPopupMenuEvent)
      {
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            val$dummy.setVisible(false);
          }
        });
      }
      
      public void popupMenuWillBecomeInvisible(PopupMenuEvent paramAnonymousPopupMenuEvent) {}
      
      public void popupMenuCanceled(PopupMenuEvent paramAnonymousPopupMenuEvent) {}
    });
    localDynamicWidthTF.putClientProperty("JTextField.variant", "search");
    localDynamicWidthTF.putClientProperty("JTextField.Search.FindPopup", localJPopupMenu);
    localDynamicWidthTF.putClientProperty("JTextField.Search.FindAction", new ActionListener()
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        maybeShowPopup(null);
      }
    });
    return localDynamicWidthTF;
  }
  
  protected JComponent getInnerComponent()
  {
    return command;
  }
  
  private final class DynamicWidthTF
    extends JTextField
  {
    private Dimension prefWidth;
    
    private DynamicWidthTF() {}
    
    public Dimension getPreferredSize()
    {
      if (prefWidth == null)
      {
        Dimension localDimension = super.getPreferredSize();
        prefWidth = new Dimension(computePrefWidth(), height);
      }
      return prefWidth;
    }
    
    public Dimension getMinimumSize()
    {
      return getPreferredSize();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.AquaQuickSearchComboBar
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.EventQueue;
import java.util.ArrayList;
import java.util.List;
import javax.swing.SwingUtilities;
import org.openide.util.NbBundle;

public final class CategoryResult
  implements Runnable
{
  static final int MAX_RESULTS = 7;
  static final int ALL_MAX_RESULTS = 30;
  private final boolean allResults;
  private final Object LOCK = new Object();
  private final ProviderModel.Category category;
  private final List<ResultsModel.ItemResult> items;
  private boolean obsolete;
  private int previousSize;
  private boolean moreResults = false;
  
  public CategoryResult(ProviderModel.Category paramCategory, boolean paramBoolean)
  {
    category = paramCategory;
    allResults = paramBoolean;
    items = new ArrayList(paramBoolean ? 30 : 7);
  }
  
  public boolean addItem(ResultsModel.ItemResult paramItemResult)
  {
    synchronized (LOCK)
    {
      if (obsolete) {
        return false;
      }
      if (items.size() >= (allResults ? 30 : 7))
      {
        if (!allResults) {
          moreResults = true;
        }
        return false;
      }
      items.add(paramItemResult);
    }
    if (EventQueue.isDispatchThread()) {
      run();
    } else {
      SwingUtilities.invokeLater(this);
    }
    return true;
  }
  
  public List<ResultsModel.ItemResult> getItems()
  {
    ArrayList localArrayList = null;
    synchronized (LOCK)
    {
      localArrayList = new ArrayList(items);
      if (moreResults) {
        localArrayList.add(new ResultsModel.ItemResult(this, null, this, NbBundle.getMessage(getClass(), "LBL_MoreResults")));
      }
    }
    return localArrayList;
  }
  
  public boolean isFirstItem(ResultsModel.ItemResult paramItemResult)
  {
    synchronized (LOCK)
    {
      if ((items.size() > 0) && (((ResultsModel.ItemResult)items.get(0)).equals(paramItemResult))) {
        return true;
      }
    }
    return false;
  }
  
  public ProviderModel.Category getCategory()
  {
    return category;
  }
  
  public void setObsolete(boolean paramBoolean)
  {
    synchronized (LOCK)
    {
      obsolete = paramBoolean;
    }
  }
  
  public boolean isObsolete()
  {
    return obsolete;
  }
  
  public void run()
  {
    int i = 0;
    int j = 0;
    synchronized (LOCK)
    {
      i = items.size();
      if (!obsolete) {}
      j = items.size() <= (allResults ? 30 : 7) ? 1 : 0;
    }
    if (j == 0) {
      return;
    }
    if (i > previousSize)
    {
      previousSize = i;
      ResultsModel.getInstance().categoryChanged(this);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.CategoryResult
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import org.netbeans.spi.quicksearch.SearchProvider;
import org.netbeans.spi.quicksearch.SearchRequest;
import org.netbeans.spi.quicksearch.SearchResponse;

final class CommandEvaluator$1
  implements Runnable
{
  CommandEvaluator$1(SearchProvider paramSearchProvider, SearchRequest paramSearchRequest, SearchResponse paramSearchResponse) {}
  
  public void run()
  {
    val$provider.evaluate(val$request, val$response);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.CommandEvaluator.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.util.List;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.Task;

class CommandEvaluator$Wait4AllTask
  extends Task
  implements Runnable
{
  private static final long TIMEOUT = 60000L;
  private List<RequestProcessor.Task> tasks;
  
  private CommandEvaluator$Wait4AllTask(List<RequestProcessor.Task> paramList)
  {
    tasks = paramList;
  }
  
  public void run()
  {
    try
    {
      notifyRunning();
      for (RequestProcessor.Task localTask : tasks) {
        try
        {
          localTask.waitFinished(60000L);
        }
        catch (InterruptedException localInterruptedException) {}
      }
    }
    finally
    {
      notifyFinished();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.CommandEvaluator.Wait4AllTask
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.netbeans.spi.quicksearch.SearchProvider;
import org.netbeans.spi.quicksearch.SearchRequest;
import org.netbeans.spi.quicksearch.SearchResponse;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.Task;

public class CommandEvaluator
{
  static final String RECENT = "Recent";
  private static Pattern COMMAND_PATTERN = Pattern.compile("(\\w+)(\\s+)(.+)");
  private static ProviderModel.Category evalCat;
  private static boolean isCatTemporary;
  private static final RequestProcessor RP = new RequestProcessor("QuickSearch Command Evaluator");
  
  public static Task evaluate(String paramString, ResultsModel paramResultsModel)
  {
    ArrayList localArrayList1 = new ArrayList();
    String[] arrayOfString = parseCommand(paramString);
    SearchRequest localSearchRequest = Accessor.DEFAULT.createRequest(arrayOfString[1], null);
    ArrayList localArrayList2 = new ArrayList();
    
    ArrayList localArrayList3 = new ArrayList();
    boolean bool = getProviderCategories(arrayOfString, localArrayList3);
    for (ProviderModel.Category localCategory : localArrayList3)
    {
      CategoryResult localCategoryResult = new CategoryResult(localCategory, bool);
      SearchResponse localSearchResponse = Accessor.DEFAULT.createResponse(localCategoryResult, localSearchRequest);
      for (SearchProvider localSearchProvider : localCategory.getProviders())
      {
        RequestProcessor.Task localTask = runEvaluation(localSearchProvider, localSearchRequest, localSearchResponse, localCategory);
        if (localTask != null) {
          localArrayList2.add(localTask);
        }
      }
      localArrayList1.add(localCategoryResult);
    }
    paramResultsModel.setContent(localArrayList1);
    
    return new Wait4AllTask(localArrayList2, null);
  }
  
  public static ProviderModel.Category getEvalCat()
  {
    return evalCat;
  }
  
  public static void setEvalCat(ProviderModel.Category paramCategory)
  {
    evalCat = paramCategory;
  }
  
  public static boolean isCatTemporary()
  {
    return isCatTemporary;
  }
  
  public static void setCatTemporary(boolean paramBoolean)
  {
    isCatTemporary = paramBoolean;
  }
  
  private static String[] parseCommand(String paramString)
  {
    String[] arrayOfString = new String[2];
    
    Matcher localMatcher = COMMAND_PATTERN.matcher(paramString);
    if (localMatcher.matches())
    {
      arrayOfString[0] = localMatcher.group(1);
      if (ProviderModel.getInstance().isKnownCommand(arrayOfString[0]))
      {
        arrayOfString[1] = localMatcher.group(3);
      }
      else
      {
        arrayOfString[0] = null;
        arrayOfString[1] = paramString;
      }
    }
    else
    {
      arrayOfString[1] = paramString;
    }
    return arrayOfString;
  }
  
  private static boolean getProviderCategories(String[] paramArrayOfString, List<ProviderModel.Category> paramList)
  {
    List localList = ProviderModel.getInstance().getCategories();
    for (Iterator localIterator = localList.iterator(); localIterator.hasNext();)
    {
      localCategory = (ProviderModel.Category)localIterator.next();
      if ("Recent".equals(localCategory.getName())) {
        paramList.add(localCategory);
      }
    }
    ProviderModel.Category localCategory;
    if ((paramArrayOfString[1] == null) || (paramArrayOfString[1].trim().equals(""))) {
      return false;
    }
    if (paramArrayOfString[0] != null) {
      for (localIterator = localList.iterator(); localIterator.hasNext();)
      {
        localCategory = (ProviderModel.Category)localIterator.next();
        String str = localCategory.getCommandPrefix();
        if ((str != null) && (str.equalsIgnoreCase(paramArrayOfString[0])))
        {
          paramList.add(localCategory);
          return true;
        }
      }
    }
    if (evalCat != null)
    {
      paramList.add(evalCat);
      return true;
    }
    paramList.clear();
    paramList.addAll(localList);
    
    return false;
  }
  
  private static RequestProcessor.Task runEvaluation(SearchProvider paramSearchProvider, final SearchRequest paramSearchRequest, final SearchResponse paramSearchResponse, ProviderModel.Category paramCategory)
  {
    if ("Actions".equals(paramCategory.getName()))
    {
      paramSearchProvider.evaluate(paramSearchRequest, paramSearchResponse);
      return null;
    }
    RP.post(new Runnable()
    {
      public void run()
      {
        val$provider.evaluate(paramSearchRequest, paramSearchResponse);
      }
    });
  }
  
  private static class Wait4AllTask
    extends Task
    implements Runnable
  {
    private static final long TIMEOUT = 60000L;
    private List<RequestProcessor.Task> tasks;
    
    private Wait4AllTask(List<RequestProcessor.Task> paramList)
    {
      tasks = paramList;
    }
    
    public void run()
    {
      try
      {
        notifyRunning();
        for (RequestProcessor.Task localTask : tasks) {
          try
          {
            localTask.waitFinished(60000L);
          }
          catch (InterruptedException localInterruptedException) {}
        }
      }
      finally
      {
        notifyFinished();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.CommandEvaluator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.netbeans.spi.quicksearch.SearchProvider;
import org.openide.filesystems.FileObject;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;

public class ProviderModel$Category
{
  private FileObject fo;
  private String displayName;
  private String commandPrefix;
  private List<SearchProvider> providers;
  
  public ProviderModel$Category(FileObject paramFileObject, String paramString1, String paramString2)
  {
    fo = paramFileObject;
    displayName = paramString1;
    commandPrefix = paramString2;
  }
  
  public List<SearchProvider> getProviders()
  {
    if (providers == null)
    {
      Collection localCollection = Lookups.forPath(fo.getPath()).lookupAll(SearchProvider.class);
      
      providers = new ArrayList(localCollection);
    }
    return providers;
  }
  
  public String getName()
  {
    return fo.getNameExt();
  }
  
  public String getDisplayName()
  {
    return displayName;
  }
  
  public String getCommandPrefix()
  {
    return commandPrefix;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.ProviderModel.Category
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.spi.quicksearch.SearchProvider;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileSystem.Status;
import org.openide.filesystems.FileUtil;
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;

public final class ProviderModel
{
  private static final String SEARCH_PROVIDERS_FOLDER = "/QuickSearch";
  private static final String COMMAND_PREFIX = "command";
  private static ProviderModel instance;
  private List<Category> categories;
  private HashSet<String> knownCommands;
  
  public static ProviderModel getInstance()
  {
    if (instance == null) {
      instance = new ProviderModel();
    }
    return instance;
  }
  
  public List<Category> getCategories()
  {
    if (categories == null) {
      categories = loadCategories();
    }
    return categories;
  }
  
  public boolean isKnownCommand(String paramString)
  {
    if (knownCommands == null)
    {
      knownCommands = new HashSet();
      for (Category localCategory : getCategories()) {
        knownCommands.add(localCategory.getCommandPrefix());
      }
    }
    return knownCommands.contains(paramString);
  }
  
  public static class Category
  {
    private FileObject fo;
    private String displayName;
    private String commandPrefix;
    private List<SearchProvider> providers;
    
    public Category(FileObject paramFileObject, String paramString1, String paramString2)
    {
      fo = paramFileObject;
      displayName = paramString1;
      commandPrefix = paramString2;
    }
    
    public List<SearchProvider> getProviders()
    {
      if (providers == null)
      {
        Collection localCollection = Lookups.forPath(fo.getPath()).lookupAll(SearchProvider.class);
        
        providers = new ArrayList(localCollection);
      }
      return providers;
    }
    
    public String getName()
    {
      return fo.getNameExt();
    }
    
    public String getDisplayName()
    {
      return displayName;
    }
    
    public String getCommandPrefix()
    {
      return commandPrefix;
    }
  }
  
  private static List<Category> loadCategories()
  {
    FileObject[] arrayOfFileObject = FileUtil.getConfigFile("/QuickSearch").getChildren();
    
    List localList = FileUtil.getOrder(Arrays.asList(arrayOfFileObject), false);
    
    ArrayList localArrayList = new ArrayList(localList.size());
    for (FileObject localFileObject : localList)
    {
      String str1 = null;
      try
      {
        str1 = localFileObject.getFileSystem().getStatus().annotateName(localFileObject.getNameExt(), Collections.singleton(localFileObject));
      }
      catch (FileStateInvalidException localFileStateInvalidException)
      {
        Logger.getLogger(ProviderModel.class.getName()).log(Level.WARNING, "Obtaining display name for " + localFileObject + " failed.", localFileStateInvalidException);
      }
      String str2 = null;
      Object localObject = localFileObject.getAttribute("command");
      if ((localObject instanceof String)) {
        str2 = (String)localObject;
      }
      localArrayList.add(new Category(localFileObject, str1, str2));
    }
    return localArrayList;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.ProviderModel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.Component;
import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.text.JTextComponent;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;

public final class QuickSearchAction
  extends CallableSystemAction
{
  private static final boolean isAqua = "Aqua".equals(UIManager.getLookAndFeel().getID());
  AbstractQuickSearchComboBar comboBar;
  
  public void performAction()
  {
    if (comboBar == null) {
      comboBar = (isAqua ? new AquaQuickSearchComboBar((KeyStroke)getValue("AcceleratorKey")) : new QuickSearchComboBar((KeyStroke)getValue("AcceleratorKey")));
    }
    comboBar.displayer.explicitlyInvoked();
    if (comboBar.getCommand().isFocusOwner()) {
      comboBar.evaluateCategory(null, false);
    } else {
      comboBar.requestFocus();
    }
  }
  
  public String getName()
  {
    return NbBundle.getMessage(QuickSearchAction.class, "CTL_QuickSearchAction");
  }
  
  protected String iconResource()
  {
    return "org/netbeans/modules/jumpto/resources/edit_parameters.png";
  }
  
  public HelpCtx getHelpCtx()
  {
    return HelpCtx.DEFAULT_HELP;
  }
  
  protected boolean asynchronous()
  {
    return false;
  }
  
  public Component getToolbarPresenter()
  {
    if (comboBar == null) {
      comboBar = (isAqua ? new AquaQuickSearchComboBar((KeyStroke)getValue("AcceleratorKey")) : new QuickSearchComboBar((KeyStroke)getValue("AcceleratorKey")));
    }
    return comboBar;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.QuickSearchAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import org.openide.util.ImageUtilities;

class QuickSearchComboBar$1
  implements ActionListener
{
  ImageIcon[] icons;
  int index = 0;
  
  QuickSearchComboBar$1(QuickSearchComboBar paramQuickSearchComboBar) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    if (icons == null)
    {
      icons = new ImageIcon[8];
      for (int i = 0; i < 8; i++) {
        icons[i] = ImageUtilities.loadImageIcon("org/netbeans/modules/quicksearch/resources/progress_" + i + ".png", false);
      }
    }
    QuickSearchComboBar.access$000(this$0).setIcon(icons[index]);
    index = ((index + 1) % 8);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.QuickSearchComboBar.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

class QuickSearchComboBar$2
  extends MouseAdapter
{
  QuickSearchComboBar$2(QuickSearchComboBar paramQuickSearchComboBar) {}
  
  public void mousePressed(MouseEvent paramMouseEvent)
  {
    QuickSearchComboBar.access$100(this$0, paramMouseEvent);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.quicksearch.QuickSearchComboBar.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.quicksearch;

import java.awt.Dimension;
import javax.swing.JTextArea;

final class QuickSe
1 2 3

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