org.eclipse.ui.browser_3.3.101.v20111019-1723

16:48:02.325 INFO  jd.cli.Main - Decompiling org.eclipse.ui.browser_3.3.101.v20111019-1723.jar
package org.eclipse.ui.browser;

public abstract class BrowserFactory
{
  public boolean isAvailable()
  {
    return true;
  }
  
  public abstract IWebBrowser createBrowser(String paramString1, String paramString2, String paramString3);
}

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

import org.eclipse.ui.IMemento;

public class BrowserDescriptor
  implements IBrowserDescriptor
{
  private static final String MEMENTO_NAME = "name";
  private static final String MEMENTO_LOCATION = "location";
  private static final String MEMENTO_PARAMETERS = "parameters";
  protected String name;
  protected String location;
  protected String parameters;
  
  public String getName()
  {
    return name;
  }
  
  public String getLocation()
  {
    return location;
  }
  
  public String getParameters()
  {
    return parameters;
  }
  
  public void delete()
  {
    BrowserManager.getInstance().removeWebBrowser(this);
  }
  
  public boolean isWorkingCopy()
  {
    return false;
  }
  
  public IBrowserDescriptorWorkingCopy getWorkingCopy()
  {
    return new BrowserDescriptorWorkingCopy(this);
  }
  
  protected void setInternal(IBrowserDescriptor browser)
  {
    name = browser.getName();
    location = browser.getLocation();
    parameters = browser.getParameters();
  }
  
  protected void save(IMemento memento)
  {
    memento.putString("name", name);
    memento.putString("location", location);
    memento.putString("parameters", parameters);
  }
  
  protected void load(IMemento memento)
  {
    name = memento.getString("name");
    location = memento.getString("location");
    parameters = memento.getString("parameters");
  }
  
  public String toString()
  {
    return "External Web browser: " + getName() + " / " + getLocation() + " / " + getParameters();
  }
}

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

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

class BrowserDescriptorDialog$1
  implements ModifyListener
{
  final BrowserDescriptorDialog this$0;
  private final BrowserDescriptorDialog.StringModifyListener val$listener;
  private final Text val$text;
  
  BrowserDescriptorDialog$1(BrowserDescriptorDialog paramBrowserDescriptorDialog, BrowserDescriptorDialog.StringModifyListener paramStringModifyListener, Text paramText)
  {
    this$0 = paramBrowserDescriptorDialog;val$listener = paramStringModifyListener;val$text = paramText;
  }
  
  public void modifyText(ModifyEvent e)
  {
    val$listener.valueChanged(val$text.getText());
  }
}

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

class BrowserDescriptorDialog$2
  implements BrowserDescriptorDialog.StringModifyListener
{
  final BrowserDescriptorDialog this$0;
  
  BrowserDescriptorDialog$2(BrowserDescriptorDialog paramBrowserDescriptorDialog)
  {
    this$0 = paramBrowserDescriptorDialog;
  }
  
  public void valueChanged(String s)
  {
    this$0.browser.setName(s);
    this$0.validateFields();
  }
}

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

class BrowserDescriptorDialog$3
  implements BrowserDescriptorDialog.StringModifyListener
{
  final BrowserDescriptorDialog this$0;
  
  BrowserDescriptorDialog$3(BrowserDescriptorDialog paramBrowserDescriptorDialog)
  {
    this$0 = paramBrowserDescriptorDialog;
  }
  
  public void valueChanged(String s)
  {
    this$0.browser.setLocation(s);
    this$0.validateFields();
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Text;

class BrowserDescriptorDialog$4
  extends SelectionAdapter
{
  final BrowserDescriptorDialog this$0;
  
  BrowserDescriptorDialog$4(BrowserDescriptorDialog paramBrowserDescriptorDialog)
  {
    this$0 = paramBrowserDescriptorDialog;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    FileDialog dialog = new FileDialog(this$0.getShell(), 4096);
    dialog.setText(Messages.browseMessage);
    
    String fname = this$0.browserLocationTextfield.getText();
    
    dialog.setFileName(fname);
    fname = dialog.open();
    if (fname != null) {
      this$0.browserLocationTextfield.setText(fname);
    }
  }
}

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

class BrowserDescriptorDialog$5
  implements BrowserDescriptorDialog.StringModifyListener
{
  final BrowserDescriptorDialog this$0;
  
  BrowserDescriptorDialog$5(BrowserDescriptorDialog paramBrowserDescriptorDialog)
  {
    this$0 = paramBrowserDescriptorDialog;
  }
  
  public void valueChanged(String s)
  {
    this$0.browser.setParameters(s);
  }
}

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

abstract interface BrowserDescriptorDialog$StringModifyListener
{
  public abstract void valueChanged(String paramString);
}

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

import java.io.File;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.osgi.util.NLS;
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.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
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.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class BrowserDescriptorDialog
  extends Dialog
{
  protected IBrowserDescriptorWorkingCopy browser;
  protected boolean isEdit;
  protected Button newPageCheckbox;
  protected Button clearHistoryCheckbox;
  protected Button browseButton;
  protected Text browserNameTextfield;
  protected Text browserLocationTextfield;
  protected Text browserParametersTextfield;
  private Button okButton;
  
  public BrowserDescriptorDialog(Shell parentShell, IBrowserDescriptorWorkingCopy browser)
  {
    super(parentShell);
    this.browser = browser;
    isEdit = true;
    setShellStyle(getShellStyle() | 0x10);
  }
  
  public BrowserDescriptorDialog(Shell parentShell)
  {
    super(parentShell);
    browser = BrowserManager.getInstance().createExternalWebBrowser();
    isEdit = false;
    setShellStyle(getShellStyle() | 0x10);
  }
  
  protected void configureShell(Shell shell)
  {
    super.configureShell(shell);
    if (isEdit) {
      shell.setText(Messages.editExternalBrowser);
    } else {
      shell.setText(Messages.createBrowser);
    }
  }
  
  protected Text createText(Composite comp, String txt, StringModifyListener listener, boolean multiLine)
  {
    int style = 2048;
    if (multiLine) {
      style = 2626;
    }
    Text text = new Text(comp, style);
    if (txt != null) {
      text.setText(txt);
    }
    GridData data = new GridData(4, 16777216, true, false);
    widthHint = 450;
    if (multiLine)
    {
      verticalAlignment = 4;
      grabExcessVerticalSpace = true;
    }
    GC gc = new GC(text);
    FontMetrics fm = gc.getFontMetrics();
    int hHint = 8 * fm.getHeight();
    gc.dispose();
    
    text.setSize(text.computeSize(-1, hHint));
    
    text.setLayoutData(data);
    if (listener != null) {
      text.addModifyListener(new ModifyListener()
      {
        private final BrowserDescriptorDialog.StringModifyListener val$listener;
        private final Text val$text;
        
        public void modifyText(ModifyEvent e)
        {
          val$listener.valueChanged(val$text.getText());
        }
      });
    }
    return text;
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Font font = parent.getFont();
    Composite composite = (Composite)super.createDialogArea(parent);
    getLayoutnumColumns = 3;
    composite.setFont(font);
    
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "org.eclipse.ui.browser.browser_preference_page_dialog_context");
    
    SWTUtil.createLabel(composite, Messages.name).setFont(font);
    browserNameTextfield = createText(composite, browser.getName(), new StringModifyListener()
    {
      public void valueChanged(String s)
      {
        browser.setName(s);
        validateFields();
      }
    }, false);
    browserNameTextfield.setFont(font);
    
    new Label(composite, 0);
    
    SWTUtil.createLabel(composite, Messages.location).setFont(font);
    browserLocationTextfield = createText(composite, browser.getLocation(), new StringModifyListener()
    {
      public void valueChanged(String s)
      {
        browser.setLocation(s);
        validateFields();
      }
    }, false);
    browserLocationTextfield.setFont(font);
    
    browseButton = SWTUtil.createButton(composite, Messages.browse);
    browseButton.setFont(font);
    browseButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FileDialog dialog = new FileDialog(getShell(), 4096);
        dialog.setText(Messages.browseMessage);
        
        String fname = browserLocationTextfield.getText();
        
        dialog.setFileName(fname);
        fname = dialog.open();
        if (fname != null) {
          browserLocationTextfield.setText(fname);
        }
      }
    });
    SWTUtil.createLabel(composite, Messages.parameters).setFont(font);
    browserParametersTextfield = createText(composite, browser.getParameters(), new StringModifyListener()
    {
      public void valueChanged(String s)
      {
        browser.setParameters(s);
      }
    }, true);
    browserParametersTextfield.setFont(font);
    
    new Label(composite, 0);
    
    new Label(composite, 0);
    Label urlLabel = new Label(composite, 0);
    urlLabel.setText(NLS.bind(Messages.parametersMessage, "%URL%"));
    urlLabel.setFont(font);
    
    return composite;
  }
  
  protected void okPressed()
  {
    try
    {
      File file = new File(browser.getLocation());
      if (!file.isFile())
      {
        WebBrowserUtil.openError(Messages.locationInvalid);
        return;
      }
    }
    catch (Exception localException)
    {
      WebBrowserUtil.openError(Messages.locationInvalid);
      return;
    }
    browser.save();
    super.okPressed();
  }
  
  private void setOKButtonEnabled(boolean curIsEnabled)
  {
    if (okButton == null) {
      okButton = getButton(0);
    }
    if (okButton != null) {
      okButton.setEnabled(curIsEnabled);
    }
  }
  
  protected Control createButtonBar(Composite parent)
  {
    Control buttonControl = super.createButtonBar(parent);
    validateFields();
    return buttonControl;
  }
  
  protected void validateFields()
  {
    boolean valid = true;
    
    String name = browserNameTextfield.getText();
    if ((name == null) || (name.trim().length() < 1)) {
      valid = false;
    }
    String location = browserLocationTextfield.getText();
    if ((location == null) || (location.trim().length() < 1)) {
      valid = false;
    }
    setOKButtonEnabled(valid);
  }
  
  static abstract interface StringModifyListener
  {
    public abstract void valueChanged(String paramString);
  }
}

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

public class BrowserDescriptorWorkingCopy
  extends BrowserDescriptor
  implements IBrowserDescriptorWorkingCopy
{
  protected BrowserDescriptor browser;
  
  public BrowserDescriptorWorkingCopy() {}
  
  public BrowserDescriptorWorkingCopy(BrowserDescriptor browser)
  {
    this.browser = browser;
    setInternal(browser);
  }
  
  public void setName(String name)
  {
    if (name == null) {
      throw new IllegalArgumentException();
    }
    this.name = name;
  }
  
  public void setLocation(String location)
  {
    this.location = location;
  }
  
  public void setParameters(String params)
  {
    parameters = params;
  }
  
  public boolean isWorkingCopy()
  {
    return true;
  }
  
  public IBrowserDescriptorWorkingCopy getWorkingCopy()
  {
    return this;
  }
  
  public IBrowserDescriptor save()
  {
    if (browser != null)
    {
      browser.setInternal(this);
    }
    else
    {
      browser = new BrowserDescriptor();
      browser.setInternal(this);
      BrowserManager.getInstance().addBrowser(browser);
    }
    return browser;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.ui.browser.BrowserFactory;
import org.eclipse.ui.browser.IWebBrowser;

public class BrowserExt
  implements IBrowserExt
{
  private static final String ATTR_FACTORY_CLASS = "factoryclass";
  private IConfigurationElement element;
  private BrowserFactory delegate;
  
  public BrowserExt(IConfigurationElement element)
  {
    this.element = element;
  }
  
  public String getId()
  {
    return element.getAttribute("id");
  }
  
  public String getName()
  {
    String label = element.getAttribute("name");
    if (label == null) {
      return "n/a";
    }
    return label;
  }
  
  public String getParameters()
  {
    return element.getAttribute("parameters");
  }
  
  public String getExecutable()
  {
    return element.getAttribute("executable");
  }
  
  public String getOS()
  {
    String os = element.getAttribute("os");
    if (os == null) {
      os = "";
    }
    return os;
  }
  
  public String[] getDefaultLocations()
  {
    List list = new ArrayList();
    IConfigurationElement[] children = element.getChildren("location");
    if (children != null)
    {
      int size = children.length;
      for (int i = 0; i < size; i++) {
        list.add(children[i].getValue());
      }
    }
    String[] s = new String[list.size()];
    list.toArray(s);
    return s;
  }
  
  protected BrowserFactory getDelegate()
  {
    if (delegate == null)
    {
      if ((element.getAttribute("factoryclass") == null) || 
        (element.getAttribute("factoryclass").length() == 0)) {
        return null;
      }
      try
      {
        delegate = 
          ((BrowserFactory)element.createExecutableExtension("factoryclass"));
      }
      catch (Exception e)
      {
        Trace.trace(
          Trace.SEVERE, 
          "Could not create delegate" + toString() + ": " + e.getMessage());
      }
    }
    return delegate;
  }
  
  public boolean isAvailable()
  {
    if ((delegate == null) && ((element.getAttribute("factoryclass") == null) || 
      (element.getAttribute("factoryclass").length() == 0))) {
      return true;
    }
    try
    {
      return getDelegate().isAvailable();
    }
    catch (Exception e)
    {
      Trace.trace(
        Trace.SEVERE, 
        "Error calling delegate " + toString() + ": " + e.getMessage());
    }
    return false;
  }
  
  public IWebBrowser createBrowser(String id, String location, String parameters)
  {
    try
    {
      return getDelegate().createBrowser(id, location, parameters);
    }
    catch (Exception e)
    {
      Trace.trace(
        Trace.SEVERE, 
        "Error calling delegate " + toString() + ": " + e.getMessage());
    }
    return null;
  }
  
  public String toString()
  {
    String s = "BrowserExt: " + getId() + ", " + getName() + ", " + getOS() + 
      ", " + getExecutable() + ", " + getParameters() + ", ";
    String[] locations = getDefaultLocations();
    if (locations != null)
    {
      int size = locations.length;
      for (int i = 0; i < size; i++) {
        s = s + locations[i] + ";";
      }
    }
    return s;
  }
}

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorLauncher;
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;

public class BrowserLauncher
  implements IEditorLauncher
{
  public void open(IPath file)
  {
    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    try
    {
      if (WebBrowserPreference.getBrowserChoice() == 0) {
        support.createBrowser(6, file.toPortableString(), null, null).openURL(file.toFile().toURI().toURL());
      } else {
        support.createBrowser(6, "org.eclipse.ui.browser", null, null).openURL(file.toFile().toURI().toURL());
      }
    }
    catch (MalformedURLException localMalformedURLException) {}catch (PartInitException e)
    {
      MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), 
        Messages.errorDialogTitle, e.getLocalizedMessage());
    }
  }
}

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

import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;

class BrowserManager$1
  implements IEclipsePreferences.IPreferenceChangeListener
{
  final BrowserManager this$0;
  
  BrowserManager$1(BrowserManager paramBrowserManager)
  {
    this$0 = paramBrowserManager;
  }
  
  public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event)
  {
    String property = event.getKey();
    if ((!this$0.ignorePreferenceChanges) && (property.equals("browsers"))) {
      this$0.loadBrowsers();
    }
    if (!property.equals("internalWebBrowserHistory"))
    {
      BrowserManager.access$0(this$0);
      this$0.notifyObservers();
    }
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Observable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;

public class BrowserManager
  extends Observable
{
  protected List browsers;
  protected IBrowserDescriptor currentBrowser;
  private IEclipsePreferences.IPreferenceChangeListener pcl;
  protected boolean ignorePreferenceChanges = false;
  protected static BrowserManager instance;
  
  public static BrowserManager getInstance()
  {
    if (instance == null) {
      instance = new BrowserManager();
    }
    return instance;
  }
  
  private BrowserManager()
  {
    pcl = new IEclipsePreferences.IPreferenceChangeListener()
    {
      public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event)
      {
        String property = event.getKey();
        if ((!ignorePreferenceChanges) && (property.equals("browsers"))) {
          loadBrowsers();
        }
        if (!property.equals("internalWebBrowserHistory"))
        {
          setChanged();
          notifyObservers();
        }
      }
    };
    InstanceScope instanceScope = new InstanceScope();
    IEclipsePreferences prefs = instanceScope.getNode("org.eclipse.ui.browser");
    prefs.addPreferenceChangeListener(pcl);
  }
  
  protected static void safeDispose()
  {
    if (instance == null) {
      return;
    }
    instance.dispose();
  }
  
  protected void dispose()
  {
    InstanceScope instanceScope = new InstanceScope();
    IEclipsePreferences prefs = instanceScope.getNode("org.eclipse.ui.browser");
    prefs.removePreferenceChangeListener(pcl);
  }
  
  public IBrowserDescriptorWorkingCopy createExternalWebBrowser()
  {
    return new BrowserDescriptorWorkingCopy();
  }
  
  public List getWebBrowsers()
  {
    if (browsers == null) {
      loadBrowsers();
    }
    return new ArrayList(browsers);
  }
  
  public void loadBrowsers()
  {
    Trace.trace(Trace.FINEST, "Loading web browsers");
    
    String xmlString = Platform.getPreferencesService().getString(
      "org.eclipse.ui.browser", "browsers", null, null);
    if ((xmlString != null) && (xmlString.length() > 0))
    {
      browsers = new ArrayList();
      try
      {
        ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("utf-8"));
        Reader reader = new InputStreamReader(in, "utf-8");
        IMemento memento = XMLMemento.createReadRoot(reader);
        
        IMemento system = memento.getChild("system");
        if ((system != null) && (WebBrowserUtil.canUseSystemBrowser())) {
          browsers.add(new SystemBrowserDescriptor());
        }
        IMemento[] children = memento.getChildren("external");
        int size = children.length;
        for (int i = 0; i < size; i++)
        {
          BrowserDescriptor browser = new BrowserDescriptor();
          browser.load(children[i]);
          browsers.add(browser);
        }
        Integer current = memento.getInteger("current");
        if (current != null) {
          currentBrowser = ((IBrowserDescriptor)browsers.get(current.intValue()));
        }
      }
      catch (Exception e)
      {
        Trace.trace(Trace.WARNING, "Could not load browsers: " + e.getMessage());
      }
      IBrowserDescriptor system = new SystemBrowserDescriptor();
      if ((WebBrowserUtil.canUseSystemBrowser()) && (!browsers.contains(system)))
      {
        browsers.add(0, system);
        currentBrowser = system;
        saveBrowsers();
      }
    }
    else
    {
      setupDefaultBrowsers();
      saveBrowsers();
    }
    if ((currentBrowser == null) && (browsers.size() > 0)) {
      currentBrowser = ((IBrowserDescriptor)browsers.get(0));
    }
    setChanged();
    notifyObservers();
  }
  
  protected void saveBrowsers()
  {
    try
    {
      ignorePreferenceChanges = true;
      XMLMemento memento = XMLMemento.createWriteRoot("web-browsers");
      
      Iterator iterator = browsers.iterator();
      while (iterator.hasNext())
      {
        Object obj = iterator.next();
        if ((obj instanceof BrowserDescriptor))
        {
          BrowserDescriptor browser = (BrowserDescriptor)obj;
          IMemento child = memento.createChild("external");
          browser.save(child);
        }
        else if ((obj instanceof SystemBrowserDescriptor))
        {
          memento.createChild("system");
        }
      }
      memento.putInteger("current", browsers.indexOf(currentBrowser));
      
      StringWriter writer = new StringWriter();
      memento.save(writer);
      String xmlString = writer.getBuffer().toString();
      InstanceScope instanceScope = new InstanceScope();
      IEclipsePreferences prefs = instanceScope.getNode("org.eclipse.ui.browser");
      prefs.put("browsers", xmlString);
      prefs.flush();
    }
    catch (Exception e)
    {
      Trace.trace(Trace.SEVERE, "Could not save browsers", e);
    }
    ignorePreferenceChanges = false;
  }
  
  protected void setupDefaultBrowsers()
  {
    browsers = new ArrayList();
    if (WebBrowserUtil.canUseSystemBrowser())
    {
      IBrowserDescriptor system = new SystemBrowserDescriptor();
      browsers.add(system);
    }
    WebBrowserUtil.addFoundBrowsers(browsers);
    if ((!browsers.isEmpty()) && (currentBrowser == null)) {
      currentBrowser = ((IBrowserDescriptor)browsers.get(0));
    }
  }
  
  protected void addBrowser(IBrowserDescriptor browser)
  {
    if (browsers == null) {
      loadBrowsers();
    }
    if (!browsers.contains(browser)) {
      browsers.add(browser);
    }
    if (browsers.size() == 1) {
      setCurrentWebBrowser(browser);
    }
  }
  
  protected void removeWebBrowser(IBrowserDescriptor browser)
  {
    if (browsers == null) {
      loadBrowsers();
    }
    browsers.remove(browser);
    if ((currentBrowser == null) || (currentBrowser.equals(browser)))
    {
      currentBrowser = null;
      if (browsers.size() > 0) {
        currentBrowser = ((IBrowserDescriptor)browsers.get(0));
      }
    }
  }
  
  public IBrowserDescriptor getCurrentWebBrowser()
  {
    if (browsers == null) {
      loadBrowsers();
    }
    if ((currentBrowser == null) && (browsers.size() > 0)) {
      return (IBrowserDescriptor)browsers.get(0);
    }
    return currentBrowser;
  }
  
  public void setCurrentWebBrowser(IBrowserDescriptor wb)
  {
    if (wb == null) {
      throw new IllegalArgumentException();
    }
    if (browsers.contains(wb)) {
      currentBrowser = wb;
    } else {
      throw new IllegalArgumentException();
    }
    saveBrowsers();
  }
}

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

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Link;

class BrowserText$1
  extends SelectionAdapter
{
  final BrowserText this$0;
  
  BrowserText$1(BrowserText paramBrowserText)
  {
    this$0 = paramBrowserText;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    BusyIndicator.showWhile(this$0.link.getDisplay(), new BrowserText.2(this));
  }
}

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

class BrowserText$2
  implements Runnable
{
  final BrowserText.1 this$1;
  
  BrowserText$2(BrowserText.1 param1)
  {
    this$1 = param1;
  }
  
  public void run()
  {
    BrowserText.1.access$0(this$1).doOpenExternal();
  }
}

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

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

class BrowserText$3
  extends SelectionAdapter
{
  final BrowserText this$0;
  
  BrowserText$3(BrowserText paramBrowserText)
  {
    this$0 = paramBrowserText;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.toggleException();
  }
}

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

import org.eclipse.swt.widgets.Composite;

class BrowserText$ReflowScrolledComposite
  extends FallbackScrolledComposite
{
  final BrowserText this$0;
  
  public BrowserText$ReflowScrolledComposite(BrowserText paramBrowserText, Composite parent, int style)
  {
    super(parent, style);
    this$0 = paramBrowserText;
  }
  
  public void reflow(boolean flushCache)
  {
    this$0.updateWidth(this);
    super.reflow(flushCache);
  }
}

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

import java.io.PrintWriter;
import java.io.StringWriter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
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.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;

public class BrowserText
{
  private String url;
  private FallbackScrolledComposite scomp;
  private Label title;
  private Label exTitle;
  private Label text;
  private Label sep;
  protected Link link;
  private BrowserViewer viewer;
  private Button button;
  private Text exception;
  private boolean expanded;
  private Throwable ex;
  
  class ReflowScrolledComposite
    extends FallbackScrolledComposite
  {
    public ReflowScrolledComposite(Composite parent, int style)
    {
      super(style);
    }
    
    public void reflow(boolean flushCache)
    {
      updateWidth(this);
      super.reflow(flushCache);
    }
  }
  
  public BrowserText(Composite parent, BrowserViewer viewer, Throwable ex)
  {
    this.viewer = viewer;
    this.ex = ex;
    Color bg = parent.getDisplay()
      .getSystemColor(25);
    scomp = new ReflowScrolledComposite(parent, 768);
    Composite client = new Composite(scomp, 0);
    fillContent(client, bg);
    scomp.setContent(client);
    scomp.setBackground(bg);
  }
  
  private void fillContent(Composite parent, Color bg)
  {
    GridLayout layout = new GridLayout();
    verticalSpacing = 10;
    parent.setLayout(layout);
    title = new Label(parent, 64);
    title.setText(Messages.BrowserText_title);
    title.setFont(JFaceResources.getHeaderFont());
    title.setLayoutData(new GridData(768));
    title.setBackground(bg);
    
    link = new Link(parent, 64);
    link.setText(Messages.BrowserText_link);
    link.setLayoutData(new GridData(768));
    link.setToolTipText(Messages.BrowserText_tooltip);
    link.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        BusyIndicator.showWhile(link.getDisplay(), new BrowserText.2(this));
      }
    });
    link.setBackground(bg);
    sep = new Label(parent, 258);
    sep.setLayoutData(new GridData(768));
    exTitle = new Label(parent, 0);
    exTitle.setBackground(bg);
    exTitle.setFont(JFaceResources.getBannerFont());
    exTitle.setText(Messages.BrowserText_dtitle);
    exTitle.setLayoutData(new GridData(768));
    text = new Label(parent, 64);
    text.setText(Messages.BrowserText_text);
    text.setLayoutData(new GridData(768));
    text.setBackground(bg);
    button = new Button(parent, 8);
    updateButtonText();
    button.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        toggleException();
      }
    });
    exception = new Text(parent, 2);
    loadExceptionText();
    GridData gd = new GridData(1808);
    exclude = true;
    exception.setLayoutData(gd);
  }
  
  private void loadExceptionText()
  {
    StringWriter swriter = new StringWriter();
    PrintWriter writer = new PrintWriter(swriter);
    writer.println(ex.getMessage());
    ex.printStackTrace(writer);
    writer.close();
    exception.setText(swriter.toString());
  }
  
  protected void toggleException()
  {
    expanded = (!expanded);
    updateButtonText();
    GridData gd = (GridData)exception.getLayoutData();
    exclude = (!expanded);
    exception.setVisible(expanded);
    refresh();
  }
  
  private void updateButtonText()
  {
    if (expanded) {
      button.setText(Messages.BrowserText_button_collapse);
    } else {
      button.setText(Messages.BrowserText_button_expand);
    }
  }
  
  protected void updateWidth(Composite parent)
  {
    Rectangle area = parent.getClientArea();
    updateWidth(title, width);
    updateWidth(text, width);
    updateWidth(sep, width);
    updateWidth(link, width);
    updateWidth(exTitle, width);
    updateWidth(exception, width);
  }
  
  private void updateWidth(Control c, int width)
  {
    GridData gd = (GridData)c.getLayoutData();
    if (gd != null) {
      widthHint = (width - 10);
    }
  }
  
  protected void doOpenExternal()
  {
    IBrowserViewerContainer container = viewer.getContainer();
    if (container != null) {
      container.openInExternalBrowser(url);
    }
  }
  
  public Control getControl()
  {
    return scomp;
  }
  
  public boolean setUrl(String url)
  {
    this.url = url;
    return true;
  }
  
  public void setFocus()
  {
    link.setFocus();
  }
  
  public String getUrl()
  {
    return url;
  }
  
  public void refresh()
  {
    scomp.reflow(true);
  }
}

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

import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;

class BrowserViewer$1
  implements MouseListener
{
  final BrowserViewer this$0;
  
  BrowserViewer$1(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void mouseDoubleClick(MouseEvent e) {}
  
  public void mouseDown(MouseEvent e)
  {
    this$0.setURL("http://www.eclipse.org");
  }
  
  public void mouseUp(MouseEvent e) {}
}

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

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

class BrowserViewer$10
  implements Listener
{
  final BrowserViewer this$0;
  
  BrowserViewer$10(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void handleEvent(Event e)
  {
    this$0.setURL(this$0.combo.getText());
  }
}

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

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

class BrowserViewer$11
  extends SelectionAdapter
{
  final BrowserViewer this$0;
  
  BrowserViewer$11(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void widgetSelected(SelectionEvent event)
  {
    this$0.setURL(this$0.combo.getText());
  }
}

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

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

class BrowserViewer$12
  extends SelectionAdapter
{
  final BrowserViewer this$0;
  
  BrowserViewer$12(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void widgetSelected(SelectionEvent event)
  {
    this$0.back();
  }
}

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

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

class BrowserViewer$13
  extends SelectionAdapter
{
  final BrowserViewer this$0;
  
  BrowserViewer$13(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void widgetSelected(SelectionEvent event)
  {
    this$0.forward();
  }
}

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

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

class BrowserViewer$14
  extends SelectionAdapter
{
  final BrowserViewer this$0;
  
  BrowserViewer$14(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void widgetSelected(SelectionEvent event)
  {
    this$0.stop();
  }
}

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

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

class BrowserViewer$15
  extends SelectionAdapter
{
  final BrowserViewer this$0;
  
  BrowserViewer$15(BrowserViewer paramBrowserViewer)
  {
    this$0 = paramBrowserViewer;
  }
  
  public void widgetSelected(SelectionEvent event)
  {
    this$0.refresh();
  }
}

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

import java.io.File;
import org.eclipse.swt.widgets.Display;

class BrowserViewer$16
  extends Thread
{
  final BrowserViewer this$0;
  
  BrowserViewer$16(BrowserViewer paramBrowserViewer, String $anonymous0)
  {
    super($anonymous0);this$0 = paramBrowserViewer;
  }
  
  public void run()
  {
    while (this$0.fileListenerThread != null)
    {
      try
      {
        Thread.sleep(2000L);
      }
      catch (Exception localException) {}
      synchronized (this$0.syncObject)
      {
        if ((this$0.file != null) && (this$0.file.lastModified() != this$0.timestamp))
        {
          this$0.timestamp = this$0.file.lastModified();
          Display.getDefault().syncExec(new BrowserViewer.17(this));
        }
      }
    }
  }
}

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

class BrowserViewer$17
  implements Runnable
{
  final BrowserViewer.16 this$1;
  
  BrowserViewer$17(BrowserViewer.16 param16)
  {
    this$1 = param16;
  }
  
  public void run()
  {
    BrowserViewer.16.access$0(this$1).refresh();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.browse
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd