org-netbeans-modules-spi-actions

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

class ActionStub$1
  implements Runnable
{
  ActionStub$1(ActionStub paramActionStub, boolean paramBoolean) {}
  
  public void run()
  {
    this$0.firePropertyChange("enabled", Boolean.valueOf(!val$enabled), Boolean.valueOf(val$enabled));
    if (ContextAction.unitTest)
    {
      synchronized (this$0.parent)
      {
        this$0.parent.notifyAll();
      }
      synchronized (this)
      {
        notifyAll();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.ActionStub.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.Map;
import org.openide.util.ContextAwareAction;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Result;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.Mutex;

class ActionStub<T>
  extends NbAction
  implements LookupListener, ContextAwareAction
{
  private final Lookup.Result<T> lkpResult;
  private final Lookup context;
  protected final ContextAction<T> parent;
  protected boolean enabled;
  
  ActionStub(Lookup paramLookup, ContextAction<T> paramContextAction)
  {
    assert (paramLookup != null);
    context = paramLookup;
    parent = paramContextAction;
    lkpResult = paramLookup.lookupResult(type);
    lkpResult.addLookupListener(this);
    if (getClass() == ActionStub.class) {
      enabled = isEnabled();
    }
  }
  
  public Object getValue(String paramString)
  {
    Object localObject = _getValue(paramString);
    if (localObject == null) {
      localObject = parent.getValue(paramString);
    }
    return localObject;
  }
  
  Object _getValue(String paramString)
  {
    if (!attached()) {
      resultChanged(null);
    }
    return pairs.get(paramString);
  }
  
  Collection<? extends T> collection()
  {
    return lkpResult.allInstances();
  }
  
  public boolean isEnabled()
  {
    Collection localCollection = collection();
    assert (localCollection != null);
    assert (parent != null);
    return !localCollection.isEmpty();
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    assert (isEnabled()) : ("Not enabled: " + this + " collection " + collection() + " of " + parent.type.getName());
    
    Collection localCollection = collection();
    parent.actionPerformed(localCollection);
  }
  
  void enabledChanged(final boolean paramBoolean)
  {
    Mutex.EVENT.readAccess(new Runnable()
    {
      public void run()
      {
        firePropertyChange("enabled", Boolean.valueOf(!paramBoolean), Boolean.valueOf(paramBoolean));
        if (ContextAction.unitTest)
        {
          synchronized (parent)
          {
            parent.notifyAll();
          }
          synchronized (this)
          {
            notifyAll();
          }
        }
      }
    });
  }
  
  public void resultChanged(LookupEvent paramLookupEvent)
  {
    if (ContextAction.unitTest) {
      synchronized (parent)
      {
        parent.notifyAll();
      }
    }
    synchronized (parent.lock())
    {
      parent.change(collection(), this == parent.stub ? parent : this);
    }
    boolean bool = enabled;
    enabled = isEnabled();
    if (bool != enabled) {
      enabledChanged(enabled);
    }
  }
  
  public String toString()
  {
    return super.toString() + "[name=" + getValue("Name") + "delegating={" + parent + "} context=" + context + "]";
  }
  
  protected NbAction internalCreateContextAwareInstance(Lookup paramLookup)
  {
    return parent.createStub(paramLookup);
  }
  
  public boolean equals(Object paramObject)
  {
    return (paramObject != null) && (paramObject.getClass() == getClass()) && (parent.equals(parent));
  }
  
  public int hashCode()
  {
    return parent.hashCode() * 37;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.ActionStub
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

class ContextAction$1 {}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.ContextAction.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

class ContextAction$StubListener
  implements PropertyChangeListener
{
  private ContextAction$StubListener(ContextAction paramContextAction) {}
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    this$0.firePropertyChange(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent.getOldValue(), paramPropertyChangeEvent.getNewValue());
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.ContextAction.StubListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.Image;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
import javax.swing.Action;
import javax.swing.ImageIcon;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.Parameters;
import org.openide.util.Utilities;

public abstract class ContextAction<T>
  extends NbAction
{
  final Class<T> type;
  private final ContextAction<T>.StubListener stubListener = new StubListener(null);
  ActionStub<T> stub;
  static boolean unitTest;
  
  protected ContextAction(Class<T> paramClass)
  {
    this(paramClass, null, null);
  }
  
  protected ContextAction(Class<T> paramClass, String paramString, Image paramImage)
  {
    type = paramClass;
    Parameters.notNull("type", paramClass);
    if (paramString != null) {
      putValue("Name", paramString);
    }
    if (paramImage != null) {
      putValue("SmallIcon", new ImageIcon(paramImage));
    }
    putValue("noIconInMenu", Boolean.valueOf(true));
  }
  
  public final boolean isEnabled()
  {
    return _isEnabled();
  }
  
  boolean _isEnabled()
  {
    ActionStub localActionStub = getStub();
    Collection localCollection = localActionStub.collection();
    boolean bool = (checkQuantity(localCollection)) && (localActionStub.isEnabled());
    return bool;
  }
  
  boolean checkQuantity(Collection<? extends T> paramCollection)
  {
    return checkQuantity(paramCollection.size());
  }
  
  protected boolean checkQuantity(int paramInt)
  {
    return paramInt > 0;
  }
  
  protected boolean isEnabled(Collection<? extends T> paramCollection)
  {
    return true;
  }
  
  protected abstract void actionPerformed(Collection<? extends T> paramCollection);
  
  public final void actionPerformed(ActionEvent paramActionEvent)
  {
    getStub().actionPerformed(null);
  }
  
  protected final NbAction internalCreateContextAwareInstance(Lookup paramLookup)
  {
    return createStub(paramLookup);
  }
  
  public boolean equals(Object paramObject)
  {
    return (paramObject != null) && (paramObject.getClass() == getClass());
  }
  
  public int hashCode()
  {
    return getClass().getName().hashCode();
  }
  
  ActionStub<T> createStub(Lookup paramLookup)
  {
    return new ActionStub(paramLookup, this);
  }
  
  private ActionStub<T> createInternalStub()
  {
    assert (Thread.holdsLock(lock()));
    ActionStub localActionStub = createStub(Utilities.actionsGlobalContext());
    return localActionStub;
  }
  
  ActionStub<T> getStub()
  {
    synchronized (lock())
    {
      if ((stub == null) && (attached()))
      {
        stub = createInternalStub();
        stub.addPropertyChangeListener(stubListener);
      }
      return stub == null ? createInternalStub() : stub;
    }
  }
  
  public String toString()
  {
    return super.toString() + "[name=" + getValue("Name") + " type=" + type.getName() + "]";
  }
  
  protected void change(Collection<? extends T> paramCollection, Action paramAction) {}
  
  void internalAddNotify()
  {
    stub = getStub();
    stub.resultChanged(null);
    super.internalAddNotify();
  }
  
  void internalRemoveNotify()
  {
    try
    {
      super.internalRemoveNotify();
    }
    finally
    {
      stub.removePropertyChangeListener(stubListener);
      stub = null;
    }
  }
  
  protected final void refresh()
  {
    getStub().resultChanged(null);
  }
  
  Collection<? extends T> stubCollection()
  {
    synchronized (lock())
    {
      return stub == null ? null : stub.collection();
    }
  }
  
  private class StubListener
    implements PropertyChangeListener
  {
    private StubListener() {}
    
    public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
    {
      firePropertyChange(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent.getOldValue(), paramPropertyChangeEvent.getNewValue());
    }
  }
  
  public static <T extends Lookup.Provider, R> ContextAction<T> createIndirectAction(Class<T> paramClass, ContextAction<R> paramContextAction, boolean paramBoolean)
  {
    return new IndirectAction(paramClass, paramContextAction, paramBoolean);
  }
  
  public static <T extends Lookup.Provider, R> ContextAction<T> createIndirectAction(Class<T> paramClass, ContextAction<R> paramContextAction)
  {
    return createIndirectAction(paramClass, paramContextAction, true);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.ContextAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

class IndirectAction$1 {}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.IndirectAction.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

final class IndirectAction$PCL
  implements PropertyChangeListener
{
  private IndirectAction$PCL(IndirectAction paramIndirectAction) {}
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    this$0.firePropertyChange(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent.getOldValue(), paramPropertyChangeEvent.getNewValue());
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.IndirectAction.PCL
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.swing.Action;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.Lookup.Result;
import org.openide.util.lookup.ProxyLookup;

final class IndirectAction<T extends Lookup.Provider, R>
  extends ContextAction<T>
{
  final ContextAction<R> delegate;
  private final IndirectAction<T, R>.PCL pcl = new PCL(null);
  private final boolean all;
  
  public IndirectAction(Class<T> paramClass, ContextAction<R> paramContextAction, boolean paramBoolean)
  {
    super(paramClass);
    delegate = paramContextAction;
    all = paramBoolean;
  }
  
  void internalAddNotify()
  {
    super.internalAddNotify();
    delegate.addPropertyChangeListener(pcl);
  }
  
  void internalRemoveNotify()
  {
    super.internalRemoveNotify();
    delegate.removePropertyChangeListener(pcl);
  }
  
  public Object getValue(String paramString)
  {
    Object localObject = super.getValue(paramString);
    if (localObject == null) {
      localObject = delegate.getValue(paramString);
    }
    return localObject;
  }
  
  private Lookup delegateLookup(Collection<? extends T> paramCollection)
  {
    LinkedList localLinkedList = new LinkedList();
    for (Object localObject = paramCollection.iterator(); ((Iterator)localObject).hasNext();)
    {
      Lookup.Provider localProvider = (Lookup.Provider)((Iterator)localObject).next();
      Lookup localLookup = localProvider.getLookup();
      if ((all) && (localLookup.lookupResult(delegate.type).allItems().size() == 0)) {
        return Lookup.EMPTY;
      }
      localLinkedList.add(localProvider.getLookup());
    }
    localObject = new ProxyLookup((Lookup[])localLinkedList.toArray(new Lookup[0]));
    return (Lookup)localObject;
  }
  
  protected void actionPerformed(Collection<? extends T> paramCollection)
  {
    Action localAction = delegate.createContextAwareInstance(delegateLookup(paramCollection));
    localAction.actionPerformed(null);
  }
  
  protected boolean isEnabled(Collection<? extends T> paramCollection)
  {
    Action localAction = delegate.createContextAwareInstance(delegateLookup(paramCollection));
    return localAction.isEnabled();
  }
  
  public boolean equals(Object paramObject)
  {
    return (paramObject != null) && (paramObject.getClass() == IndirectAction.class) && (delegate.equals(delegate));
  }
  
  public int hashCode()
  {
    return delegate.hashCode();
  }
  
  private final class PCL
    implements PropertyChangeListener
  {
    private PCL() {}
    
    public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
    {
      firePropertyChange(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent.getOldValue(), paramPropertyChangeEvent.getNewValue());
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.IndirectAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.util.Collection;

class LookupProviderAction$InternalDelegateAction
  extends ContextAction<R>
{
  public LookupProviderAction$InternalDelegateAction(Class<R> paramClass)
  {
    super(localClass);
  }
  
  protected void actionPerformed(Collection<? extends R> paramCollection)
  {
    this$0.perform(paramCollection);
  }
  
  protected boolean isEnabled(Collection<? extends R> paramCollection)
  {
    return this$0.enabled(paramCollection);
  }
  
  public Object getValue(String paramString)
  {
    Object localObject = super.getValue(paramString);
    if (localObject == null) {
      localObject = this$0.getValue(paramString);
    }
    return localObject;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.LookupProviderAction.InternalDelegateAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.Image;
import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.swing.Action;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.lookup.ProxyLookup;

public abstract class LookupProviderAction<T extends Lookup.Provider, R>
  extends ContextAction<T>
{
  private final Class<R> delegateType;
  private final boolean all;
  final ContextAction<R> overDelegateType;
  private boolean inDelegate;
  
  protected LookupProviderAction(Class<T> paramClass, Class<R> paramClass1, boolean paramBoolean)
  {
    super(paramClass);
    assert (paramClass1 != null);
    delegateType = paramClass1;
    all = paramBoolean;
    overDelegateType = new InternalDelegateAction(paramClass1);
  }
  
  protected LookupProviderAction(Class<T> paramClass, Class<R> paramClass1, boolean paramBoolean, String paramString, Image paramImage)
  {
    super(paramClass, paramString, paramImage);
    assert (paramClass1 != null);
    delegateType = paramClass1;
    all = paramBoolean;
    overDelegateType = new InternalDelegateAction(paramClass1);
  }
  
  protected final void actionPerformed(Collection<? extends T> paramCollection)
  {
    if (all)
    {
      localObject = delegates(paramCollection);
      assert ((localObject != null) && (!((Collection)localObject).isEmpty()));
    }
    Object localObject = overDelegateType.createContextAwareInstance(delegateLookup());
    
    assert (((Action)localObject).isEnabled());
    ((Action)localObject).actionPerformed((ActionEvent)null);
  }
  
  protected boolean checkQuantity(int paramInt)
  {
    return paramInt > 0;
  }
  
  private synchronized Lookup delegateLookup()
  {
    inDelegate = true;
    try
    {
      LinkedList localLinkedList = new LinkedList();
      Collection localCollection = super.getStub().collection();
      assert (localCollection != null);
      for (Object localObject1 = localCollection.iterator(); ((Iterator)localObject1).hasNext();)
      {
        localObject2 = (Lookup.Provider)((Iterator)localObject1).next();
        localLinkedList.add(((Lookup.Provider)localObject2).getLookup());
      }
      Object localObject2;
      localObject1 = (Lookup[])localLinkedList.toArray(new Lookup[0]);
      return new ProxyLookup((Lookup[])localObject1);
    }
    finally
    {
      inDelegate = false;
    }
  }
  
  private Set<? extends R> delegates(Collection<? extends T> paramCollection)
  {
    HashSet localHashSet = new HashSet();
    for (Lookup.Provider localProvider : paramCollection)
    {
      Collection localCollection = localProvider.getLookup().lookupAll(delegateType);
      if ((all) && (localCollection.isEmpty())) {
        return null;
      }
      localHashSet.addAll(localCollection);
    }
    return localHashSet;
  }
  
  protected abstract void perform(Collection<? extends R> paramCollection);
  
  protected boolean enabled(Collection<? extends R> paramCollection)
  {
    return true;
  }
  
  protected final boolean isEnabled(Collection<? extends T> paramCollection)
  {
    if (inDelegate) {
      return true;
    }
    boolean bool;
    if (all)
    {
      Set localSet = delegates(paramCollection);
      bool = (localSet != null) && (!localSet.isEmpty());
    }
    else
    {
      bool = true;
    }
    if (bool) {
      bool = overDelegateType.createContextAwareInstance(delegateLookup()).isEnabled();
    }
    return bool;
  }
  
  private class InternalDelegateAction
    extends ContextAction<R>
  {
    public InternalDelegateAction()
    {
      super();
    }
    
    protected void actionPerformed(Collection<? extends R> paramCollection)
    {
      perform(paramCollection);
    }
    
    protected boolean isEnabled(Collection<? extends R> paramCollection)
    {
      return enabled(paramCollection);
    }
    
    public Object getValue(String paramString)
    {
      Object localObject = super.getValue(paramString);
      if (localObject == null) {
        localObject = LookupProviderAction.this.getValue(paramString);
      }
      return localObject;
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.LookupProviderAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

class MergeAction$1
  implements NbAction.ActionRunnable<Boolean>
{
  MergeAction$1(MergeAction paramMergeAction) {}
  
  public Boolean run(NbAction paramNbAction)
  {
    return Boolean.valueOf(paramNbAction.isEnabled());
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.MergeAction.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

class MergeAction$2
  implements NbAction.ActionRunnable<Object>
{
  MergeAction$2(MergeAction paramMergeAction, String paramString) {}
  
  public Object run(NbAction paramNbAction)
  {
    return paramNbAction.getValue(val$key);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.MergeAction.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import org.openide.util.Lookup;
import org.openide.util.Parameters;

final class MergeAction
  extends NbAction
  implements PropertyChangeListener
{
  private NbAction[] actions;
  private Map<String, Object> knownValues = new HashMap();
  private Action delegateAction;
  private volatile boolean enabled;
  final boolean allowOnlyOne;
  boolean logged;
  
  public MergeAction(NbAction[] paramArrayOfNbAction, boolean paramBoolean)
  {
    actions = paramArrayOfNbAction;
    allowOnlyOne = paramBoolean;
    assert (paramArrayOfNbAction.length > 0);
    
    assert (new HashSet(Arrays.asList(paramArrayOfNbAction)).size() == paramArrayOfNbAction.length) : ("Duplicate actions in " + Arrays.asList(paramArrayOfNbAction));
    for (int i = 0; i < paramArrayOfNbAction.length; i++) {
      Parameters.notNull("Action " + i, paramArrayOfNbAction[i]);
    }
    knownValues.put("Name", null);
    knownValues.put("AcceleratorKey", null);
    knownValues.put("LongDescription", null);
    knownValues.put("SmallIcon", null);
    knownValues.put("ShortDescription", null);
    knownValues.put("LongDescription", null);
    knownValues.put("SmallIcon", null);
    knownValues.put("MnemonicKey", null);
    knownValues.put("noIconInMenu", null);
    knownValues.put("enabled", null);
  }
  
  public MergeAction(NbAction[] paramArrayOfNbAction)
  {
    this(paramArrayOfNbAction, false);
  }
  
  public boolean equals(Object paramObject)
  {
    return (paramObject != null) && (MergeAction.class == paramObject.getClass()) && (Arrays.equals(actions, actions));
  }
  
  public int hashCode()
  {
    return Arrays.hashCode(actions);
  }
  
  /* Error */
  Action updateDelegateAction()
  {
    // Byte code:
    //   0: aload_0
    //   1: dup
    //   2: astore_1
    //   3: monitorenter
    //   4: aload_0
    //   5: aload_0
    //   6: invokevirtual 38	org/netbeans/spi/actions/MergeAction:findEnabledAction	()Ljavax/swing/Action;
    //   9: invokevirtual 39	org/netbeans/spi/actions/MergeAction:setDelegateAction	(Ljavax/swing/Action;)Ljavax/swing/Action;
    //   12: aload_1
    //   13: monitorexit
    //   14: areturn
    //   15: astore_2
    //   16: aload_1
    //   17: monitorexit
    //   18: aload_2
    //   19: athrow
    // Line number table:
    //   Java source line #106	-> byte code offset #0
    //   Java source line #107	-> byte code offset #4
    //   Java source line #108	-> byte code offset #15
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	20	0	this	MergeAction
    //   2	15	1	Ljava/lang/Object;	Object
    //   15	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   4	14	15	finally
    //   15	18	15	finally
  }
  
  Action setDelegateAction(Action paramAction)
  {
    assert (Thread.holdsLock(this));
    synchronized (this)
    {
      Action localAction = delegateAction;
      if (localAction != paramAction)
      {
        delegateAction = paramAction;
        boolean bool = getDelegateAction().isEnabled();
        if (bool != enabled)
        {
          enabled = bool;
          firePropertyChange("enabled", Boolean.valueOf(!enabled), Boolean.valueOf(enabled));
        }
        if (paramAction != null) {
          sievePropertyChanges();
        }
      }
    }
    return paramAction;
  }
  
  Action findEnabledAction()
  {
    Object localObject = null;
    int i = 0;
    
    NbAction.ActionRunnable local1 = new NbAction.ActionRunnable()
    {
      public Boolean run(NbAction paramAnonymousNbAction)
      {
        return Boolean.valueOf(paramAnonymousNbAction.isEnabled());
      }
    };
    for (NbAction localNbAction : actions) {
      if (((Boolean)runActive(local1, localNbAction)).booleanValue())
      {
        i++;
        if (!allowOnlyOne)
        {
          localObject = localNbAction;
          break;
        }
        if (localObject == null) {
          localObject = localNbAction;
        }
      }
    }
    if ((allowOnlyOne) && (i > 1) && (localObject != null)) {
      localObject = null;
    }
    return (Action)localObject;
  }
  
  Action getDelegateAction()
  {
    Object localObject1 = null;
    synchronized (this)
    {
      localObject1 = delegateAction;
      if ((localObject1 == null) || (!((Action)localObject1).isEnabled())) {
        if (attached()) {
          localObject1 = updateDelegateAction();
        } else {
          localObject1 = findEnabledAction();
        }
      }
    }
    if (localObject1 == null) {
      localObject1 = actions[0];
    }
    return (Action)localObject1;
  }
  
  private void sievePropertyChanges()
  {
    HashMap localHashMap = new HashMap();
    for (String str : knownValues.keySet())
    {
      Object localObject1 = knownValues.get(str);
      Object localObject2 = getValue(str);
      if (localObject2 != localObject1)
      {
        localHashMap.put(str, localObject2);
        firePropertyChange(str, localObject1, localObject2);
      }
    }
  }
  
  protected synchronized void addNotify()
  {
    for (NbAction localNbAction : actions) {
      localNbAction.addPropertyChangeListener(this);
    }
    updateDelegateAction();
  }
  
  protected synchronized void removeNotify()
  {
    for (NbAction localNbAction : actions) {
      localNbAction.removePropertyChangeListener(this);
    }
    setDelegateAction(null);
  }
  
  protected NbAction internalCreateContextAwareInstance(Lookup paramLookup)
  {
    NbAction[] arrayOfNbAction = new NbAction[actions.length];
    for (int i = 0; i < arrayOfNbAction.length; i++) {
      arrayOfNbAction[i] = ((NbAction)actions[i].createContextAwareInstance(paramLookup));
    }
    MergeAction localMergeAction = new MergeAction(arrayOfNbAction, allowOnlyOne);
    knownValues.putAll(knownValues);
    pairs.putAll(pairs);
    return localMergeAction;
  }
  
  public Object getValue(final String paramString)
  {
    Object localObject1 = super.getValue(paramString);
    Object localObject2;
    if ((localObject1 == null) && 
      (isEnabled()))
    {
      localObject2 = getDelegateAction();
      localObject1 = ((Action)localObject2).getValue(paramString);
    }
    if (localObject1 == null)
    {
      localObject2 = new NbAction.ActionRunnable()
      {
        public Object run(NbAction paramAnonymousNbAction)
        {
          return paramAnonymousNbAction.getValue(paramString);
        }
      };
      for (NbAction localNbAction : actions)
      {
        localObject1 = runActive((NbAction.ActionRunnable)localObject2, localNbAction);
        if (localObject1 != null) {
          break;
        }
      }
    }
    knownValues.put(paramString, localObject1);
    return localObject1;
  }
  
  public void putValue(String paramString, Object paramObject)
  {
    if (!logged) {
      Logger.getLogger(MergeAction.class.getName()).log(Level.INFO, "putValue (" + paramString + ',' + paramObject + "called on merged action.  This is probably a mistake.");
    }
    super.putValue(paramString, paramObject);
  }
  
  public boolean isEnabled()
  {
    boolean bool = updateEnabled();
    return bool;
  }
  
  boolean updateEnabled()
  {
    enabled = getDelegateAction().isEnabled();
    if ((allowOnlyOne) && (enabled) && 
      (findEnabledAction() == null)) {
      enabled = false;
    }
    return enabled;
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    Action localAction = getDelegateAction();
    if (localAction == null) {
      throw new IllegalStateException("Not enabled or no delegate: " + this);
    }
    localAction.actionPerformed(paramActionEvent);
  }
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    Object localObject1 = enabled;
    synchronized (this)
    {
      if (attached()) {
        updateDelegateAction();
      }
    }
    ??? = isEnabled();
    if (!"enabled".equals(paramPropertyChangeEvent.getPropertyName()))
    {
      Object localObject3 = knownValues.get(paramPropertyChangeEvent.getPropertyName());
      Object localObject4 = getValue(paramPropertyChangeEvent.getPropertyName());
      if (localObject4 != localObject3) {
        firePropertyChange(paramPropertyChangeEvent.getPropertyName(), localObject3, localObject4);
      }
      knownValues.put(paramPropertyChangeEvent.getPropertyName(), paramPropertyChangeEvent.getNewValue());
    }
    if (localObject1 != ???) {
      firePropertyChange("enabled", Boolean.valueOf(localObject1), Boolean.valueOf(???));
    }
  }
  
  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder(super.toString());
    localStringBuilder.append('[');
    for (int i = 0; i < actions.length; i++)
    {
      localStringBuilder.append(actions[i]);
      if (i != actions.length - 1) {
        localStringBuilder.append(',');
      }
    }
    localStringBuilder.append(']');
    return localStringBuilder.toString();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.MergeAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

abstract interface NbAction$ActionRunnable<T>
{
  public abstract T run(NbAction paramNbAction);
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.NbAction.ActionRunnable
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Action;
import org.openide.util.ContextAwareAction;
import org.openide.util.Lookup;

public abstract class NbAction
  implements ContextAwareAction
{
  private final PropertyChangeSupport supp;
  final Map<String, Object> pairs;
  private final Object STATE_LOCK;
  private volatile boolean attached;
  public static final String PROP_ENABLED = "enabled";
  
  public NbAction()
  {
    supp = new PropertyChangeSupport(this);
    pairs = Collections.synchronizedMap(new HashMap());
    STATE_LOCK = new Object();
  }
  
  boolean attached()
  {
    return attached;
  }
  
  Object lock()
  {
    return STATE_LOCK;
  }
  
  protected void addNotify() {}
  
  protected void removeNotify() {}
  
  void internalAddNotify()
  {
    addNotify();
  }
  
  void internalRemoveNotify()
  {
    removeNotify();
  }
  
  protected final void firePropertyChange(String paramString, Object paramObject1, Object paramObject2)
  {
    supp.firePropertyChange(paramString, paramObject1, paramObject2);
  }
  
  <T> T runActive(ActionRunnable<T> paramActionRunnable, NbAction paramNbAction)
  {
    boolean bool = paramNbAction.attached();
    try
    {
      if (!bool) {
        paramNbAction.internalAddNotify();
      }
      return (T)paramActionRunnable.run(paramNbAction);
    }
    finally
    {
      if (!bool) {
        paramNbAction.internalRemoveNotify();
      }
    }
  }
  
  public Object getValue(String paramString)
  {
    return pairs.get(paramString);
  }
  
  public void putValue(String paramString, Object paramObject)
  {
    Object localObject = pairs.put(paramString, paramObject);
    int i = (localObject == null ? 1 : 0) != (paramObject == null ? 1 : 0) ? 1 : 0;
    if (i != 0)
    {
      i = ((paramObject != null) && (!paramObject.equals(localObject))) || ((localObject != null) && (localObject.equals(paramObject))) ? 1 : 0;
      if (i != 0) {
        supp.firePropertyChange(paramString, localObject, paramObject);
      }
    }
  }
  
  public final void setEnabled(boolean paramBoolean)
  {
    throw new UnsupportedOperationException("Illegal");
  }
  
  public final void addPropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    supp.addPropertyChangeListener(paramPropertyChangeListener);
    if (supp.getPropertyChangeListeners().length == 1)
    {
      attached = true;
      internalAddNotify();
    }
  }
  
  public final void removePropertyChangeListener(PropertyChangeListener paramPropertyChangeListener)
  {
    supp.removePropertyChangeListener(paramPropertyChangeListener);
    if (supp.getPropertyChangeListeners().length == 0)
    {
      attached = false;
      internalRemoveNotify();
    }
  }
  
  public final Action createContextAwareInstance(Lookup paramLookup)
  {
    return internalCreateContextAwareInstance(paramLookup);
  }
  
  protected NbAction internalCreateContextAwareInstance(Lookup paramLookup)
  {
    return this;
  }
  
  public static NbAction merge(boolean paramBoolean, NbAction... paramVarArgs)
  {
    return new MergeAction(paramVarArgs, paramBoolean);
  }
  
  public static NbAction merge(NbAction... paramVarArgs)
  {
    return new MergeAction(paramVarArgs);
  }
  
  static abstract interface ActionRunnable<T>
  {
    public abstract T run(NbAction paramNbAction);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.NbAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.util.Collection;
import org.openide.util.Lookup;

final class RetainingStub<T>
  extends ActionStub<T>
{
  Collection<? extends T> retained;
  
  RetainingStub(Lookup paramLookup, SurviveSelectionChange<T> paramSurviveSelectionChange)
  {
    super(paramLookup, paramSurviveSelectionChange);
    assert (paramSurviveSelectionChange != null);
    assert (paramLookup != null);
    retained = super.collection();
    assert (retained != null);
    enabled = isEnabled();
  }
  
  Collection<? extends T> collection()
  {
    boolean bool = enabled;
    if (bool)
    {
      Collection localCollection = super.collection();
      assert (localCollection != null);
      if (!parent.checkQuantity(localCollection)) {
        retained = localCollection;
      }
      if (!localCollection.isEmpty()) {
        retained = localCollection;
      }
    }
    return retained;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.RetainingStub
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.Image;
import java.util.Collection;
import java.util.Iterator;

public abstract class Single<T>
  extends ContextAction<T>
{
  protected Single(Class<T> paramClass)
  {
    super(paramClass);
  }
  
  protected Single(Class<T> paramClass, String paramString, Image paramImage)
  {
    super(paramClass, paramString, paramImage);
  }
  
  protected final void actionPerformed(Collection<? extends T> paramCollection)
  {
    actionPerformed(paramCollection.iterator().next());
  }
  
  protected abstract void actionPerformed(T paramT);
  
  protected final boolean checkQuantity(int paramInt)
  {
    return paramInt == 1;
  }
  
  protected final boolean isEnabled(Collection<? extends T> paramCollection)
  {
    assert (!paramCollection.isEmpty());
    return isEnabled(paramCollection.iterator().next());
  }
  
  protected boolean isEnabled(T paramT)
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.Single
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.actions;

import java.awt.Image;
import java.util.Collection;
import org.openide.util.Lookup;

public abstract class SurviveSelectionChange<T>
  extends ContextAction<T>
{
  protected SurviveSelectionChange(Class<T> paramClass)
  {
    super(paramClass);
  }
  
  protected SurviveSelectionChange(Class<T> paramClass, String paramString, Image paramImage)
  {
    super(paramClass, paramString, paramImage);
  }
  
  ActionStub<T> createStub(Lookup paramLookup)
  {
    return new RetainingStub(paramLookup, this);
  }
  
  boolean checkQuantity(Collection<? extends T> paramCollection)
  {
    return (super.checkQuantity(paramCollection)) || ((stub != null) && (super.checkQuantity(stub).retained)));
  }
}

/* Location:
 * Qualified Name:     org.netbeans.spi.actions.SurviveSelectionChange
 * Java Class Version: 6 (50.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