org.eclipse.mylyn.commons.team_0.9.1.v20120412-0100

16:46:32.952 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.team_0.9.1.v20120412-0100.jar
package org.eclipse.mylyn.commons.ui.team;

import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.databinding.dialog.DialogPageSupport;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.databinding.wizard.WizardPageSupport;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
import org.eclipse.mylyn.commons.repositories.RepositoryValidator;
import org.eclipse.mylyn.commons.repositories.auth.AuthenticationType;
import org.eclipse.mylyn.commons.repositories.auth.UsernamePasswordCredentials;
import org.eclipse.mylyn.internal.commons.ui.SectionComposite;
import org.eclipse.mylyn.internal.commons.ui.team.RepositoryLocationValueProperty;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.statushandlers.StatusManager;

@Deprecated
public class RepositoryLocationPart
{
  protected static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences";
  private DataBindingContext bindingContext;
  private boolean needsAdditionalSections;
  private boolean needsAnonymousLogin;
  private boolean needsHttpAuth;
  private boolean needsProxy;
  private boolean needsValidation;
  private IAdaptable serviceLocator;
  private final RepositoryLocation workingCopy;
  
  public class UrlValidator
    implements IValidator
  {
    public UrlValidator() {}
    
    public IStatus validate(Object value)
    {
      if (!isValidUrl(value.toString())) {
        return new Status(4, "org.eclipse.mylyn.commons.team", 
          Messages.RepositoryLocationPart_Enter_a_valid_server_url);
      }
      return Status.OK_STATUS;
    }
  }
  
  private class UsernamePasswordListener
    implements ModifyListener, SelectionListener
  {
    private final AuthenticationType authenticationType;
    private final Button enabledButton;
    private boolean enablementReversed;
    private final Text passwordText;
    private final Button savePasswordButton;
    private boolean updating;
    private final Text userText;
    
    public UsernamePasswordListener(AuthenticationType authenticationType, Button enabledButton, Text userText, Text passwordText, Button savePasswordButton)
    {
      this.authenticationType = authenticationType;
      this.enabledButton = enabledButton;
      this.userText = userText;
      this.passwordText = passwordText;
      this.savePasswordButton = savePasswordButton;
      init();
    }
    
    private void apply()
    {
      if (updating) {
        return;
      }
      if (isEnabled())
      {
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userText.getText(), 
          passwordText.getText());
        getWorkingCopy().setCredentials(authenticationType, credentials);
      }
      else
      {
        getWorkingCopy().setCredentials(authenticationType, null);
      }
    }
    
    protected void init()
    {
      enabledButton.addSelectionListener(this);
      userText.addModifyListener(this);
      passwordText.addModifyListener(this);
      savePasswordButton.addSelectionListener(this);
    }
    
    protected boolean isEnabled()
    {
      return enabledButton.getSelection() ^ isEnablementReversed();
    }
    
    public boolean isEnablementReversed()
    {
      return enablementReversed;
    }
    
    public void modifyText(ModifyEvent event)
    {
      apply();
    }
    
    /* Error */
    private void restore()
    {
      // Byte code:
      //   0: aload_0
      //   1: iconst_1
      //   2: putfield 113	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:updating	Z
      //   5: aload_0
      //   6: getfield 115	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:this$0	Lorg/eclipse/mylyn/commons/ui/team/RepositoryLocationPart;
      //   9: invokevirtual 126	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart:getWorkingCopy	()Lorg/eclipse/mylyn/commons/repositories/RepositoryLocation;
      //   12: aload_0
      //   13: getfield 114	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:authenticationType	Lorg/eclipse/mylyn/commons/repositories/auth/AuthenticationType;
      //   16: ldc 2
      //   18: invokevirtual 123	org/eclipse/mylyn/commons/repositories/RepositoryLocation:getCredentials	(Lorg/eclipse/mylyn/commons/repositories/auth/AuthenticationType;Ljava/lang/Class;)Lorg/eclipse/mylyn/commons/repositories/auth/AuthenticationCredentials;
      //   21: checkcast 2	org/eclipse/mylyn/commons/repositories/auth/UsernamePasswordCredentials
      //   24: astore_1
      //   25: aload_1
      //   26: ifnull +55 -> 81
      //   29: aload_0
      //   30: getfield 116	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:enabledButton	Lorg/eclipse/swt/widgets/Button;
      //   33: aload_0
      //   34: invokevirtual 132	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:isEnablementReversed	()Z
      //   37: ifeq +7 -> 44
      //   40: iconst_0
      //   41: goto +4 -> 45
      //   44: iconst_1
      //   45: invokevirtual 135	org/eclipse/swt/widgets/Button:setSelection	(Z)V
      //   48: aload_0
      //   49: getfield 119	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:userText	Lorg/eclipse/swt/widgets/Text;
      //   52: aload_1
      //   53: invokevirtual 124	org/eclipse/mylyn/commons/repositories/auth/UsernamePasswordCredentials:getUserName	()Ljava/lang/String;
      //   56: invokevirtual 139	org/eclipse/swt/widgets/Text:setText	(Ljava/lang/String;)V
      //   59: aload_0
      //   60: getfield 118	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:passwordText	Lorg/eclipse/swt/widgets/Text;
      //   63: aload_1
      //   64: invokevirtual 124	org/eclipse/mylyn/commons/repositories/auth/UsernamePasswordCredentials:getUserName	()Ljava/lang/String;
      //   67: invokevirtual 139	org/eclipse/swt/widgets/Text:setText	(Ljava/lang/String;)V
      //   70: aload_0
      //   71: getfield 117	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:savePasswordButton	Lorg/eclipse/swt/widgets/Button;
      //   74: iconst_1
      //   75: invokevirtual 135	org/eclipse/swt/widgets/Button:setSelection	(Z)V
      //   78: goto +51 -> 129
      //   81: aload_0
      //   82: getfield 116	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:enabledButton	Lorg/eclipse/swt/widgets/Button;
      //   85: aload_0
      //   86: invokevirtual 132	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:isEnablementReversed	()Z
      //   89: invokevirtual 135	org/eclipse/swt/widgets/Button:setSelection	(Z)V
      //   92: aload_0
      //   93: getfield 119	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:userText	Lorg/eclipse/swt/widgets/Text;
      //   96: ldc 1
      //   98: invokevirtual 139	org/eclipse/swt/widgets/Text:setText	(Ljava/lang/String;)V
      //   101: aload_0
      //   102: getfield 118	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:passwordText	Lorg/eclipse/swt/widgets/Text;
      //   105: ldc 1
      //   107: invokevirtual 139	org/eclipse/swt/widgets/Text:setText	(Ljava/lang/String;)V
      //   110: aload_0
      //   111: getfield 117	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:savePasswordButton	Lorg/eclipse/swt/widgets/Button;
      //   114: iconst_1
      //   115: invokevirtual 135	org/eclipse/swt/widgets/Button:setSelection	(Z)V
      //   118: goto +11 -> 129
      //   121: astore_2
      //   122: aload_0
      //   123: iconst_0
      //   124: putfield 113	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:updating	Z
      //   127: aload_2
      //   128: athrow
      //   129: aload_0
      //   130: iconst_0
      //   131: putfield 113	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:updating	Z
      //   134: aload_0
      //   135: invokespecial 130	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:updateWidgetEnablement	()V
      //   138: return
      // Line number table:
      //   Java source line #142	-> byte code offset #0
      //   Java source line #143	-> byte code offset #5
      //   Java source line #144	-> byte code offset #16
      //   Java source line #143	-> byte code offset #18
      //   Java source line #145	-> byte code offset #25
      //   Java source line #146	-> byte code offset #29
      //   Java source line #147	-> byte code offset #48
      //   Java source line #148	-> byte code offset #59
      //   Java source line #149	-> byte code offset #70
      //   Java source line #151	-> byte code offset #81
      //   Java source line #152	-> byte code offset #92
      //   Java source line #153	-> byte code offset #101
      //   Java source line #154	-> byte code offset #110
      //   Java source line #156	-> byte code offset #121
      //   Java source line #157	-> byte code offset #122
      //   Java source line #158	-> byte code offset #127
      //   Java source line #157	-> byte code offset #129
      //   Java source line #159	-> byte code offset #134
      //   Java source line #160	-> byte code offset #138
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	139	0	this	UsernamePasswordListener
      //   24	40	1	credentials	UsernamePasswordCredentials
      //   121	7	2	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   0	121	121	finally
    }
    
    public void setEnablementReversed(boolean enablementReversed)
    {
      this.enablementReversed = enablementReversed;
    }
    
    private void updateWidgetEnablement()
    {
      boolean enabled = isEnabled();
      userText.setEnabled(enabled);
      passwordText.setEnabled(enabled);
      savePasswordButton.setEnabled(enabled);
    }
    
    public void widgetDefaultSelected(SelectionEvent event)
    {
      apply();
    }
    
    public void widgetSelected(SelectionEvent event)
    {
      apply();
      if (widget == enabledButton) {
        updateWidgetEnablement();
      }
    }
  }
  
  public RepositoryLocationPart(RepositoryLocation workingCopy)
  {
    this.workingCopy = workingCopy;
    setNeedsProxy(false);
    setNeedsHttpAuth(false);
    setNeedsValidation(true);
  }
  
  protected void applyValidatorResult(RepositoryValidator validator)
  {
    IStatus status = validator.getResult();
    String message = status.getMessage();
    if ((message == null) || (message.length() == 0)) {
      message = null;
    }
    switch (status.getSeverity())
    {
    case 0: 
      if (status == Status.OK_STATUS) {
        message = Messages.RepositoryLocationPart_Repository_is_valid;
      }
      getPartContainer().setMessage(message, 1);
      break;
    case 1: 
      getPartContainer().setMessage(message, 1);
      break;
    case 2: 
      getPartContainer().setMessage(message, 2);
      break;
    default: 
      getPartContainer().setMessage(message, 3);
    }
  }
  
  private void bind(AuthenticationType authType, Button anonymousButton, Text userText, Text passwordText, Button savePasswordButton, boolean reverseEnablement)
  {
    UsernamePasswordListener listener = new UsernamePasswordListener(authType, anonymousButton, userText, 
      passwordText, savePasswordButton);
    listener.setEnablementReversed(reverseEnablement);
    listener.restore();
  }
  
  protected void bind(Button button, String property)
  {
    ISWTObservableValue uiElement = SWTObservables.observeSelection(button);
    IObservableValue modelElement = new RepositoryLocationValueProperty(property, Boolean.FALSE.toString()).observe(workingCopy);
    bindingContext.bindValue(uiElement, modelElement, null, null);
  }
  
  protected void bind(Text text, String property)
  {
    bind(text, property, null, null);
  }
  
  protected void bind(Text text, String property, UpdateValueStrategy targetObservableValue, UpdateValueStrategy modelObservableValue)
  {
    ISWTObservableValue uiElement = SWTObservables.observeText(text, 24);
    IObservableValue modelElement = new RepositoryLocationValueProperty(property, null).observe(workingCopy);
    bindingContext.bindValue(uiElement, modelElement, targetObservableValue, modelObservableValue);
  }
  
  public boolean canValidate()
  {
    return getValidator() != null;
  }
  
  protected Control createAdditionalContents(Composite composite)
  {
    return null;
  }
  
  public Control createContents(Composite parent)
  {
    bindingContext = new DataBindingContext();
    WizardPage wizardPage = (WizardPage)getContainer(WizardPage.class);
    if (wizardPage != null)
    {
      WizardPageSupport.create(wizardPage, bindingContext);
    }
    else
    {
      DialogPage page = (DialogPage)getContainer(DialogPage.class);
      if (page != null) {
        DialogPageSupport.create(page, bindingContext);
      }
    }
    Composite composite = new Composite(parent, 0);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(composite);
    
    createServerSection(composite);
    createUserSection(composite);
    
    Control control = createAdditionalContents(composite);
    if (control != null) {
      GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(control);
    }
    if ((needsHttpAuth()) || (needsProxy()) || (needsAdditionalSections()))
    {
      SectionComposite sectionComposite = new SectionComposite(composite, 0);
      GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(sectionComposite);
      if (needsHttpAuth()) {
        createHttpAuthSection(sectionComposite);
      }
      if (needsProxy()) {
        createProxySection(sectionComposite);
      }
      createSections(sectionComposite);
    }
    return composite;
  }
  
  private void createHttpAuthSection(SectionComposite parent)
  {
    int style = 0;
    if (getWorkingCopy().getCredentials(AuthenticationType.HTTP, UsernamePasswordCredentials.class) != null) {
      style |= 0x40;
    }
    ExpandableComposite section = parent.createSection(Messages.RepositoryLocationPart_HTTP_Authentication, style);
    clientVerticalSpacing = 5;
    
    Composite composite = new Composite(section, 0);
    section.setClient(composite);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(composite);
    
    Button enableButton = new Button(composite, 32);
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(enableButton);
    enableButton.setText(Messages.RepositoryLocationPart_Enable_HTTP_Authentication);
    
    Label label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_User);
    
    Text userText = new Text(composite, 2048);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(userText);
    
    label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_Password);
    
    Text passwordText = new Text(composite, 4196352);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText);
    
    Button savePasswordButton = new Button(composite, 32);
    savePasswordButton.setText(Messages.RepositoryLocationPart_Save_Password);
    
    bind(AuthenticationType.HTTP, enableButton, userText, passwordText, savePasswordButton, false);
  }
  
  private void createProxySection(final SectionComposite parent)
  {
    ExpandableComposite section = parent.createSection(Messages.RepositoryLocationPart_Proxy_Server_Configuration);
    
    Composite composite = new Composite(section, 0);
    section.setClient(composite);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(composite);
    
    Button systemProxyButton = new Button(composite, 32);
    GridDataFactory.fillDefaults().span(2, -1).applyTo(systemProxyButton);
    systemProxyButton.setText(Messages.RepositoryLocationPart_Use_global_Network_Connections_preferences);
    
    bind(systemProxyButton, "org.eclipse.mylyn.repositories.proxy.usedefault");
    
    Link changeProxySettingsLink = new Link(composite, 0);
    changeProxySettingsLink.setText(Messages.RepositoryLocationPart_Change_Settings);
    changeProxySettingsLink.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), 
          "org.eclipse.ui.net.NetPreferences", new String[] { "org.eclipse.ui.net.NetPreferences" }, null);
        dlg.open();
      }
    });
    Label label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_Proxy_Host);
    
    Text proxyHostText = new Text(composite, 2048);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(proxyHostText);
    bind(proxyHostText, "org.eclipse.mylyn.repositories.proxy.host");
    
    label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_Proxy_Port);
    
    Text proxyPortText = new Text(composite, 4196352);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(proxyPortText);
    bind(proxyPortText, "org.eclipse.mylyn.repositories.proxy.port");
    
    Button enableButton = new Button(composite, 32);
    GridDataFactory.fillDefaults().grab(true, false).span(3, 1).applyTo(enableButton);
    enableButton.setText(Messages.RepositoryLocationPart_Enable_Proxy_Authentication);
    
    label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_User);
    
    Text userText = new Text(composite, 2048);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(userText);
    
    label = new Label(composite, 0);
    label.setText(Messages.RepositoryLocationPart_Password);
    
    Text passwordText = new Text(composite, 4196352);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText);
    
    Button savePasswordButton = new Button(composite, 32);
    savePasswordButton.setText(Messages.RepositoryLocationPart_Save_Password);
    
    bind(AuthenticationType.PROXY, enableButton, userText, passwordText, savePasswordButton, false);
  }
  
  protected void createSections(SectionComposite sectionComposite) {}
  
  private void createServerSection(Composite parent)
  {
    Label label = new Label(parent, 0);
    label.setText(Messages.RepositoryLocationPart_Server);
    
    Text urlText = new Text(parent, 2048);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(urlText);
    bind(urlText, "url", getUrlUpdateValueStrategy(), null);
    
    label = new Label(parent, 0);
    label.setText(Messages.RepositoryLocationPart_Label);
    
    Text labelText = new Text(parent, 2048);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(labelText);
    bind(labelText, "label");
    
    Button disconnectedButton = new Button(parent, 32);
    disconnectedButton.setText(Messages.RepositoryLocationPart_Disconnected);
    bind(disconnectedButton, "org.eclipse.mylyn.tasklist.repositories.offline");
  }
  
  protected UpdateValueStrategy getUrlUpdateValueStrategy()
  {
    return new UpdateValueStrategy().setAfterConvertValidator(new UrlValidator());
  }
  
  private void createUserSection(Composite parent)
  {
    Label label = new Label(parent, 0);
    label.setText(Messages.RepositoryLocationPart_User);
    
    Text userText = new Text(parent, 2048);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(userText);
    bind(userText, "org.eclipse.mylyn.repositories.username");
    
    Button anonymousButton = new Button(parent, 32);
    anonymousButton.setText(Messages.RepositoryLocationPart_Anonymous);
    
    label = new Label(parent, 0);
    label.setText(Messages.RepositoryLocationPart_Password);
    
    Text passwordText = new Text(parent, 4196352);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText);
    
    Button savePasswordButton = new Button(parent, 32);
    savePasswordButton.setText(Messages.RepositoryLocationPart_Save_Password);
    
    bind(AuthenticationType.REPOSITORY, anonymousButton, userText, passwordText, savePasswordButton, true);
  }
  
  public <T> T getContainer(Class<T> clazz)
  {
    return (T)getServiceLocator().getAdapter(clazz);
  }
  
  public IPartContainer getPartContainer()
  {
    return (IPartContainer)getContainer(IPartContainer.class);
  }
  
  private IAdaptable getServiceLocator()
  {
    return serviceLocator;
  }
  
  protected RepositoryValidator getValidator()
  {
    return null;
  }
  
  protected RepositoryLocation getWorkingCopy()
  {
    return workingCopy;
  }
  
  public boolean isValidUrl(String url)
  {
    if ((url.startsWith("https://")) || (url.startsWith("http://"))) {
      try
      {
        new URI(url);
        return true;
      }
      catch (Exception localException) {}
    }
    return false;
  }
  
  public boolean needsAdditionalSections()
  {
    return needsAdditionalSections;
  }
  
  public boolean needsAnonymousLogin()
  {
    return needsAnonymousLogin;
  }
  
  public boolean needsHttpAuth()
  {
    return needsHttpAuth;
  }
  
  public boolean needsProxy()
  {
    return needsProxy;
  }
  
  public boolean needsValidation()
  {
    return needsValidation;
  }
  
  public void setNeedsAdditionalSections(boolean needsAdditionalSections)
  {
    this.needsAdditionalSections = needsAdditionalSections;
  }
  
  public void setNeedsAnonymousLogin(boolean needsAnonymousLogin)
  {
    this.needsAnonymousLogin = needsAnonymousLogin;
  }
  
  public void setNeedsHttpAuth(boolean needsHttpAuth)
  {
    this.needsHttpAuth = needsHttpAuth;
  }
  
  public void setNeedsProxy(boolean needsProxy)
  {
    this.needsProxy = needsProxy;
  }
  
  public void setNeedsValidation(boolean needsValidation)
  {
    this.needsValidation = needsValidation;
  }
  
  public void setServiceLocator(IAdaptable container)
  {
    serviceLocator = container;
  }
  
  public void validate()
  {
    final RepositoryValidator validator = getValidator();
    if (validator == null) {
      return;
    }
    final AtomicReference<IStatus> result = new AtomicReference();
    try
    {
      ((IPartContainer)getContainer(IPartContainer.class)).run(true, true, new IRunnableWithProgress()
      {
        /* Error */
        public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
          throws InvocationTargetException, InterruptedException
        {
          // Byte code:
          //   0: aload_1
          //   1: getstatic 69	org/eclipse/mylyn/commons/ui/team/Messages:RepositoryLocationPart_Validating_repository	Ljava/lang/String;
          //   4: iconst_m1
          //   5: invokeinterface 79 3 0
          //   10: aload_0
          //   11: getfield 70	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$result	Ljava/util/concurrent/atomic/AtomicReference;
          //   14: aload_0
          //   15: getfield 71	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$validator	Lorg/eclipse/mylyn/commons/repositories/RepositoryValidator;
          //   18: aload_1
          //   19: invokevirtual 77	org/eclipse/mylyn/commons/repositories/RepositoryValidator:run	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;
          //   22: invokevirtual 76	java/util/concurrent/atomic/AtomicReference:set	(Ljava/lang/Object;)V
          //   25: goto +41 -> 66
          //   28: pop
          //   29: aload_0
          //   30: getfield 70	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$result	Ljava/util/concurrent/atomic/AtomicReference;
          //   33: getstatic 68	org/eclipse/core/runtime/Status:CANCEL_STATUS	Lorg/eclipse/core/runtime/IStatus;
          //   36: invokevirtual 76	java/util/concurrent/atomic/AtomicReference:set	(Ljava/lang/Object;)V
          //   39: new 30	java/lang/InterruptedException
          //   42: dup
          //   43: invokespecial 73	java/lang/InterruptedException:<init>	()V
          //   46: athrow
          //   47: astore_2
          //   48: new 32	java/lang/reflect/InvocationTargetException
          //   51: dup
          //   52: aload_2
          //   53: invokespecial 75	java/lang/reflect/InvocationTargetException:<init>	(Ljava/lang/Throwable;)V
          //   56: athrow
          //   57: astore_3
          //   58: aload_1
          //   59: invokeinterface 78 1 0
          //   64: aload_3
          //   65: athrow
          //   66: aload_1
          //   67: invokeinterface 78 1 0
          //   72: return
          // Line number table:
          //   Java source line #583	-> byte code offset #0
          //   Java source line #585	-> byte code offset #10
          //   Java source line #586	-> byte code offset #28
          //   Java source line #587	-> byte code offset #29
          //   Java source line #588	-> byte code offset #39
          //   Java source line #589	-> byte code offset #47
          //   Java source line #590	-> byte code offset #48
          //   Java source line #591	-> byte code offset #57
          //   Java source line #592	-> byte code offset #58
          //   Java source line #593	-> byte code offset #64
          //   Java source line #592	-> byte code offset #66
          //   Java source line #594	-> byte code offset #72
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	73	0	this	2
          //   0	73	1	monitor	org.eclipse.core.runtime.IProgressMonitor
          //   47	6	2	e	Exception
          //   57	8	3	localObject	Object
          //   28	1	4	localOperationCanceledException	org.eclipse.core.runtime.OperationCanceledException
          // Exception table:
          //   from	to	target	type
          //   10	25	28	org/eclipse/core/runtime/OperationCanceledException
          //   10	25	47	java/lang/Exception
          //   10	57	57	finally
        }
      });
    }
    catch (InvocationTargetException e)
    {
      StatusManager.getManager().handle(
        new Status(4, "org.eclipse.mylyn.commons.team", 
        Messages.RepositoryLocationPart_Unexpected_error_during_repository_validation, e), 
        7);
      return;
    }
    catch (InterruptedException localInterruptedException)
    {
      return;
    }
    if (result.get() == null) {
      validator.setResult(Status.OK_STATUS);
    } else {
      validator.setResult((IStatus)result.get());
    }
    getPartContainer().updateButtons();
    applyValidatorResult(validator);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.RepositoryLocationPart
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
import org.eclipse.mylyn.internal.provisional.commons.ui.dialogs.IValidatable;
import org.eclipse.swt.widgets.Composite;

@Deprecated
public class RepositoryWizardPage
  extends WizardPage
  implements IPartContainer, IAdaptable, IValidatable
{
  private IAdaptable element;
  private RepositoryLocationPart part;
  private RepositoryLocation workingCopy;
  
  public RepositoryWizardPage(String pageName)
  {
    super(pageName);
    setPageComplete(false);
  }
  
  public boolean canValidate()
  {
    return part.canValidate();
  }
  
  public void createControl(Composite parent)
  {
    initializeDialogUnits(parent);
    
    String message = getMessage();
    
    part = doCreateRepositoryPart();
    part.setServiceLocator(this);
    setControl(part.createContents(parent));
    Dialog.applyDialogFont(parent);
    
    setMessage(message);
  }
  
  protected RepositoryLocationPart doCreateRepositoryPart()
  {
    return new RepositoryLocationPart(getWorkingCopy());
  }
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == WizardPage.class) {
      return this;
    }
    if (adapter == DialogPage.class) {
      return this;
    }
    if (adapter == IPartContainer.class) {
      return this;
    }
    return null;
  }
  
  public IAdaptable getElement()
  {
    return element;
  }
  
  public RepositoryLocationPart getPart()
  {
    return part;
  }
  
  protected RepositoryLocation getWorkingCopy()
  {
    if (workingCopy == null) {
      workingCopy = ((RepositoryLocation)getElement().getAdapter(RepositoryLocation.class));
    }
    return workingCopy;
  }
  
  public boolean needsValidation()
  {
    return part.needsValidation();
  }
  
  public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
    throws InvocationTargetException, InterruptedException
  {
    getContainer().run(fork, cancelable, runnable);
  }
  
  public void setElement(IAdaptable element)
  {
    this.element = element;
  }
  
  public void updateButtons()
  {
    getContainer().updateButtons();
  }
  
  public void validate()
  {
    part.validate();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.RepositoryWizardPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.mylyn.internal.commons.ui.SectionComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.ui.dialogs.PreferencesUtil;

class RepositoryLocationPart$1
  extends SelectionAdapter
{
  RepositoryLocationPart$1(RepositoryLocationPart paramRepositoryLocationPart, SectionComposite paramSectionComposite) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(val$parent.getShell(), 
      "org.eclipse.ui.net.NetPreferences", new String[] { "org.eclipse.ui.net.NetPreferences" }, null);
    dlg.open();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.RepositoryLocationPart.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.commons.repositories.RepositoryValidator;

class RepositoryLocationPart$2
  implements IRunnableWithProgress
{
  RepositoryLocationPart$2(RepositoryLocationPart paramRepositoryLocationPart, AtomicReference paramAtomicReference, RepositoryValidator paramRepositoryValidator) {}
  
  /* Error */
  public void run(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aload_1
    //   1: getstatic 69	org/eclipse/mylyn/commons/ui/team/Messages:RepositoryLocationPart_Validating_repository	Ljava/lang/String;
    //   4: iconst_m1
    //   5: invokeinterface 79 3 0
    //   10: aload_0
    //   11: getfield 70	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$result	Ljava/util/concurrent/atomic/AtomicReference;
    //   14: aload_0
    //   15: getfield 71	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$validator	Lorg/eclipse/mylyn/commons/repositories/RepositoryValidator;
    //   18: aload_1
    //   19: invokevirtual 77	org/eclipse/mylyn/commons/repositories/RepositoryValidator:run	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;
    //   22: invokevirtual 76	java/util/concurrent/atomic/AtomicReference:set	(Ljava/lang/Object;)V
    //   25: goto +41 -> 66
    //   28: pop
    //   29: aload_0
    //   30: getfield 70	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$2:val$result	Ljava/util/concurrent/atomic/AtomicReference;
    //   33: getstatic 68	org/eclipse/core/runtime/Status:CANCEL_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   36: invokevirtual 76	java/util/concurrent/atomic/AtomicReference:set	(Ljava/lang/Object;)V
    //   39: new 30	java/lang/InterruptedException
    //   42: dup
    //   43: invokespecial 73	java/lang/InterruptedException:<init>	()V
    //   46: athrow
    //   47: astore_2
    //   48: new 32	java/lang/reflect/InvocationTargetException
    //   51: dup
    //   52: aload_2
    //   53: invokespecial 75	java/lang/reflect/InvocationTargetException:<init>	(Ljava/lang/Throwable;)V
    //   56: athrow
    //   57: astore_3
    //   58: aload_1
    //   59: invokeinterface 78 1 0
    //   64: aload_3
    //   65: athrow
    //   66: aload_1
    //   67: invokeinterface 78 1 0
    //   72: return
    // Line number table:
    //   Java source line #583	-> byte code offset #0
    //   Java source line #585	-> byte code offset #10
    //   Java source line #586	-> byte code offset #28
    //   Java source line #587	-> byte code offset #29
    //   Java source line #588	-> byte code offset #39
    //   Java source line #589	-> byte code offset #47
    //   Java source line #590	-> byte code offset #48
    //   Java source line #591	-> byte code offset #57
    //   Java source line #592	-> byte code offset #58
    //   Java source line #593	-> byte code offset #64
    //   Java source line #592	-> byte code offset #66
    //   Java source line #594	-> byte code offset #72
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	73	0	this	2
    //   0	73	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   47	6	2	e	Exception
    //   57	8	3	localObject	Object
    //   28	1	4	localOperationCanceledException	org.eclipse.core.runtime.OperationCanceledException
    // Exception table:
    //   from	to	target	type
    //   10	25	28	org/eclipse/core/runtime/OperationCanceledException
    //   10	25	47	java/lang/Exception
    //   10	57	57	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.RepositoryLocationPart.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import org.eclipse.jface.operation.IRunnableContext;

@Deprecated
public abstract interface IPartContainer
  extends IRunnableContext
{
  public abstract void setMessage(String paramString, int paramInt);
  
  public abstract void updateButtons();
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.IPartContainer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

public class RepositoryLocationPart$UrlValidator
  implements IValidator
{
  public RepositoryLocationPart$UrlValidator(RepositoryLocationPart paramRepositoryLocationPart) {}
  
  public IStatus validate(Object value)
  {
    if (!this$0.isValidUrl(value.toString())) {
      return new Status(4, "org.eclipse.mylyn.commons.team", 
        Messages.RepositoryLocationPart_Enter_a_valid_server_url);
    }
    return Status.OK_STATUS;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.ui.team.RepositoryLocationPart.UrlValidator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.ui.team;

import org.eclipse.mylyn.commons.repositories.RepositoryLocation;
import org.eclipse.mylyn.commons.repositories.auth.AuthenticationType;
import org.eclipse.mylyn.commons.repositories.auth.UsernamePasswordCredentials;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;

class RepositoryLocationPart$UsernamePasswordListener
  implements ModifyListener, SelectionListener
{
  private final AuthenticationType authenticationType;
  private final Button enabledButton;
  private boolean enablementReversed;
  private final Text passwordText;
  private final Button savePasswordButton;
  private boolean updating;
  private final Text userText;
  
  public RepositoryLocationPart$UsernamePasswordListener(RepositoryLocationPart paramRepositoryLocationPart, AuthenticationType authenticationType, Button enabledButton, Text userText, Text passwordText, Button savePasswordButton)
  {
    this.authenticationType = authenticationType;
    this.enabledButton = enabledButton;
    this.userText = userText;
    this.passwordText = passwordText;
    this.savePasswordButton = savePasswordButton;
    init();
  }
  
  private void apply()
  {
    if (updating) {
      return;
    }
    if (isEnabled())
    {
      UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userText.getText(), 
        passwordText.getText());
      this$0.getWorkingCopy().setCredentials(authenticationType, credentials);
    }
    else
    {
      this$0.getWorkingCopy().setCredentials(authenticationType, null);
    }
  }
  
  protected void init()
  {
    enabledButton.addSelectionListener(this);
    userText.addModifyListener(this);
    passwordText.addModifyListener(this);
    savePasswordButton.addSelectionListener(this);
  }
  
  protected boolean isEnabled()
  {
    return enabledButton.getSelection() ^ isEnablementReversed();
  }
  
  public boolean isEnablementReversed()
  {
    return enablementReversed;
  }
  
  public void modifyText(ModifyEvent event)
  {
    apply();
  }
  
  /* Error */
  private void restore()
  {
    // Byte code:
    //   0: aload_0
    //   1: iconst_1
    //   2: putfield 113	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:updating	Z
    //   5: aload_0
    //   6: getfield 115	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:this$0	Lorg/eclipse/mylyn/commons/ui/team/RepositoryLocationPart;
    //   9: invokevirtual 126	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart:getWorkingCopy	()Lorg/eclipse/mylyn/commons/repositories/RepositoryLocation;
    //   12: aload_0
    //   13: getfield 114	org/eclipse/mylyn/commons/ui/team/RepositoryLocationPart$UsernamePasswordListener:authenticationType	Lorg/eclipse/mylyn/commons/repositories/auth/Authenticati
1 2 3 4

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