org.eclipse.help.ui_3.5.101.r37_20110819

16:44:55.662 INFO  jd.cli.Main - Decompiling org.eclipse.help.ui_3.5.101.r37_20110819.jar
package org.eclipse.help.ui;

import java.util.Dictionary;

public abstract interface IEngineDescriptor
{
  public abstract String getId();
  
  public abstract String getEngineTypeId();
  
  public abstract String getLabel();
  
  public abstract void setLabel(String paramString);
  
  public abstract String getDescription();
  
  public abstract void setDescription(String paramString);
  
  public abstract Dictionary getParameters();
  
  public abstract boolean isUserDefined();
}

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

import java.util.Dictionary;
import org.eclipse.help.search.ISearchScope;
import org.eclipse.jface.preference.IPreferenceStore;

public abstract interface ISearchScopeFactory
{
  public abstract ISearchScope createSearchScope(IPreferenceStore paramIPreferenceStore, String paramString, Dictionary paramDictionary);
}

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

import org.eclipse.jface.preference.IPreferencePage;

public abstract interface ISearchScopePage
  extends IPreferencePage
{
  public abstract void init(IEngineDescriptor paramIEngineDescriptor, String paramString);
}

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

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

class RootScopePage$1
  extends SelectionAdapter
{
  final RootScopePage this$0;
  
  RootScopePage$1(RootScopePage paramRootScopePage)
  {
    this$0 = paramRootScopePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.masterValueChanged(RootScopePage.access$0(this$0).getSelection());
  }
}

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

import java.util.Dictionary;
import java.util.Hashtable;
import org.eclipse.help.ui.internal.Messages;
import org.eclipse.help.ui.internal.views.ScopeSet;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
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.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public abstract class RootScopePage
  extends PreferencePage
  implements ISearchScopePage
{
  private IEngineDescriptor ed;
  private String scopeSetName;
  private Button masterButton;
  private Text labelText;
  private Text descText;
  private Hashtable disabledStates = new Hashtable();
  private Label spacer;
  private Composite contentContainer;
  
  public void init(IEngineDescriptor ed, String scopeSetName)
  {
    this.ed = ed;
    this.scopeSetName = scopeSetName;
  }
  
  protected final Control createContents(Composite parent)
  {
    initializeDefaults(getPreferenceStore());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, 
      "org.eclipse.help.ui.searchScope");
    contentContainer = new Composite(parent, 0);
    GridLayout layout = new GridLayout();
    
    numColumns = 2;
    contentContainer.setLayout(layout);
    if (isInPreferenceDialog())
    {
      masterButton = new Button(contentContainer, 32);
      masterButton.setText(Messages.RootScopePage_masterButton);
      GridData gd = new GridData();
      horizontalSpan = 2;
      masterButton.setLayoutData(gd);
      
      spacer = new Label(contentContainer, 0);
      gd = new GridData();
      horizontalSpan = 2;
      spacer.setLayoutData(gd);
      boolean masterValue = getPreferenceStore().getBoolean(ScopeSet.getMasterKey(ed.getId()));
      masterButton.setSelection(masterValue);
      masterButton.addSelectionListener(new SelectionAdapter()
      {
        public void widgetSelected(SelectionEvent e)
        {
          masterValueChanged(masterButton.getSelection());
        }
      });
      Label label = new Label(contentContainer, 0);
      label.setText(Messages.RootScopePage_name);
      labelText = new Text(contentContainer, 2048);
      gd = new GridData(768);
      widthHint = 200;
      labelText.setLayoutData(gd);
      labelText.setEditable(ed.isUserDefined());
      label = new Label(contentContainer, 0);
      label.setText(Messages.RootScopePage_desc);
      gd = new GridData(2);
      label.setLayoutData(gd);
      descText = new Text(contentContainer, 2114);
      gd = new GridData(768);
      descText.setEditable(ed.isUserDefined());
      widthHint = 200;
      heightHint = 48;
      descText.setLayoutData(gd);
    }
    int ccol = createScopeContents(contentContainer);
    if ((ccol > numColumns) && (isInPreferenceDialog()))
    {
      numColumns = ccol;
      GridData gd = (GridData)masterButton.getLayoutData();
      horizontalSpan = numColumns;
      gd = (GridData)spacer.getLayoutData();
      horizontalSpan = numColumns;
      
      gd = (GridData)labelText.getLayoutData();
      horizontalSpan = (numColumns - 1);
      gd = (GridData)descText.getLayoutData();
      horizontalSpan = (numColumns - 1);
    }
    updateControls(true);
    return contentContainer;
  }
  
  protected void masterValueChanged(boolean value)
  {
    updateEnableState(value);
  }
  
  private void updateEnableState(boolean enabled)
  {
    Control[] children = contentContainer.getChildren();
    
    boolean first = disabledStates.isEmpty();
    for (int i = 0; i < children.length; i++)
    {
      Control child = children[i];
      if (child != masterButton) {
        if (!enabled)
        {
          disabledStates.put(child, new Boolean(child.isEnabled()));
          child.setEnabled(false);
        }
        else
        {
          Boolean savedState = (Boolean)disabledStates.get(child);
          if (!first) {
            child.setEnabled(savedState != null ? savedState
              .booleanValue() : true);
          }
        }
      }
    }
  }
  
  protected String getScopeSetName()
  {
    return scopeSetName;
  }
  
  protected IEngineDescriptor getEngineDescriptor()
  {
    return ed;
  }
  
  protected boolean isEngineEnabled()
  {
    if (!isInPreferenceDialog()) {
      return true;
    }
    return masterButton.getSelection();
  }
  
  public boolean performOk()
  {
    getPreferenceStore().setValue(ScopeSet.getMasterKey(ed.getId()), 
      isEngineEnabled());
    if (labelText != null)
    {
      ed.setLabel(labelText.getText());
      ed.setDescription(descText.getText());
    }
    return true;
  }
  
  protected void performDefaults()
  {
    getPreferenceStore().setToDefault(ScopeSet.getMasterKey(ed.getId()));
    updateControls(false);
    super.performDefaults();
  }
  
  private void updateControls(boolean first)
  {
    if (isInPreferenceDialog())
    {
      boolean value = getPreferenceStore().getBoolean(ScopeSet.getMasterKey(ed.getId()));
      boolean cvalue = masterButton.getSelection();
      if (value != cvalue)
      {
        masterButton.setSelection(value);
        masterValueChanged(value);
      }
      else if (first)
      {
        masterValueChanged(value);
      }
      labelText.setText(ed.getLabel());
      descText.setText(ed.getDescription());
    }
  }
  
  private boolean isInPreferenceDialog()
  {
    return getContainer() != null;
  }
  
  protected void initializeDefaults(IPreferenceStore store)
  {
    Boolean value = (Boolean)ed.getParameters().get(
      "__enabled__");
    store.setDefault(ScopeSet.getMasterKey(ed.getId()), value
      .booleanValue());
  }
  
  protected abstract int createScopeContents(Composite paramComposite);
}

/* Location:
 * Qualified Name:     org.eclipse.help.ui.RootScopePage
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.help.ui.browser;

import java.util.Hashtable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.help.browser.IBrowser;
import org.eclipse.help.internal.browser.BrowserManager;
import org.eclipse.help.ui.internal.HelpUIPlugin;
import org.eclipse.help.ui.internal.Messages;
import org.eclipse.help.ui.internal.util.ErrorUtil;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

public class LaunchURL
  implements IWorkbenchWindowActionDelegate, IExecutableExtension
{
  private String url;
  
  public void dispose() {}
  
  public void init(IWorkbenchWindow window) {}
  
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
    throws CoreException
  {
    if ((data != null) && ((data instanceof Hashtable))) {
      url = ((String)((Hashtable)data).get("url"));
    }
    if ((url == null) || (url.length() == 0)) {
      url = config.getAttribute("url");
    }
  }
  
  public void run(IAction action)
  {
    if ((url == null) || ("".equals(url))) {
      return;
    }
    IBrowser browser = BrowserManager.getInstance().createBrowser(true);
    try
    {
      browser.displayURL(url);
    }
    catch (Exception e)
    {
      HelpUIPlugin.logError(
        "Exception occurred when opening URL: " + url + ".", e);
      ErrorUtil.displayErrorDialog(Messages.LaunchURL_exception);
    }
  }
  
  public void selectionChanged(IAction action, ISelection selection) {}
}

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

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.help.ui.internal.views.HelpTray;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CloseHelpTrayHandler
  extends AbstractHandler
{
  public Object execute(ExecutionEvent event)
    throws ExecutionException
  {
    Display display = Display.getCurrent();
    if (display == null) {
      display = Display.getDefault();
    }
    if (display != null)
    {
      Shell shell = Display.getCurrent().getActiveShell();
      if ((shell != null) && (!shell.isDisposed()))
      {
        Object shellData = shell.getData();
        if ((shellData instanceof TrayDialog))
        {
          TrayDialog trayDialog = (TrayDialog)shellData;
          if ((trayDialog.getTray() instanceof HelpTray)) {
            trayDialog.closeTray();
          }
        }
      }
    }
    return null;
  }
}

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

import java.io.PrintStream;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class ContextHelpDialog$1
  implements Listener
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$1(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void handleEvent(Event e)
  {
    if (HelpUIPlugin.DEBUG_INFOPOP) {
      System.out.println("ContextHelpDialog shell deactivate listener: SWT.Deactivate called. ");
    }
    this$0.close();
  }
}

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

import java.io.PrintStream;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;

class ContextHelpDialog$2
  implements TraverseListener
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$2(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void keyTraversed(TraverseEvent e)
  {
    if (detail == 2)
    {
      if (HelpUIPlugin.DEBUG_INFOPOP) {
        System.out.println("ContextHelpDialog: shell traverse listener: SWT.TRAVERSE_ESCAPE called. ");
      }
      doit = true;
    }
  }
}

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

import java.io.PrintStream;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;

class ContextHelpDialog$3
  extends ControlAdapter
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$3(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void controlMoved(ControlEvent e)
  {
    if (HelpUIPlugin.DEBUG_INFOPOP) {
      System.out.println("ContextHelpDialog: shell control adapter called.");
    }
    Rectangle clientArea = this$0.shell.getClientArea();
    this$0.shell.redraw(x, y, width, 
      height, true);
    this$0.shell.update();
  }
}

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

import java.io.PrintStream;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;

class ContextHelpDialog$4
  implements TraverseListener
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$4(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void keyTraversed(TraverseEvent e)
  {
    if (detail == 2)
    {
      if (HelpUIPlugin.DEBUG_INFOPOP) {
        System.out.println("ContextHelpDialog text TraverseListener.handleEvent(): SWT.TRAVERSE_ESCAPE.");
      }
      doit = true;
    }
  }
}

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

import org.eclipse.swt.widgets.Control;

class ContextHelpDialog$5
  extends HyperlinkAdapter
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$5(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void linkActivated(Control label)
  {
    ContextHelpDialog.access$0(this$0);
  }
}

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

class ContextHelpDialog$6
  implements Runnable
{
  final ContextHelpDialog this$0;
  
  ContextHelpDialog$6(ContextHelpDialog paramContextHelpDialog)
  {
    this$0 = paramContextHelpDialog;
  }
  
  public void run()
  {
    this$0.close();
    DefaultHelpUI.getInstance().displayContext(ContextHelpDialog.access$1(this$0), 0, 0, true);
  }
}

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

import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.widgets.Control;

class ContextHelpDialog$7
  extends AccessibleAdapter
{
  final ContextHelpDialog this$0;
  private final Control val$control;
  
  ContextHelpDialog$7(ContextHelpDialog paramContextHelpDialog, Control paramControl)
  {
    this$0 = paramContextHelpDialog;val$control = paramControl;
  }
  
  public void getName(AccessibleEvent e)
  {
    result = this$0.infopopText;
  }
  
  public void getHelp(AccessibleEvent e)
  {
    result = val$control.getToolTipText();
  }
}

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

import org.eclipse.swt.accessibility.AccessibleControlAdapter;
import org.eclipse.swt.accessibility.AccessibleControlEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;

class ContextHelpDialog$8
  extends AccessibleControlAdapter
{
  final ContextHelpDialog this$0;
  private final Control val$control;
  
  ContextHelpDialog$8(ContextHelpDialog paramContextHelpDialog, Control paramControl)
  {
    this$0 = paramContextHelpDialog;val$control = paramControl;
  }
  
  public void getChildAtPoint(AccessibleControlEvent e)
  {
    Point pt = val$control.toControl(new Point(x, y));
    childID = (val$control.getBounds().contains(pt) ? -3 : 
      -2);
  }
  
  public void getLocation(AccessibleControlEvent e)
  {
    Rectangle location = val$control.getBounds();
    Point pt = val$control.toDisplay(new Point(x, y));
    x = x;
    y = y;
    width = width;
    height = height;
  }
  
  public void getChildCount(AccessibleControlEvent e)
  {
    detail = 1;
  }
  
  public void getRole(AccessibleControlEvent e)
  {
    detail = 41;
  }
  
  public void getState(AccessibleControlEvent e)
  {
    detail = 64;
  }
}

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

import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;

public class ContextHelpDialog$Description
  extends StyledText
{
  final ContextHelpDialog this$0;
  
  public ContextHelpDialog$Description(ContextHelpDialog paramContextHelpDialog, Composite parent, int style)
  {
    super(parent, style);
    this$0 = paramContextHelpDialog;
  }
  
  public boolean setFocus()
  {
    return false;
  }
  
  public boolean isFocusControl()
  {
    return false;
  }
}

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

import org.eclipse.help.IHelpResource;
import org.eclipse.swt.widgets.Control;

class ContextHelpDialog$LinkListener
  extends HyperlinkAdapter
{
  IHelpResource topic;
  final ContextHelpDialog this$0;
  
  public ContextHelpDialog$LinkListener(ContextHelpDialog paramContextHelpDialog, IHelpResource topic)
  {
    this$0 = paramContextHelpDialog;
    this.topic = topic;
  }
  
  public void linkActivated(Control c)
  {
    this$0.launchLinks(topic);
  }
}

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

import java.io.PrintStream;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.IContext;
import org.eclipse.help.IContext2;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.UAContentFilter;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpDisplay;
import org.eclipse.help.internal.base.HelpEvaluationContext;
import org.eclipse.help.ui.internal.views.HelpTray;
import org.eclipse.jface.window.IShellProvider;
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.BusyIndicator;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Caret;
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.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class ContextHelpDialog
{
  private Color backgroundColour = null;
  private IContext context;
  private Color foregroundColour = null;
  private Color linkColour = null;
  private static HyperlinkHandler linkManager = new HyperlinkHandler();
  protected Shell parentShell;
  protected Shell shell;
  protected String infopopText;
  
  class LinkListener
    extends HyperlinkAdapter
  {
    IHelpResource topic;
    
    public LinkListener(IHelpResource topic)
    {
      this.topic = topic;
    }
    
    public void linkActivated(Control c)
    {
      launchLinks(topic);
    }
  }
  
  ContextHelpDialog(IContext context, int x, int y)
  {
    this.context = context;
    Display display = Display.getCurrent();
    if (display == null) {
      return;
    }
    backgroundColour = display.getSystemColor(29);
    foregroundColour = display.getSystemColor(28);
    linkColour = display.getSystemColor(9);
    parentShell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
    if (parentShell != null)
    {
      boolean isModal = (parentShell.getStyle() & 0x38000) > 0;
      if (HelpUIPlugin.DEBUG_INFOPOP) {
        System.out.println("ContextHelpDialog.ContextHelpDialog(): ParentShell: " + 
          parentShell.toString() + " is " + (
          isModal ? "modal" : "modeless"));
      }
    }
    shell = new Shell(parentShell, 0);
    if (HelpUIPlugin.DEBUG_INFOPOP) {
      System.out.println("ContextHelpDialog.ContextHelpDialog(): Shell is:" + 
        shell.toString());
    }
    PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, "org.eclipse.help.ui.f1Shell");
    
    shell.addListener(27, new Listener()
    {
      public void handleEvent(Event e)
      {
        if (HelpUIPlugin.DEBUG_INFOPOP) {
          System.out.println("ContextHelpDialog shell deactivate listener: SWT.Deactivate called. ");
        }
        close();
      }
    });
    shell.addTraverseListener(new TraverseListener()
    {
      public void keyTraversed(TraverseEvent e)
      {
        if (detail == 2)
        {
          if (HelpUIPlugin.DEBUG_INFOPOP) {
            System.out.println("ContextHelpDialog: shell traverse listener: SWT.TRAVERSE_ESCAPE called. ");
          }
          doit = true;
        }
      }
    });
    shell.addControlListener(new ControlAdapter()
    {
      public void controlMoved(ControlEvent e)
      {
        if (HelpUIPlugin.DEBUG_INFOPOP) {
          System.out.println("ContextHelpDialog: shell control adapter called.");
        }
        Rectangle clientArea = shell.getClientArea();
        shell.redraw(x, y, width, 
          height, true);
        shell.update();
      }
    });
    if (HelpUIPlugin.DEBUG_INFOPOP) {
      System.out.println("ContextHelpDialog.ContextHelpDialog(): Focus owner is: " + 
        Display.getCurrent().getFocusControl().toString());
    }
    linkManager.setHyperlinkUnderlineMode(3);
    createContents(shell);
    shell.pack();
    
    int width = shell.getBounds().width;
    int height = shell.getBounds().height;
    
    Rectangle screen = display.getClientArea();
    
    x = x >= x ? x : x;
    y = y >= y ? y : y;
    
    x = x + width <= width ? x : width - width;
    y = y + height <= height ? y : height - height;
    shell.setLocation(x, y);
    
    initAccessible(shell);
  }
  
  public synchronized void close()
  {
    try
    {
      if (HelpUIPlugin.DEBUG_INFOPOP) {
        System.out.println("ContextHelpDialog.close()");
      }
      if (shell != null)
      {
        shell.close();
        if (!shell.isDisposed()) {
          shell.dispose();
        }
        shell = null;
      }
    }
    catch (Throwable localThrowable) {}
  }
  
  protected Control createContents(Composite contents)
  {
    initAccessible(contents);
    contents.setBackground(backgroundColour);
    GridLayout layout = new GridLayout();
    marginHeight = 5;
    marginWidth = 5;
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(1808));
    
    createInfoArea(contents);
    Control c = createLinksArea(contents);
    if (c != null) {
      contents.setTabList(new Control[] { c });
    }
    return contents;
  }
  
  private Control createInfoArea(Composite parent)
  {
    String styledText = null;
    if ((context instanceof IContext2)) {
      styledText = ((IContext2)context).getStyledText();
    }
    if ((styledText == null) && (context.getText() != null))
    {
      styledText = context.getText();
      styledText = styledText.replaceAll("<b>", "<@#\\$b>");
      styledText = styledText.replaceAll("</b>", "</@#\\$b>");
    }
    if (styledText == null) {
      styledText = Messages.ContextHelpPart_noDescription;
    }
    Description text = new Description(parent, 10);
    text.addTraverseListener(new TraverseListener()
    {
      public void keyTraversed(TraverseEvent e)
      {
        if (detail == 2)
        {
          if (HelpUIPlugin.DEBUG_INFOPOP) {
            System.out.println("ContextHelpDialog text TraverseListener.handleEvent(): SWT.TRAVERSE_ESCAPE.");
          }
          doit = true;
        }
      }
    });
    text.getCaret().setVisible(false);
    text.setBackground(backgroundColour);
    text.setForeground(foregroundColour);
    text.setFont(parent.getFont());
    int linkWidth = getLinksWidth(text);
    StyledLineWrapper content = new StyledLineWrapper(styledText, text, 
      linkWidth + 70);
    text.setContent(content);
    text.setStyleRanges(content.getStyles());
    
    infopopText = text.getText();
    initAccessible(text);
    
    return text;
  }
  
  private int getLinksWidth(Description text)
  {
    int linkWidth = 0;
    IHelpResource[] relatedTopics = context.getRelatedTopics();
    if (relatedTopics != null)
    {
      GC gc = new GC(text);
      for (int i = 0; i < relatedTopics.length; i++) {
        linkWidth = Math.max(linkWidth, 
          textExtentgetLabelx);
      }
      gc.dispose();
    }
    return linkWidth;
  }
  
  private Control createLink(Composite parent, IHelpResource topic)
  {
    Label image = new Label(parent, 0);
    image.setImage(getImage());
    image.setBackground(backgroundColour);
    GridData data = new GridData();
    horizontalAlignment = 32;
    verticalAlignment = 2;
    
    image.setLayoutData(data);
    HyperlinkLabel link = new HyperlinkLabel(parent, 0);
    link.setText(topic.getLabel());
    link.setBackground(backgroundColour);
    link.setForeground(linkColour);
    link.setFont(parent.getFont());
    linkManager.registerHyperlink(link, new LinkListener(topic));
    return link;
  }
  
  private Control createLinksArea(Composite parent)
  {
    IHelpResource[] relatedTopics = context.getRelatedTopics();
    if (relatedTopics == null) {
      return null;
    }
    Composite composite = new Composite(parent, 0);
    initAccessible(composite);
    
    composite.setBackground(backgroundColour);
    GridLayout layout = new GridLayout();
    marginHeight = 2;
    marginWidth = 0;
    verticalSpacing = 3;
    horizontalSpacing = 2;
    numColumns = 2;
    composite.setLayout(layout);
    composite.setFont(parent.getFont());
    GridData data = new GridData(1844);
    
    composite.setLayoutData(data);
    
    Label label = new Label(composite, 258);
    label.setBackground(backgroundColour);
    label.setForeground(foregroundColour);
    data = new GridData(802);
    
    horizontalSpan = 2;
    label.setLayoutData(data);
    for (int i = 0; i < relatedTopics.length; i++) {
      if (!UAContentFilter.isFiltered(relatedTopics[i], HelpEvaluationContext.getContext())) {
        createLink(composite, relatedTopics[i]);
      }
    }
    IWorkbenchWindow wbWindow = HelpUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
    if ((DefaultHelpUI.isActiveShell(parentShell, wbWindow)) || (HelpTray.isAppropriateFor(parentShell)))
    {
      label = new Label(composite, 258);
      label.setBackground(backgroundColour);
      label.setForeground(foregroundColour);
      data = new GridData(802);
      
      horizontalSpan = 2;
      label.setLayoutData(data);
      
      createDynamicHelpLink(composite);
    }
    return composite;
  }
  
  private Control createDynamicHelpLink(Composite parent)
  {
    Label image = new Label(parent, 0);
    Image img = HelpUIResources.getImage("view16/help_view.gif");
    image.setImage(img);
    image.setBackground(backgroundColour);
    GridData data = new GridData();
    horizontalAlignment = 32;
    verticalAlignment = 2;
    
    image.setLayoutData(data);
    HyperlinkLabel link = new HyperlinkLabel(parent, 0);
    link.setText(Messages.ContextHelpDialog_showInDynamicHelp);
    link.setBackground(backgroundColour);
    link.setForeground(linkColour);
    link.setFont(parent.getFont());
    linkManager.registerHyperlink(link, new HyperlinkAdapter()
    {
      public void linkActivated(Control label)
      {
        ContextHelpDialog.this.openDynamicHelp();
      }
    });
    return link;
  }
  
  protected void launchLinks(IHelpResource selectedTopic)
  {
    close();
    if (HelpUIPlugin.DEBUG_INFOPOP) {
      System.out.println("ContextHelpDialog.launchLinks(): closed shell");
    }
    BaseHelpSystem.getHelpDisplay().displayHelp(
      context, 
      selectedTopic, 
      (DefaultHelpUI.isDisplayModal(parentShell)) && 
      (!"win32".equalsIgnoreCase(
      Platform.getOS())));
  }
  
  private void openDynamicHelp()
  {
    BusyIndicator.showWhile(shell.getDisplay(), new Runnable()
    {
      public void run()
      {
        close();
        DefaultHelpUI.getInstance().displayContext(context, 0, 0, true);
      }
    });
  }
  
  public synchronized void open()
  {
    try
    {
      shell.open();
      if (HelpUIPlugin.DEBUG_INFOPOP) {
        System.out.println("ContextHelpDialog.open(): Focus owner after open is: " + 
          Display.getCurrent().getFocusControl()
          .toString());
      }
    }
    catch (Throwable e)
    {
      HelpUIPlugin.logError(
        "An error occurred when opening context-sensitive help pop-up.", 
        e);
    }
  }
  
  private Image getImage()
  {
    return HelpUIResources.getImage("obj16/topic_small.gif");
  }
  
  public boolean isShowing()
  {
    return (shell != null) && (!shell.isDisposed()) && (shell.isVisible());
  }
  
  private void initAccessible(Control control)
  {
    Accessible accessible = control.getAccessible();
    accessible.addAccessibleListener(new AccessibleAdapter()
    {
      private final Control val$control;
      
      public void getName(AccessibleEvent e)
      {
        result = infopopText;
      }
      
      public void getHelp(AccessibleEvent e)
      {
        result = val$control.getToolTipText();
      }
    });
    accessible.addAccessibleControlListener(new AccessibleControlAdapter()
    {
      private final Control val$control;
      
      public void getChildAtPoint(AccessibleControlEvent e)
      {
        Point pt = val$control.toControl(new Point(x, y));
        childID = (val$control.getBounds().contains(pt) ? -3 : 
          -2);
      }
      
      public void getLocation(AccessibleControlEvent e)
      {
        Rectangle location = val$control.getBounds();
        Point pt = val$control.toDisplay(new Point(x, y));
        x = x;
        y = y;
        width = width;
        height = height;
      }
      
      public void getChildCount(AccessibleControlEvent e)
      {
        detail = 1;
      }
      
      public void getRole(AccessibleControlEvent e)
      {
        detail = 41;
      }
      
      public void getState(AccessibleControlEvent e)
      {
        detail = 64;
      }
    });
  }
  
  public class Description
    extends StyledText
  {
    public Description(Composite parent, int style)
    {
      super(style);
    }
    
    public boolean setFocus()
    {
      return false;
    }
    
    public boolean isFocusControl()
    {
      return false;
    }
  }
}

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

import java.net.URL;
import org.eclipse.help.browser.IBrowser;
import org.eclipse.help.ui.internal.util.ErrorUtil;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

class DefaultHelpUI$ExternalWorkbenchBrowser
  implements IBrowser
{
  final DefaultHelpUI this$0;
  
  public DefaultHelpUI$ExternalWorkbenchBrowser(DefaultHelpUI paramDefaultHelpUI)
  {
    this$0 = paramDefaultHelpUI;
  }
  
  private IWebBrowser getExternalBrowser()
    throws PartInitException
  {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    return support.getExternalBrowser();
  }
  
  public void close() {}
  
  public boolean isCloseSupported()
  {
    return false;
  }
  
  public void displayURL(String url)
    throws Exception
  {
    try
    {
      IWebBrowser browser = getExternalBrowser();
      if (browser != null) {
        browser.openURL(new URL(url));
      }
    }
    catch (PartInitException pie)
    {
      ErrorUtil.displayErrorDialog(pie.getLocalizedMessage());
    }
  }
  
  public boolean isSetLocationSupported()
  {
    return false;
  }
  
  public boolean isSetSizeSupported()
  {
    return false;
  }
  
  public void setLocation(int x, int y) {}
  
  public void setSize(int width, int height) {}
}

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

import java.net.URL;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.help.IContext;
import org.eclipse.help.IContextProvider;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.browser.IBrowser;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpDisplay;
import org.eclipse.help.internal.context.Context;
import org.eclipse.help.ui.internal.util.ErrorUtil;
import org.eclipse.help.ui.internal.util.FontUtils;
import org.eclipse.help.ui.internal.views.ContextHelpPart;
import org.eclipse.help.ui.internal.views.HelpTray;
import org.eclipse.help.ui.internal.views.HelpView;
import org.eclipse.help.ui.internal.views.ReusableHelpPart;
import org.eclipse.jface.dialogs.DialogTray;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.help.AbstractHelpUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;

public class DefaultHelpUI
  extends AbstractHelpUI
{
  private ContextHelpDialog f1Dialog = null;
  private static DefaultHelpUI instance;
  private static boolean openingHelpView = false;
  private static final String HELP_VIEW_ID = "org.eclipse.help.ui.HelpView";
  
  class ExternalWorkbenchBrowser
    implements IBrowser
  {
    public ExternalWorkbenchBrowser() {}
    
    private IWebBrowser getExternalBrowser()
      throws PartInitException
    {
      IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
      return support.getExternalBrowser();
    }
    
    public void close() {}
    
    public boolean isCloseSupported()
    {
      return false;
    }
    
    public void displayURL(String url)
      throws Exception
    {
      try
      {
        IWebBrowser browser = getExternalBrowser();
        if (browser != null) {
          browser.openURL(new URL(url));
        }
      }
      catch (PartInitException pie)
      {
        ErrorUtil.displayErrorDialog(pie.getLocalizedMessage());
      }
    }
    
    public boolean isSetLocationSupported()
    {
      return false;
    }
    
    public boolean isSetSizeSupported()
    {
      return false;
    }
    
    public void setLocation(int x, int y) {}
    
    public void setSize(int width, int height) {}
  }
  
  public DefaultHelpUI()
  {
    instance = this;
    
    BaseHelpSystem.getInstance().setBrowserInstance(new ExternalWorkbenchBrowser());
  }
  
  public static DefaultHelpUI getInstance()
  {
    return instance;
  }
  
  public void displayHelp()
  {
    BaseHelpSystem.getHelpDisplay().displayHelp(useExternalBrowser(null));
  }
  
  public void displaySearch()
  {
    search(null);
  }
  
  public void displayDynamicHelp()
  {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Shell activeShell = getActiveShell();
    if ((window != null) && (isActiveShell(activeShell, window)))
    {
      setIntroStandby();
      
      IWorkbenchPage page = window.getActivePage();
      Control c = activeShell.getDisplay().getFocusControl();
      if (page != null)
      {
        IWorkbenchPart activePart = page.getActivePart();
        try
        {
          IViewPart part = page.showView("org.eclipse.help.ui.HelpView", null, 1);
          if (part == null) {
            return;
          }
          HelpView view = (HelpView)part;
          view.showDynamicHelp(activePart, c);
        }
        catch (PartInitException localPartInitException) {}
      }
      else
      {
        if (activeShell != null)
        {
          Object data = activeShell.getData();
          if ((data instanceof TrayDialog))
          {
            IContext context = ContextHelpPart.findHelpContext(c);
            displayContextAsHelpTray(activeShell, context);
            return;
          }
        }
        warnNoOpenPerspective(window);
      }
    }
  }
  
  public void search(String expression)
  {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Shell activeShell = getActiveShell();
    if ((window != null) && (isActiveShell(activeShell, window)))
    {
      setIntroStandby();
      
      IWorkbenchPage page = window.getActivePage();
      if (page != null)
      {
        boolean searchFromBrowser = Platform.getPreferencesService().getBoolean(
          "org.eclipse.help.base", "search_from_browser", false, null);
        if (searchFromBrowser)
        {
          String parameters = "tab=search";
          if (expression !=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

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