org-openide-dialogs

16:40:28.401 INFO  jd.cli.Main - Decompiling org-openide-dialogs.jar
package org.openide;

import java.awt.event.ActionListener;
import java.util.ResourceBundle;
import org.openide.util.HelpCtx;
import org.openide.util.HelpCtx.Provider;
import org.openide.util.NbBundle;

public class DialogDescriptor
  extends NotifyDescriptor
  implements HelpCtx.Provider
{
  public static final String PROP_OPTIONS_ALIGN = "optionsAlign";
  public static final String PROP_MODAL = "modal";
  public static final String PROP_LEAF = "leaf";
  public static final String PROP_HELP_CTX = "helpCtx";
  public static final String PROP_BUTTON_LISTENER = "buttonListener";
  public static final String PROP_CLOSING_OPTIONS = "closingOptions";
  public static final int BOTTOM_ALIGN = 0;
  public static final int RIGHT_ALIGN = 1;
  public static final int DEFAULT_ALIGN = 0;
  private static final Object[] DEFAULT_CLOSING_OPTIONS = { YES_OPTION, NO_OPTION, CANCEL_OPTION, OK_OPTION };
  private boolean leaf = false;
  private boolean modal;
  private int optionsAlign;
  private HelpCtx helpCtx;
  private ActionListener buttonListener;
  private Object[] closingOptions = DEFAULT_CLOSING_OPTIONS;
  
  public DialogDescriptor(Object paramObject, String paramString)
  {
    this(paramObject, paramString, true, 2, OK_OPTION, 0, null, null);
  }
  
  public DialogDescriptor(Object paramObject, String paramString, boolean paramBoolean, ActionListener paramActionListener)
  {
    this(paramObject, paramString, paramBoolean, 2, OK_OPTION, 0, null, paramActionListener);
  }
  
  public DialogDescriptor(Object paramObject1, String paramString, boolean paramBoolean, int paramInt, Object paramObject2, ActionListener paramActionListener)
  {
    this(paramObject1, paramString, paramBoolean, paramInt, paramObject2, 0, null, paramActionListener);
  }
  
  public DialogDescriptor(Object paramObject1, String paramString, boolean paramBoolean, Object[] paramArrayOfObject, Object paramObject2, int paramInt, HelpCtx paramHelpCtx, ActionListener paramActionListener)
  {
    super(paramObject1, paramString, -1, -1, paramArrayOfObject, paramObject2);
    modal = paramBoolean;
    optionsAlign = paramInt;
    helpCtx = (paramHelpCtx == null ? HelpCtx.DEFAULT_HELP : paramHelpCtx);
    buttonListener = paramActionListener;
    if (paramActionListener == null) {
      setClosingOptions(paramArrayOfObject);
    }
  }
  
  public DialogDescriptor(Object paramObject1, String paramString, boolean paramBoolean1, Object[] paramArrayOfObject, Object paramObject2, int paramInt, HelpCtx paramHelpCtx, ActionListener paramActionListener, boolean paramBoolean2)
  {
    super(paramObject1, paramString, -1, -1, paramArrayOfObject, paramObject2);
    modal = paramBoolean1;
    optionsAlign = paramInt;
    helpCtx = (paramHelpCtx == null ? HelpCtx.DEFAULT_HELP : paramHelpCtx);
    buttonListener = paramActionListener;
    leaf = paramBoolean2;
    if (paramActionListener == null) {
      setClosingOptions(paramArrayOfObject);
    }
  }
  
  public DialogDescriptor(Object paramObject1, String paramString, boolean paramBoolean, int paramInt1, Object paramObject2, int paramInt2, HelpCtx paramHelpCtx, ActionListener paramActionListener)
  {
    super(paramObject1, paramString, paramInt1, -1, null, paramObject2);
    modal = paramBoolean;
    optionsAlign = paramInt2;
    helpCtx = (paramHelpCtx == null ? HelpCtx.DEFAULT_HELP : paramHelpCtx);
    buttonListener = paramActionListener;
    if (paramActionListener == null) {
      setClosingOptions(null);
    }
  }
  
  public int getOptionsAlign()
  {
    getterCalled();
    
    return optionsAlign;
  }
  
  public void setOptionsAlign(int paramInt)
  {
    if ((paramInt != 0) && (paramInt != 1)) {
      throw new IllegalArgumentException(NbBundle.getBundle(DialogDescriptor.class).getString("EXC_OptionsAlign"));
    }
    if (optionsAlign == paramInt) {
      return;
    }
    int i = optionsAlign;
    optionsAlign = paramInt;
    firePropertyChange("optionsAlign", new Integer(i), new Integer(paramInt));
  }
  
  public boolean isModal()
  {
    getterCalled();
    
    return modal;
  }
  
  public void setModal(boolean paramBoolean)
  {
    if (modal == paramBoolean) {
      return;
    }
    boolean bool = modal;
    modal = paramBoolean;
    firePropertyChange("modal", Boolean.valueOf(bool), Boolean.valueOf(paramBoolean));
  }
  
  public boolean isLeaf()
  {
    getterCalled();
    
    return leaf;
  }
  
  public void setLeaf(boolean paramBoolean)
  {
    if (leaf == paramBoolean) {
      return;
    }
    boolean bool = leaf;
    leaf = paramBoolean;
    firePropertyChange("leaf", Boolean.valueOf(bool), Boolean.valueOf(paramBoolean));
  }
  
  public void setClosingOptions(Object[] paramArrayOfObject)
  {
    Object[] arrayOfObject = closingOptions;
    closingOptions = paramArrayOfObject;
    
    firePropertyChange("closingOptions", arrayOfObject, paramArrayOfObject);
  }
  
  public Object[] getClosingOptions()
  {
    getterCalled();
    
    return closingOptions;
  }
  
  public HelpCtx getHelpCtx()
  {
    getterCalled();
    
    return helpCtx;
  }
  
  public void setHelpCtx(HelpCtx paramHelpCtx)
  {
    if ((helpCtx != null) && (helpCtx.equals(paramHelpCtx))) {
      return;
    }
    HelpCtx localHelpCtx = helpCtx;
    helpCtx = paramHelpCtx;
    firePropertyChange("helpCtx", localHelpCtx, paramHelpCtx);
  }
  
  public ActionListener getButtonListener()
  {
    getterCalled();
    
    return buttonListener;
  }
  
  public void setButtonListener(ActionListener paramActionListener)
  {
    if (buttonListener == paramActionListener) {
      return;
    }
    ActionListener localActionListener = buttonListener;
    buttonListener = paramActionListener;
    firePropertyChange("buttonListener", localActionListener, paramActionListener);
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDescriptor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

class DialogDisplayer$1
  implements Runnable
{
  DialogDisplayer$1(DialogDisplayer paramDialogDisplayer, NotifyDescriptor paramNotifyDescriptor) {}
  
  public void run()
  {
    this$0.notify(val$descriptor);
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.beans.PropertyChangeEvent;

class DialogDisplayer$Trivial$DialogUpdater$1
  implements Runnable
{
  DialogDisplayer$Trivial$DialogUpdater$1(DialogDisplayer.Trivial.DialogUpdater paramDialogUpdater, PropertyChangeEvent paramPropertyChangeEvent) {}
  
  public void run()
  {
    this$0.propertyChange(val$ev);
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.DialogUpdater.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.SwingUtilities;

class DialogDisplayer$Trivial$DialogUpdater
  implements PropertyChangeListener
{
  private DialogDisplayer.Trivial.StandardDialog dialog;
  private DialogDescriptor dd;
  
  public DialogDisplayer$Trivial$DialogUpdater(DialogDisplayer.Trivial.StandardDialog paramStandardDialog, DialogDescriptor paramDialogDescriptor)
  {
    dialog = paramStandardDialog;
    dd = paramDialogDescriptor;
  }
  
  public void propertyChange(final PropertyChangeEvent paramPropertyChangeEvent)
  {
    if (!SwingUtilities.isEventDispatchThread())
    {
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          propertyChange(paramPropertyChangeEvent);
        }
      });
      return;
    }
    String str = paramPropertyChangeEvent.getPropertyName();
    if ("title".equals(str))
    {
      dialog.setTitle(dd.getTitle());
    }
    else if ("message".equals(str))
    {
      dialog.updateMessage();
      dialog.validate();
      dialog.repaint();
    }
    else if (("options".equals(str)) || ("optionType".equals(str)))
    {
      dialog.updateOptions();
      dialog.validate();
      dialog.repaint();
    }
    else if ("infoNotification".equals(paramPropertyChangeEvent.getPropertyName()))
    {
      DialogDisplayer.Trivial.access$400(dialog, 3, paramPropertyChangeEvent.getNewValue());
    }
    else if ("warningNotification".equals(paramPropertyChangeEvent.getPropertyName()))
    {
      DialogDisplayer.Trivial.access$400(dialog, 2, paramPropertyChangeEvent.getNewValue());
    }
    else if ("errorNotification".equals(paramPropertyChangeEvent.getPropertyName()))
    {
      DialogDisplayer.Trivial.access$400(dialog, 1, paramPropertyChangeEvent.getNewValue());
    }
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.DialogUpdater
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.Dimension;
import java.awt.Image;
import javax.swing.JLabel;
import org.openide.util.ImageUtilities;

final class DialogDisplayer$Trivial$FixedHeightLabel
  extends JLabel
{
  private static final int ESTIMATED_HEIGHT = 16;
  
  public Dimension getPreferredSize()
  {
    Dimension localDimension = super.getPreferredSize();
    assert (16 == ImageUtilities.loadImage("org/netbeans/modules/dialogs/warning.gif").getHeight(null)) : "Use only 16px icon.";
    height = Math.max(16, height);
    return localDimension;
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.FixedHeightLabel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;

class DialogDisplayer$Trivial$StandardDialog$1
  extends AbstractAction
{
  DialogDisplayer$Trivial$StandardDialog$1(DialogDisplayer.Trivial.StandardDialog paramStandardDialog) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    DialogDisplayer.Trivial.StandardDialog.access$100(this$0);
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.StandardDialog.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

class DialogDisplayer$Trivial$StandardDialog$2
  extends WindowAdapter
{
  DialogDisplayer$Trivial$StandardDialog$2(DialogDisplayer.Trivial.StandardDialog paramStandardDialog) {}
  
  public void windowClosing(WindowEvent paramWindowEvent)
  {
    if (!DialogDisplayer.Trivial.StandardDialog.access$200(this$0)) {
      this$0.nd.setValue(NotifyDescriptor.CLOSED_OPTION);
    }
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.StandardDialog.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.List;

class DialogDisplayer$Trivial$StandardDialog$3
  implements ActionListener
{
  DialogDisplayer$Trivial$StandardDialog$3(DialogDisplayer.Trivial.StandardDialog paramStandardDialog, Object paramObject) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    this$0.nd.setValue(val$option);
    if (DialogDisplayer.Trivial.StandardDialog.access$600(this$0) != null)
    {
      ActionEvent localActionEvent = new ActionEvent(val$option, paramActionEvent.getID(), paramActionEvent.getActionCommand(), paramActionEvent.getWhen(), paramActionEvent.getModifiers());
      
      DialogDisplayer.Trivial.StandardDialog.access$600(this$0).actionPerformed(localActionEvent);
    }
    if ((DialogDisplayer.Trivial.StandardDialog.access$700(this$0) == null) || (Arrays.asList(DialogDisplayer.Trivial.StandardDialog.access$700(this$0)).contains(val$option)))
    {
      DialogDisplayer.Trivial.StandardDialog.access$202(this$0, true);
      this$0.setVisible(false);
    }
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.StandardDialog.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import org.openide.util.Utilities;

final class DialogDisplayer$Trivial$StandardDialog
  extends JDialog
{
  final NotifyDescriptor nd;
  private Component messageComponent;
  private final JPanel buttonPanel;
  private final Object[] closingOptions;
  private final ActionListener buttonListener;
  private boolean haveFinalValue = false;
  private Color nbErrorForeground;
  private Color nbWarningForeground;
  private Color nbInfoForeground;
  private JLabel notificationLine;
  private static final int MSG_TYPE_ERROR = 1;
  private static final int MSG_TYPE_WARNING = 2;
  private static final int MSG_TYPE_INFO = 3;
  
  public DialogDisplayer$Trivial$StandardDialog(String paramString, boolean paramBoolean, NotifyDescriptor paramNotifyDescriptor, Object[] paramArrayOfObject, ActionListener paramActionListener)
  {
    super((Frame)null, paramString, paramBoolean);
    nd = paramNotifyDescriptor;
    closingOptions = paramArrayOfObject;
    buttonListener = paramActionListener;
    getContentPane().setLayout(new BorderLayout());
    setDefaultCloseOperation(2);
    updateMessage();
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(2));
    updateOptions();
    getContentPane().add(buttonPanel, "South", 1);
    
    KeyStroke localKeyStroke = KeyStroke.getKeyStroke(27, 0);
    String str = "cancel";
    getRootPane().getInputMap(1).put(localKeyStroke, str);
    
    AbstractAction local1 = new AbstractAction()
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        DialogDisplayer.Trivial.StandardDialog.this.cancel();
      }
    };
    getRootPane().getActionMap().put(str, local1);
    addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent paramAnonymousWindowEvent)
      {
        if (!haveFinalValue) {
          nd.setValue(NotifyDescriptor.CLOSED_OPTION);
        }
      }
    });
    pack();
    
    Rectangle localRectangle = Utilities.getUsableScreenBounds();
    int i = width * 9 / 10;
    int j = height * 9 / 10;
    Dimension localDimension = getPreferredSize();
    width = Math.min(width, i);
    height = Math.min(height, j);
    setBounds(Utilities.findCenterBounds(localDimension));
  }
  
  private void cancel()
  {
    nd.setValue(NotifyDescriptor.CANCEL_OPTION);
    haveFinalValue = true;
    dispose();
  }
  
  public void updateMessage()
  {
    if (messageComponent != null) {
      getContentPane().remove(messageComponent);
    }
    messageComponent = DialogDisplayer.Trivial.access$300(nd.getMessage());
    if ((!(nd instanceof WizardDescriptor)) && (nd.getNotificationLineSupport() != null))
    {
      JPanel localJPanel = new JPanel(new BorderLayout());
      localJPanel.add(messageComponent, "Center");
      
      nbErrorForeground = UIManager.getColor("nb.errorForeground");
      if (nbErrorForeground == null) {
        nbErrorForeground = new Color(255, 0, 0);
      }
      nbWarningForeground = UIManager.getColor("nb.warningForeground");
      if (nbWarningForeground == null) {
        nbWarningForeground = new Color(51, 51, 51);
      }
      nbInfoForeground = UIManager.getColor("nb.warningForeground");
      if (nbInfoForeground == null) {
        nbInfoForeground = UIManager.getColor("Label.foreground");
      }
      notificationLine = new DialogDisplayer.Trivial.FixedHeightLabel();
      NotificationLineSupport localNotificationLineSupport = nd.getNotificationLineSupport();
      if (localNotificationLineSupport.getInformationMessage() != null) {
        DialogDisplayer.Trivial.access$400(this, 3, localNotificationLineSupport.getInformationMessage());
      } else if (localNotificationLineSupport.getWarningMessage() != null) {
        DialogDisplayer.Trivial.access$400(this, 2, localNotificationLineSupport.getWarningMessage());
      } else if (localNotificationLineSupport.getErrorMessage() != null) {
        DialogDisplayer.Trivial.access$400(this, 1, localNotificationLineSupport.getErrorMessage());
      }
      localJPanel.add(notificationLine, "South");
      messageComponent = localJPanel;
    }
    getContentPane().add(messageComponent, "Center");
  }
  
  public void updateOptions()
  {
    HashSet localHashSet = new HashSet(5);
    Object[] arrayOfObject = nd.getOptions();
    if (arrayOfObject == null) {
      switch (nd.getOptionType())
      {
      case -1: 
      case 2: 
        arrayOfObject = new Object[] { NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION };
        
        break;
      case 0: 
        arrayOfObject = new Object[] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION };
        
        break;
      case 1: 
        arrayOfObject = new Object[] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION, NotifyDescriptor.CANCEL_OPTION };
        
        break;
      default: 
        throw new IllegalArgumentException();
      }
    }
    buttonPanel.removeAll();
    
    JRootPane localJRootPane = getRootPane();
    for (int i = 0; i < arrayOfObject.length; i++)
    {
      localHashSet.add(arrayOfObject[i]);
      buttonPanel.add(DialogDisplayer.Trivial.access$500(arrayOfObject[i], nd, makeListener(arrayOfObject[i]), localJRootPane));
    }
    arrayOfObject = nd.getAdditionalOptions();
    if (arrayOfObject != null) {
      for (i = 0; i < arrayOfObject.length; i++)
      {
        localHashSet.add(arrayOfObject[i]);
        buttonPanel.add(DialogDisplayer.Trivial.access$500(arrayOfObject[i], nd, makeListener(arrayOfObject[i]), localJRootPane));
      }
    }
    if (closingOptions != null) {
      for (i = 0; i < closingOptions.length; i++) {
        if (localHashSet.add(closingOptions[i]))
        {
          ActionListener localActionListener = makeListener(closingOptions[i]);
          attachActionListener(closingOptions[i], localActionListener);
        }
      }
    }
  }
  
  private void attachActionListener(Object paramObject, ActionListener paramActionListener)
  {
    Object localObject;
    if ((paramObject instanceof JButton))
    {
      localObject = (JButton)paramObject;
      ((JButton)localObject).addActionListener(paramActionListener);
      
      return;
    }
    try
    {
      localObject = paramObject.getClass().getMethod("addActionListener", new Class[] { ActionListener.class });
      try
      {
        ((Method)localObject).setAccessible(true);
      }
      catch (SecurityException localSecurityException1)
      {
        localObject = null;
      }
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      localObject = null;
    }
    catch (SecurityException localSecurityException2)
    {
      localObject = null;
    }
    if (localObject != null) {
      try
      {
        ((Method)localObject).invoke(paramObject, new Object[] { paramActionListener });
      }
      catch (Exception localException) {}
    }
  }
  
  private ActionListener makeListener(final Object paramObject)
  {
    new ActionListener()
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        nd.setValue(paramObject);
        if (buttonListener != null)
        {
          ActionEvent localActionEvent = new ActionEvent(paramObject, paramAnonymousActionEvent.getID(), paramAnonymousActionEvent.getActionCommand(), paramAnonymousActionEvent.getWhen(), paramAnonymousActionEvent.getModifiers());
          
          buttonListener.actionPerformed(localActionEvent);
        }
        if ((closingOptions == null) || (Arrays.asList(closingOptions).contains(paramObject)))
        {
          haveFinalValue = true;
          setVisible(false);
        }
      }
    };
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial.StandardDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.accessibility.AccessibleContext;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.ActionMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.openide.util.ImageUtilities;
import org.openide.util.Utilities;

final class DialogDisplayer$Trivial
  extends DialogDisplayer
{
  public Object notify(NotifyDescriptor paramNotifyDescriptor)
  {
    StandardDialog localStandardDialog = new StandardDialog(paramNotifyDescriptor.getTitle(), true, paramNotifyDescriptor, null, null);
    localStandardDialog.setVisible(true);
    
    return paramNotifyDescriptor.getValue() != null ? paramNotifyDescriptor.getValue() : NotifyDescriptor.CLOSED_OPTION;
  }
  
  public Dialog createDialog(DialogDescriptor paramDialogDescriptor)
  {
    StandardDialog localStandardDialog = new StandardDialog(paramDialogDescriptor.getTitle(), paramDialogDescriptor.isModal(), paramDialogDescriptor, paramDialogDescriptor.getClosingOptions(), paramDialogDescriptor.getButtonListener());
    
    paramDialogDescriptor.addPropertyChangeListener(new DialogUpdater(localStandardDialog, paramDialogDescriptor));
    
    return localStandardDialog;
  }
  
  private static Component message2Component(Object paramObject)
  {
    if ((paramObject instanceof Component)) {
      return (Component)paramObject;
    }
    if ((paramObject instanceof Object[]))
    {
      localObject1 = (Object[])paramObject;
      localObject2 = new JPanel();
      ((JPanel)localObject2).setLayout(new FlowLayout());
      for (int i = 0; i < localObject1.length; i++) {
        ((JPanel)localObject2).add(message2Component(localObject1[i]));
      }
      return (Component)localObject2;
    }
    if ((paramObject instanceof Icon)) {
      return new JLabel((Icon)paramObject);
    }
    Object localObject1 = paramObject.toString();
    Object localObject2 = new JTextArea((String)localObject1);
    Color localColor = UIManager.getColor("Label.background");
    if (localColor != null) {
      ((JTextArea)localObject2).setBackground(localColor);
    }
    ((JTextArea)localObject2).setLineWrap(true);
    ((JTextArea)localObject2).setWrapStyleWord(true);
    ((JTextArea)localObject2).setEditable(false);
    ((JTextArea)localObject2).setTabSize(4);
    
    ((JTextArea)localObject2).setColumns(40);
    if (((String)localObject1).indexOf('\n') != -1) {
      return new JScrollPane((Component)localObject2);
    }
    return (Component)localObject2;
  }
  
  private static Component option2Button(Object paramObject, NotifyDescriptor paramNotifyDescriptor, ActionListener paramActionListener, JRootPane paramJRootPane)
  {
    Object localObject;
    if ((paramObject instanceof AbstractButton))
    {
      localObject = (AbstractButton)paramObject;
      ((AbstractButton)localObject).addActionListener(paramActionListener);
      
      return (Component)localObject;
    }
    if ((paramObject instanceof Component)) {
      return (Component)paramObject;
    }
    if ((paramObject instanceof Icon)) {
      return new JLabel((Icon)paramObject);
    }
    int i;
    if (paramObject == NotifyDescriptor.OK_OPTION)
    {
      localObject = "OK";
      i = 1;
    }
    else if (paramObject == NotifyDescriptor.CANCEL_OPTION)
    {
      localObject = "Cancel";
      i = 0;
    }
    else if (paramObject == NotifyDescriptor.YES_OPTION)
    {
      localObject = "Yes";
      i = 1;
    }
    else if (paramObject == NotifyDescriptor.NO_OPTION)
    {
      localObject = "No";
      i = 0;
    }
    else
    {
      if (paramObject == NotifyDescriptor.CLOSED_OPTION) {
        throw new IllegalArgumentException();
      }
      localObject = paramObject.toString();
      i = 0;
    }
    JButton localJButton = new JButton((String)localObject);
    if ((i != 0) && (paramJRootPane.getDefaultButton() == null)) {
      paramJRootPane.setDefaultButton(localJButton);
    }
    localJButton.getAccessibleContext().setAccessibleName((String)localObject);
    localJButton.addActionListener(paramActionListener);
    
    return localJButton;
  }
  
  private static final class StandardDialog
    extends JDialog
  {
    final NotifyDescriptor nd;
    private Component messageComponent;
    private final JPanel buttonPanel;
    private final Object[] closingOptions;
    private final ActionListener buttonListener;
    private boolean haveFinalValue = false;
    private Color nbErrorForeground;
    private Color nbWarningForeground;
    private Color nbInfoForeground;
    private JLabel notificationLine;
    private static final int MSG_TYPE_ERROR = 1;
    private static final int MSG_TYPE_WARNING = 2;
    private static final int MSG_TYPE_INFO = 3;
    
    public StandardDialog(String paramString, boolean paramBoolean, NotifyDescriptor paramNotifyDescriptor, Object[] paramArrayOfObject, ActionListener paramActionListener)
    {
      super(paramString, paramBoolean);
      nd = paramNotifyDescriptor;
      closingOptions = paramArrayOfObject;
      buttonListener = paramActionListener;
      getContentPane().setLayout(new BorderLayout());
      setDefaultCloseOperation(2);
      updateMessage();
      buttonPanel = new JPanel();
      buttonPanel.setLayout(new FlowLayout(2));
      updateOptions();
      getContentPane().add(buttonPanel, "South", 1);
      
      KeyStroke localKeyStroke = KeyStroke.getKeyStroke(27, 0);
      String str = "cancel";
      getRootPane().getInputMap(1).put(localKeyStroke, str);
      
      AbstractAction local1 = new AbstractAction()
      {
        public void actionPerformed(ActionEvent paramAnonymousActionEvent)
        {
          DialogDisplayer.Trivial.StandardDialog.this.cancel();
        }
      };
      getRootPane().getActionMap().put(str, local1);
      addWindowListener(new WindowAdapter()
      {
        public void windowClosing(WindowEvent paramAnonymousWindowEvent)
        {
          if (!haveFinalValue) {
            nd.setValue(NotifyDescriptor.CLOSED_OPTION);
          }
        }
      });
      pack();
      
      Rectangle localRectangle = Utilities.getUsableScreenBounds();
      int i = width * 9 / 10;
      int j = height * 9 / 10;
      Dimension localDimension = getPreferredSize();
      width = Math.min(width, i);
      height = Math.min(height, j);
      setBounds(Utilities.findCenterBounds(localDimension));
    }
    
    private void cancel()
    {
      nd.setValue(NotifyDescriptor.CANCEL_OPTION);
      haveFinalValue = true;
      dispose();
    }
    
    public void updateMessage()
    {
      if (messageComponent != null) {
        getContentPane().remove(messageComponent);
      }
      messageComponent = DialogDisplayer.Trivial.message2Component(nd.getMessage());
      if ((!(nd instanceof WizardDescriptor)) && (nd.getNotificationLineSupport() != null))
      {
        JPanel localJPanel = new JPanel(new BorderLayout());
        localJPanel.add(messageComponent, "Center");
        
        nbErrorForeground = UIManager.getColor("nb.errorForeground");
        if (nbErrorForeground == null) {
          nbErrorForeground = new Color(255, 0, 0);
        }
        nbWarningForeground = UIManager.getColor("nb.warningForeground");
        if (nbWarningForeground == null) {
          nbWarningForeground = new Color(51, 51, 51);
        }
        nbInfoForeground = UIManager.getColor("nb.warningForeground");
        if (nbInfoForeground == null) {
          nbInfoForeground = UIManager.getColor("Label.foreground");
        }
        notificationLine = new DialogDisplayer.Trivial.FixedHeightLabel();
        NotificationLineSupport localNotificationLineSupport = nd.getNotificationLineSupport();
        if (localNotificationLineSupport.getInformationMessage() != null) {
          DialogDisplayer.Trivial.updateNotificationLine(this, 3, localNotificationLineSupport.getInformationMessage());
        } else if (localNotificationLineSupport.getWarningMessage() != null) {
          DialogDisplayer.Trivial.updateNotificationLine(this, 2, localNotificationLineSupport.getWarningMessage());
        } else if (localNotificationLineSupport.getErrorMessage() != null) {
          DialogDisplayer.Trivial.updateNotificationLine(this, 1, localNotificationLineSupport.getErrorMessage());
        }
        localJPanel.add(notificationLine, "South");
        messageComponent = localJPanel;
      }
      getContentPane().add(messageComponent, "Center");
    }
    
    public void updateOptions()
    {
      HashSet localHashSet = new HashSet(5);
      Object[] arrayOfObject = nd.getOptions();
      if (arrayOfObject == null) {
        switch (nd.getOptionType())
        {
        case -1: 
        case 2: 
          arrayOfObject = new Object[] { NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION };
          
          break;
        case 0: 
          arrayOfObject = new Object[] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION };
          
          break;
        case 1: 
          arrayOfObject = new Object[] { NotifyDescriptor.YES_OPTION, NotifyDescriptor.NO_OPTION, NotifyDescriptor.CANCEL_OPTION };
          
          break;
        default: 
          throw new IllegalArgumentException();
        }
      }
      buttonPanel.removeAll();
      
      JRootPane localJRootPane = getRootPane();
      for (int i = 0; i < arrayOfObject.length; i++)
      {
        localHashSet.add(arrayOfObject[i]);
        buttonPanel.add(DialogDisplayer.Trivial.option2Button(arrayOfObject[i], nd, makeListener(arrayOfObject[i]), localJRootPane));
      }
      arrayOfObject = nd.getAdditionalOptions();
      if (arrayOfObject != null) {
        for (i = 0; i < arrayOfObject.length; i++)
        {
          localHashSet.add(arrayOfObject[i]);
          buttonPanel.add(DialogDisplayer.Trivial.option2Button(arrayOfObject[i], nd, makeListener(arrayOfObject[i]), localJRootPane));
        }
      }
      if (closingOptions != null) {
        for (i = 0; i < closingOptions.length; i++) {
          if (localHashSet.add(closingOptions[i]))
          {
            ActionListener localActionListener = makeListener(closingOptions[i]);
            attachActionListener(closingOptions[i], localActionListener);
          }
        }
      }
    }
    
    private void attachActionListener(Object paramObject, ActionListener paramActionListener)
    {
      Object localObject;
      if ((paramObject instanceof JButton))
      {
        localObject = (JButton)paramObject;
        ((JButton)localObject).addActionListener(paramActionListener);
        
        return;
      }
      try
      {
        localObject = paramObject.getClass().getMethod("addActionListener", new Class[] { ActionListener.class });
        try
        {
          ((Method)localObject).setAccessible(true);
        }
        catch (SecurityException localSecurityException1)
        {
          localObject = null;
        }
      }
      catch (NoSuchMethodException localNoSuchMethodException)
      {
        localObject = null;
      }
      catch (SecurityException localSecurityException2)
      {
        localObject = null;
      }
      if (localObject != null) {
        try
        {
          ((Method)localObject).invoke(paramObject, new Object[] { paramActionListener });
        }
        catch (Exception localException) {}
      }
    }
    
    private ActionListener makeListener(final Object paramObject)
    {
      new ActionListener()
      {
        public void actionPerformed(ActionEvent paramAnonymousActionEvent)
        {
          nd.setValue(paramObject);
          if (buttonListener != null)
          {
            ActionEvent localActionEvent = new ActionEvent(paramObject, paramAnonymousActionEvent.getID(), paramAnonymousActionEvent.getActionCommand(), paramAnonymousActionEvent.getWhen(), paramAnonymousActionEvent.getModifiers());
            
            buttonListener.actionPerformed(localActionEvent);
          }
          if ((closingOptions == null) || (Arrays.asList(closingOptions).contains(paramObject)))
          {
            haveFinalValue = true;
            setVisible(false);
          }
        }
      };
    }
  }
  
  private static class DialogUpdater
    implements PropertyChangeListener
  {
    private DialogDisplayer.Trivial.StandardDialog dialog;
    private DialogDescriptor dd;
    
    public DialogUpdater(DialogDisplayer.Trivial.StandardDialog paramStandardDialog, DialogDescriptor paramDialogDescriptor)
    {
      dialog = paramStandardDialog;
      dd = paramDialogDescriptor;
    }
    
    public void propertyChange(final PropertyChangeEvent paramPropertyChangeEvent)
    {
      if (!SwingUtilities.isEventDispatchThread())
      {
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            propertyChange(paramPropertyChangeEvent);
          }
        });
        return;
      }
      String str = paramPropertyChangeEvent.getPropertyName();
      if ("title".equals(str))
      {
        dialog.setTitle(dd.getTitle());
      }
      else if ("message".equals(str))
      {
        dialog.updateMessage();
        dialog.validate();
        dialog.repaint();
      }
      else if (("options".equals(str)) || ("optionType".equals(str)))
      {
        dialog.updateOptions();
        dialog.validate();
        dialog.repaint();
      }
      else if ("infoNotification".equals(paramPropertyChangeEvent.getPropertyName()))
      {
        DialogDisplayer.Trivial.updateNotificationLine(dialog, 3, paramPropertyChangeEvent.getNewValue());
      }
      else if ("warningNotification".equals(paramPropertyChangeEvent.getPropertyName()))
      {
        DialogDisplayer.Trivial.updateNotificationLine(dialog, 2, paramPropertyChangeEvent.getNewValue());
      }
      else if ("errorNotification".equals(paramPropertyChangeEvent.getPropertyName()))
      {
        DialogDisplayer.Trivial.updateNotificationLine(dialog, 1, paramPropertyChangeEvent.getNewValue());
      }
    }
  }
  
  private static void updateNotificationLine(StandardDialog paramStandardDialog, int paramInt, Object paramObject)
  {
    String str = paramObject == null ? null : paramObject.toString();
    if ((str != null) && (str.trim().length() > 0))
    {
      switch (paramInt)
      {
      case 1: 
        prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/modules/dialogs/error.gif", false), nbErrorForeground);
        
        break;
      case 2: 
        prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/modules/dialogs/warning.gif", false), nbWarningForeground);
        
        break;
      case 3: 
        prepareMessage(notificationLine, ImageUtilities.loadImageIcon("org/netbeans/modules/dialogs/info.png", false), nbInfoForeground);
        
        break;
      }
      notificationLine.setToolTipText(str);
    }
    else
    {
      prepareMessage(notificationLine, null, null);
      notificationLine.setToolTipText(null);
    }
    notificationLine.setText(str);
  }
  
  private static void prepareMessage(JLabel paramJLabel, ImageIcon paramImageIcon, Color paramColor)
  {
    paramJLabel.setIcon(paramImageIcon);
    paramJLabel.setForeground(paramColor);
  }
  
  private static final class FixedHeightLabel
    extends JLabel
  {
    private static final int ESTIMATED_HEIGHT = 16;
    
    public Dimension getPreferredSize()
    {
      Dimension localDimension = super.getPreferredSize();
      assert (16 == ImageUtilities.loadImage("org/netbeans/modules/dialogs/warning.gif").getHeight(null)) : "Use only 16px icon.";
      height = Math.max(16, height);
      return localDimension;
    }
  }
}

/* Location:
 * Qualified Name:     org.openide.DialogDisplayer.Trivial
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.openide;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.accessibility.AccessibleContext;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.ActionMap;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.Utilities;

public abstract class DialogDisplayer
{
  public static DialogDisplayer getDefault()
  {
    Object localObject = (DialogDisplayer)Lookup.getDefault().lookup(DialogDisplayer.class);
    if (localObject == null) {
      localObject = new Trivial(null);
    }
    return (DialogDisplayer)localObject;
  }
  
  public abstract Object notify(NotifyDescriptor paramNotifyDescriptor);
  
  public void notifyLater(final NotifyDescriptor paramNotifyDescriptor)
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        notify(paramNotifyDescriptor);
      }
    });
  }
  
  public abstract Dialog createDialog(DialogDescriptor paramDialogDescriptor);
  
  private static final class Trivial
    extends DialogDisplayer
  {
    public Object notify(NotifyDescriptor paramNotifyDescriptor)
    {
      StandardDialog localStandardDialog = new StandardDialog(paramNotifyDescriptor.getTitle(), true, paramNotifyDescriptor, null, null);
      localStandardDialog.setVisible(true);
      
      return paramNotifyDescriptor.getValue() != null ? paramNotifyDescriptor.getValue() : NotifyDescriptor.CLOSED_OPTION;
    }
    
    public Dialog createDialog(DialogDescriptor paramDialogDescriptor)
    {
1 2 3 4 5 6

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