org.eclipse.mylyn.discovery.ui_3.7.1.v20120425-0100

16:46:40.843 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.discovery.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.discovery.ui.util;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public abstract class DiscoveryUiUtil
{
  public static Shell getShell()
  {
    if ((!PlatformUI.isWorkbenchRunning()) || (PlatformUI.getWorkbench().isClosing())) {
      return null;
    }
    Shell modal = getModalShellExcluding(null);
    if (modal != null) {
      return modal;
    }
    return getNonModalShell();
  }
  
  public static Shell getNonModalShell()
  {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null)
    {
      IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
      if (windows.length > 0) {
        return windows[0].getShell();
      }
    }
    else
    {
      return window.getShell();
    }
    return null;
  }
  
  public static Shell getModalShellExcluding(Shell shell)
  {
    IWorkbench workbench = PlatformUI.getWorkbench();
    Shell[] shells = workbench.getDisplay().getShells();
    int modal = 229376;
    Shell[] arrayOfShell1;
    int j = (arrayOfShell1 = shells).length;
    for (int i = 0; i < j; i++)
    {
      Shell shell2 = arrayOfShell1[i];
      if (shell2.equals(shell)) {
        break;
      }
      if (shell2.isVisible())
      {
        int style = shell2.getStyle();
        if ((style & modal) != 0) {
          return shell2;
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.util.DiscoveryUiUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.util;

import org.eclipse.osgi.util.NLS;

class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.discovery.ui.util.messages";
  public static String DiscoveryUi_seeErrorLog;
  
  static
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.discovery.ui.util.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.util.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptor;
import org.eclipse.mylyn.internal.discovery.core.model.DiscoveryFeedbackJob;
import org.eclipse.mylyn.internal.discovery.ui.wizards.Messages;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.Bundle;

public abstract class DiscoveryUi
{
  public static final String ID_PLUGIN = "org.eclipse.mylyn.discovery.ui";
  public static final String PREF_LAST_INSTALLED = "lastInstalled";
  
  public static AbstractInstallJob createInstallJob()
  {
    List<ConnectorDescriptor> emptyList = Collections.emptyList();
    return createInstallJob(emptyList);
  }
  
  public static AbstractInstallJob createInstallJob(List<ConnectorDescriptor> descriptors)
  {
    AbstractInstallJob runner = null;
    Bundle bundle = Platform.getBundle("org.eclipse.equinox.p2.engine");
    if ((bundle != null) && (new VersionRange("[1.0.0,1.1.0)").isIncluded(CoreUtil.getVersion(bundle)))) {
      runner = new PrepareInstallProfileJob_e_3_5(descriptors);
    }
    if (runner == null) {
      runner = new PrepareInstallProfileJob_e_3_6(descriptors);
    }
    return runner;
  }
  
  public static boolean install(List<ConnectorDescriptor> descriptors, IRunnableContext context)
  {
    try
    {
      IRunnableWithProgress runner = createInstallJob(descriptors);
      context.run(true, true, runner);
      
      new DiscoveryFeedbackJob(descriptors).schedule();
      recordInstalled(descriptors);
    }
    catch (InvocationTargetException e)
    {
      IStatus status = new Status(4, "org.eclipse.mylyn.discovery.ui", NLS.bind(
        Messages.ConnectorDiscoveryWizard_installProblems, new Object[] { e.getCause().getMessage() }), 
        e.getCause());
      StatusManager.getManager().handle(status, 7);
      return false;
    }
    catch (InterruptedException localInterruptedException)
    {
      return false;
    }
    return true;
  }
  
  private static void recordInstalled(List<ConnectorDescriptor> descriptors)
  {
    StringBuilder sb = new StringBuilder();
    for (ConnectorDescriptor descriptor : descriptors)
    {
      if (sb.length() > 0) {
        sb.append(",");
      }
      sb.append(descriptor.getId());
    }
    ScopedPreferenceStore store = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.mylyn.discovery.ui");
    store.putValue("lastInstalled", sb.toString());
    try
    {
      store.save();
    }
    catch (IOException localIOException) {}
  }
}

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

import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.Bundle;

public class DiscoveryImages
{
  private static final String T_OVR_32 = "ovr32";
  private static final String T_OBJ_16 = "obj16";
  private static final URL baseURL = Platform.getBundle("org.eclipse.mylyn.discovery.ui").getEntry("/icons/");
  public static final ImageDescriptor OVERLAY_WARNING_32 = create("ovr32", "message_warning.gif");
  public static final ImageDescriptor MESSAGE_INFO = create("obj16", "message_info.gif");
  
  private static ImageDescriptor create(String prefix, String name)
  {
    try
    {
      return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
    }
    catch (MalformedURLException localMalformedURLException) {}
    return ImageDescriptor.getMissingImageDescriptor();
  }
  
  private static URL makeIconFileURL(String prefix, String name)
    throws MalformedURLException
  {
    if (baseURL == null) {
      throw new MalformedURLException();
    }
    StringBuilder buffer = new StringBuilder(prefix);
    buffer.append('/');
    buffer.append(name);
    return new URL(baseURL, buffer.toString());
  }
}

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

public abstract class UninstallRequest
{
  public abstract boolean select(InstalledItem paramInstalledItem);
}

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

import org.osgi.framework.Version;

public class InstalledItem<T>
{
  private final String id;
  private final Version version;
  private final T data;
  
  public InstalledItem(T data, String id, Version version)
  {
    this.data = data;
    this.id = id;
    this.version = version;
  }
  
  public String getId()
  {
    return id;
  }
  
  public Version getVersion()
  {
    return version;
  }
  
  public T getData()
  {
    return (T)data;
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;

public abstract class AbstractInstallJob
  implements IRunnableWithProgress
{
  public abstract Set<String> getInstalledFeatures(IProgressMonitor paramIProgressMonitor);
  
  public abstract IStatus uninstall(UninstallRequest paramUninstallRequest, IProgressMonitor paramIProgressMonitor)
    throws InvocationTargetException, InterruptedException;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.AbstractInstallJob
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.commands;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.discovery.ui.util.DiscoveryUiUtil;
import org.eclipse.mylyn.internal.discovery.ui.wizards.ConnectorDiscoveryWizard;

public class ShowConnectorDiscoveryWizardCommandHandler
  extends AbstractHandler
{
  private static final String ID_P2_INSTALL_UI = "org.eclipse.equinox.p2.ui.sdk/org.eclipse.equinox.p2.ui.sdk.install";
  
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    if (WorkbenchUtil.allowUseOf("org.eclipse.equinox.p2.ui.sdk/org.eclipse.equinox.p2.ui.sdk.install"))
    {
      ConnectorDiscoveryWizard wizard = new ConnectorDiscoveryWizard();
      WizardDialog dialog = new WizardDialog(DiscoveryUiUtil.getShell(), wizard);
      dialog.open();
    }
    else
    {
      MessageDialog.openWarning(DiscoveryUiUtil.getShell(), 
        Messages.ShowConnectorDiscoveryWizardCommandHandler_Install_Connectors, 
        Messages.ShowConnectorDiscoveryWizardCommandHandler_Unable_To_Install_No_P2);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.commands.ShowConnectorDiscoveryWizardCommandHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.commands;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.discovery.ui.commands.messages";
  public static String ShowConnectorDiscoveryWizardCommandHandler_Install_Connectors;
  public static String ShowConnectorDiscoveryWizardCommandHandler_Unable_To_Install_No_P2;
  
  static
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.discovery.ui.commands.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.commands.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.mylyn.commons.core.CoreUtil;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptorKind;
import org.eclipse.mylyn.internal.discovery.ui.DiscoveryUi;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

public class ConnectorDiscoveryWizard
  extends Wizard
{
  private ConnectorDiscoveryWizardMainPage mainPage;
  private final Map<ConnectorDescriptorKind, Boolean> connectorDescriptorKindToVisibility = new HashMap();
  private boolean showConnectorDescriptorKindFilter;
  private boolean showConnectorDescriptorTextFilter;
  private Dictionary<Object, Object> environment;
  
  public ConnectorDiscoveryWizard()
  {
    ConnectorDescriptorKind[] arrayOfConnectorDescriptorKind;
    int j = (arrayOfConnectorDescriptorKind = ConnectorDescriptorKind.values()).length;
    for (int i = 0; i < j; i++)
    {
      ConnectorDescriptorKind kind = arrayOfConnectorDescriptorKind[i];
      connectorDescriptorKindToVisibility.put(kind, Boolean.valueOf(true));
    }
    showConnectorDescriptorKindFilter = false;
    
    showConnectorDescriptorTextFilter = true;
    
    setWindowTitle(Messages.ConnectorDiscoveryWizard_connectorDiscovery);
    setNeedsProgressMonitor(true);
    setDefaultPageImageDescriptor(CommonImages.BANNER_DISOVERY);
    createEnvironment();
  }
  
  private void createEnvironment()
  {
    environment = new Hashtable(System.getProperties());
    
    Bundle bundle = Platform.getBundle("org.eclipse.mylyn.tasks.core");
    Version version = CoreUtil.getVersion(bundle);
    environment.put("org.eclipse.mylyn.version", version.toString());
    environment.put("org.eclipse.mylyn.version.major", Integer.valueOf(version.getMajor()));
    environment.put("org.eclipse.mylyn.version.minor", Integer.valueOf(version.getMinor()));
    environment.put("org.eclipse.mylyn.version.micro", Integer.valueOf(version.getMicro()));
  }
  
  public void addPages()
  {
    addPage(mainPage = new ConnectorDiscoveryWizardMainPage());
  }
  
  public boolean performFinish()
  {
    return DiscoveryUi.install(mainPage.getInstallableConnectors(), getContainer());
  }
  
  public void setVisibility(ConnectorDescriptorKind kind, boolean visible)
  {
    if (kind == null) {
      throw new IllegalArgumentException();
    }
    connectorDescriptorKindToVisibility.put(kind, Boolean.valueOf(visible));
  }
  
  public boolean isVisible(ConnectorDescriptorKind kind)
  {
    if (kind == null) {
      throw new IllegalArgumentException();
    }
    return ((Boolean)connectorDescriptorKindToVisibility.get(kind)).booleanValue();
  }
  
  public boolean isShowConnectorDescriptorKindFilter()
  {
    return showConnectorDescriptorKindFilter;
  }
  
  public void setShowConnectorDescriptorKindFilter(boolean showConnectorDescriptorKindFilter)
  {
    this.showConnectorDescriptorKindFilter = showConnectorDescriptorKindFilter;
  }
  
  public boolean isShowConnectorDescriptorTextFilter()
  {
    return showConnectorDescriptorTextFilter;
  }
  
  public void setShowConnectorDescriptorTextFilter(boolean showConnectorDescriptorTextFilter)
  {
    this.showConnectorDescriptorTextFilter = showConnectorDescriptorTextFilter;
  }
  
  public Dictionary<Object, Object> getEnvironment()
  {
    return environment;
  }
  
  public void setEnvironment(Dictionary<Object, Object> environment)
  {
    if (environment == null) {
      throw new IllegalArgumentException();
    }
    this.environment = environment;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.wizards.ConnectorDiscoveryWizard
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;

class DiscoveryViewer$12
  implements Listener
{
  DiscoveryViewer$12(DiscoveryViewer paramDiscoveryViewer) {}
  
  public void handleEvent(Event event)
  {
    DiscoveryViewer.access$12(this$0);
    DiscoveryViewer.access$18(this$0).setFocus();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.wizards.DiscoveryViewer.12
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;

class DiscoveryViewer$1
  extends ControlAdapter
{
  DiscoveryViewer$1(DiscoveryViewer paramDiscoveryViewer, Composite paramComposite) {}
  
  public void controlResized(ControlEvent e)
  {
    Point size = val$scrolledContents.computeSize(access$11this$0).getSize().x - 20, -1, true);
    val$scrolledContents.setSize(size);
    DiscoveryViewer.access$2(this$0).setMinHeight(y);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.wizards.DiscoveryViewer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import org.eclipse.mylyn.commons.workbench.browser.BrowserUtil;
import org.eclipse.mylyn.internal.discovery.core.model.Overview;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class OverviewToolTip$2
  implements SelectionListener
{
  OverviewToolTip$2(OverviewToolTip paramOverviewToolTip) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    BrowserUtil.openUrl(OverviewToolTip.access$0(this$0).getUrl(), 128);
  }
  
  public void widgetDefaultSelected(SelectionEvent e)
  {
    widgetSelected(e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.wizards.OverviewToolTip.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;

class DiscoveryViewer$8
  implements ModifyListener
{
  DiscoveryViewer$8(DiscoveryViewer paramDiscoveryViewer) {}
  
  public void modifyText(ModifyEvent e)
  {
    DiscoveryViewer.access$17(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.discovery.ui.wizards.DiscoveryViewer.8
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.discovery.ui.wizards;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.GradientCanvas;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.commons.workbench.browser.BrowserUtil;
import org.eclipse.mylyn.internal.discovery.core.model.AbstractDiscoverySource;
import org.eclipse.mylyn.internal.discovery.core.model.BundleDiscoveryStrategy;
import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptor;
import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDescriptorKind;
import org.eclipse.mylyn.internal.discovery.core.model.ConnectorDiscovery;
import org.eclipse.mylyn.internal.discovery.core.model.DiscoveryCategory;
import org.eclipse.mylyn.internal.discovery.core.model.DiscoveryCertification;
import org.eclipse.mylyn.internal.discovery.core.model.DiscoveryConnector;
import org.eclipse.mylyn.internal.discovery.core.model.Icon;
import org.eclipse.mylyn.internal.discovery.core.model.Overview;
import org.eclipse.mylyn.internal.discovery.core.model.RemoteBundleDiscoveryStrategy;
import org.eclipse.mylyn.internal.discovery.core.util.DiscoveryCategoryComparator;
import org.eclipse.mylyn.internal.discovery.core.util.DiscoveryConnectorComparator;
import org.eclipse.mylyn.internal.discovery.ui.AbstractInstallJob;
import org.eclipse.mylyn.internal.discovery.ui.DiscoveryImages;
import org.eclipse.mylyn.internal.discovery.ui.DiscoveryUi;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.accessibility.Accessible;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleControlAdapter;
import org.eclipse.swt.accessibility.AccessibleControlEvent;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Resource;
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.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.WorkbenchJob;
import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.ui.themes.ITheme;
import org.eclipse.ui.themes.IThemeManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

public class DiscoveryViewer
{
  public static final int ICON_CANCEL = 256;
  private static final int MINIMUM_HEIGHT = 100;
  private boolean showConnectorDescriptorKindFilter;
  private boolean showConnectorDescriptorTextFilter;
  private static final String COLOR_WHITE = "white";
  private static final String COLOR_DARK_GRAY = "DarkGray";
  private static Boolean useNativeSearchField;
  /* Error */
  private static boolean useNativeSearchField(Composite composite)
  {
    // Byte code:
    //   0: getstatic 1197	org/eclipse/mylyn/internal/discovery/ui/wizards/DiscoveryViewer:useNativeSearchField	Ljava/lang/Boolean;
    //   3: ifnonnull +71 -> 74
    //   6: getstatic 1181	java/lang/Boolean:FALSE	Ljava/lang/Boolean;
    //   9: putstatic 1197	org/eclipse/mylyn/internal/discovery/ui/wizards/DiscoveryViewer:useNativeSearchField	Ljava/lang/Boolean;
    //   12: aconst_null
    //   13: astore_1
    //   14: new 661	org/eclipse/swt/widgets/Text
    //   17: dup
    //   18: aload_0
    //   19: sipush 384
    //   22: invokespecial 1474	org/eclipse/swt/widgets/Text:<init>	(Lorg/eclipse/swt/widgets/Composite;I)V
    //   25: astore_1
    //   26: new 561	java/lang/Boolean
    //   29: dup
    //   30: aload_1
    //   31: invokevirtual 1468	org/eclipse/swt/widgets/Text:getStyle	()I
    //   34: sipush 256
    //   37: iand
    //   38: ifeq +7 -> 45
    //   41: iconst_1
    //   42: goto +4 -> 46
    //   45: iconst_0
    //   46: invokespecial 1244	java/lang/Boolean:<init>	(Z)V
    //   49: putstatic 1197	org/eclipse/mylyn/internal/discovery/ui/wizards/DiscoveryViewer:useNativeSearchField	Ljava/lang/Boolean;
    //   52: goto +14 -> 66
    //   55: astore_2
    //   56: aload_1
    //   57: ifnull +7 -> 64
    //   60: aload_1
    //   61: invokevirtual 1469	org/eclipse/swt/widgets/Text:dispose	()V
    //   64: aload_2
    //   65: athrow
    //   66: aload_1
    //   67: ifnull +7 -> 74
    //   70: aload_1
    //   71: invokevirtual 1469	org/eclipse/swt/widgets/Text:dispose	()V
    //   74: getstatic 1197	org/eclipse/mylyn/internal/discovery/ui/wizards/DiscoveryViewer:useNativeSearchField	Ljava/lang/Boolean;
    //   77: invokevirtual 1243	java/lang/Boolean:booleanValue	()Z
    //   80: ireturn
    // Line number table:
    //   Java source line #391	-> byte code offset #0
    //   Java source line #392	-> byte code offset #6
    //   Java source line #393	-> byte code offset #12
    //   Java source line #395	-> byte code offset #14
    //   Java source line #396	-> byte code offset #26
    //   Java source line #397	-> byte code offset #55
    //   Java source line #398	-> byte code offset #56
    //   Java source line #399	-> byte code offset #60
    //   Java source line #401	-> byte code offset #64
    //   Java source line #398	-> byte code offset #66
    //   Java source line #399	-> byte code offset #70
    //   Java source line #404	-> byte code offset #74
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	81	0	composite	Composite
    //   13	58	1	testText	Text
    //   55	10	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   14	55	55	finally
  }
  
  public class ConnectorBorderPaintListener
    implements PaintListener
  {
    public ConnectorBorderPaintListener() {}
    
    public void paintControl(PaintEvent e)
    {
      Composite composite = (Composite)widget;
      Rectangle bounds = composite.getBounds();
      GC gc = gc;
      gc.setLineStyle(3);
      gc.drawLine(x, y, x + width, y);
    }
  }
  
  private class ConnectorDescriptorItemUi
    implements PropertyChangeListener, Runnable
  {
    private final DiscoveryConnector connector;
    private final Button checkbox;
    private final Label iconLabel;
    private final Label nameLabel;
    private ToolItem infoButton;
    private final Link providerLabel;
    private final Label description;
    private final Composite checkboxContainer;
    private final Composite connectorContainer;
    private final Display display;
    private Image iconImage;
    
    public ConnectorDescriptorItemUi(final DiscoveryConnector connector, Composite categoryChildrenContainer, Color background)
    {
      display = categoryChildrenContainer.getDisplay();
      this.connector = connector;
      connector.addPropertyChangeListener(this);
      
      connectorContainer = new Composite(categoryChildrenContainer, 0);
      
      DiscoveryViewer.this.configureLook(connectorContainer, background);
      GridDataFactory.fillDefaults().grab(true, false).applyTo(connectorContainer);
      GridLayout layout = new GridLayout(4, false);
      marginLeft = 7;
      marginTop = 2;
      marginBottom = 2;
      connectorContainer.setLayout(layout);
      
      checkboxContainer = new Composite(connectorContainer, 0);
      DiscoveryViewer.this.configureLook(checkboxContainer, background);
      GridDataFactory.swtDefaults().align(16777216, 1).span(1, 2).applyTo(checkboxContainer);
      GridLayoutFactory.fillDefaults().spacing(1, 1).numColumns(2).applyTo(checkboxContainer);
      
      checkbox = new Button(checkboxContainer, 32);
      checkbox.setText(" ");
      
      checkbox.setData("connectorId", connector.getId());
      checkbox.setVisible(connector.isInstallable());
      DiscoveryViewer.this.configureLook(checkbox, background);
      checkbox.setSelection(installableConnectors.contains(connector));
      checkbox.addFocusListener(new FocusAdapter()
      {
        public void focusGained(FocusEvent e)
        {
          bodyScrolledComposite.showControl(connectorContainer);
        }
      });
      GridDataFactory.swtDefaults().align(16777216, 16777216).applyTo(checkbox);
      
      iconLabel = new Label(checkboxContainer, 0);
      DiscoveryViewer.this.configureLook(iconLabel, background);
      GridDataFactory.swtDefaults().align(16777216, 16777216).applyTo(iconLabel);
      if (connector.getIcon() != null)
      {
        iconImage = DiscoveryViewer.this.computeIconImage(connector.getSource(), connector.getIcon(), 32, false);
        if (iconImage != null) {
          iconLabel.setImage(iconImage);
        }
      }
      nameLabel = new Label(connectorContainer, 0);
      DiscoveryViewer.this.configureLook(nameLabel, background);
      GridDataFactory.fillDefaults().grab(true, false).align(1, 16777216).applyTo(nameLabel);
      nameLabel.setFont(h2Font);
      if (connector.isInstalled()) {
        nameLabel.setText(NLS.bind(Messages.DiscoveryViewer_X_installed, connector.getName()));
      } else {
        nameLabel.setText(connector.getName());
      }
      providerLabel = new Link(connectorContainer, 131072);
      DiscoveryViewer.this.configureLook(providerLabel, background);
      GridDataFactory.fillDefaults().align(16777224, 16777216).applyTo(providerLabel);
      if (connector.getCertification() != null)
      {
        providerLabel.setText(NLS.bind(Messages.DiscoveryViewer_Certification_Label0, 
          new String[] { connector.getProvider(), connector.getLicense(), 
          connector.getCertification().getName() }));
        if (connector.getCertification().getUrl() != null) {
          providerLabel.addSelectionListener(new SelectionAdapter()
          {
            public void widgetSelected(SelectionEvent e)
            {
              BrowserUtil.openUrl(connector.getCertification().getUrl(), 
                128);
            }
          });
        }
        Overview overview = new Overview();
        overview.setSummary(connector.getCertification().getDescription());
        overview.setUrl(connector.getCertification().getUrl());
        Image image = DiscoveryViewer.this.computeIconImage(connector.getSource(), connector.getCertification().getIcon(), 48, true);
        DiscoveryViewer.this.hookTooltip(providerLabel, providerLabel, connectorContainer, providerLabel, connector.getSource(), 
          overview, image);
      }
      else
      {
        providerLabel.setText(NLS.bind(Messages.ConnectorDiscoveryWizardMainPage_provider_and_license, 
          connector.getProvider(), connector.getLicense()));
      }
      if (DiscoveryViewer.this.hasTooltip(connector))
      {
        ToolBar toolBar = new ToolBar(connectorContainer, 8388608);
        toolBar.setBackground(background);
        
        infoButton = new ToolItem(toolBar, 8);
        infoButton.setImage(infoImage);
        infoButton.setToolTipText(Messages.ConnectorDiscoveryWizardMainPage_tooltip_showOverview);
        DiscoveryViewer.this.hookTooltip(toolBar, infoButton, connectorContainer, nameLabel, connector.getSource(), 
          connector.getOverview(), null);
        GridDataFactory.fillDefaults().align(16777224, 16777216).applyTo(toolBar);
      }
      else
      {
        Label label = new Label(connectorContainer, 0);
        label.setText(" ");
        DiscoveryViewer.this.configureLook(label, background);
      }
      description = new Label(connectorContainer, 64);
      DiscoveryViewer.this.configureLook(description, background);
      
      GridDataFactory.fillDefaults().grab(true, false).span(3, 1).hint(100, -1).applyTo(description);
      String descriptionText = connector.getDescription();
      int maxDescriptionLength = 162;
      if (descriptionText.length() > maxDescriptionLength) {
        descriptionText = descriptionText.substring(0, maxDescriptionLength);
      }
      description.setText(descriptionText.replaceAll("(\\r\\n)|\\n|\\r", " "));
      
      providerLabel.setForeground(colorDisabled);
      
      checkbox.addSelectionListener(new SelectionListener()
      {
        public void widgetDefaultSelected(SelectionEvent e)
        {
          widgetSelected(e);
        }
        
        public void widgetSelected(SelectionEvent e)
        {
          boolean selected = checkbox.getSelection();
          maybeModifySelection(selected);
        }
      });
      MouseListener connectorItemMouseListener = new MouseAdapter()
      {
        public void mouseUp(MouseEvent e)
        {
          boolean selected = !checkbox.getSelection();
          if (maybeModifySelection(selected)) {
            checkbox.setSelection(selected);
          }
        }
      };
      checkboxContainer.addMouseListener(connectorItemMouseListener);
      connectorContainer.addMouseListener(connectorItemMouseListener);
      iconLabel.addMouseListener(connectorItemMouseListener);
      nameLabel.addMouseListener(connectorItemMouseListener);
      
      description.addMouseListener(connectorItemMouseListener);
    }
    
    protected boolean maybeModifySelection(boolean selected)
    {
      if (selected)
      {
        if (connector.isInstalled())
        {
          MessageDialog.openWarning(shellProvider.getShell(), 
            Messages.DiscoveryViewer_Install_Connector_Title, 
            NLS.bind(Messages.DiscoveryViewer_Already_installed_Error, connector.getName()));
          return false;
        }
        if (!connector.isInstallable())
        {
          if (connector.getInstallMessage() != null) {
            MessageDialog.openInformation(shellProvider.getShell(), 
              Messages.DiscoveryViewer_Install_Connector_Title, connector.getInstallMessage());
          }
          return false;
        }
        if ((connector.getAvailable() != null) && (!connector.getAvailable().booleanValue()))
        {
          MessageDialog.openWarning(shellProvider.getShell(), 
            Messages.ConnectorDiscoveryWizardMainPage_warningTitleConnectorUnavailable, NLS.bind(
            Messages.ConnectorDiscoveryWizardMainPage_warningMessageConnectorUnavailable, 
            connector.getName()));
          return false;
        }
      }
      DiscoveryViewer.this.modifySelection(connector, selected);
      return true;
    }
    
    public void propertyChange(PropertyChangeEvent evt)
    {
      display.asyncExec(this);
    }
    
    public void run()
    {
      if (!connectorContainer.isDisposed()) {
        updateAvailability();
      }
    }
    
    public void updateAvailability()
    {
      boolean enabled = (!connector.isInstalled()) && (
        (connector.getAvailable() == null) || (connector.getAvailable().booleanValue()));
      
      checkbox.setEnabled(enabled);
      nameLabel.setEnabled(enabled);
      providerLabel.setEnabled(enabled);
      description.setEnabled(enabled);
      Color foreground;
      Color foreground;
      if (enabled) {
        foreground = connectorContainer.getForeground();
      } else {
        foreground = colorDisabled;
      }
      nameLabel.setForeground(foreground);
      description.setForeground(foreground);
      if (iconImage != null) {
        iconLabel.setImage(iconImage);
      }
    }
  }
  
  private final List<ConnectorDescriptor> installableConnectors = new ArrayList();
  private volatile ConnectorDiscovery discovery;
  private Composite body;
  private final List<Resource> disposables;
  private Font h2Font;
  private Font h1Font;
  private Color colorWhite;
  private Text filterText;
  private WorkbenchJob refreshJob;
  private String previousFilterText = "";
  private Pattern filterPattern;
  private Label clearFilterTextControl;
  private Set<String> installedFeatures;
  private Image infoImage;
  private Cursor handCursor;
  private Color colorCategoryGradientStart;
  private Color colorCategoryGradientEnd;
  private Color colorDisabled;
  private ScrolledComposite bodyScrolledComposite;
  private boolean verifyUpdateSiteAvailability;
  private final Map<ConnectorDescriptorKind, Boolean> connectorDescriptorKindToVisibility = new HashMap();
  private Dictionary<Object, Object> environment;
  private boolean complete;
  private final IRunnableContext context;
  private final IShellProvider shellProvider;
  private Control control;
  private String directoryUrl;
  private final SelectionProviderAdapter selectionProvider;
  private List<DiscoveryConnector> allConnectors;
  private int minimumHeight;
  private final List<ViewerFilter> filters;
  private boolean showInstalledFilterEnabled;
  private boolean showInstalled;
  
  public DiscoveryViewer(IShellProvider shellProvider, IRunnableContext context)
  {
    ConnectorDescriptorKind[] arrayOfConnectorDescriptorKind;
    int j = (arrayOfConnectorDescriptorKind = ConnectorDescriptorKind.values()).length;
    for (int i = 0; i < j; i++)
    {
      ConnectorDescriptorKind kind = arrayOfConnectorDescriptorKind[i];
      connectorDescriptorKindToVisibility.put(kind, Boolean.valueOf(true));
    }
    filters = new ArrayList();
    
    this.shellProvider = shellProvider;
    this.context = context;
    selectionProvider = new SelectionProviderAdapter();
    allConnectors = Collections.emptyList();
    disposables = new ArrayList();
    setShowConnectorDescriptorKindFilter(true);
    setShowConnectorDescriptorTextFilter(true);
    setMinimumHeight(100);
    createEnvironment();
    setComplete(false);
  }
  
  public void addSelectionChangedListener(ISelectionChangedListener listener)
  {
    selectionProvider.addSelectionChangedListener(listener);
  }
  
  private void clearDisposables()
  {
    disposables.clear();
    h1Font = null;
    h2Font = null;
    infoImage = null;
    handCursor = null;
    colorCategoryGradientStart = null;
    colorCategoryGradientEnd = null;
  }
  
  private void clearFilterText()
  {
    filterText.setText("");
    filterTextChanged();
  }
  
  private Image computeIconImage(AbstractDiscoverySource discoverySource, Icon icon, int dimension, boolean fallback)
  {
    String imagePath;
    switch (dimension)
    {
    case 64: 
      String imagePath = icon.getImage64();
      if ((imagePath != null) || (!fallback)) {
        break;
      }
    case 48: 
      String imagePath = icon.getImage48();
      if ((imagePath != null) || (!fallback)) {
        break;
      }
    case 32: 
      imagePath = icon.getImage32();
      break;
    default: 
      throw new IllegalArgumentException();
    }
    String imagePath;
    if ((imagePath != null) && (imagePath.length() > 0))
    {
      URL resource = discoverySource.getResource(imagePath);
      if (resource != null)
      {
        ImageDescriptor descriptor = ImageDescriptor.createFromURL(resource);
        Image image = descriptor.createImage();
        if (image != null)
        {
          disposables.add(image);
          return image;
        }
      }
    }
    return null;
  }
  
  private IStatus computeStatus(InvocationTargetException e, String message)
  {
    Throwable cause = e.getCause();
    IStatus statusCause;
    IStatus statusCause;
    if ((cause instanceof CoreException)) {
      statusC
1 2 3 4 5

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