org-netbeans-modules-progress-ui

16:40:11.048 INFO  jd.cli.Main - Decompiling org-netbeans-modules-progress-ui.jar
package org.netbeans.modules.progress.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Future;

class AbstractWindowRunner$1
  implements ActionListener
{
  AbstractWindowRunner$1(AbstractWindowRunner paramAbstractWindowRunner) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    AbstractWindowRunner.access$200(this$0).cancel(true);
  }
}

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

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

class AbstractWindowRunner$2
  extends AbstractAction
{
  AbstractWindowRunner$2(AbstractWindowRunner paramAbstractWindowRunner, JButton paramJButton) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    val$closeButton.doClick();
  }
}

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

import javax.swing.JDialog;

class AbstractWindowRunner$3
  implements Runnable
{
  AbstractWindowRunner$3(AbstractWindowRunner paramAbstractWindowRunner, JDialog paramJDialog) {}
  
  public void run()
  {
    val$result.setVisible(true);
  }
}

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

import java.util.concurrent.CountDownLatch;

final class AbstractWindowRunner$DialogCreator
  implements Runnable
{
  private final CountDownLatch latch;
  
  AbstractWindowRunner$DialogCreator(AbstractWindowRunner paramAbstractWindowRunner, CountDownLatch paramCountDownLatch)
  {
    latch = paramCountDownLatch;
  }
  
  public void run()
  {
    AbstractWindowRunner.access$100(this$0, this$0.handle, AbstractWindowRunner.access$000(this$0));
    latch.countDown();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.AbstractWindowRunner.DialogCreator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import javax.accessibility.AccessibleContext;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.Utilities;
import org.openide.windows.WindowManager;

abstract class AbstractWindowRunner<T>
  extends WindowAdapter
  implements Runnable, Callable<T>
{
  private volatile JDialog dlg;
  private final boolean includeDetail;
  protected final ProgressHandle handle;
  private final CountDownLatch latch = new CountDownLatch(1);
  private volatile T operationResult;
  private final CountDownLatch startLatch = new CountDownLatch(1);
  private final CountDownLatch waitForTaskAssignment = new CountDownLatch(1);
  private RunOffEDTImpl.CancellableFutureTask<T> future;
  private final boolean showCancel;
  boolean isDispatchThread;
  private Component oldGlassPane;
  
  AbstractWindowRunner(ProgressHandle paramProgressHandle, boolean paramBoolean1, boolean paramBoolean2)
  {
    includeDetail = paramBoolean1;
    handle = paramProgressHandle;
    showCancel = paramBoolean2;
  }
  
  public T call()
    throws Exception
  {
    try
    {
      return (T)runBackground();
    }
    finally
    {
      EventQueue.invokeLater(this);
    }
  }
  
  private Future<T> task()
  {
    RunOffEDTImpl.CancellableFutureTask localCancellableFutureTask;
    synchronized (handle)
    {
      localCancellableFutureTask = future;
    }
    return localCancellableFutureTask;
  }
  
  Future<T> waitForStart()
    throws InterruptedException
  {
    Future localFuture = task();
    if ((!EventQueue.isDispatchThread()) && 
      (localFuture == null))
    {
      startLatch.await();
      localFuture = task();
    }
    assert (localFuture != null);
    return localFuture;
  }
  
  public final void windowOpened(WindowEvent paramWindowEvent)
  {
    dlg = ((JDialog)paramWindowEvent.getSource());
    if (!isDispatchThread) {
      createTask();
    }
    RunOffEDTImpl.CancellableFutureTask localCancellableFutureTask;
    synchronized (this)
    {
      localCancellableFutureTask = future;
    }
    waitForTaskAssignment.countDown();
    grayOutMainWindow();
    task.schedule(0);
    startLatch.countDown();
  }
  
  private Future<T> createTask()
  {
    RunOffEDTImpl.CancellableFutureTask localCancellableFutureTask = new RunOffEDTImpl.CancellableFutureTask(this);
    task = RequestProcessor.getDefault().create(localCancellableFutureTask);
    synchronized (handle)
    {
      future = localCancellableFutureTask;
    }
    return localCancellableFutureTask;
  }
  
  public final void windowClosed(WindowEvent paramWindowEvent)
  {
    ungrayMainWindow();
    latch.countDown();
  }
  
  final void await()
    throws InterruptedException
  {
    latch.await();
  }
  
  Future<T> start()
  {
    if (EventQueue.isDispatchThread())
    {
      isDispatchThread = true;
      localObject = createTask();
      dlg = createModalProgressDialog(handle, includeDetail);
      dlg.setVisible(true);
      return (Future<T>)localObject;
    }
    Object localObject = new CountDownLatch(1);
    DialogCreator localDialogCreator = new DialogCreator((CountDownLatch)localObject);
    EventQueue.invokeLater(localDialogCreator);
    try
    {
      ((CountDownLatch)localObject).await();
    }
    catch (InterruptedException localInterruptedException)
    {
      throw new IllegalStateException(localInterruptedException);
    }
    return null;
  }
  
  protected abstract T runBackground();
  
  T getResult()
  {
    return (T)operationResult;
  }
  
  public void run()
  {
    if (!EventQueue.isDispatchThread())
    {
      try
      {
        try
        {
          waitForTaskAssignment.await();
        }
        catch (InterruptedException localInterruptedException) {}
        operationResult = runBackground();
      }
      finally
      {
        EventQueue.invokeLater(this);
      }
    }
    else
    {
      dlg.setVisible(false);
      dlg.dispose();
    }
  }
  
  private final class DialogCreator
    implements Runnable
  {
    private final CountDownLatch latch;
    
    DialogCreator(CountDownLatch paramCountDownLatch)
    {
      latch = paramCountDownLatch;
    }
    
    public void run()
    {
      AbstractWindowRunner.this.createModalProgressDialog(handle, includeDetail);
      latch.countDown();
    }
  }
  
  private JDialog createModalProgressDialog(ProgressHandle paramProgressHandle, boolean paramBoolean)
  {
    assert (EventQueue.isDispatchThread());
    int i = Utilities.isMac() ? 12 : 8;
    int j = Utilities.isMac() ? 9 : 5;
    JPanel localJPanel1 = new JPanel(new GridLayout(paramBoolean ? 3 : 2, 1, j, j));
    JLabel localJLabel = ProgressHandleFactory.createMainLabelComponent(paramProgressHandle);
    Font localFont = localJLabel.getFont();
    if (localFont != null) {
      localJLabel.setFont(localFont.deriveFont(1));
    }
    localJPanel1.add(localJLabel);
    JComponent localJComponent = ProgressHandleFactory.createProgressComponent(paramProgressHandle);
    localJComponent.setMinimumSize(new Dimension(400, 32));
    JPanel localJPanel2 = new JPanel(new GridBagLayout());
    GridBagConstraints localGridBagConstraints = new GridBagConstraints();
    gridx = 0;
    gridwidth = 1;
    gridheight = 1;
    weightx = 1.0D;
    weighty = 1.0D;
    anchor = 17;
    fill = 1;
    localJPanel2.add(localJComponent, localGridBagConstraints);
    if (showCancel)
    {
      localObject1 = new JButton();
      gridx = 1;
      weightx = 0.0D;
      anchor = 13;
      fill = 0;
      insets = new Insets(0, Utilities.isMac() ? 12 : 5, 0, 0);
      localJPanel2.add((Component)localObject1, localGridBagConstraints);
      ((JButton)localObject1).addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent paramAnonymousActionEvent)
        {
          AbstractWindowRunner.this.task().cancel(true);
        }
      });
      ((JButton)localObject1).setBorderPainted(false);
      ((JButton)localObject1).setBorder(BorderFactory.createEmptyBorder());
      ((JButton)localObject1).setOpaque(false);
      ((JButton)localObject1).setContentAreaFilled(false);
      
      localObject2 = (Image)UIManager.get("nb.progress.cancel.icon");
      if (null != localObject2) {
        ((JButton)localObject1).setIcon(ImageUtilities.image2Icon((Image)localObject2));
      } else {
        ((JButton)localObject1).setText(NbBundle.getMessage(AbstractWindowRunner.class, "ModalDialog.btnClose.text"));
      }
      localObject2 = (Image)UIManager.get("nb.progress.cancel.icon.mouseover");
      if (null != localObject2)
      {
        ((JButton)localObject1).setRolloverEnabled(true);
        ((JButton)localObject1).setRolloverIcon(ImageUtilities.image2Icon((Image)localObject2));
      }
      localObject2 = (Image)UIManager.get("nb.progress.cancel.icon.pressed");
      if (null != localObject2) {
        ((JButton)localObject1).setPressedIcon(ImageUtilities.image2Icon((Image)localObject2));
      }
      ((JButton)localObject1).setToolTipText(NbBundle.getMessage(AbstractWindowRunner.class, "ModalDialog.btnClose.tooltip"));
      
      ((JButton)localObject1).getAccessibleContext().setAccessibleName(NbBundle.getMessage(AbstractWindowRunner.class, "ModalDialog.btnClose.accessibleName"));
      
      ((JButton)localObject1).getAccessibleContext().setAccessibleName(NbBundle.getMessage(AbstractWindowRunner.class, "ModalDialog.btnClose.accessibleDescription"));
      
      localJPanel1.getInputMap(2).put(KeyStroke.getKeyStroke(27, 0), "cancel");
      
      localJPanel1.getActionMap().put("cancel", new AbstractAction()
      {
        public void actionPerformed(ActionEvent paramAnonymousActionEvent)
        {
          localObject1.doClick();
        }
      });
    }
    localJPanel1.add(localJPanel2);
    if (paramBoolean)
    {
      localObject1 = ProgressHandleFactory.createDetailLabelComponent(paramProgressHandle);
      ((JLabel)localObject1).setMinimumSize(new Dimension(300, 16));
      localJPanel1.add((Component)localObject1);
    }
    localJPanel1.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createEmptyBorder(i, i, i, i)));
    localJPanel1.setMinimumSize(new Dimension(400, 100));
    final Object localObject1 = WindowManager.getDefault().getMainWindow();
    final Object localObject2 = new JDialog((Frame)localObject1, true);
    ((JDialog)localObject2).setDefaultCloseOperation(0);
    ((JDialog)localObject2).setUndecorated(true);
    ((JDialog)localObject2).setSize(400, 100);
    ((JDialog)localObject2).getContentPane().setLayout(new BorderLayout());
    ((JDialog)localObject2).getContentPane().add(localJPanel1, "Center");
    ((JDialog)localObject2).pack();
    int k = ((JDialog)localObject2).getWidth();
    ((JDialog)localObject2).setSize(Math.max(k, (localObject1 instanceof JFrame) ? ((JFrame)localObject1).getContentPane().getWidth() / 3 : ((Frame)localObject1).getWidth()), ((JDialog)localObject2).getHeight());
    ((JDialog)localObject2).setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
    ((JDialog)localObject2).addWindowListener(this);
    if (EventQueue.isDispatchThread()) {
      EventQueue.invokeLater(new Runnable()
      {
        public void run()
        {
          localObject2.setVisible(true);
        }
      });
    } else {
      ((JDialog)localObject2).setVisible(true);
    }
    return (JDialog)localObject2;
  }
  
  private void grayOutMainWindow()
  {
    assert (EventQueue.isDispatchThread());
    Frame localFrame = WindowManager.getDefault().getMainWindow();
    if ((localFrame instanceof JFrame))
    {
      Map localMap = (Map)Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints");
      if ((localMap == null) || (!RenderingHints.VALUE_TEXT_ANTIALIAS_OFF.equals(localMap.get(RenderingHints.KEY_TEXT_ANTIALIASING))))
      {
        JFrame localJFrame = (JFrame)localFrame;
        RunOffEDTImpl.TranslucentMask localTranslucentMask = new RunOffEDTImpl.TranslucentMask();
        oldGlassPane = localJFrame.getGlassPane();
        localJFrame.setGlassPane(localTranslucentMask);
        localTranslucentMask.setVisible(true);
        localTranslucentMask.setBounds(0, 0, localJFrame.getContentPane().getWidth(), localJFrame.getContentPane().getHeight());
        localTranslucentMask.invalidate();
        localTranslucentMask.revalidate();
        localTranslucentMask.repaint();
        localJFrame.getRootPane().paintImmediately(0, 0, localJFrame.getRootPane().getWidth(), localJFrame.getRootPane().getHeight());
      }
    }
  }
  
  private void ungrayMainWindow()
  {
    if (oldGlassPane != null)
    {
      JFrame localJFrame = (JFrame)WindowManager.getDefault().getMainWindow();
      localJFrame.setGlassPane(oldGlassPane);
      localJFrame.invalidate();
      localJFrame.repaint();
    }
  }
}

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

import org.netbeans.modules.progress.spi.Controller;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.netbeans.modules.progress.spi.TaskModel;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;

public final class CancelAction
  extends CallableSystemAction
{
  public void performAction()
  {
    InternalHandle localInternalHandle = Controller.getDefault().getModel().getSelectedHandle();
    if (localInternalHandle != null) {
      localInternalHandle.requestCancel();
    }
  }
  
  public String getName()
  {
    return NbBundle.getMessage(CancelAction.class, "CTL_CancelAction");
  }
  
  protected void initialize()
  {
    super.initialize();
    
    putValue("noIconInMenu", Boolean.TRUE);
  }
  
  public HelpCtx getHelpCtx()
  {
    return HelpCtx.DEFAULT_HELP;
  }
  
  protected boolean asynchronous()
  {
    return true;
  }
}

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

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JLabel;

class ListComponent$1
  implements FocusListener
{
  ListComponent$1(ListComponent paramListComponent) {}
  
  public void focusGained(FocusEvent paramFocusEvent)
  {
    if (!paramFocusEvent.isTemporary())
    {
      this$0.setBackground(ListComponent.access$200(this$0));
      ListComponent.access$300(this$0).setBackground(ListComponent.access$200(this$0));
      ListComponent.access$400(this$0).setBackground(ListComponent.access$200(this$0));
      ListComponent.access$300(this$0).setForeground(ListComponent.access$500(this$0));
      
      this$0.scrollRectToVisible(this$0.getBounds());
    }
  }
  
  public void focusLost(FocusEvent paramFocusEvent)
  {
    if (!paramFocusEvent.isTemporary())
    {
      this$0.setBackground(ListComponent.access$600(this$0));
      ListComponent.access$300(this$0).setBackground(ListComponent.access$600(this$0));
      ListComponent.access$400(this$0).setBackground(ListComponent.access$600(this$0));
      ListComponent.access$300(this$0).setForeground(ListComponent.access$700(this$0));
    }
  }
}

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

import java.awt.Image;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

class ListComponent$CancelAction
  extends AbstractAction
{
  ListComponent$CancelAction(ListComponent paramListComponent, boolean paramBoolean)
  {
    if (paramBoolean)
    {
      putValue("Name", NbBundle.getMessage(ListComponent.class, "StatusLineComponent.Cancel"));
      putValue("AcceleratorKey", KeyStroke.getKeyStroke(127, 0));
    }
    else
    {
      Image localImage = (Image)UIManager.get("nb.progress.cancel.icon");
      if (localImage == null) {
        localImage = ImageUtilities.loadImage("org/netbeans/progress/module/resources/buton.png");
      }
      putValue("SmallIcon", new ImageIcon(localImage));
    }
    setEnabled(ListComponent.access$900(paramListComponent) == null ? false : ListComponent.access$900(paramListComponent).isAllowCancel());
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    if (ListComponent.access$900(this$0).getState() == 1)
    {
      String str1 = NbBundle.getMessage(ListComponent.class, "Cancel_Question", ListComponent.access$900(this$0).getDisplayName());
      String str2 = NbBundle.getMessage(ListComponent.class, "Cancel_Question_Title");
      NotifyDescriptor localNotifyDescriptor = new NotifyDescriptor(str1, str2, 0, 3, null, null);
      
      Object localObject = DialogDisplayer.getDefault().notify(localNotifyDescriptor);
      if (localObject == NotifyDescriptor.YES_OPTION) {
        ListComponent.access$900(this$0).requestCancel();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.ListComponent.CancelAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import javax.swing.JButton;
import javax.swing.JLabel;

class ListComponent$CustomLayout
  implements LayoutManager
{
  private ListComponent$CustomLayout(ListComponent paramListComponent) {}
  
  public void addLayoutComponent(String paramString, Component paramComponent) {}
  
  public Dimension preferredLayoutSize(Container paramContainer)
  {
    int i = 3 + ListComponent.access$1100(this$0) + 3 + ListComponent.access$1200(this$0) + 2;
    return new Dimension(400, i);
  }
  
  public void layoutContainer(Container paramContainer)
  {
    int i = paramContainer.getWidth();
    int j = paramContainer.getHeight();
    int k = i - 18;
    if (ListComponent.access$1300(this$0) != null) {
      ListComponent.access$1300(this$0).setBounds(k, 3, 18, ListComponent.access$1100(this$0));
    }
    int m = k - 133;
    ListComponent.access$800(this$0).setBounds(m, 3, k - m, ListComponent.access$1100(this$0));
    ListComponent.access$300(this$0).setBounds(2, 3, m - 2, ListComponent.access$1100(this$0));
    ListComponent.access$400(this$0).setBounds(2, ListComponent.access$1100(this$0) + 3 + 3, i - 2, ListComponent.access$1200(this$0));
  }
  
  public Dimension minimumLayoutSize(Container paramContainer)
  {
    return preferredLayoutSize(paramContainer);
  }
  
  public void removeLayoutComponent(Component paramComponent) {}
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.ListComponent.CustomLayout
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import org.netbeans.modules.progress.spi.InternalHandle;

class ListComponent$MListener
  extends MouseAdapter
{
  private ListComponent$MListener(ListComponent paramListComponent) {}
  
  public void mouseClicked(MouseEvent paramMouseEvent)
  {
    if (paramMouseEvent.getSource() == ListComponent.access$800(this$0)) {
      ListComponent.access$900(this$0).requestExplicitSelection();
    }
    if ((paramMouseEvent.getClickCount() > 1) && ((paramMouseEvent.getSource() == ListComponent.access$300(this$0)) || (paramMouseEvent.getSource() == ListComponent.access$400(this$0)))) {
      ListComponent.access$900(this$0).requestView();
    }
    if (paramMouseEvent.getButton() != 1) {
      ListComponent.access$1000(this$0, paramMouseEvent);
    } else {
      this$0.requestFocus();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.ListComponent.MListener
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.openide.util.NbBundle;

class ListComponent$ViewAction
  extends AbstractAction
{
  public ListComponent$ViewAction(ListComponent paramListComponent)
  {
    putValue("Name", NbBundle.getMessage(ListComponent.class, "StatusLineComponent.View"));
    setEnabled(ListComponent.access$900(paramListComponent) == null ? false : ListComponent.access$900(paramListComponent).isAllowView());
    putValue("AcceleratorKey", KeyStroke.getKeyStroke(10, 0));
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    if (ListComponent.access$900(this$0) != null) {
      ListComponent.access$900(this$0).requestView();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.ListComponent.ViewAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.openide.util.NbBundle;

class ListComponent$WatchAction
  extends AbstractAction
{
  public ListComponent$WatchAction(ListComponent paramListComponent)
  {
    putValue("Name", NbBundle.getMessage(ListComponent.class, "ListComponent.Watch"));
    putValue("AcceleratorKey", KeyStroke.getKeyStroke(32, 0));
    setEnabled(true);
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    if (ListComponent.access$900(this$0) != null) {
      ListComponent.access$900(this$0).requestExplicitSelection();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.ListComponent.WatchAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.progress.ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.plaf.ProgressBarUI;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.netbeans.modules.progress.spi.ProgressEvent;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

public class ListComponent
  extends JPanel
{
  private NbProgressBar bar;
  private JLabel mainLabel;
  private JLabel dynaLabel;
  private JButton closeButton;
  private InternalHandle handle;
  private boolean watched;
  private Action cancelAction;
  private Color selectBgColor;
  private Color selectFgColor;
  private Color bgColor;
  private Color fgColor;
  private int mainHeight;
  private int dynaHeight;
  private static final int UPPERMARGIN = 3;
  private static final int LEFTMARGIN = 2;
  private static final int BOTTOMMARGIN = 2;
  private static final int BETWEENTEXTMARGIN = 3;
  static final int ITEM_WIDTH = 400;
  
  public ListComponent(InternalHandle paramInternalHandle)
  {
    setFocusable(true);
    setRequestFocusEnabled(true);
    
    mainLabel = new JLabel();
    dynaLabel = new JLabel();
    
    setOpaque(true);
    dynaLabel.setFont(dynaLabel.getFont().deriveFont(dynaLabel.getFont().getSize() - 2));
    bar = new NbProgressBar();
    handle = paramInternalHandle;
    Color localColor1 = UIManager.getColor("nbProgressBar.popupText.background");
    if (localColor1 != null)
    {
      setBackground(localColor1);
      mainLabel.setBackground(localColor1);
      dynaLabel.setBackground(localColor1);
    }
    bgColor = getBackground();
    Color localColor2 = UIManager.getColor("nbProgressBar.popupDynaText.foreground");
    if (localColor2 != null) {
      dynaLabel.setForeground(localColor2);
    }
    fgColor = UIManager.getColor("nbProgressBar.popupText.foreground");
    if (fgColor != null) {
      mainLabel.setForeground(fgColor);
    }
    fgColor = mainLabel.getForeground();
    selectBgColor = UIManager.getColor("nbProgressBar.popupText.selectBackground");
    if (selectBgColor == null) {
      selectBgColor = UIManager.getColor("List.selectionBackground");
    }
    selectFgColor = UIManager.getColor("nbProgressBar.popupText.selectForeground");
    if (selectFgColor == null) {
      selectFgColor = UIManager.getColor("List.selectionForeground");
    }
    bar.setToolTipText(NbBundle.getMessage(ListComponent.class, "ListComponent.bar.tooltip"));
    bar.setCursor(Cursor.getPredefinedCursor(12));
    
    mainLabel.setText("XYZ");
    dynaLabel.setText("XYZ");
    mainHeight = mainLabel.getPreferredSize().height;
    dynaHeight = dynaLabel.getPreferredSize().height;
    mainLabel.setText(null);
    dynaLabel.setText(null);
    
    setLayout(new CustomLayout(null));
    add(mainLabel);
    add(bar);
    MListener localMListener = new MListener(null);
    if (handle.isAllowCancel())
    {
      cancelAction = new CancelAction(false);
      closeButton = new JButton(cancelAction);
      closeButton.setBorderPainted(false);
      closeButton.setBorder(BorderFactory.createEmptyBorder());
      closeButton.setOpaque(false);
      closeButton.setContentAreaFilled(false);
      closeButton.setFocusable(false);
      
      Image localImage = (Image)UIManager.get("nb.progress.cancel.icon");
      if (null != localImage) {
        closeButton.setIcon(new ImageIcon(localImage));
      }
      localImage = (Image)UIManager.get("nb.progress.cancel.icon.mouseover");
      if (null != localImage)
      {
        closeButton.setRolloverEnabled(true);
        closeButton.setRolloverIcon(new ImageIcon(localImage));
      }
      localImage = (Image)UIManager.get("nb.progress.cancel.icon.pressed");
      if (null != localImage) {
        closeButton.setPressedIcon(new ImageIcon(localImage));
      }
      closeButton.setToolTipText(NbBundle.getMessage(ListComponent.class, "ListComponent.btnClose.tooltip"));
      add(closeButton);
      if (handle.getState() != 1) {
        closeButton.setEnabled(false);
      }
    }
    add(dynaLabel);
    setBorder(BorderFactory.createEmptyBorder());
    addMouseListener(localMListener);
    bar.addMouseListener(localMListener);
    mainLabel.addMouseListener(localMListener);
    dynaLabel.addMouseListener(localMListener);
    if (handle.isAllowCancel()) {
      closeButton.addMouseListener(localMListener);
    }
    mainLabel.setText(handle.getDisplayName());
    NbProgressBar.setupBar(handle, bar);
    addFocusListener(new FocusListener()
    {
      public void focusGained(FocusEvent paramAnonymousFocusEvent)
      {
        if (!paramAnonymousFocusEvent.isTemporary())
        {
          setBackground(selectBgColor);
          mainLabel.setBackground(selectBgColor);
          dynaLabel.setBackground(selectBgColor);
          mainLabel.setForeground(selectFgColor);
          
          scrollRectToVisible(getBounds());
        }
      }
      
      public void focusLost(FocusEvent paramAnonymousFocusEvent)
      {
        if (!paramAnonymousFocusEvent.isTemporary())
        {
          setBackground(bgColor);
          mainLabel.setBackground(bgColor);
          dynaLabel.setBackground(bgColor);
          mainLabel.setForeground(fgColor);
        }
      }
    });
  }
  
  Action getCancelAction()
  {
    return cancelAction;
  }
  
  InternalHandle getHandle()
  {
    return handle;
  }
  
  void processProgressEvent(ProgressEvent paramProgressEvent)
  {
    if ((paramProgressEvent.getType() == 1) || (paramProgressEvent.getType() == 5) || (paramProgressEvent.getType() == 6))
    {
      if (paramProgressEvent.getSource() != handle) {
        throw new IllegalStateException();
      }
      if (paramProgressEvent.isSwitched()) {
        NbProgressBar.setupBar(paramProgressEvent.getSource(), bar);
      }
      if (paramProgressEvent.getWorkunitsDone() > 0) {
        bar.setValue(paramProgressEvent.getWorkunitsDone());
      }
      bar.setString(StatusLineComponent.getBarString(paramProgressEvent.getPercentageDone(), paramProgressEvent.getEstimatedCompletion()));
      if (paramProgressEvent.getMessage() != null) {
        dynaLabel.setText(paramProgressEvent.getMessage());
      }
      if (paramProgressEvent.getSource().getState() == 3) {
        closeButton.setEnabled(false);
      }
      if (paramProgressEvent.getDisplayName() != null) {
        mainLabel.setText(paramProgressEvent.getDisplayName());
      }
    }
    else
    {
      throw new IllegalStateException();
    }
  }
  
  void markAsActive(boolean paramBoolean)
  {
    if (paramBoolean == watched) {
      return;
    }
    watched = paramBoolean;
    if (paramBoolean) {
      mainLabel.setFont(mainLabel.getFont().deriveFont(1));
    } else {
      mainLabel.setFont(mainLabel.getFont().deriveFont(0));
    }
    if (mainLabel.isVisible()) {
      mainLabel.repaint();
    }
  }
  
  void clearProgressBarOSX()
  {
    if (bar != null) {
      bar.getUI().uninstallUI(bar);
    }
  }
  
  private class MListener
    extends MouseAdapter
  {
    private MListener() {}
    
    public void mouseClicked(MouseEvent paramMouseEvent)
    {
      if (paramMouseEvent.getSource() == bar) {
        handle.requestExplicitSelection();
      }
      if ((paramMouseEvent.getClickCount() > 1) && ((paramMouseEvent.getSource() == mainLabel) || (paramMouseEvent.getSource() == dynaLabel))) {
        handle.requestView();
      }
      if (paramMouseEvent.getButton() != 1) {
        ListComponent.this.showMenu(paramMouseEvent);
      } else {
        requestFocus();
      }
    }
  }
  
  private void showMenu(MouseEvent paramMouseEvent)
  {
    if (!isShowing()) {
      return;
    }
    JPopupMenu localJPopupMenu = new JPopupMenu();
    
    localJPopupMenu.setName("progresspopup");
    localJPopupMenu.add(new ViewAction());
    localJPopupMenu.add(new WatchAction());
    localJPopupMenu.add(new CancelAction(true));
    localJPopupMenu.show((Component)paramMouseEvent.getSource(), paramMouseEvent.getX(), paramMouseEvent.getY());
  }
  
  private class CancelAction
    extends AbstractAction
  {
    CancelAction(boolean paramBoolean)
    {
      if (paramBoolean)
      {
        putValue("Name", NbBundle.getMessage(ListComponent.class, "StatusLineComponent.Cancel"));
        putValue("AcceleratorKey", KeyStroke.getKeyStroke(127, 0));
      }
      else
      {
        Image localImage = (Image)UIManager.get("nb.progress.cancel.icon");
        if (localImage == null) {
          localImage = ImageUtilities.loadImage("org/netbeans/progress/module/resources/buton.png");
        }
        putValue("SmallIcon", new ImageIcon(localImage));
      }
      setEnabled(handle == null ? false : handle.isAllowCancel());
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      if (handle.getState() == 1)
      {
        String str1 = NbBundle.getMessage(ListComponent.class, "Cancel_Question", handle.getDisplayName());
        String str2 = NbBundle.getMessage(ListComponent.class, "Cancel_Question_Title");
        NotifyDescriptor localNotifyDescriptor = new NotifyDescriptor(str1, str2, 0, 3, null, null);
        
        Object localObject = DialogDisplayer.getDefault().notify(localNotifyDescriptor);
        if (localObject == NotifyDescriptor.YES_OPTION) {
          handle.requestCancel();
        }
      }
    }
  }
  
  private class ViewAction
    extends AbstractAction
  {
    public ViewAction()
    {
      putValue("Name", NbBundle.getMessage(ListComponent.class, "StatusLineComponent.View"));
      setEnabled(handle == null ? false : handle.isAllowView());
      putValue("AcceleratorKey", KeyStroke.getKeyStroke(10, 0));
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      if (handle != null) {
        handle.requestView();
      }
    }
  }
  
  private class WatchAction
    extends AbstractAction
  {
    public WatchAction()
    {
      putValue("Name", NbBundle.getMessage(ListComponent.class, "ListComponent.Watch"));
      putValue("AcceleratorKey", KeyStroke.getKeyStroke(32, 0));
      setEnabled(true);
    }
    
    public void actionPerformed(ActionEvent paramActionEvent)
    {
      if (handle != null) {
        handle.requestExplicitSelection();
      }
    }
  }
  
  private class CustomLayout
    implements LayoutManager
  {
    private CustomLayout() {}
    
    public void addLayoutComponent(String paramString, Component paramComponent) {}
    
    public Dimension preferredLayoutSize(Container paramContainer)
    {
      int i = 3 + mainHeight + 3 + dynaHeight + 2;
      return new Dimension(400, i);
    }
    
    public void layoutContainer(Container paramContainer)
    {
      int i = paramContainer.getWidth();
      int j = paramContainer.getHeight();
      int k = i - 18;
      if (closeButton != null) {
        closeButton.setBounds(k, 3, 18, mainHeight);
      }
      int m = k - 133;
      bar.setBounds(m, 3, k - m, mainHeight);
      mainLabel.setBounds(2, 3, m - 2, mainHeight);
      dynaLabel.setBounds(2, mainHeight + 3 + 3, i - 2, dynaHeight);
    }
    
    public Dimension minimumLayoutSize(Container paramContainer)
    {
      return preferredLayoutSize(paramContainer);
    }
    
    public void removeLayoutComponent(Component paramComponent) {}
  }
}

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

import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import org.netbeans.modules.progress.spi.ExtractedProgressUIWorker;
import org.netbeans.modules.progress.spi.InternalHandle;
import org.netbeans.modules.progress.spi.ProgressEvent;

public class NbProgressBar
  extends JProgressBar
  implements ExtractedProgressUIWorker
{
  static final String SLEEPY = "sleepy";
  boolean isSetup = false;
  boolean usedInStatusBar = false;
  private JLabel detailLabel = new JLabel();
  private JLabel mainLabel = new JLabel();
  
  public NbProgressBar()
  {
    setOrientation(0);
    setAlignmentX(0.5F);
    setAlignmentY(0.5F);
    Color localColor1 = UIManager.getColor("nbProgressBar.Foreground");
    if (localColor1 != null) {
      setForeground(localColor1);
    }
    Color localColor2 = UIManager.getColor("nbProgressBar.Background");
    if (localColor2 != null) {
      setBackground(localColor2);
    }
  }
  
  public void setUseInStatusBar(boolean paramBoolean)
  {
    usedInStatusBar = paramBoolean;
  }
  
  public Dimension getPreferredSize()
  {
    Dimension localDimension = super.getPreferredSize();
    if (usedInStatusBar) {
      width = 133;
    }
    return localDimension;
  }
  
  public void processProgressEvent(ProgressEvent paramProgressEvent)
  {
    if ((paramProgressEvent.getType() == 0) || (!isSetup) || (paramProgressEvent.isSwitched()))
    {
      setupBar(paramProgressEvent.getSource(), this);
      mainLabel.setText(paramProgressEvent.getSource().getDisplayName());
      isSetup = true;
    }
    if (paramProgressEvent.getType() == 1)
    {
      if (paramProgressEvent.getWorkunitsDone() > 0) {
        setValue(paramProgressEvent.getWorkunitsDone());
      }
      setString(StatusLineComponent.getBarString(paramProgressEvent.getPercentageDone(), paramProgressEvent.getEstimatedCompletion()));
      if (paramProgressEvent.getDisplayName() != null) {
        mainLabel.setText(paramProgressEvent.getDisplayName());
      }
      if (paramProgressEvent.getMessage() != null) {
        detailLabel.setText(paramProgressEvent.getMessage());
      }
    }
    else if (paramProgressEvent.getType() == 4)
    {
      boolean bool = isIndeterminate();
      setIndeterminate(false);
      setMaximum(paramProgressEvent.getSource().getTotalUnits());
      setValue(paramProgressEvent.getSource().getTotalUnits());
      if (bool) {
        setStringPainted(false);
      } else {
        setString(StatusLineComponent.getBarString(100.0D, -1L));
      }
    }
  }
  
  public void processSelectedProgressEvent(ProgressEvent paramProgressEvent) {}
  
  static void setupBar(InternalHandle paramInternalHandle, NbProgressBar paramNbProgressBar)
  {
    paramNbProgressBar.putClientProperty("sleepy", null);
    int i = paramInternalHandle.getTotalUnits();
    if (paramInternalHandle.isInSleepMode())
    {
      paramNbProgressBar.setStringPainted(true);
      paramNbProgressBar.setIndeterminate(false);
      paramNbProgressBar.setMaximum(1);
      paramNbProgressBar.setMinimum(0);
      paramNbProgressBar.setValue(0);
      paramNbProgressBar.putClientProperty("sleepy", new Object());
    }
    else if (i < 1)
    {
      paramNbProgressBar.setValue(paramNbProgressBar.getMaximum());
      paramNbProgressBar.setIndeterminate(true);
      paramNbProgressBar.setStringPainted(false);
    }
    else
    {
      paramNbProgressBar.setStringPainted(true);
      paramNbProgressBar.setIndeterminate(false);
      paramNbProgressBar.setMaximum(i);
      paramNbProgressBar.setMinimum(0);
      paramNbProgressBar.setValue(0);
    }
    paramNbProgressBar.setString(" ");
  }
  
  public JComponent getProgressComponent()
  {
    return this;
  }
  
  public JLabel getMainLabelComponent()
  {
    return mainLabel;
  }
  
  public JLabel getDetailLabelComponent()
  {
    return detailLabel;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.progress.ui.NbProgressBar
 * 
1 2 3

Further reading...

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

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd