org.eclipse.ui.net_1.2.100.v20111208-1155

16:48:23.679 INFO  jd.cli.Main - Decompiling org.eclipse.ui.net_1.2.100.v20111208-1155.jar
package org.eclipse.ui.internal.net;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class Activator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.ui.net";
  private static Activator plugin;
  
  public Activator()
  {
    plugin = this;
  }
  
  public static Activator getDefault()
  {
    return plugin;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.Activator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.osgi.util.NLS;

public final class NetUIMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.ui.internal.net.messages";
  public static String ProxyPreferencePage_0;
  public static String ProxyPreferencePage_1;
  public static String ProxyPreferencePage_2;
  public static String ProxyPreferencePage_3;
  public static String ProxyPreferencePage_4;
  public static String ProxyPreferencePage_5;
  public static String ProxyPreferencePage_6;
  public static String ProxyPreferencePage_7;
  public static String ProxyPreferencePage_8;
  public static String ProxyPreferencePage_9;
  public static String ProxyPreferencePage_10;
  public static String ProxyPreferencePage_11;
  public static String ProxyPreferencePage_12;
  public static String ProxyPreferencePage_13;
  public static String ProxyPreferencePage_14;
  public static String ProxyPreferencePage_15;
  public static String ProxyPreferencePage_16;
  public static String ProxyPreferencePage_17;
  public static String ProxyPreferencePage_18;
  public static String ProxyEntryDialog_0;
  public static String ProxyEntryDialog_1;
  public static String ProxyEntryDialog_2;
  public static String ProxyEntryDialog_3;
  public static String ProxyEntryDialog_4;
  public static String ProxyEntryDialog_5;
  public static String ProxyEntryDialog_6;
  public static String ProxyEntryDialog_7;
  public static String ProxyEntryDialog_8;
  public static String ProxyEntryDialog_9;
  public static String ProxyEntryDialog_10;
  public static String ProxyEntryDialog_11;
  public static String ProxyEntryDialog_12;
  public static String ProxyEntryDialog_13;
  public static String ProxyBypassDialog_0;
  public static String ProxyBypassDialog_1;
  public static String ProxyBypassDialog_2;
  public static String UserValidationDialog_0;
  public static String UserValidationDialog_1;
  public static String UserValidationDialog_2;
  public static String UserValidationDialog_3;
  
  static
  {
    NLS.initializeMessages("org.eclipse.ui.internal.net.messages", NetUIMessages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NetUIMessages
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class NonProxyHostsComposite$1
  implements ISelectionChangedListener
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$1(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.enableButtons();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;

class NonProxyHostsComposite$2
  implements ICheckStateListener
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$2(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    this$0.setProvider(this$0.currentProvider);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;

class NonProxyHostsComposite$3
  implements IDoubleClickListener
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$3(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void doubleClick(DoubleClickEvent event)
  {
    this$0.editSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class NonProxyHostsComposite$4
  extends SelectionAdapter
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$4(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.addHost();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class NonProxyHostsComposite$5
  extends SelectionAdapter
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$5(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.editSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class NonProxyHostsComposite$6
  extends SelectionAdapter
{
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$6(NonProxyHostsComposite paramNonProxyHostsComposite)
  {
    this$0 = paramNonProxyHostsComposite;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.removeSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.6
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

class NonProxyHostsComposite$7
  extends InputDialog
{
  private ControlDecoration decorator;
  final NonProxyHostsComposite this$0;
  
  NonProxyHostsComposite$7(NonProxyHostsComposite paramNonProxyHostsComposite, Shell $anonymous0, String $anonymous1, String $anonymous2, String $anonymous3, IInputValidator $anonymous4)
  {
    super($anonymous0, $anonymous1, $anonymous2, $anonymous3, $anonymous4);this$0 = paramNonProxyHostsComposite;
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Control createDialogArea = super.createDialogArea(parent);
    decorator = new ControlDecoration(getText(), 16512);
    decorator.setDescriptionText(NetUIMessages.ProxyBypassDialog_2);
    decorator.setImage(FieldDecorationRegistry.getDefault()
      .getFieldDecoration(
      "DEC_INFORMATION")
      .getImage());
    return createDialogArea;
  }
  
  public boolean close()
  {
    decorator.dispose();
    return super.close();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite.7
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.core.internal.net.StringUtil;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;

public class NonProxyHostsComposite
  extends Composite
{
  private Label hostsLabel;
  CheckboxTableViewer hostsViewer;
  private Button addButton;
  private Button editButton;
  private Button removeButton;
  protected String currentProvider;
  private ArrayList bypassHosts = new ArrayList();
  
  NonProxyHostsComposite(Composite parent, int style)
  {
    super(parent, style);
    createWidgets();
  }
  
  protected void createWidgets()
  {
    setLayout(new GridLayout(2, false));
    
    hostsLabel = new Label(this, 0);
    hostsLabel.setText(NetUIMessages.ProxyPreferencePage_12);
    hostsLabel.setLayoutData(new GridData(16384, 128, false, false, 
      2, 1));
    
    Table hostsTable = new Table(this, 68386);
    
    hostsTable.setHeaderVisible(true);
    hostsTable.setLinesVisible(true);
    hostsTable.setLayoutData(new GridData(4, 4, true, true, 
      1, 3));
    
    hostsViewer = new CheckboxTableViewer(hostsTable);
    NonProxyHostsLabelProvider labelProvider = new NonProxyHostsLabelProvider();
    NonProxyHostsContentProvider contentProvider = new NonProxyHostsContentProvider();
    labelProvider.createColumns(hostsViewer);
    hostsViewer.setContentProvider(contentProvider);
    hostsViewer.setLabelProvider(labelProvider);
    
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(24));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    hostsTable.setLayout(tableLayout);
    
    addButton = createButton(NetUIMessages.ProxyPreferencePage_15);
    editButton = createButton(NetUIMessages.ProxyPreferencePage_16);
    removeButton = createButton(NetUIMessages.ProxyPreferencePage_17);
    
    hostsViewer
      .addSelectionChangedListener(new ISelectionChangedListener()
      {
        public void selectionChanged(SelectionChangedEvent event)
        {
          enableButtons();
        }
      });
    hostsViewer.addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        setProvider(currentProvider);
      }
    });
    hostsViewer.addDoubleClickListener(new IDoubleClickListener()
    {
      public void doubleClick(DoubleClickEvent event)
      {
        editSelection();
      }
    });
    addButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        addHost();
      }
    });
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        editSelection();
      }
    });
    removeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        removeSelection();
      }
    });
    initializeValues();
    enableButtons();
  }
  
  public void setEnabled(boolean enabled)
  {
    super.setEnabled(enabled);
    hostsViewer.getTable().setEnabled(enabled);
    enableButtons();
  }
  
  protected void enableButtons()
  {
    boolean enabled = getEnabled();
    if (enabled)
    {
      boolean editable = isSelectionEditable();
      addButton.setEnabled(true);
      editButton.setEnabled(editable);
      removeButton.setEnabled(editable);
    }
    else
    {
      addButton.setEnabled(false);
      editButton.setEnabled(false);
      removeButton.setEnabled(false);
    }
  }
  
  private boolean isSelectionEditable()
  {
    IStructuredSelection selection = (IStructuredSelection)hostsViewer
      .getSelection();
    Iterator iterator = selection.iterator();
    boolean editable = iterator.hasNext();
    while (iterator.hasNext())
    {
      String provider = ((ProxyBypassData)iterator.next()).getSource();
      if (!ProxySelector.canSetBypassHosts(provider)) {
        editable = false;
      }
    }
    return editable;
  }
  
  protected void addHost()
  {
    String[] hosts = promptForHost(null);
    if (hosts != null)
    {
      for (int i = 0; i < hosts.length; i++) {
        bypassHosts.add(0, new ProxyBypassData(hosts[i], 
          getEditableProvider()));
      }
      hostsViewer.refresh();
      setProvider(currentProvider);
    }
  }
  
  private String getEditableProvider()
  {
    String[] providers = ProxySelector.getProviders();
    for (int i = 0; i < providers.length; i++) {
      if (ProxySelector.canSetBypassHosts(providers[i])) {
        return providers[i];
      }
    }
    return null;
  }
  
  protected void removeSelection()
  {
    IStructuredSelection selection = (IStructuredSelection)hostsViewer
      .getSelection();
    Iterator it = selection.iterator();
    while (it.hasNext())
    {
      ProxyBypassData data = (ProxyBypassData)it.next();
      bypassHosts.remove(data);
    }
    hostsViewer.refresh();
  }
  
  protected void editSelection()
  {
    if (!isSelectionEditable()) {
      return;
    }
    IStructuredSelection selection = (IStructuredSelection)hostsViewer
      .getSelection();
    String selectedHosts = getStringList(selection.iterator());
    String[] hosts = promptForHost(selectedHosts);
    if (hosts != null)
    {
      Object[] selectedItems = selection.toArray();
      for (int i = 0; i < selectedItems.length; i++)
      {
        ProxyBypassData data = (ProxyBypassData)selectedItems[i];
        data.setHost(hosts[i]);
      }
      hostsViewer.refresh();
    }
  }
  
  String getStringList(Iterator iterator)
  {
    StringBuffer buffer = new StringBuffer();
    if (iterator.hasNext())
    {
      ProxyBypassData data = (ProxyBypassData)iterator.next();
      buffer.append(data.getHost());
    }
    while (iterator.hasNext())
    {
      buffer.append(';');
      ProxyBypassData data = (ProxyBypassData)iterator.next();
      buffer.append(data.getHost());
    }
    return buffer.toString();
  }
  
  private String[] promptForHost(String selectedHosts)
  {
    InputDialog dialog = new InputDialog(getShell(), 
      NetUIMessages.ProxyBypassDialog_0, 
      NetUIMessages.ProxyBypassDialog_1, selectedHosts, null)
      {
        private ControlDecoration decorator;
        
        protected Control createDialogArea(Composite parent)
        {
          Control createDialogArea = super.createDialogArea(parent);
          decorator = new ControlDecoration(getText(), 16512);
          decorator.setDescriptionText(NetUIMessages.ProxyBypassDialog_2);
          decorator.setImage(FieldDecorationRegistry.getDefault()
            .getFieldDecoration(
            "DEC_INFORMATION")
            .getImage());
          return createDialogArea;
        }
        
        public boolean close()
        {
          decorator.dispose();
          return super.close();
        }
      };
      int result = dialog.open();
      if (result != 1)
      {
        String value = dialog.getValue();
        String[] hosts = StringUtil.split(value, new String[] { ";", "|" });
        ArrayList filtered = new ArrayList();
        for (int i = 0; i < hosts.length; i++) {
          if (hosts[i].length() != 0) {
            filtered.add(hosts[i]);
          }
        }
        return (String[])filtered.toArray(new String[0]);
      }
      return null;
    }
    
    private Button createButton(String message)
    {
      Button button = new Button(this, 8);
      button.setText(message);
      button.setLayoutData(new GridData(4, 128, false, false));
      return button;
    }
    
    public void initializeValues()
    {
      String[] providers = ProxySelector.getProviders();
      for (int i = 0; i < providers.length; i++) {
        bypassHosts.addAll(getProxyBypassData(providers[i]));
      }
      hostsViewer.setInput(bypassHosts);
      setProvider(ProxySelector.getDefaultProvider());
    }
    
    public void setProvider(String item)
    {
      if (item == null) {
        item = currentProvider;
      } else {
        currentProvider = item;
      }
      ArrayList selected = new ArrayList();
      Iterator it = bypassHosts.iterator();
      while (it.hasNext())
      {
        ProxyBypassData data = (ProxyBypassData)it.next();
        if (data.getSource().equalsIgnoreCase(item)) {
          selected.add(data);
        }
      }
      hostsViewer.setCheckedElements(selected.toArray(new ProxyBypassData[0]));
    }
    
    public void performApply()
    {
      String provider = getEditableProvider();
      Iterator it = bypassHosts.iterator();
      ArrayList hosts = new ArrayList();
      while (it.hasNext())
      {
        ProxyBypassData data = (ProxyBypassData)it.next();
        if (data.getSource().equals(provider)) {
          hosts.add(data.getHost());
        }
      }
      String[] data = (String[])hosts.toArray(new String[0]);
      ProxySelector.setBypassHosts(provider, data);
    }
    
    public void refresh()
    {
      ArrayList natives = new ArrayList();
      String provider = getEditableProvider();
      Iterator it = bypassHosts.iterator();
      while (it.hasNext())
      {
        ProxyBypassData data = (ProxyBypassData)it.next();
        if (!data.getSource().equals(provider)) {
          natives.add(data);
        }
      }
      bypassHosts.removeAll(natives);
      String[] providers = ProxySelector.getProviders();
      for (int i = 0; i < providers.length; i++) {
        if (!providers[i].equals(provider)) {
          bypassHosts.addAll(getProxyBypassData(providers[i]));
        }
      }
      hostsViewer.refresh();
      setProvider(currentProvider);
    }
    
    private List getProxyBypassData(String provider)
    {
      List bypassProxyData = new ArrayList();
      String[] hosts = ProxySelector.getBypassHosts(provider);
      for (int j = 0; (hosts != null) && (j < hosts.length); j++)
      {
        ProxyBypassData data = new ProxyBypassData(hosts[j], provider);
        bypassProxyData.add(data);
      }
      return bypassProxyData;
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsComposite
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import java.util.Collection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class NonProxyHostsContentProvider
  implements IStructuredContentProvider
{
  public void dispose() {}
  
  public Object[] getElements(Object inputElement)
  {
    Collection coll = (Collection)inputElement;
    return coll.toArray(new ProxyBypassData[0]);
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsContentProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableColumn;

public class NonProxyHostsLabelProvider
  extends BaseLabelProvider
  implements ITableLabelProvider, IColorProvider
{
  public Image getColumnImage(Object element, int columnIndex)
  {
    return null;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    if (element == null) {
      return null;
    }
    ProxyBypassData data = (ProxyBypassData)element;
    switch (columnIndex)
    {
    case 0: 
      return null;
    case 1: 
      return data.getHost();
    case 2: 
      return ProxySelector.localizeProvider(data.getSource());
    }
    return null;
  }
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void createColumns(TableViewer viewer)
  {
    String[] titles = {
      "", 
      NetUIMessages.ProxyPreferencePage_13, 
      NetUIMessages.ProxyPreferencePage_14 };
    for (int i = 0; i < titles.length; i++)
    {
      TableColumn column = new TableViewerColumn(viewer, 0)
        .getColumn();
      column.setText(titles[i]);
      column.setResizable(true);
    }
  }
  
  public Color getBackground(Object element)
  {
    if ((element instanceof ProxyBypassData))
    {
      String provider = ((ProxyBypassData)element).getSource();
      if (!ProxySelector.canSetBypassHosts(provider)) {
        return Display.getCurrent().getSystemColor(
          29);
      }
    }
    return null;
  }
  
  public Color getForeground(Object element)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.NonProxyHostsLabelProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

public class ProxyBypassData
{
  private String host;
  private String source;
  
  public ProxyBypassData(String host, String source)
  {
    this.host = host;
    this.source = source;
  }
  
  public String getHost()
  {
    return host;
  }
  
  public void setHost(String host)
  {
    this.host = host;
  }
  
  public String getSource()
  {
    return source;
  }
  
  public void setSource(String source)
  {
    this.source = source;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyBypassData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class ProxyEntriesComposite$1
  implements ISelectionChangedListener
{
  final ProxyEntriesComposite this$0;
  
  ProxyEntriesComposite$1(ProxyEntriesComposite paramProxyEntriesComposite)
  {
    this$0 = paramProxyEntriesComposite;
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.enableButtons();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;

class ProxyEntriesComposite$2
  implements ICheckStateListener
{
  final ProxyEntriesComposite this$0;
  
  ProxyEntriesComposite$2(ProxyEntriesComposite paramProxyEntriesComposite)
  {
    this$0 = paramProxyEntriesComposite;
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    this$0.setProvider(this$0.currentProvider);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;

class ProxyEntriesComposite$3
  implements IDoubleClickListener
{
  final ProxyEntriesComposite this$0;
  
  ProxyEntriesComposite$3(ProxyEntriesComposite paramProxyEntriesComposite)
  {
    this$0 = paramProxyEntriesComposite;
  }
  
  public void doubleClick(DoubleClickEvent event)
  {
    this$0.editSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ProxyEntriesComposite$4
  extends SelectionAdapter
{
  final ProxyEntriesComposite this$0;
  
  ProxyEntriesComposite$4(ProxyEntriesComposite paramProxyEntriesComposite)
  {
    this$0 = paramProxyEntriesComposite;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.editSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ProxyEntriesComposite$5
  extends SelectionAdapter
{
  final ProxyEntriesComposite this$0;
  
  ProxyEntriesComposite$5(ProxyEntriesComposite paramProxyEntriesComposite)
  {
    this$0 = paramProxyEntriesComposite;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.removeSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.internal.net.ProxyData;
import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;

public class ProxyEntriesComposite
  extends Composite
{
  private Label entriesLabel;
  private CheckboxTableViewer entriesViewer;
  private Button editButton;
  private Button removeButton;
  protected String currentProvider;
  private ArrayList proxyEntries = new ArrayList();
  
  ProxyEntriesComposite(Composite parent, int style)
  {
    super(parent, style);
    createWidgets();
  }
  
  protected void createWidgets()
  {
    setLayout(new GridLayout(2, false));
    
    entriesLabel = new Label(this, 0);
    entriesLabel.setText(NetUIMessages.ProxyPreferencePage_1);
    entriesLabel.setLayoutData(new GridData(1, 16777216, 
      false, false, 2, 1));
    
    Table entriesTable = new Table(this, 68386);
    
    entriesTable.setHeaderVisible(true);
    entriesTable.setLinesVisible(true);
    entriesTable.setLayoutData(new GridData(4, 4, true, true, 
      1, 3));
    
    entriesViewer = new CheckboxTableViewer(entriesTable);
    ProxyEntriesLabelProvider labelProvider = new ProxyEntriesLabelProvider();
    ProxyEntriesContentProvider contentProvider = new ProxyEntriesContentProvider();
    labelProvider.createColumns(entriesViewer);
    entriesViewer.setContentProvider(contentProvider);
    entriesViewer.setLabelProvider(labelProvider);
    
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(24));
    tableLayout.addColumnData(new ColumnWeightData(20, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(20, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(20, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(20, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
    
    entriesTable.setLayout(tableLayout);
    
    editButton = createButton(NetUIMessages.ProxyPreferencePage_10);
    removeButton = createButton(NetUIMessages.ProxyPreferencePage_11);
    
    entriesViewer
      .addSelectionChangedListener(new ISelectionChangedListener()
      {
        public void selectionChanged(SelectionChangedEvent event)
        {
          enableButtons();
        }
      });
    entriesViewer.addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        setProvider(currentProvider);
      }
    });
    entriesViewer.addDoubleClickListener(new IDoubleClickListener()
    {
      public void doubleClick(DoubleClickEvent event)
      {
        editSelection();
      }
    });
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        editSelection();
      }
    });
    removeButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        removeSelection();
      }
    });
    initializeValues();
    enableButtons();
  }
  
  protected void enableButtons()
  {
    boolean enabled = getEnabled();
    if (enabled)
    {
      editButton.setEnabled(isSelectionEditable());
      removeButton.setEnabled(isSelectionRemovable());
    }
    else
    {
      editButton.setEnabled(false);
      removeButton.setEnabled(false);
    }
  }
  
  private boolean isSelectionEditable()
  {
    IStructuredSelection selection = (IStructuredSelection)entriesViewer
      .getSelection();
    return (isSelectionRemovable()) && (selection.size() == 1);
  }
  
  private boolean isSelectionRemovable()
  {
    IStructuredSelection selection = (IStructuredSelection)entriesViewer
      .getSelection();
    Iterator iterator = selection.iterator();
    boolean editable = iterator.hasNext();
    while (iterator.hasNext())
    {
      String provider = ((ProxyData)iterator.next()).getSource();
      if (!ProxySelector.canSetProxyData(provider)) {
        editable = false;
      }
    }
    return editable;
  }
  
  protected void addEntry()
  {
    Iterator it = proxyEntries.iterator();
    ArrayList added = new ArrayList();
    String editableProvider = getEditableProvider();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      if (data.getSource().equalsIgnoreCase(editableProvider)) {
        added.add(data.getType());
      }
    }
    String[] addedArray = (String[])added.toArray(new String[0]);
    ProxyData data = promptForEntry(null, addedArray, 
      NetUIMessages.ProxyEntryDialog_0);
    if (data != null)
    {
      data.setSource(editableProvider);
      proxyEntries.add(0, data);
      entriesViewer.refresh();
    }
  }
  
  private String getEditableProvider()
  {
    String[] providers = ProxySelector.getProviders();
    for (int i = 0; i < providers.length; i++) {
      if (ProxySelector.canSetProxyData(providers[i])) {
        return providers[i];
      }
    }
    return null;
  }
  
  private ProxyData promptForEntry(ProxyData entry, String[] addedArray, String title)
  {
    ProxyEntryDialog dialog = new ProxyEntryDialog(getShell(), entry, 
      addedArray, title);
    int result = dialog.open();
    if (result != 1) {
      return dialog.getValue();
    }
    return null;
  }
  
  protected void editSelection()
  {
    if (!isSelectionRemovable()) {
      return;
    }
    Iterator itsel = ((IStructuredSelection)entriesViewer.getSelection()).iterator();
    ProxyData toEdit = null;
    if (itsel.hasNext()) {
      toEdit = (ProxyData)itsel.next();
    } else {
      return;
    }
    Iterator it = proxyEntries.iterator();
    ArrayList added = new ArrayList();
    String editableProvider = getEditableProvider();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      if ((data.getSource().equalsIgnoreCase(editableProvider)) && 
        (data.getType() != toEdit.getType())) {
        added.add(data.getType());
      }
    }
    String[] addedArray = (String[])added.toArray(new String[0]);
    ProxyData data = promptForEntry(toEdit, addedArray, 
      NetUIMessages.ProxyEntryDialog_1);
    if (data != null) {
      entriesViewer.refresh();
    }
  }
  
  protected void removeSelection()
  {
    IStructuredSelection selection = (IStructuredSelection)entriesViewer
      .getSelection();
    Iterator it = selection.iterator();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      data.setHost("");
      data.setPort(-1);
      data.setUserid(null);
      data.setPassword(null);
    }
    entriesViewer.refresh();
  }
  
  private Button createButton(String message)
  {
    Button button = new Button(this, 8);
    button.setText(message);
    button.setLayoutData(new GridData(4, 128, false, false));
    return button;
  }
  
  public void initializeValues()
  {
    String[] providers = ProxySelector.getProviders();
    for (int i = 0; i < providers.length; i++) {
      proxyEntries.addAll(getProxyData(providers[i]));
    }
    entriesViewer.setInput(proxyEntries);
    setProvider(ProxySelector.getDefaultProvider());
  }
  
  public void setProvider(String item)
  {
    if (item == null) {
      item = currentProvider;
    } else {
      currentProvider = item;
    }
    ArrayList checked = new ArrayList();
    Iterator it = proxyEntries.iterator();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      if (data.getSource().equalsIgnoreCase(item)) {
        checked.add(data);
      }
    }
    entriesViewer.setCheckedElements(checked.toArray(new ProxyData[0]));
  }
  
  public void performApply()
  {
    String provider = getEditableProvider();
    Iterator it = proxyEntries.iterator();
    ArrayList proxies = new ArrayList();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      if (data.getSource().equals(provider)) {
        proxies.add(data);
      }
    }
    ProxyData[] data = (ProxyData[])proxies.toArray(new ProxyData[0]);
    ProxySelector.setProxyData(provider, data);
  }
  
  public void refresh()
  {
    String provider = getEditableProvider();
    Iterator it = proxyEntries.iterator();
    ArrayList natives = new ArrayList();
    while (it.hasNext())
    {
      ProxyData data = (ProxyData)it.next();
      if (!data.getSource().equals(provider)) {
        natives.add(data);
      }
    }
    proxyEntries.removeAll(natives);
    String[] providers = ProxySelector.getProviders();
    for (int i = 0; i < providers.length; i++) {
      if (!providers[i].equals(provider)) {
        proxyEntries.addAll(getProxyData(providers[i]));
      }
    }
    entriesViewer.refresh();
    setProvider(currentProvider);
  }
  
  private List getProxyData(String provider)
  {
    List proxyDatas = new ArrayList();
    ProxyData[] entries = ProxySelector.getProxyData(provider);
    for (int j = 0; j < entries.length; j++)
    {
      entries[j].setSource(provider);
      proxyDatas.add(entries[j]);
    }
    return proxyDatas;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesComposite
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import java.util.Collection;
import org.eclipse.core.internal.net.ProxyData;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class ProxyEntriesContentProvider
  implements IStructuredContentProvider
{
  public void dispose() {}
  
  public Object[] getElements(Object inputElement)
  {
    Collection coll = (Collection)inputElement;
    return coll.toArray(new ProxyData[0]);
  }
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.net.ProxyEntriesContentProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.net;

import org.eclipse.core.internal.net.ProxyData;
import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableColumn;

public class ProxyEntriesLabelProvider
  extends BaseLabelProvider
  implements ITableLabelProvider, IColorProvider
{
  public Image getColumnImage(Object element, int columnIndex)
  {
    return null;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    if (element == null) {
      return null;
    }
    ProxyData data = (ProxyData)element;
    switch (columnIndex)
    {
    case 0: 
      return null;
    case 1: 
      return data.getType();
    case 2: 
      if (data.isDynamic()) {
        return NetUIMessages.ProxyPreferencePage_18;
      }
      return data.getHost();
    case 3: 
      if (data.isDynamic()) {
        return NetUIMessages.ProxyPreferencePage_18;
      }
      if (data.getPort() == -1) {
        return "";
      }
      return Integer.toString(data.getPort());
    case 4: 
      return ProxySelector.localizeProvider(data.getSource());
    case 5: 
      return Boolean.toString(data.isRequiresAuthentication());
    case 6: 
      return data.getUserId();
    case 7: 
      if (data.getPassword() == null) {
        return null;
      }
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < data.getPassword().length(); i++) {
        sb.append('*');
      }
      return sb.toString();
    }
    return null;
  }
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void createColumns(TableViewer viewer)
  {
    String[] titles = {
      "", 
      NetUIMessages.ProxyPreferencePage_2, 
      NetUIMessages.ProxyPreferencePage_3, 
      NetUIMessages.ProxyPreferencePage_4, 
      NetUIMessages.ProxyPreferencePage_5, 
      NetUIMessages.ProxyPreferencePage_6, 
      NetUIMessages.ProxyPreferencePage_7, 
      NetUIMessages.ProxyPreferencePage_8 };
    for (int i = 0; i < titles.length; i++)
    {
      TableColumn column = new Tab
1 2

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-2019. Infinite Loop Ltd