swingx-soapui

16:53:22.793 INFO  jd.cli.Main - Decompiling swingx-soapui.jar
package org.jdesktop.beans;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;

public abstract class AbstractBean
{
  private transient PropertyChangeSupport pcs;
  private transient VetoableChangeSupport vcs;
  
  protected AbstractBean()
  {
    pcs = new PropertyChangeSupport(this);
    vcs = new VetoableChangeSupport(this);
  }
  
  protected AbstractBean(PropertyChangeSupport pcs, VetoableChangeSupport vcs)
  {
    if (pcs == null) {
      throw new NullPointerException("PropertyChangeSupport must not be null");
    }
    if (vcs == null) {
      throw new NullPointerException("VetoableChangeSupport must not be null");
    }
    this.pcs = pcs;
    this.vcs = vcs;
  }
  
  public final void addPropertyChangeListener(PropertyChangeListener listener)
  {
    pcs.addPropertyChangeListener(listener);
  }
  
  public final void removePropertyChangeListener(PropertyChangeListener listener)
  {
    pcs.removePropertyChangeListener(listener);
  }
  
  public final PropertyChangeListener[] getPropertyChangeListeners()
  {
    return pcs.getPropertyChangeListeners();
  }
  
  public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
  {
    pcs.addPropertyChangeListener(propertyName, listener);
  }
  
  public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
  {
    pcs.removePropertyChangeListener(propertyName, listener);
  }
  
  public final PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
  {
    return pcs.getPropertyChangeListeners(propertyName);
  }
  
  protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue)
  {
    pcs.firePropertyChange(propertyName, oldValue, newValue);
  }
  
  protected final void firePropertyChange(PropertyChangeEvent evt)
  {
    pcs.firePropertyChange(evt);
  }
  
  protected final void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
  {
    pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
  }
  
  protected final boolean hasPropertyChangeListeners(String propertyName)
  {
    return pcs.hasListeners(propertyName);
  }
  
  protected final boolean hasVetoableChangeListeners(String propertyName)
  {
    return vcs.hasListeners(propertyName);
  }
  
  public final void addVetoableChangeListener(VetoableChangeListener listener)
  {
    vcs.addVetoableChangeListener(listener);
  }
  
  public final void removeVetoableChangeListener(VetoableChangeListener listener)
  {
    vcs.removeVetoableChangeListener(listener);
  }
  
  public final VetoableChangeListener[] getVetoableChangeListeners()
  {
    return vcs.getVetoableChangeListeners();
  }
  
  public final void addVetoableChangeListener(String propertyName, VetoableChangeListener listener)
  {
    vcs.addVetoableChangeListener(propertyName, listener);
  }
  
  public final void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)
  {
    vcs.removeVetoableChangeListener(propertyName, listener);
  }
  
  public final VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
  {
    return vcs.getVetoableChangeListeners(propertyName);
  }
  
  protected final void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
    throws PropertyVetoException
  {
    vcs.fireVetoableChange(propertyName, oldValue, newValue);
  }
  
  protected final void fireVetoableChange(PropertyChangeEvent evt)
    throws PropertyVetoException
  {
    vcs.fireVetoableChange(evt);
  }
  
  public Object clone()
    throws CloneNotSupportedException
  {
    AbstractBean result = (AbstractBean)super.clone();
    pcs = new PropertyChangeSupport(result);
    vcs = new VetoableChangeSupport(result);
    return result;
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.beans.AbstractBean
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.jdesktop.swingx.action.AbstractActionExt;

class AbstractPatternPanel$1
  implements PropertyChangeListener
{
  AbstractPatternPanel$1(AbstractPatternPanel paramAbstractPatternPanel) {}
  
  public void propertyChange(PropertyChangeEvent evt)
  {
    String property = evt.getPropertyName();
    if ("pattern".equals(property)) {
      this$0.refreshPatternFromModel();
    } else if ("rawText".equals(property)) {
      this$0.refreshDocumentFromModel();
    } else if ("caseSensitive".equals(property)) {
      this$0.getAction("matchCase").setSelected(((Boolean)evt.getNewValue()).booleanValue());
    } else if ("wrapping".equals(property)) {
      this$0.getAction("wrapSearch").setSelected(((Boolean)evt.getNewValue()).booleanValue());
    } else if ("backwards".equals(property)) {
      this$0.getAction("backwardsSearch").setSelected(((Boolean)evt.getNewValue()).booleanValue());
    } else if ("incremental".equals(property)) {
      this$0.getAction("matchIncremental").setSelected(((Boolean)evt.getNewValue()).booleanValue());
    } else if ("empty".equals(property)) {
      this$0.refreshEmptyFromModel();
    }
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractPatternPanel.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

import javax.swing.JTextField;

class AbstractPatternPanel$2
  implements Runnable
{
  AbstractPatternPanel$2(AbstractPatternPanel paramAbstractPatternPanel) {}
  
  public void run()
  {
    this$0.searchField.setText(this$0.getPatternModel().getRawText());
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractPatternPanel.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

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

class AbstractPatternPanel$3
  implements DocumentListener
{
  AbstractPatternPanel$3(AbstractPatternPanel paramAbstractPatternPanel) {}
  
  public void changedUpdate(DocumentEvent ev)
  {
    this$0.refreshModelFromDocument();
  }
  
  public void insertUpdate(DocumentEvent ev)
  {
    this$0.refreshModelFromDocument();
  }
  
  public void removeUpdate(DocumentEvent ev)
  {
    this$0.refreshModelFromDocument();
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractPatternPanel.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

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

class AbstractPatternPanel$4
  extends JTextField
{
  AbstractPatternPanel$4(AbstractPatternPanel paramAbstractPatternPanel, int x0)
  {
    super(x0);
  }
  
  public Dimension getMaximumSize()
  {
    Dimension superMax = super.getMaximumSize();
    height = getPreferredSizeheight;
    return superMax;
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractPatternPanel.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import org.jdesktop.swingx.action.AbstractActionExt;
import org.jdesktop.swingx.action.ActionContainerFactory;
import org.jdesktop.swingx.action.BoundAction;
import org.jdesktop.swingx.plaf.LookAndFeelAddons;

public abstract class AbstractPatternPanel
  extends JXPanel
{
  public static final String SEARCH_FIELD_LABEL = "searchFieldLabel";
  public static final String SEARCH_FIELD_MNEMONIC = "searchFieldLabel.mnemonic";
  public static final String SEARCH_TITLE = "searchTitle";
  public static final String MATCH_ACTION_COMMAND = "match";
  protected JLabel searchLabel;
  protected JTextField searchField;
  protected JCheckBox matchCheck;
  protected PatternModel patternModel;
  private ActionContainerFactory actionFactory;
  
  static
  {
    LookAndFeelAddons.getAddon();
  }
  
  protected AbstractActionExt getAction(String key)
  {
    return (AbstractActionExt)getActionMap().get(key);
  }
  
  protected void initActions()
  {
    initPatternActions();
    initExecutables();
  }
  
  protected void initExecutables()
  {
    Action execute = createBoundAction("match", "match");
    getActionMap().put("execute", execute);
    
    getActionMap().put("match", execute);
    refreshEmptyFromModel();
  }
  
  protected void initPatternActions()
  {
    ActionMap map = getActionMap();
    map.put("matchCase", createModelStateAction("matchCase", "setCaseSensitive", getPatternModel().isCaseSensitive()));
    
    map.put("wrapSearch", createModelStateAction("wrapSearch", "setWrapping", getPatternModel().isWrapping()));
    
    map.put("backwardsSearch", createModelStateAction("backwardsSearch", "setBackwards", getPatternModel().isBackwards()));
    
    map.put("matchIncremental", createModelStateAction("matchIncremental", "setIncremental", getPatternModel().isIncremental()));
  }
  
  protected String getUIString(String key)
  {
    String text = UIManager.getString("Search." + key);
    return text != null ? text : key;
  }
  
  protected AbstractActionExt createModelStateAction(String command, String methodName, boolean initial)
  {
    String actionName = getUIString(command);
    BoundAction action = new BoundAction(actionName, command);
    
    action.setStateAction();
    action.registerCallback(getPatternModel(), methodName);
    action.setSelected(initial);
    return action;
  }
  
  protected AbstractActionExt createBoundAction(String actionCommand, String methodName)
  {
    String actionName = getUIString(actionCommand);
    BoundAction action = new BoundAction(actionName, actionCommand);
    
    action.registerCallback(this, methodName);
    return action;
  }
  
  protected void refreshPatternFromModel()
  {
    if (getPatternModel().isIncremental()) {
      match();
    }
  }
  
  protected PatternModel getPatternModel()
  {
    if (patternModel == null)
    {
      patternModel = createPatternModel();
      patternModel.addPropertyChangeListener(getPatternModelListener());
    }
    return patternModel;
  }
  
  protected PatternModel createPatternModel()
  {
    PatternModel l = new PatternModel();
    return l;
  }
  
  protected PropertyChangeListener getPatternModelListener()
  {
    PropertyChangeListener l = new PropertyChangeListener()
    {
      public void propertyChange(PropertyChangeEvent evt)
      {
        String property = evt.getPropertyName();
        if ("pattern".equals(property)) {
          refreshPatternFromModel();
        } else if ("rawText".equals(property)) {
          refreshDocumentFromModel();
        } else if ("caseSensitive".equals(property)) {
          getAction("matchCase").setSelected(((Boolean)evt.getNewValue()).booleanValue());
        } else if ("wrapping".equals(property)) {
          getAction("wrapSearch").setSelected(((Boolean)evt.getNewValue()).booleanValue());
        } else if ("backwards".equals(property)) {
          getAction("backwardsSearch").setSelected(((Boolean)evt.getNewValue()).booleanValue());
        } else if ("incremental".equals(property)) {
          getAction("matchIncremental").setSelected(((Boolean)evt.getNewValue()).booleanValue());
        } else if ("empty".equals(property)) {
          refreshEmptyFromModel();
        }
      }
    };
    return l;
  }
  
  protected void refreshEmptyFromModel()
  {
    boolean enabled = !getPatternModel().isEmpty();
    getAction("match").setEnabled(enabled);
  }
  
  protected void refreshModelFromDocument()
  {
    getPatternModel().setRawText(searchField.getText());
  }
  
  protected void refreshDocumentFromModel()
  {
    if (searchField.getText().equals(getPatternModel().getRawText())) {
      return;
    }
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        searchField.setText(getPatternModel().getRawText());
      }
    });
  }
  
  protected DocumentListener getSearchFieldListener()
  {
    DocumentListener l = new DocumentListener()
    {
      public void changedUpdate(DocumentEvent ev)
      {
        refreshModelFromDocument();
      }
      
      public void insertUpdate(DocumentEvent ev)
      {
        refreshModelFromDocument();
      }
      
      public void removeUpdate(DocumentEvent ev)
      {
        refreshModelFromDocument();
      }
    };
    return l;
  }
  
  protected void bind()
  {
    bindSearchLabel();
    searchField.getDocument().addDocumentListener(getSearchFieldListener());
    getActionContainerFactory().configureButton(matchCheck, (AbstractActionExt)getActionMap().get("matchCase"), null);
  }
  
  protected void bindSearchLabel()
  {
    searchLabel.setText(getUIString("searchFieldLabel"));
    String mnemonic = getUIString("searchFieldLabel.mnemonic");
    if (mnemonic != "searchFieldLabel.mnemonic") {
      searchLabel.setDisplayedMnemonic(mnemonic.charAt(0));
    }
    searchLabel.setLabelFor(searchField);
  }
  
  protected ActionContainerFactory getActionContainerFactory()
  {
    if (actionFactory == null) {
      actionFactory = new ActionContainerFactory(null);
    }
    return actionFactory;
  }
  
  protected void initComponents()
  {
    searchLabel = new JLabel();
    searchField = new JTextField(getSearchFieldWidth())
    {
      public Dimension getMaximumSize()
      {
        Dimension superMax = super.getMaximumSize();
        height = getPreferredSizeheight;
        return superMax;
      }
    };
    matchCheck = new JCheckBox();
  }
  
  protected int getSearchFieldWidth()
  {
    return 15;
  }
  
  public abstract void match();
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractPatternPanel
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

import java.util.regex.MatchResult;
import java.util.regex.Pattern;

public class AbstractSearchable$SearchResult
{
  int foundRow;
  int foundColumn;
  MatchResult matchResult;
  Pattern pattern;
  
  public AbstractSearchable$SearchResult()
  {
    reset();
  }
  
  public void updateFrom(SearchResult searchResult)
  {
    if (searchResult == null)
    {
      reset();
      return;
    }
    foundRow = foundRow;
    foundColumn = foundColumn;
    matchResult = matchResult;
    pattern = pattern;
  }
  
  public String getRegEx()
  {
    return pattern != null ? pattern.pattern() : null;
  }
  
  public AbstractSearchable$SearchResult(Pattern ex, MatchResult result, int row, int column)
  {
    pattern = ex;
    matchResult = result;
    foundRow = row;
    foundColumn = column;
  }
  
  public void reset()
  {
    foundRow = -1;
    foundColumn = -1;
    matchResult = null;
    pattern = null;
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractSearchable.SearchResult
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx;

import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public abstract class AbstractSearchable
  implements Searchable
{
  public static final SearchResult NO_MATCH = new SearchResult();
  protected SearchResult lastSearchResult;
  public static final String MATCH_HIGHLIGHTER = "match.highlighter";
  
  public AbstractSearchable()
  {
    lastSearchResult = new SearchResult();
  }
  
  public int search(String searchString)
  {
    return search(searchString, -1);
  }
  
  public int search(String searchString, int startIndex)
  {
    return search(searchString, startIndex, false);
  }
  
  public int search(String searchString, int startIndex, boolean backward)
  {
    Pattern pattern = null;
    if (!isEmpty(searchString)) {
      pattern = Pattern.compile(searchString, 0);
    }
    return search(pattern, startIndex, backward);
  }
  
  public int search(Pattern pattern)
  {
    return search(pattern, -1);
  }
  
  public int search(Pattern pattern, int startIndex)
  {
    return search(pattern, startIndex, false);
  }
  
  public int search(Pattern pattern, int startIndex, boolean backwards)
  {
    int matchingRow = doSearch(pattern, startIndex, backwards);
    moveMatchMarker();
    return matchingRow;
  }
  
  protected int doSearch(Pattern pattern, int startIndex, boolean backwards)
  {
    if (isTrivialNoMatch(pattern, startIndex))
    {
      updateState(null);
      return lastSearchResult.foundRow;
    }
    int startRow;
    int startRow;
    if (isEqualStartIndex(startIndex))
    {
      if (!isEqualPattern(pattern))
      {
        SearchResult searchResult = findExtendedMatch(pattern, startIndex);
        if (searchResult != null)
        {
          updateState(searchResult);
          return lastSearchResult.foundRow;
        }
      }
      startRow = moveStartPosition(startIndex, backwards);
    }
    else
    {
      startRow = adjustStartPosition(startIndex, backwards);
    }
    findMatchAndUpdateState(pattern, startRow, backwards);
    return lastSearchResult.foundRow;
  }
  
  protected abstract void findMatchAndUpdateState(Pattern paramPattern, int paramInt, boolean paramBoolean);
  
  protected boolean isTrivialNoMatch(Pattern pattern, int startIndex)
  {
    return (pattern == null) || (startIndex >= getSize());
  }
  
  protected int adjustStartPosition(int startIndex, boolean backwards)
  {
    if (startIndex < 0)
    {
      if (backwards) {
        return getSize() - 1;
      }
      return 0;
    }
    return startIndex;
  }
  
  protected int moveStartPosition(int startIndex, boolean backwards)
  {
    if (backwards) {
      startIndex--;
    } else {
      startIndex++;
    }
    return startIndex;
  }
  
  protected boolean isEqualPattern(Pattern pattern)
  {
    return pattern.pattern().equals(lastSearchResult.getRegEx());
  }
  
  protected boolean isEqualStartIndex(int startIndex)
  {
    return (isValidIndex(startIndex)) && (startIndex == lastSearchResult.foundRow);
  }
  
  protected boolean isEmpty(String searchString)
  {
    return (searchString == null) || (searchString.length() == 0);
  }
  
  protected abstract SearchResult findExtendedMatch(Pattern paramPattern, int paramInt);
  
  protected SearchResult createSearchResult(Matcher matcher, int row, int column)
  {
    return new SearchResult(matcher.pattern(), matcher.toMatchResult(), row, column);
  }
  
  protected boolean isValidIndex(int index)
  {
    return (index >= 0) && (index < getSize());
  }
  
  protected abstract int getSize();
  
  protected void updateState(SearchResult searchResult)
  {
    lastSearchResult.updateFrom(searchResult);
  }
  
  protected abstract void moveMatchMarker();
  
  public static class SearchResult
  {
    int foundRow;
    int foundColumn;
    MatchResult matchResult;
    Pattern pattern;
    
    public SearchResult()
    {
      reset();
    }
    
    public void updateFrom(SearchResult searchResult)
    {
      if (searchResult == null)
      {
        reset();
        return;
      }
      foundRow = foundRow;
      foundColumn = foundColumn;
      matchResult = matchResult;
      pattern = pattern;
    }
    
    public String getRegEx()
    {
      return pattern != null ? pattern.pattern() : null;
    }
    
    public SearchResult(Pattern ex, MatchResult result, int row, int column)
    {
      pattern = ex;
      matchResult = result;
      foundRow = row;
      foundColumn = column;
    }
    
    public void reset()
    {
      foundRow = -1;
      foundColumn = -1;
      matchResult = null;
      pattern = null;
    }
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.AbstractSearchable
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx.action;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.KeyStroke;

public abstract class AbstractActionExt
  extends AbstractAction
  implements ItemListener
{
  public static final String LARGE_ICON = "__LargeIcon__";
  public static final String GROUP = "__Group__";
  public static final String IS_STATE = "__State__";
  private boolean selected = false;
  
  public AbstractActionExt() {}
  
  public AbstractActionExt(AbstractActionExt action)
  {
    Object[] keys = action.getKeys();
    for (int i = 0; i < keys.length; i++) {
      putValue((String)keys[i], action.getValue((String)keys[i]));
    }
    selected = selected;
    enabled = enabled;
    
    PropertyChangeListener[] listeners = action.getPropertyChangeListeners();
    for (int i = 0; i < listeners.length; i++) {
      addPropertyChangeListener(listeners[i]);
    }
  }
  
  public AbstractActionExt(String name)
  {
    super(name);
  }
  
  public AbstractActionExt(String name, Icon icon)
  {
    super(name, icon);
  }
  
  public AbstractActionExt(String name, String command)
  {
    this(name);
    setActionCommand(command);
  }
  
  public AbstractActionExt(String name, String command, Icon icon)
  {
    super(name, icon);
    setActionCommand(command);
  }
  
  public String getShortDescription()
  {
    return (String)getValue("ShortDescription");
  }
  
  public void setShortDescription(String desc)
  {
    putValue("ShortDescription", desc);
    if ((desc != null) && (getLongDescription() == null)) {
      setLongDescription(desc);
    }
  }
  
  public String getLongDescription()
  {
    return (String)getValue("LongDescription");
  }
  
  public void setLongDescription(String desc)
  {
    putValue("LongDescription", desc);
    if ((desc != null) && (getShortDescription() == null)) {
      setShortDescription(desc);
    }
  }
  
  public Icon getSmallIcon()
  {
    return (Icon)getValue("SmallIcon");
  }
  
  public void setSmallIcon(Icon icon)
  {
    putValue("SmallIcon", icon);
  }
  
  public Icon getLargeIcon()
  {
    return (Icon)getValue("__LargeIcon__");
  }
  
  public void setLargeIcon(Icon icon)
  {
    putValue("__LargeIcon__", icon);
  }
  
  public void setName(String name)
  {
    putValue("Name", name);
  }
  
  public String getName()
  {
    return (String)getValue("Name");
  }
  
  public void setMnemonic(String mnemonic)
  {
    if ((mnemonic != null) && (mnemonic.length() > 0)) {
      putValue("MnemonicKey", new Integer(mnemonic.charAt(0)));
    }
  }
  
  public void setMnemonic(int mnemonic)
  {
    putValue("MnemonicKey", new Integer(mnemonic));
  }
  
  public int getMnemonic()
  {
    Integer value = (Integer)getValue("MnemonicKey");
    if (value != null) {
      return value.intValue();
    }
    return 0;
  }
  
  public void setActionCommand(Object key)
  {
    putValue("ActionCommandKey", key);
  }
  
  public Object getActionCommand()
  {
    return getValue("ActionCommandKey");
  }
  
  public KeyStroke getAccelerator()
  {
    return (KeyStroke)getValue("AcceleratorKey");
  }
  
  public void setAccelerator(KeyStroke key)
  {
    putValue("AcceleratorKey", key);
  }
  
  public void setGroup(Object group)
  {
    putValue("__Group__", group);
  }
  
  public Object getGroup()
  {
    return getValue("__Group__");
  }
  
  public void dispose()
  {
    PropertyChangeListener[] listeners = getPropertyChangeListeners();
    for (int i = 0; i < listeners.length; i++) {
      removePropertyChangeListener(listeners[i]);
    }
  }
  
  public boolean isStateAction()
  {
    Boolean state = (Boolean)getValue("__State__");
    if (state != null) {
      return state.booleanValue();
    }
    return false;
  }
  
  public void setStateAction()
  {
    setStateAction(true);
  }
  
  public void setStateAction(boolean state)
  {
    putValue("__State__", Boolean.valueOf(state));
  }
  
  public boolean isSelected()
  {
    return selected;
  }
  
  public synchronized void setSelected(boolean newValue)
  {
    boolean oldValue = selected;
    if (oldValue != newValue)
    {
      selected = newValue;
      firePropertyChange("selected", Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
    }
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer("[");
    
    buffer.append(getClass().toString());
    buffer.append(":");
    try
    {
      Object[] keys = getKeys();
      for (int i = 0; i < keys.length; i++)
      {
        buffer.append(keys[i]);
        buffer.append('=');
        buffer.append(getValue((String)keys[i]).toString());
        if (i < keys.length - 1) {
          buffer.append(',');
        }
      }
      buffer.append(']');
    }
    catch (Exception ex) {}
    return buffer.toString();
  }
  
  public void itemStateChanged(ItemEvent e) {}
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.action.AbstractActionExt
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx.action;

import java.awt.Insets;
import java.beans.PropertyChangeListener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;

public class ActionContainerFactory
{
  private static Insets TOOLBAR_BUTTON_MARGIN = new Insets(1, 1, 1, 1);
  private ActionManager manager;
  private Map groupMap;
  
  public ActionContainerFactory() {}
  
  public ActionContainerFactory(ActionManager manager)
  {
    setActionManager(manager);
  }
  
  public ActionManager getActionManager()
  {
    if (manager == null) {
      manager = ActionManager.getInstance();
    }
    return manager;
  }
  
  public void setActionManager(ActionManager manager)
  {
    this.manager = manager;
  }
  
  public JToolBar createToolBar(Object[] list)
  {
    return createToolBar(Arrays.asList(list));
  }
  
  public JToolBar createToolBar(List list)
  {
    JToolBar toolbar = new JToolBar();
    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
      Object element = iter.next();
      if (element == null)
      {
        toolbar.addSeparator();
      }
      else
      {
        AbstractButton button = createButton(element, toolbar);
        
        button.setFocusable(false);
        
        button.setMargin(TOOLBAR_BUTTON_MARGIN);
        button.setBorderPainted(false);
        
        toolbar.add(button);
      }
    }
    return toolbar;
  }
  
  public JPopupMenu createPopup(Object[] list)
  {
    return createPopup(Arrays.asList(list));
  }
  
  public JPopupMenu createPopup(List list)
  {
    JPopupMenu popup = new JPopupMenu();
    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
      Object element = iter.next();
      if (element == null)
      {
        popup.addSeparator();
      }
      else if ((element instanceof List))
      {
        JMenu newMenu = createMenu((List)element);
        if (newMenu != null) {
          popup.add(newMenu);
        }
      }
      else
      {
        popup.add(createMenuItem(element, popup));
      }
    }
    return popup;
  }
  
  public JMenuBar createMenuBar(Object[] actionIds)
  {
    return createMenuBar(Arrays.asList(actionIds));
  }
  
  public JMenuBar createMenuBar(List list)
  {
    JMenuBar menubar = new JMenuBar();
    JMenu menu = null;
    
    Iterator iter = list.iterator();
    while (iter.hasNext())
    {
      Object element = iter.next();
      if (element == null)
      {
        if (menu != null) {
          menu.addSeparator();
        }
      }
      else if ((element instanceof List))
      {
        menu = createMenu((List)element);
        if (menu != null) {
          menubar.add(menu);
        }
      }
      else if (menu != null)
      {
        menu.add(createMenuItem(element, menu));
      }
    }
    return menubar;
  }
  
  public JMenu createMenu(Object[] actionIds)
  {
    return createMenu(Arrays.asList(actionIds));
  }
  
  public JMenu createMenu(List list)
  {
    Action action = getAction(list.get(0));
    if (action == null) {
      return null;
    }
    JMenu menu = new JMenu(action);
    
    Iterator iter = list.listIterator(1);
    while (iter.hasNext())
    {
      Object element = iter.next();
      if (element == null)
      {
        menu.addSeparator();
      }
      else if ((element instanceof List))
      {
        JMenu newMenu = createMenu((List)element);
        if (newMenu != null) {
          menu.add(newMenu);
        }
      }
      else
      {
        menu.add(createMenuItem(element, menu));
      }
    }
    return menu;
  }
  
  private Action getAction(Object id)
  {
    Action action = getActionManager().getAction(id);
    if (action == null) {
      throw new RuntimeException("ERROR: No Action for " + id);
    }
    return action;
  }
  
  private ButtonGroup getGroup(String groupid, JComponent container)
  {
    if (groupMap == null) {
      groupMap = new HashMap();
    }
    int intCode = groupid.hashCode();
    if (container != null) {
      intCode ^= container.hashCode();
    }
    Integer hashCode = new Integer(intCode);
    
    ButtonGroup group = (ButtonGroup)groupMap.get(hashCode);
    if (group == null)
    {
      group = new ButtonGroup();
      groupMap.put(hashCode, group);
    }
    return group;
  }
  
  private JMenuItem createMenuItem(Object id, JComponent container)
  {
    return createMenuItem(getAction(id), container);
  }
  
  public JMenuItem createMenuItem(Action action, JComponent container)
  {
    JMenuItem menuItem = null;
    if ((action instanceof AbstractActionExt))
    {
      AbstractActionExt ta = (AbstractActionExt)action;
      if (ta.isStateAction())
      {
        String groupid = (String)ta.getGroup();
        if (groupid != null) {
          menuItem = createRadioButtonMenuItem(getGroup(groupid, container), (AbstractActionExt)action);
        } else {
          menuItem = createCheckBoxMenuItem((AbstractActionExt)action);
        }
      }
    }
    if (menuItem == null)
    {
      menuItem = new JMenuItem(action);
      configureMenuItemFromExtActionProperties(menuItem, action);
    }
    return menuItem;
  }
  
  public JMenuItem createMenuItem(Action action)
  {
    return createMenuItem(action, null);
  }
  
  public AbstractButton createButton(Object id, JComponent container)
  {
    return createButton(getAction(id), container);
  }
  
  public AbstractButton createButton(Action action, JComponent container)
  {
    if (action == null) {
      return null;
    }
    AbstractButton button = null;
    if ((action instanceof AbstractActionExt))
    {
      AbstractActionExt ta = (AbstractActionExt)action;
      if (ta.isStateAction())
      {
        String groupid = (String)ta.getGroup();
        if (groupid == null) {
          button = createToggleButton(ta);
        } else {
          button = createToggleButton(ta, getGroup(groupid, container));
        }
      }
    }
    if (button == null)
    {
      button = new JButton(action);
      configureButtonFromExtActionProperties(button, action);
    }
    return button;
  }
  
  public AbstractButton createButton(Action action)
  {
    return createButton(action, null);
  }
  
  private JToggleButton createToggleButton(AbstractActionExt a)
  {
    return createToggleButton(a, null);
  }
  
  private JToggleButton createToggleButton(AbstractActionExt a, ButtonGroup group)
  {
    JToggleButton button = new JToggleButton();
    configureButton(button, a, group);
    return button;
  }
  
  public void configureButton(JToggleButton button, AbstractActionExt a, ButtonGroup group)
  {
    configureSelectableButton(button, a, group);
    configureButtonFromExtActionProperties(button, a);
  }
  
  public void configureSelectableButton(AbstractButton button, AbstractActionExt a, ButtonGroup group)
  {
    if ((a != null) && (!a.isStateAction())) {
      throw new IllegalArgumentException("the Action must be a stateAction");
    }
    if (button.getAction() == a) {
      return;
    }
    Action oldAction = button.getAction();
    if ((oldAction instanceof AbstractActionExt))
    {
      AbstractActionExt actionExt = (AbstractActionExt)oldAction;
      
      button.removeItemListener(actionExt);
      
      PropertyChangeListener[] l = actionExt.getPropertyChangeListeners();
      for (int i = l.length - 1; i >= 0; i--) {
        if ((l[i] instanceof ToggleActionPropertyChangeListener))
        {
          ToggleActionPropertyChangeListener togglePCL = (ToggleActionPropertyChangeListener)l[i];
          if (togglePCL.isToggling(button)) {
            actionExt.removePropertyChangeListener(togglePCL);
          }
        }
      }
    }
    button.setAction(a);
    if (group != null) {
      group.add(button);
    }
    if (a != null)
    {
      button.addItemListener(a);
      
      button.setSelected(a.isSelected());
      new ToggleActionPropertyChangeListener(a, button);
    }
  }
  
  protected void configureButtonFromExtActionProperties(AbstractButton button, Action action)
  {
    if (action.getValue("ShortDescription") == null) {
      button.setToolTipText((String)action.getValue("Name"));
    }
    if (action.getValue("__LargeIcon__") != null) {
      button.setIcon((Icon)action.getValue("__LargeIcon__"));
    }
    if (button.getIcon() != null) {
      button.setText("");
    }
  }
  
  protected void configureMenuItemFromExtActionProperties(JMenuItem menuItem, Action action) {}
  
  private JCheckBoxMenuItem createCheckBoxMenuItem(AbstractActionExt a)
  {
    JCheckBoxMenuItem mi = new JCheckBoxMenuItem();
    configureSelectableButton(mi, a, null);
    configureMenuItemFromExtActionProperties(mi, a);
    return mi;
  }
  
  private JRadioButtonMenuItem createRadioButtonMenuItem(ButtonGroup group, AbstractActionExt a)
  {
    JRadioButtonMenuItem mi = new JRadioButtonMenuItem();
    configureSelectableButton(mi, a, group);
    configureMenuItemFromExtActionProperties(mi, a);
    return mi;
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.action.ActionContainerFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx.action;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.KeyStroke;

public class ActionFactory
{
  public static BoundAction createBoundAction(String id, String name, String mnemonic)
  {
    return createBoundAction(id, name, mnemonic, false);
  }
  
  public static BoundAction createBoundAction(String id, String name, String mnemonic, boolean toggle)
  {
    return createBoundAction(id, name, mnemonic, toggle, null);
  }
  
  public static BoundAction createBoundAction(String id, String name, String mnemonic, boolean toggle, String group)
  {
    return (BoundAction)configureAction(new BoundAction(name, id), mnemonic, toggle, group);
  }
  
  public static CompositeAction createCompositeAction(String id, String name, String mnemonic)
  {
    return createCompositeAction(id, name, mnemonic, false);
  }
  
  public static CompositeAction createCompositeAction(String id, String name, String mnemonic, boolean toggle)
  {
    return createCompositeAction(id, name, mnemonic, toggle, null);
  }
  
  public static CompositeAction createCompositeAction(String id, String name, String mnemonic, boolean toggle, String group)
  {
    return (CompositeAction)configureAction(new CompositeAction(name, id), mnemonic, toggle, group);
  }
  
  public static ServerAction createServerAction(String id, String name, String mnemonic)
  {
    ServerAction action = new ServerAction(name, id);
    if ((mnemonic != null) && (!mnemonic.equals(""))) {
      action.putValue("MnemonicKey", new Integer(mnemonic.charAt(0)));
    }
    return action;
  }
  
  public static TargetableAction createTargetableAction(String id, String name)
  {
    return createTargetableAction(id, name, null);
  }
  
  public static TargetableAction createTargetableAction(String id, String name, String mnemonic)
  {
    return createTargetableAction(id, name, mnemonic, false);
  }
  
  public static TargetableAction createTargetableAction(String id, String name, String mnemonic, boolean toggle)
  {
    return createTargetableAction(id, name, mnemonic, toggle, null);
  }
  
  public static TargetableAction createTargetableAction(String id, String name, String mnemonic, boolean toggle, String group)
  {
    return (TargetableAction)configureAction(new TargetableAction(name, id), mnemonic, toggle, group);
  }
  
  private static Action configureAction(AbstractActionExt action, String mnemonic, boolean toggle, String group)
  {
    action.setMnemonic(mnemonic);
    String description = action.getName() + " action with comand " + action.getActionCommand();
    action.setShortDescription(description);
    action.setLongDescription(description);
    if (toggle) {
      action.setStateAction();
    }
    if (group != null) {
      action.setGroup(group);
    }
    return action;
  }
  
  public static void decorateAction(AbstractAction action, String shortDesc, String longDesc, Icon smallIcon, Icon largeIcon, KeyStroke accel)
  {
    if ((action instanceof AbstractActionExt))
    {
      AbstractActionExt a = (AbstractActionExt)action;
      a.setShortDescription(shortDesc);
      a.setLongDescription(longDesc);
      a.setSmallIcon(smallIcon);
      a.setLargeIcon(largeIcon);
      a.setAccelerator(accel);
    }
    else
    {
      action.putValue("ShortDescription", shortDesc);
      action.putValue("LongDescription", longDesc);
      action.putValue("SmallIcon", smallIcon);
      action.putValue("__LargeIcon__", largeIcon);
      action.putValue("AcceleratorKey", accel);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdesktop.swingx.action.ActionFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.jdesktop.swingx.action;

import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;

public class ActionManager
  extends ActionMap
{
  private static ActionManager INSTANCE;
  
  public static ActionManager getInstance()
  {
    if (INSTANCE == null) {
      INSTANCE = new ActionManager();
    }
    return INSTANCE;
  }
  
  public static void setInstance(ActionManager manager)
  {
    INSTANCE = manager;
  }
  
  public Set getActionIDs()
  {
    Object[] keys = keys();
    if (keys == null) {
      return null;
    }
    return new HashSet(Arrays.asList(keys));
  }
  
  public Action addAction(Action action)
  {
    return addAction(action.getValue("ActionCommandKey"), action);
  }
  
  public Action addAction(Object id, Action action)
  {
    put(id, action);
    return action;
  }
  
  public Action getAction(Object id)
  {
    return get(id);
  }
  
  public TargetableAction getTargetableAction(Object id)
  {
    Action a = getAction(id);
    if ((a instanceof TargetableAction)) {
      return (TargetableAction)a;
    }
    return null;
  }
  
  public BoundAction getBoundAction(Object id)
  {
    Action a = getAction(id);
    if ((a instanceof BoundAction)) {
      return (BoundAction)a;
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

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