com-sun-tools-visualvm-host

16:33:52.035 INFO  jd.cli.Main - Decompiling com-sun-tools-visualvm-host.jar
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.host.impl.HostProperties;

class AddRemoteHostAction$1
  implements Runnable
{
  AddRemoteHostAction$1(AddRemoteHostAction paramAddRemoteHostAction, HostProperties paramHostProperties) {}
  
  public void run()
  {
    HostsSupport.getInstance().createHost(val$hostDescriptor, true, true);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.AddRemoteHostAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.ui.actions.SingleDataSourceAction;
import com.sun.tools.visualvm.host.impl.HostCustomizer;
import com.sun.tools.visualvm.host.impl.HostProperties;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.util.Set;
import javax.swing.ImageIcon;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;

class AddRemoteHostAction
  extends SingleDataSourceAction<RemoteHostsContainer>
{
  private static final String ICON_PATH = "com/sun/tools/visualvm/host/resources/addRemoteHost.png";
  private static final Image ICON = ImageUtilities.loadImage("com/sun/tools/visualvm/host/resources/addRemoteHost.png");
  private boolean tracksSelection = false;
  private static AddRemoteHostAction alwaysEnabled;
  private static AddRemoteHostAction selectionAware;
  
  public static synchronized AddRemoteHostAction alwaysEnabled()
  {
    if (alwaysEnabled == null)
    {
      alwaysEnabled = new AddRemoteHostAction();
      alwaysEnabled.putValue("SmallIcon", new ImageIcon(ICON));
      alwaysEnabled.putValue("iconBase", "com/sun/tools/visualvm/host/resources/addRemoteHost.png");
    }
    return alwaysEnabled;
  }
  
  public static synchronized AddRemoteHostAction selectionAware()
  {
    if (selectionAware == null)
    {
      selectionAware = new AddRemoteHostAction();
      selectionAwaretracksSelection = true;
    }
    return selectionAware;
  }
  
  protected void actionPerformed(RemoteHostsContainer remoteHostsContainer, ActionEvent actionEvent)
  {
    final HostProperties hostDescriptor = HostCustomizer.defineHost();
    if (hostDescriptor != null) {
      RequestProcessor.getDefault().post(new Runnable()
      {
        public void run()
        {
          HostsSupport.getInstance().createHost(hostDescriptor, true, true);
        }
      });
    }
  }
  
  protected boolean isEnabled(RemoteHostsContainer remoteHostsContainer)
  {
    return true;
  }
  
  protected void updateState(Set<RemoteHostsContainer> remoteHostsContainerSet)
  {
    if (tracksSelection) {
      super.updateState(remoteHostsContainerSet);
    }
  }
  
  private AddRemoteHostAction()
  {
    super(RemoteHostsContainer.class);
    putValue("Name", NbBundle.getMessage(AddRemoteHostAction.class, "LBL_Add_Remote_Host"));
    putValue("ShortDescription", NbBundle.getMessage(AddRemoteHostAction.class, "ToolTip_Add_Remote_Host"));
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.AddRemoteHostAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasupport.Stateful;
import java.beans.PropertyChangeSupport;
import java.net.InetAddress;
import java.net.UnknownHostException;

public abstract class Host
  extends DataSource
  implements Stateful
{
  public static final Host LOCALHOST = HostsSupport.getInstance().createLocalHost();
  public static final Host UNKNOWN_HOST = HostsSupport.getInstance().createUnknownHost();
  private final String hostName;
  private InetAddress inetAddress;
  private int state = 1;
  
  public Host(String hostName)
    throws UnknownHostException
  {
    this(hostName, InetAddress.getByName(hostName));
  }
  
  public Host(String hostName, InetAddress inetAddress)
  {
    if (hostName == null) {
      throw new IllegalArgumentException("Host name cannot be null");
    }
    if (inetAddress == null) {
      throw new IllegalArgumentException("InetAddress cannot be null");
    }
    this.hostName = hostName;
    this.inetAddress = inetAddress;
  }
  
  public String getHostName()
  {
    return hostName;
  }
  
  public final InetAddress getInetAddress()
  {
    return inetAddress;
  }
  
  public synchronized int getState()
  {
    return state;
  }
  
  protected final synchronized void setState(int newState)
  {
    int oldState = state;
    state = newState;
    getChangeSupport().firePropertyChange("prop_state", oldState, newState);
  }
  
  public int hashCode()
  {
    if (UNKNOWN_HOST == this) {
      return super.hashCode();
    }
    InetAddress address = getInetAddress();
    if (this == LOCALHOST) {
      return address.hashCode();
    }
    if (address.isLoopbackAddress()) {
      return LOCALHOST.hashCode();
    }
    return address.hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof Host)) {
      return false;
    }
    if (UNKNOWN_HOST == this) {
      return obj == this;
    }
    Host host = (Host)obj;
    InetAddress thisAddress = getInetAddress();
    InetAddress otherAddress = host.getInetAddress();
    if ((thisAddress.isLoopbackAddress()) && (otherAddress.isLoopbackAddress())) {
      return true;
    }
    return thisAddress.equals(otherAddress);
  }
  
  public String toString()
  {
    return getHostName() + " [IP: " + getInetAddress().getHostAddress() + "]";
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.Host
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import java.awt.Component;
import javax.swing.JMenu;

class HostsSorting$1
  extends JMenu
{
  HostsSorting$1(HostsSorting paramHostsSorting) {}
  
  protected void fireMenuSelected()
  {
    Component[] items = getMenuComponents();
    for (Component item : items) {
      if ((item instanceof HostsSorting.SortAction)) {
        ((HostsSorting.SortAction)item).updateAction();
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import java.util.Comparator;

final class HostsSorting$2
  implements Comparator<DataSource>
{
  public int compare(DataSource d1, DataSource d2)
  {
    if (d1 == Host.UNKNOWN_HOST) {
      return -1;
    }
    if (d2 == Host.UNKNOWN_HOST) {
      return 1;
    }
    DataSourceDescriptor dd1 = DataSourceDescriptorFactory.getDescriptor(d1);
    DataSourceDescriptor dd2 = DataSourceDescriptorFactory.getDescriptor(d2);
    
    return dd1.getName().compareTo(dd2.getName());
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import java.util.Comparator;
import java.util.List;
import java.util.prefs.Preferences;

class HostsSorting$3
  implements HostsSorting.Sorter
{
  HostsSorting$3(HostsSorting paramHostsSorting) {}
  
  public void sort(Comparator<DataSource> comparator)
  {
    DataSourceDescriptor d = DataSourceDescriptorFactory.getDescriptor(RemoteHostsContainer.sharedInstance());
    if ((d instanceof RemoteHostsContainerDescriptor))
    {
      ((RemoteHostsContainerDescriptor)d).setChildrenComparator(comparator);
      HostsSorting.access$100(this$0).putInt("Hosts.sorting", HostsSorting.access$000().indexOf(comparator));
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import java.awt.event.ActionEvent;
import java.util.Comparator;
import javax.swing.JRadioButtonMenuItem;
import org.openide.awt.Mnemonics;

class HostsSorting$SortAction
  extends JRadioButtonMenuItem
{
  private final HostsSorting.Sorter sorter;
  private final Comparator<DataSource> comparator;
  private boolean currentlySelected;
  
  HostsSorting$SortAction(String name, Comparator<DataSource> comparator, HostsSorting.Sorter sorter)
  {
    Mnemonics.setLocalizedText(this, name);
    this.comparator = comparator;
    this.sorter = sorter;
  }
  
  void updateAction()
  {
    DataSourceDescriptor d = DataSourceDescriptorFactory.getDescriptor(RemoteHostsContainer.sharedInstance());
    
    setEnabled(d instanceof RemoteHostsContainerDescriptor);
    currentlySelected = (d.getChildrenComparator() == comparator);
    setSelected(currentlySelected);
  }
  
  protected void fireActionPerformed(ActionEvent e)
  {
    if (!currentlySelected) {
      sorter.sort(comparator);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting.SortAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import java.util.Comparator;

abstract interface HostsSorting$Sorter
{
  public abstract void sort(Comparator<DataSource> paramComparator);
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting.Sorter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.prefs.Preferences;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
import org.openide.util.actions.Presenter.Menu;

final class HostsSorting
  implements Presenter.Menu
{
  private static final String PROP_HOSTS_SORTING = "Hosts.sorting";
  private static HostsSorting instance;
  private static final Comparator<DataSource> BY_TIME_COMPARATOR = ;
  private static final Comparator<DataSource> BY_NAME_COMPARATOR = byNameComparator();
  private static final List<Comparator<DataSource>> COMPARATORS = new ArrayList();
  private final Preferences prefs;
  private JMenuItem presenter;
  private final Sorter sorter;
  
  static
  {
    COMPARATORS.add(BY_TIME_COMPARATOR);COMPARATORS.add(BY_NAME_COMPARATOR);
  }
  
  public static synchronized HostsSorting instance()
  {
    if (instance == null) {
      instance = new HostsSorting();
    }
    return instance;
  }
  
  public JMenuItem getMenuPresenter()
  {
    if (presenter == null) {
      presenter = createPresenter();
    }
    return presenter;
  }
  
  Comparator<DataSource> getInitialSorting()
  {
    return (Comparator)COMPARATORS.get(prefs.getInt("Hosts.sorting", COMPARATORS.indexOf(BY_TIME_COMPARATOR)));
  }
  
  private JMenuItem createPresenter()
  {
    JMenu menu = new JMenu()
    {
      protected void fireMenuSelected()
      {
        Component[] items = getMenuComponents();
        for (Component item : items) {
          if ((item instanceof HostsSorting.SortAction)) {
            ((HostsSorting.SortAction)item).updateAction();
          }
        }
      }
    };
    Mnemonics.setLocalizedText(menu, NbBundle.getMessage(HostsSorting.class, "ACT_SortHosts"));
    
    menu.add(new SortAction(NbBundle.getMessage(HostsSorting.class, "ACT_TimeAdded"), BY_TIME_COMPARATOR, sorter));
    
    menu.add(new SortAction(NbBundle.getMessage(HostsSorting.class, "ACT_DisplayName"), BY_NAME_COMPARATOR, sorter));
    
    return menu;
  }
  
  private static Comparator<DataSource> byTimeComparator()
  {
    return null;
  }
  
  private static Comparator<DataSource> byNameComparator()
  {
    new Comparator()
    {
      public int compare(DataSource d1, DataSource d2)
      {
        if (d1 == Host.UNKNOWN_HOST) {
          return -1;
        }
        if (d2 == Host.UNKNOWN_HOST) {
          return 1;
        }
        DataSourceDescriptor dd1 = DataSourceDescriptorFactory.getDescriptor(d1);
        DataSourceDescriptor dd2 = DataSourceDescriptorFactory.getDescriptor(d2);
        
        return dd1.getName().compareTo(dd2.getName());
      }
    };
  }
  
  private HostsSorting()
  {
    prefs = NbPreferences.forModule(HostsSorting.class);
    
    sorter = new Sorter()
    {
      public void sort(Comparator<DataSource> comparator)
      {
        DataSourceDescriptor d = DataSourceDescriptorFactory.getDescriptor(RemoteHostsContainer.sharedInstance());
        if ((d instanceof RemoteHostsContainerDescriptor))
        {
          ((RemoteHostsContainerDescriptor)d).setChildrenComparator(comparator);
          prefs.putInt("Hosts.sorting", HostsSorting.COMPARATORS.indexOf(comparator));
        }
      }
    };
  }
  
  private static abstract interface Sorter
  {
    public abstract void sort(Comparator<DataSource> paramComparator);
  }
  
  private static class SortAction
    extends JRadioButtonMenuItem
  {
    private final HostsSorting.Sorter sorter;
    private final Comparator<DataSource> comparator;
    private boolean currentlySelected;
    
    SortAction(String name, Comparator<DataSource> comparator, HostsSorting.Sorter sorter)
    {
      Mnemonics.setLocalizedText(this, name);
      this.comparator = comparator;
      this.sorter = sorter;
    }
    
    void updateAction()
    {
      DataSourceDescriptor d = DataSourceDescriptorFactory.getDescriptor(RemoteHostsContainer.sharedInstance());
      
      setEnabled(d instanceof RemoteHostsContainerDescriptor);
      currentlySelected = (d.getChildrenComparator() == comparator);
      setSelected(currentlySelected);
    }
    
    protected void fireActionPerformed(ActionEvent e)
    {
      if (!currentlySelected) {
        sorter.sort(comparator);
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSorting
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.DataSourceContainer;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import com.sun.tools.visualvm.core.datasupport.Utils;
import com.sun.tools.visualvm.host.impl.HostDescriptorProvider;
import com.sun.tools.visualvm.host.impl.HostProperties;
import com.sun.tools.visualvm.host.impl.HostProvider;
import com.sun.tools.visualvm.host.impl.HostsSupportImpl;
import java.io.File;
import java.net.InetAddress;

public final class HostsSupport
{
  private static final Object hostsStorageDirectoryLock = new Object();
  private static File hostsStorageDirectory;
  private static HostsSupport instance;
  private final HostProvider hostProvider = new HostProvider();
  
  public static synchronized HostsSupport getInstance()
  {
    if (instance == null) {
      instance = new HostsSupport();
    }
    return instance;
  }
  
  public Host createHost(String hostname)
  {
    return createHost(new HostProperties(hostname, hostname, null), true, true);
  }
  
  public Host createHost(String hostname, String displayname)
  {
    return createHost(new HostProperties(hostname, displayname, null), true, true);
  }
  
  public Host getOrCreateHost(String hostname, boolean interactive)
  {
    return createHost(new HostProperties(hostname, hostname, null), false, interactive);
  }
  
  Host createHost(HostProperties properties, boolean createOnly, boolean interactive)
  {
    return hostProvider.createHost(properties, createOnly, interactive);
  }
  
  public Host getHostByAddress(InetAddress inetAddress)
  {
    return hostProvider.getHostByAddress(inetAddress);
  }
  
  public static File getStorageDirectory()
  {
    synchronized (hostsStorageDirectoryLock)
    {
      if (hostsStorageDirectory == null)
      {
        String snapshotsStorageString = HostsSupportImpl.getStorageDirectoryString();
        hostsStorageDirectory = new File(snapshotsStorageString);
        if ((hostsStorageDirectory.exists()) && (hostsStorageDirectory.isFile())) {
          throw new IllegalStateException("Cannot create hosts storage directory " + snapshotsStorageString + ", file in the way");
        }
        if ((hostsStorageDirectory.exists()) && ((!hostsStorageDirectory.canRead()) || (!hostsStorageDirectory.canWrite()))) {
          throw new IllegalStateException("Cannot access hosts storage directory " + snapshotsStorageString + ", read&write permission required");
        }
        if (!Utils.prepareDirectory(hostsStorageDirectory)) {
          throw new IllegalStateException("Cannot create hosts storage directory " + snapshotsStorageString);
        }
      }
      return hostsStorageDirectory;
    }
  }
  
  public static boolean storageDirectoryExists()
  {
    return new File(HostsSupportImpl.getStorageDirectoryString()).isDirectory();
  }
  
  Host createLocalHost()
  {
    return hostProvider.createLocalHost();
  }
  
  Host createUnknownHost()
  {
    return hostProvider.createUnknownHost();
  }
  
  private HostsSupport()
  {
    DataSourceDescriptorFactory.getDefault().registerProvider(new HostDescriptorProvider());
    
    RemoteHostsContainer container = RemoteHostsContainer.sharedInstance();
    DataSource.ROOT.getRepository().addDataSource(container);
    
    hostProvider.initialize();
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.HostsSupport
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.properties.PropertiesSupport;
import com.sun.tools.visualvm.host.impl.GeneralPropertiesProvider;
import org.openide.modules.ModuleInstall;

class Installer
  extends ModuleInstall
{
  public void restored()
  {
    HostsSupport.getInstance();
    PropertiesSupport.sharedInstance().registerPropertiesProvider(new GeneralPropertiesProvider(), Host.class);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.Installer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import java.awt.Image;
import java.util.Comparator;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

public class LocalHostDescriptor
  extends DataSourceDescriptor<Host>
{
  private static final Image NODE_ICON = ImageUtilities.loadImage("com/sun/tools/visualvm/host/resources/localHost.png", true);
  
  public LocalHostDescriptor()
  {
    super(Host.LOCALHOST, NbBundle.getMessage(LocalHostDescriptor.class, "LBL_Local"), NbBundle.getMessage(LocalHostDescriptor.class, "DESCR_Local"), NODE_ICON, 0, 1);
  }
  
  public void setChildrenComparator(Comparator<DataSource> newComparator)
  {
    super.setChildrenComparator(newComparator);
  }
  
  public Comparator<DataSource> getChildrenComparator()
  {
    return super.getChildrenComparator();
  }
  
  public boolean providesProperties()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.LocalHostDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import java.awt.Image;
import java.util.Comparator;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

public class RemoteHostDescriptor
  extends DataSourceDescriptor<Host>
{
  private static final Image NODE_ICON = ImageUtilities.loadImage("com/sun/tools/visualvm/host/resources/remoteHost.png", true);
  
  public RemoteHostDescriptor(Host host)
  {
    super(host, resolveName(host, host.getHostName()), NbBundle.getMessage(RemoteHostDescriptor.class, "DESCR_Remote"), NODE_ICON, resolvePosition(host, 2147483646, true), 1);
    
    setChildrenComparator(DataSourceDescriptorFactory.getDescriptor(Host.LOCALHOST).getChildrenComparator());
  }
  
  public void setChildrenComparator(Comparator<DataSource> newComparator)
  {
    super.setChildrenComparator(newComparator);
  }
  
  public boolean supportsRename()
  {
    return true;
  }
  
  public boolean providesProperties()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.RemoteHostDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.model.AbstractModelProvider;

class RemoteHostsContainer$1
  extends AbstractModelProvider<DataSourceDescriptor, DataSource>
{
  RemoteHostsContainer$1(RemoteHostsContainer paramRemoteHostsContainer) {}
  
  public DataSourceDescriptor createModelFor(DataSource ds)
  {
    if (RemoteHostsContainer.sharedInstance().equals(ds)) {
      return new RemoteHostsContainerDescriptor();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.RemoteHostsContainer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptorFactory;
import com.sun.tools.visualvm.core.model.AbstractModelProvider;

public final class RemoteHostsContainer
  extends DataSource
{
  private static RemoteHostsContainer sharedInstance;
  
  public static synchronized RemoteHostsContainer sharedInstance()
  {
    if (sharedInstance == null) {
      sharedInstance = new RemoteHostsContainer();
    }
    return sharedInstance;
  }
  
  private RemoteHostsContainer()
  {
    DataSourceDescriptorFactory.getDefault().registerProvider(new AbstractModelProvider()
    {
      public DataSourceDescriptor createModelFor(DataSource ds)
      {
        if (RemoteHostsContainer.sharedInstance().equals(ds)) {
          return new RemoteHostsContainerDescriptor();
        }
        return null;
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.RemoteHostsContainer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.DataSource;
import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import java.awt.Image;
import java.util.Comparator;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

public final class RemoteHostsContainerDescriptor
  extends DataSourceDescriptor<RemoteHostsContainer>
{
  private static final Image NODE_ICON = ImageUtilities.loadImage("com/sun/tools/visualvm/host/resources/remoteHosts.png", true);
  
  RemoteHostsContainerDescriptor()
  {
    super(RemoteHostsContainer.sharedInstance(), NbBundle.getMessage(RemoteHostsContainerDescriptor.class, "LBL_Remote"), null, NODE_ICON, 10, 3);
    
    setChildrenComparator(HostsSorting.instance().getInitialSorting());
  }
  
  public void setChildrenComparator(Comparator<DataSource> newComparator)
  {
    super.setChildrenComparator(newComparator);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.RemoteHostsContainerDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host;

import com.sun.tools.visualvm.core.datasource.descriptor.DataSourceDescriptor;
import java.awt.Image;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;

public class UnknownHostDescriptor
  extends DataSourceDescriptor
{
  private static final Image NODE_ICON = ImageUtilities.loadImage("com/sun/tools/visualvm/host/resources/remoteHosts.png", true);
  
  public UnknownHostDescriptor()
  {
    super(Host.UNKNOWN_HOST, NbBundle.getMessage(UnknownHostDescriptor.class, "LBL_Unknown_Host"), NbBundle.getMessage(UnknownHostDescriptor.class, "DESCR_Unknown"), NODE_ICON, Integer.MAX_VALUE, 1);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.UnknownHostDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

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

class GeneralPropertiesProvider$1
  extends JTextArea
{
  GeneralPropertiesProvider$1(GeneralPropertiesProvider paramGeneralPropertiesProvider) {}
  
  public Dimension getMinimumSize()
  {
    Dimension prefSize = getPreferredSize();
    Dimension minSize = super.getMinimumSize();
    width = 0;
    if (height < height) {
      return prefSize;
    }
    return minSize;
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.GeneralPropertiesProvider.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

class GeneralPropertiesProvider$2$1
  implements Runnable
{
  GeneralPropertiesProvider$2$1(GeneralPropertiesProvider.2 param2, String paramString1, String paramString2) {}
  
  public void run()
  {
    GeneralPropertiesProvider.access$000(this$1.val$textArea, val$hostname, val$ip);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.GeneralPropertiesProvider.2.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import com.sun.tools.visualvm.host.Host;
import java.net.InetAddress;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

class GeneralPropertiesProvider$2
  implements Runnable
{
  GeneralPropertiesProvider$2(GeneralPropertiesProvider paramGeneralPropertiesProvider, Host paramHost, JTextArea paramJTextArea) {}
  
  public void run()
  {
    InetAddress address = val$dataSource.getInetAddress();
    final String hostname = address.getCanonicalHostName();
    final String ip = address.getHostAddress();
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        GeneralPropertiesProvider.access$000(val$textArea, hostname, ip);
      }
    });
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.GeneralPropertiesProvider.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import com.sun.tools.visualvm.core.properties.PropertiesPanel;
import com.sun.tools.visualvm.core.properties.PropertiesProvider;
import com.sun.tools.visualvm.host.Host;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.net.InetAddress;
import javax.swing.BorderFactory;
import javax.swing.JTextArea;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;

public class GeneralPropertiesProvider
  extends PropertiesProvider<Host>
{
  public GeneralPropertiesProvider()
  {
    super(NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_HostProperties"), NbBundle.getMessage(GeneralPropertiesProvider.class, "DESCR_HostProperties"), Integer.MIN_VALUE, 50);
  }
  
  public PropertiesPanel createPanel(final Host dataSource)
  {
    PropertiesPanel panel = new PropertiesPanel();
    panel.setLayout(new BorderLayout());
    final JTextArea textArea = new JTextArea()
    {
      public Dimension getMinimumSize()
      {
        Dimension prefSize = getPreferredSize();
        Dimension minSize = super.getMinimumSize();
        width = 0;
        if (height < height) {
          return prefSize;
        }
        return minSize;
      }
    };
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.setOpaque(false);
    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
      textArea.setBackground(new Color(0, 0, 0, 0));
    }
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    String resolving = NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_Resolving");
    updateProperties(textArea, resolving, resolving);
    textArea.setMinimumSize(new Dimension(1, 1));
    panel.add(textArea, "Center");
    RequestProcessor.getDefault().post(new Runnable()
    {
      public void run()
      {
        InetAddress address = dataSource.getInetAddress();
        final String hostname = address.getCanonicalHostName();
        final String ip = address.getHostAddress();
        SwingUtilities.invokeLater(new Runnable()
        {
          public void run()
          {
            GeneralPropertiesProvider.updateProperties(val$textArea, hostname, ip);
          }
        });
      }
    });
    return panel;
  }
  
  private static void updateProperties(JTextArea textArea, String hostname, String ip)
  {
    String dnsName = NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_DnsName");
    String ipAddress = NbBundle.getMessage(GeneralPropertiesProvider.class, "LBL_IpAddress");
    textArea.setText(dnsName + " " + hostname + "\n" + ipAddress + " " + ip);
    textArea.setCaretPosition(0);
  }
  
  public boolean supportsDataSource(Host dataSource)
  {
    return dataSource != null;
  }
  
  public void propertiesDefined(PropertiesPanel panel, Host dataSource) {}
  
  public void propertiesChanged(PropertiesPanel panel, Host dataSource) {}
  
  public void propertiesCancelled(PropertiesPanel panel, Host dataSource) {}
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.GeneralPropertiesProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import com.sun.tools.visualvm.core.properties.PropertiesCustomizer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JTextField;

class HostCustomizer$1
  implements Runnable
{
  HostCustomizer$1(HostCustomizer paramHostCustomizer) {}
  
  public void run()
  {
    String hostname = HostCustomizer.access$000(this$0);
    if (!HostCustomizer.access$100(this$0).isSelected())
    {
      HostCustomizer.access$202(this$0, true);
      HostCustomizer.access$300(this$0).setText(hostname);
      HostCustomizer.access$202(this$0, false);
    }
    String displayname = HostCustomizer.access$400(this$0);
    HostCustomizer.access$300(this$0).setEnabled(HostCustomizer.access$100(this$0).isSelected());
    
    boolean hostValid = (hostname.length() > 0) && (displayname.length() > 0);
    boolean settingsValid = HostCustomizer.access$500(this$0) == null ? true : HostCustomizer.access$500(this$0).settingsValid();
    
    HostCustomizer.access$600(this$0).setEnabled((hostValid) && (settingsValid));
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import com.sun.tools.visualvm.core.properties.PropertiesCustomizer;
import java.awt.Dimension;
import java.awt.Window;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;

class HostCustomizer$2
  implements Runnable
{
  HostCustomizer$2(HostCustomizer paramHostCustomizer) {}
  
  public void run()
  {
    if (HostCustomizer.access$700(this$0).isSelected())
    {
      HostCustomizer.access$800(this$0).add(HostCustomizer.access$500(this$0), "Center");
      HostCustomizer.access$800(this$0).setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
      
      Dimension prefSize = HostCustomizer.access$500(this$0).getPreferredSize();
      
      height = Math.max(height, access$900height);
      height = Math.min(height, access$1000height);
      HostCustomizer.access$500(this$0).setPreferredSize(prefSize);
    }
    else
    {
      HostCustomizer.access$800(this$0).removeAll();
      HostCustomizer.access$800(this$0).setBorder(BorderFactory.createEmptyBorder());
    }
    Window w = SwingUtilities.getWindowAncestor(this$0);
    if (w != null) {
      w.pack();
    }
    HostCustomizer.access$1100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

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

class HostCustomizer$3
  implements DocumentListener
{
  HostCustomizer$3(HostCustomizer paramHostCustomizer) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
  
  public void removeUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
  
  public void changedUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

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

class HostCustomizer$4
  implements ActionListener
{
  HostCustomizer$4(HostCustomizer paramHostCustomizer) {}
  
  public void actionPerformed(ActionEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

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

class HostCustomizer$5
  implements DocumentListener
{
  HostCustomizer$5(HostCustomizer paramHostCustomizer) {}
  
  public void insertUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
  
  public void removeUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
  
  public void changedUpdate(DocumentEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.5
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

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

class HostCustomizer$6
  extends JToggleButton
{
  HostCustomizer$6(HostCustomizer paramHostCustomizer) {}
  
  protected void fireActionPerformed(ActionEvent e)
  {
    HostCustomizer.access$1200(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.6
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

class HostCustomizer$7
  implements ChangeListener
{
  HostCustomizer$7(HostCustomizer paramHostCustomizer) {}
  
  public void stateChanged(ChangeEvent e)
  {
    HostCustomizer.access$1100(this$0);
  }
}

/* Location:
 * Qualified Name:     com.sun.tools.visualvm.host.impl.HostCustomizer.7
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.tools.visualvm.host.impl;

import com.sun.tools.visualvm.core.properties.PropertiesCustomizer;
import com.sun.tools.visualvm.core.properties.PropertiesSupport;
import com.sun.tools.visualvm.core.ui.components.ScrollableContainer;
import com.sun.tools.visualvm.host.Host;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.awt.Mnemonics;
import org.openide.util.NbBundle;

public class HostCustomizer
  extends JPanel
{
  private static Dimension MIN_PROPERTIES_SIZE = new Dimension(400, 200);
  private static Dimension MAX_PROPERTIES_SIZE = new Dimension(700, 400);
  private boolean internalChange = false;
  private static HostCustomizer instance;
  private JLabel hostnameLabel;
  private JTextField hostnameField;
  private JCheckBox displaynameCheckbox;
  private JTextField displaynameField;
  private JPanel settingsContainer;
  private PropertiesCustomizer settingsPanel;
  private JButton okButton;
  private JToggleButton settingsButton;
  
  public static HostProperties defineHost()
  {
    HostCustomizer hc = getInstance();
    hc.setup();
    
    ScrollableContainer sc = new ScrollableContainer(hc, 20, 31);
    
    sc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    sc.setViewportBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    
    DialogDescriptor dd = new DialogDescriptor(sc, NbBundle.getMessage(HostCustomizer.class, "Title_Add_Remote_Host"), true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, 0, null, null);
    
    dd.setAdditionalOptions(new Object[] { settingsButton });
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
    if (dd.getValue() == okButton)
    {
      HostProperties hp = new HostProperties(hc.getHostName(), hc.getDisplayName(), hc.getPropertiesCustomizer());
      
      hc.accepted();
      return hp;
    }
    hc.cancelled();
    return null;
  }
  
  private HostCustomizer()
  {
    initComponents();
    update();
  }
  
  private static HostCustomizer getInstance()
  {
    if (instance == null) {
      instance = new HostCustomizer();
    }
    return instance;
  }
  
  private String getHostName()
  {
    return hostnameField.getText().trim();
  }
  
  private String getDisplayName()
  {
    return displaynameField.getText().trim();
  }
  
  private PropertiesCustomizer getPropertiesCustomizer()
  {
    return settingsPanel;
  }
  
  private void setup()
  {
    hostnameField.setEnabled(true);
    displaynameCheckbox.setSelected(false);
    displaynameCheckbox.setEnabled(true);
    hostnameField.setText("");
    displaynameField.setText("");
    
    PropertiesSupport support = PropertiesSupport.sharedInstance();
    settingsPanel = (!support.hasProperties(Host.class) ? null : support.getCustomizer(Host.class));
    if (settingsPanel != null) {
      settingsPanel.addChangeListener(listener);
    }
    settingsButton.setVisible(settingsPanel != null);
    if (!settingsButton.isVisible()) {
      settingsButton.setSelected(fal
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