org.eclipse.e4.ui.css.swt.theme_0.9.4.v20130123-162658

16:42:59.074 INFO  jd.cli.Main - Decompiling org.eclipse.e4.ui.css.swt.theme_0.9.4.v20130123-162658.jar
package org.eclipse.e4.ui.css.swt.internal.theme;

import org.eclipse.e4.ui.css.swt.theme.ITheme;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;

public class BootstrapTheme3x
{
  public BootstrapTheme3x(Display display)
  {
    this(display, null);
  }
  
  public BootstrapTheme3x(Display display, String themeId)
  {
    Bundle bundle = FrameworkUtil.getBundle(BootstrapTheme3x.class);
    BundleContext context = bundle.getBundleContext();
    ServiceReference ref = context.getServiceReference(IThemeManager.class
      .getName());
    IThemeManager mgr = (IThemeManager)context.getService(ref);
    IThemeEngine engine = mgr.getEngineForDisplay(display);
    ITheme theme = engine.registerTheme("org.eclipse.e4.ui.workbench.swt.theme.default", "Default Theme", "platform:/plugin/org.eclipse.e4.ui.css.swt.theme/css/dummy.css");
    if (themeId == null) {
      engine.setTheme(theme, false);
    } else {
      engine.setTheme(themeId, false);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.internal.theme.BootstrapTheme3x
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.internal.theme;

import org.eclipse.e4.ui.css.swt.theme.ITheme;

public class Theme
  implements ITheme
{
  private String id;
  private String label;
  private String osVersion;
  
  public Theme(String id, String label)
  {
    this.id = id;
    this.label = label;
  }
  
  public String getId()
  {
    return id;
  }
  
  public String getLabel()
  {
    return label;
  }
  
  public void setOsVersion(String version)
  {
    osVersion = version;
  }
  
  public String getOsVersion()
  {
    return osVersion;
  }
  
  public String toString()
  {
    return 
      "Theme [id=" + id + ", label='" + label + "', osVersion=" + osVersion + "]";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.internal.theme.Theme
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.internal.theme;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.e4.ui.css.core.engine.CSSElementContext;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.core.util.impl.resources.FileResourcesLocatorImpl;
import org.eclipse.e4.ui.css.core.util.impl.resources.OSGiResourceLocator;
import org.eclipse.e4.ui.css.core.util.resources.IResourceLocator;
import org.eclipse.e4.ui.css.swt.theme.ITheme;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.widgets.Display;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.w3c.dom.Element;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.ViewCSS;

public class ThemeEngine
  implements IThemeEngine
{
  private List<Theme> themes = new ArrayList();
  private List<CSSEngine> cssEngines = new ArrayList();
  private Display display;
  private ITheme currentTheme;
  private List<String> globalStyles = new ArrayList();
  private List<IResourceLocator> globalSourceLocators = new ArrayList();
  private HashMap<String, List<String>> stylesheets = new HashMap();
  private HashMap<String, List<String>> modifiedStylesheets = new HashMap();
  private HashMap<String, List<IResourceLocator>> sourceLocators = new HashMap();
  private static final String THEMEID_KEY = "themeid";
  public static final String THEME_PLUGIN_ID = "org.eclipse.e4.ui.css.swt.theme";
  
  public ThemeEngine(Display display)
  {
    this.display = display;
    
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtensionPoint extPoint = registry
      .getExtensionPoint("org.eclipse.e4.ui.css.swt.theme");
    
    Location configLocation = Platform.getConfigurationLocation();
    String e4CSSPath = null;
    try
    {
      URL locationURL = new URL(configLocation.getDataArea("org.eclipse.e4.ui.css.swt.theme").toString());
      File locationFile = new File(locationURL.getFile());
      e4CSSPath = locationFile.getPath();
    }
    catch (IOException localIOException1) {}
    IPath path = new Path(e4CSSPath + System.getProperty("file.separator"));
    File modDir = new File(path.toFile().toURI());
    if (!modDir.exists()) {
      modDir.mkdirs();
    }
    File oldModDir = new File(
      System.getProperty("user.home") + System.getProperty("file.separator") + ".e4css" + System.getProperty("file.separator"));
    if (oldModDir.exists())
    {
      File done = new File(oldModDir, ".processed");
      if (!done.exists()) {
        try
        {
          done.createNewFile();
          File[] oldModifiedFiles = oldModDir.listFiles();
          for (i = 0; i < oldModifiedFiles.length; i++) {
            if (oldModifiedFiles[i].getName().contains(".css")) {
              copyFile(oldModifiedFiles[i].getPath(), path + 
                System.getProperty("file.separator") + 
                oldModifiedFiles[i].getName());
            }
          }
        }
        catch (IOException localIOException2) {}
      }
    }
    File[] modifiedFiles = modDir.listFiles();
    IExtension[] arrayOfIExtension;
    int i = (arrayOfIExtension = extPoint.getExtensions()).length;
    IConfigurationElement[] arrayOfIConfigurationElement1;
    int k;
    int j;
    String basestylesheeturi;
    String themeId;
    int slash;
    for (int i = 0; i < i; i++)
    {
      IExtension e = arrayOfIExtension[i];
      k = (arrayOfIConfigurationElement1 = getPlatformMatches(e
        .getConfigurationElements())).length;
      for (j = 0; j < k; j++)
      {
        IConfigurationElement ce = arrayOfIConfigurationElement1[j];
        if (ce.getName().equals("theme")) {
          try
          {
            String version = ce.getAttribute("os_version");
            if (version == null) {
              version = "";
            }
            String originalCSSFile;
            basestylesheeturi = originalCSSFile = ce
              .getAttribute("basestylesheeturi");
            if (!basestylesheeturi.startsWith("platform:/plugin/")) {
              basestylesheeturi = 
              
                "platform:/plugin/" + ce.getContributor().getName() + "/" + basestylesheeturi;
            }
            themeId = ce.getAttribute("id") + version;
            registerTheme(
              themeId, 
              ce.getAttribute("label"), basestylesheeturi, 
              version);
            if (modifiedFiles != null)
            {
              slash = originalCSSFile.lastIndexOf("/");
              if (slash != -1)
              {
                originalCSSFile = originalCSSFile.substring(slash + 1);
                for (int i = 0; i < modifiedFiles.length; i++)
                {
                  String modifiedFileName = modifiedFiles[i].getName();
                  if ((modifiedFileName.contains(".css")) && (modifiedFileName.equals(originalCSSFile)))
                  {
                    ArrayList<String> styleSheets = new ArrayList();
                    styleSheets.add(modifiedFiles[i].toURI().toString());
                    modifiedStylesheets.put(themeId, styleSheets);
                  }
                }
              }
            }
          }
          catch (IllegalArgumentException e1)
          {
            e1.printStackTrace();
          }
        }
      }
    }
    i = (arrayOfIExtension = extPoint.getExtensions()).length;
    for (i = 0; i < i; i++)
    {
      IExtension e = arrayOfIExtension[i];
      k = (arrayOfIConfigurationElement1 = getPlatformMatches(e.getConfigurationElements())).length;
      for (j = 0; j < k; j++)
      {
        IConfigurationElement ce = arrayOfIConfigurationElement1[j];
        if (ce.getName().equals("stylesheet"))
        {
          IConfigurationElement[] cces = ce.getChildren("themeid");
          String uri;
          if (cces.length == 0)
          {
            registerStylesheet("platform:/plugin/" + 
              ce.getContributor().getName() + "/" + 
              ce.getAttribute("uri"), new String[0]);
            
            themeId = (slash = ce.getChildren("osgiresourcelocator")).length;
            for (basestylesheeturi = 0; basestylesheeturi < themeId; basestylesheeturi++)
            {
              IConfigurationElement resourceEl = slash[basestylesheeturi];
              uri = resourceEl.getAttribute("uri");
              if (uri != null) {
                registerResourceLocator(new OSGiResourceLocator(
                  uri), new String[0]);
              }
            }
          }
          else
          {
            String[] themes = new String[cces.length];
            for (int i = 0; i < cces.length; i++) {
              themes[i] = cces[i].getAttribute("refid");
            }
            registerStylesheet(
              "platform:/plugin/" + 
              ce.getContributor().getName() + "/" + 
              ce.getAttribute("uri"), themes);
            
            slash = (uri = ce.getChildren("osgiresourcelocator")).length;
            for (themeId = 0; themeId < slash; themeId++)
            {
              IConfigurationElement resourceEl = uri[themeId];
              String uri = resourceEl.getAttribute("uri");
              if (uri != null) {
                registerResourceLocator(new OSGiResourceLocator(
                  uri), new String[0]);
              }
            }
          }
        }
      }
    }
    registerResourceLocator(new OSGiResourceLocator("platform:/plugin/org.eclipse.platform/css/"), new String[0]);
    registerResourceLocator(new FileResourcesLocatorImpl(), new String[0]);
  }
  
  public synchronized ITheme registerTheme(String id, String label, String basestylesheetURI)
    throws IllegalArgumentException
  {
    return registerTheme(id, label, basestylesheetURI, "");
  }
  
  public synchronized ITheme registerTheme(String id, String label, String basestylesheetURI, String osVersion)
    throws IllegalArgumentException
  {
    for (Theme t : themes) {
      if (t.getId().equals(id)) {
        throw new IllegalArgumentException("A theme with the id '" + id + 
          "' is already registered");
      }
    }
    Theme theme = new Theme(id, label);
    if (osVersion != "") {
      theme.setOsVersion(osVersion);
    }
    themes.add(theme);
    registerStyle(id, basestylesheetURI);
    return theme;
  }
  
  public synchronized void registerStylesheet(String uri, String... themes)
  {
    Bundle bundle = FrameworkUtil.getBundle(ThemeEngine.class);
    String osname = bundle.getBundleContext().getProperty("osgi.os");
    String wsname = bundle.getBundleContext().getProperty("ogsi.ws");
    
    uri = uri.replaceAll("\\$os\\$", osname).replaceAll("\\$ws\\$", wsname);
    if (themes.length == 0)
    {
      globalStyles.add(uri);
    }
    else
    {
      String[] arrayOfString;
      int j = (arrayOfString = themes).length;
      for (int i = 0; i < j; i++)
      {
        String t = arrayOfString[i];
        registerStyle(t, uri);
      }
    }
  }
  
  public synchronized void registerResourceLocator(IResourceLocator locator, String... themes)
  {
    if (themes.length == 0)
    {
      globalSourceLocators.add(locator);
    }
    else
    {
      String[] arrayOfString;
      int j = (arrayOfString = themes).length;
      for (int i = 0; i < j; i++)
      {
        String t = arrayOfString[i];
        List<IResourceLocator> list = (List)sourceLocators.get(t);
        if (list == null)
        {
          list = new ArrayList();
          sourceLocators.put(t, list);
        }
        list.add(locator);
      }
    }
  }
  
  private void registerStyle(String id, String stylesheet)
  {
    List<String> s = (List)stylesheets.get(id);
    if (s == null)
    {
      s = new ArrayList();
      stylesheets.put(id, s);
    }
    s.add(stylesheet);
  }
  
  private List<String> getAllStyles(String id)
  {
    List<String> m = (List)modifiedStylesheets.get(id);
    if (m != null)
    {
      m = new ArrayList(m);
      m.addAll(globalStyles);
      return m;
    }
    List<String> s = (List)stylesheets.get(id);
    if (s == null) {
      s = Collections.emptyList();
    }
    s = new ArrayList(s);
    s.addAll(globalStyles);
    return s;
  }
  
  private List<IResourceLocator> getResourceLocators(String id)
  {
    List<IResourceLocator> list = new ArrayList(
      globalSourceLocators);
    List<IResourceLocator> s = (List)sourceLocators.get(id);
    if (s != null) {
      list.addAll(s);
    }
    return list;
  }
  
  private IConfigurationElement[] getPlatformMatches(IConfigurationElement[] elements)
  {
    Bundle bundle = FrameworkUtil.getBundle(ThemeEngine.class);
    String osname = bundle.getBundleContext().getProperty("osgi.os");
    
    String os_version = System.getProperty("os.version");
    String wsname = bundle.getBundleContext().getProperty("ogsi.ws");
    ArrayList<IConfigurationElement> matchingElements = new ArrayList();
    for (int i = 0; i < elements.length; i++)
    {
      IConfigurationElement element = elements[i];
      String elementOs = element.getAttribute("os");
      String elementWs = element.getAttribute("ws");
      String elementOsVersion = element.getAttribute("os_version");
      if ((osname != null) && (
        (elementOs == null) || (elementOs.contains(osname))))
      {
        if ((os_version != null) && (os_version.equalsIgnoreCase(elementOsVersion))) {
          matchingElements.add(element);
        } else {
          matchingElements.add(element);
        }
      }
      else if ((wsname != null) && (wsname.equalsIgnoreCase(elementWs))) {
        matchingElements.add(element);
      }
    }
    return 
      (IConfigurationElement[])matchingElements.toArray(new IConfigurationElement[matchingElements.size()]);
  }
  
  public void setTheme(String themeId, boolean restore)
  {
    String osVersion = System.getProperty("os.version");
    Theme t;
    if (osVersion != null)
    {
      boolean found = false;
      for (Iterator localIterator = themes.iterator(); localIterator.hasNext();)
      {
        t = (Theme)localIterator.next();
        String version = t.getOsVersion();
        if ((version != null) && (osVersion.contains(version)))
        {
          String themeVersion = themeId + version;
          if (t.getId().equals(themeVersion))
          {
            setTheme(t, restore);
            found = true;
            break;
          }
        }
      }
      if (found) {
        return;
      }
    }
    for (Theme t : themes) {
      if (t.getId().equals(themeId))
      {
        setTheme(t, restore);
        break;
      }
    }
  }
  
  public void setTheme(ITheme theme, boolean restore)
  {
    setTheme(theme, restore, false);
  }
  
  /* Error */
  public void setTheme(ITheme theme, boolean restore, boolean force)
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc_w 294
    //   4: invokestatic 672	org/eclipse/core/runtime/Assert:isNotNull	(Ljava/lang/Object;Ljava/lang/String;)V
    //   7: aload_0
    //   8: getfield 614	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:currentTheme	Lorg/eclipse/e4/ui/css/swt/theme/ITheme;
    //   11: aload_1
    //   12: if_acmpne +7 -> 19
    //   15: iload_3
    //   16: ifeq +527 -> 543
    //   19: aload_0
    //   20: getfield 614	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:currentTheme	Lorg/eclipse/e4/ui/css/swt/theme/ITheme;
    //   23: ifnull +98 -> 121
    //   26: aload_0
    //   27: aload_0
    //   28: getfield 614	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:currentTheme	Lorg/eclipse/e4/ui/css/swt/theme/ITheme;
    //   31: invokeinterface 738 1 0
    //   36: invokespecial 699	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:getResourceLocators	(Ljava/lang/String;)Ljava/util/List;
    //   39: invokeinterface 713 1 0
    //   44: astore 5
    //   46: goto +65 -> 111
    //   49: aload 5
    //   51: invokeinterface 709 1 0
    //   56: checkcast 350	org/eclipse/e4/ui/css/core/util/resources/IResourceLocator
    //   59: astore 4
    //   61: aload_0
    //   62: getfield 610	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:cssEngines	Ljava/util/List;
    //   65: invokeinterface 713 1 0
    //   70: astore 7
    //   72: goto +29 -> 101
    //   75: aload 7
    //   77: invokeinterface 709 1 0
    //   82: checkcast 347	org/eclipse/e4/ui/css/core/engine/CSSEngine
    //   85: astore 6
    //   87: aload 6
    //   89: invokeinterface 731 1 0
    //   94: aload 4
    //   96: invokeinterface 737 2 0
    //   101: aload 7
    //   103: invokeinterface 708 1 0
    //   108: ifne -33 -> 75
    //   111: aload 5
    //   113: invokeinterface 708 1 0
    //   118: ifne -69 -> 49
    //   121: aload_0
    //   122: aload_1
    //   123: putfield 614	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:currentTheme	Lorg/eclipse/e4/ui/css/swt/theme/ITheme;
    //   126: aload_0
    //   127: getfield 610	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:cssEngines	Ljava/util/List;
    //   130: invokeinterface 713 1 0
    //   135: astore 5
    //   137: goto +22 -> 159
    //   140: aload 5
    //   142: invokeinterface 709 1 0
    //   147: checkcast 347	org/eclipse/e4/ui/css/core/engine/CSSEngine
    //   150: astore 4
    //   152: aload 4
    //   154: invokeinterface 729 1 0
    //   159: aload 5
    //   161: invokeinterface 708 1 0
    //   166: ifne -26 -> 140
    //   169: aload_0
    //   170: aload_1
    //   171: invokeinterface 738 1 0
    //   176: invokespecial 699	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:getResourceLocators	(Ljava/lang/String;)Ljava/util/List;
    //   179: invokeinterface 713 1 0
    //   184: astore 5
    //   186: goto +65 -> 251
    //   189: aload 5
    //   191: invokeinterface 709 1 0
    //   196: checkcast 350	org/eclipse/e4/ui/css/core/util/resources/IResourceLocator
    //   199: astore 4
    //   201: aload_0
    //   202: getfield 610	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:cssEngines	Ljava/util/List;
    //   205: invokeinterface 713 1 0
    //   210: astore 7
    //   212: goto +29 -> 241
    //   215: aload 7
    //   217: invokeinterface 709 1 0
    //   222: checkcast 347	org/eclipse/e4/ui/css/core/engine/CSSEngine
    //   225: astore 6
    //   227: aload 6
    //   229: invokeinterface 731 1 0
    //   234: aload 4
    //   236: invokeinterface 736 2 0
    //   241: aload 7
    //   243: invokeinterface 708 1 0
    //   248: ifne -33 -> 215
    //   251: aload 5
    //   253: invokeinterface 708 1 0
    //   258: ifne -69 -> 189
    //   261: aload_0
    //   262: aload_1
    //   263: invokeinterface 738 1 0
    //   268: invokespecial 698	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:getAllStyles	(Ljava/lang/String;)Ljava/util/List;
    //   271: invokeinterface 713 1 0
    //   276: astore 5
    //   278: goto +212 -> 490
    //   281: aload 5
    //   283: invokeinterface 709 1 0
    //   288: checkcast 321	java/lang/String
    //   291: astore 4
    //   293: aconst_null
    //   294: astore 7
    //   296: new 326	java/net/URL
    //   299: dup
    //   300: aload 4
    //   302: invokevirtual 642	java/lang/String:toString	()Ljava/lang/String;
    //   305: invokespecial 660	java/net/URL:<init>	(Ljava/lang/String;)V
    //   308: invokestatic 673	org/eclipse/core/runtime/FileLocator:resolve	(Ljava/net/URL;)Ljava/net/URL;
    //   311: astore 6
    //   313: aload_0
    //   314: getfield 610	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:cssEngines	Ljava/util/List;
    //   317: invokeinterface 713 1 0
    //   322: astore 9
    //   324: goto +136 -> 460
    //   327: aload 9
    //   329: invokeinterface 709 1 0
    //   334: checkcast 347	org/eclipse/e4/ui/css/core/engine/CSSEngine
    //   337: astore 8
    //   339: aload 6
    //   341: invokevirtual 657	java/net/URL:openStream	()Ljava/io/InputStream;
    //   344: astore 7
    //   346: new 362	org/w3c/css/sac/InputSource
    //   349: dup
    //   350: invokespecial 705	org/w3c/css/sac/InputSource:<init>	()V
    //   353: astore 10
    //   355: aload 10
    //   357: aload 7
    //   359: invokevirtual 706	org/w3c/css/sac/InputSource:setByteStream	(Ljava/io/InputStream;)V
    //   362: aload 10
    //   364: aload 6
    //   366: invokevirtual 659	java/net/URL:toString	()Ljava/lang/String;
    //   369: invokevirtual 707	org/w3c/css/sac/InputSource:setURI	(Ljava/lang/String;)V
    //   372: aload 8
    //   374: aload 10
    //   376: invokeinterface 735 2 0
    //   381: pop
    //   382: goto +58 -> 440
    //   385: astore 10
    //   387: aload 10
    //   389: invokevirtual 633	java/io/IOException:printStackTrace	()V
    //   392: aload 7
    //   394: ifnull +66 -> 460
    //   397: aload 7
    //   399: invokevirtual 634	java/io/InputStream:close	()V
    //   402: goto +58 -> 460
    //   405: astore 12
    //   407: aload 12
    //   409: invokevirtual 633	java/io/IOException:printStackTrace	()V
    //   412: goto +48 -> 460
    //   415: astore 11
    //   417: aload 7
    //   419: ifnull +18 -> 437
    //   422: aload 7
    //   424: invokevirtual 634	java/io/InputStream:close	()V
    //   427: goto +10 -> 437
    //   430: astore 12
    //   432: aload 12
    //   434: invokevirtual 633	java/io/IOException:printStackTrace	()V
    //   437: aload 11
    //   439: athrow
    //   440: aload 7
    //   442: ifnull +18 -> 460
    //   445: aload 7
    //   447: invokevirtual 634	java/io/InputStream:close	()V
    //   450: goto +10 -> 460
    //   453: astore 12
    //   455: aload 12
    //   457: invokevirtual 633	java/io/IOException:printStackTrace	()V
    //   460: aload 9
    //   462: invokeinterface 708 1 0
    //   467: ifne -140 -> 327
    //   470: goto +20 -> 490
    //   473: astore 8
    //   475: aload 8
    //   477: invokevirtual 655	java/net/MalformedURLException:printStackTrace	()V
    //   480: goto +10 -> 490
    //   483: astore 8
    //   485: aload 8
    //   487: invokevirtual 633	java/io/IOException:printStackTrace	()V
    //   490: aload 5
    //   492: invokeinterface 708 1 0
    //   497: ifne -216 -> 281
    //   500: aload_0
    //   501: getfield 610	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:cssEngines	Ljava/util/List;
    //   504: invokeinterface 713 1 0
    //   509: astore 5
    //   511: goto +22 -> 533
    //   514: aload 5
    //   516: invokeinterface 709 1 0
    //   521: checkcast 347	org/eclipse/e4/ui/css/core/engine/CSSEngine
    //   524: astore 4
    //   526: aload 4
    //   528: invokeinterface 728 1 0
    //   533: aload 5
    //   535: invokeinterface 708 1 0
    //   540: ifne -26 -> 514
    //   543: iload_2
    //   544: ifeq +41 -> 585
    //   547: aload_0
    //   548: invokespecial 690	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:getPreferences	()Lorg/eclipse/core/runtime/preferences/IEclipsePreferences;
    //   551: astore 4
    //   553: aload 4
    //   555: ldc 14
    //   557: aload_1
    //   558: invokeinterface 738 1 0
    //   563: invokeinterface 725 3 0
    //   568: aload 4
    //   570: invokeinterface 724 1 0
    //   575: goto +10 -> 585
    //   578: astore 5
    //   580: aload 5
    //   582: invokevirtual 704	org/osgi/service/prefs/BackingStoreException:printStackTrace	()V
    //   585: aload_0
    //   586: iload_2
    //   587: invokespecial 686	org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine:sendThemeChangeEvent	(Z)V
    //   590: return
    // Line number table:
    //   Java source line #380	-> byte code offset #0
    //   Java source line #382	-> byte code offset #7
    //   Java source line #383	-> byte code offset #19
    //   Java source line #384	-> byte code offset #26
    //   Java source line #385	-> byte code offset #31
    //   Java source line #384	-> byte code offset #36
    //   Java source line #386	-> byte code offset #61
    //   Java source line #387	-> byte code offset #87
    //   Java source line #388	-> byte code offset #94
    //   Java source line #386	-> byte code offset #101
    //   Java source line #384	-> byte code offset #111
    //   Java source line #393	-> byte code offset #121
    //   Java source line #394	-> byte code offset #126
    //   Java source line #395	-> byte code offset #152
    //   Java source line #394	-> byte code offset #159
    //   Java source line #398	-> byte code offset #169
    //   Java source line #399	-> byte code offset #201
    //   Java source line #400	-> byte code offset #227
    //   Java source line #401	-> byte code offset #234
    //   Java source line #399	-> byte code offset #241
    //   Java source line #398	-> byte code offset #251
    //   Java source line #404	-> byte code offset #261
    //   Java source line #406	-> byte code offset #293
    //   Java source line #408	-> byte code offset #296
    //   Java source line #409	-> byte code offset #313
    //   Java source line #411	-> byte code offset #339
    //   Java source line #412	-> byte code offset #346
    //   Java source line #413	-> byte code offset #355
    //   Java source line #414	-> byte code offset #362
    //   Java source line #415	-> byte code offset #372
    //   Java source line #416	-> byte code offset #382
    //   Java source line #418	-> byte code offset #387
    //   Java source line #420	-> byte code offset #392
    //   Java source line #422	-> byte code offset #397
    //   Java source line #423	-> byte code offset #402
    //   Java source line #425	-> byte code offset #407
    //   Java source line #419	-> byte code offset #415
    //   Java source line #420	-> byte code offset #417
    //   Java source line #422	-> byte code offset #422
    //   Java source line #423	-> byte code offset #427
    //   Java source line #425	-> byte code offset #432
    //   Java source line #428	-> byte code offset #437
    //   Java source line #420	-> byte code offset #440
    //   Java source line #422	-> byte code offset #445
    //   Java source line #423	-> byte code offset #450
    //   Java source line #425	-> byte code offset #455
    //   Java source line #409	-> byte code offset #460
    //   Java source line #430	-> byte code offset #470
    //   Java source line #432	-> byte code offset #475
    //   Java source line #433	-> byte code offset #483
    //   Java source line #435	-> byte code offset #485
    //   Java source line #404	-> byte code offset #490
    //   Java source line #439	-> byte code offset #500
    //   Java source line #440	-> byte code offset #526
    //   Java source line #439	-> byte code offset #533
    //   Java source line #444	-> byte code offset #543
    //   Java source line #445	-> byte code offset #547
    //   Java source line #446	-> byte code offset #553
    //   Java source line #448	-> byte code offset #568
    //   Java source line #449	-> byte code offset #575
    //   Java source line #451	-> byte code offset #580
    //   Java source line #454	-> byte code offset #585
    //   Java source line #455	-> byte code offset #590
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	591	0	this	ThemeEngine
    //   0	591	1	theme	ITheme
    //   0	591	2	restore	boolean
    //   0	591	3	force	boolean
    //   59	36	4	l	IResourceLocator
    //   150	3	4	engine	CSSEngine
    //   199	36	4	l	IResourceLocator
    //   291	10	4	stylesheet	String
    //   524	3	4	engine	CSSEngine
    //   551	18	4	pref	IEclipsePreferences
    //   44	490	5	localIterator1	Iterator
    //   578	3	5	e	org.osgi.service.prefs.BackingStoreException
    //   85	3	6	engine	CSSEngine
    //   225	3	6	engine	CSSEngine
    //   311	54	6	url	URL
    //   70	172	7	localIterator2	Iterator
    //   294	152	7	stream	java.io.InputStream
    //   337	36	8	engine	CSSEngine
    //   473	3	8	e	java.net.MalformedURLException
    //   483	3	8	e	IOException
    //   322	139	9	localIterator3	Iterator
    //   353	22	10	source	org.w3c.css.sac.InputSource
    //   385	3	10	e	IOException
    //   415	23	11	localObject	Object
    //   405	3	12	e	IOException
    //   430	3	12	e	IOException
    //   453	3	12	e	IOException
    // Exception table:
    //   from	to	target	type
    //   339	382	385	java/io/IOException
    //   397	402	405	java/io/IOException
    //   339	392	415	finally
    //   422	427	430	java/io/IOException
    //   445	450	453	java/io/IOException
    //   296	470	473	java/net/MalformedURLException
    //   296	470	483	java/io/IOException
    //   568	575	578	org/osgi/service/prefs/BackingStoreException
  }
  
  private void sendThemeChangeEvent(boolean restore)
  {
    EventAdmin eventAdmin = getEventAdmin();
    if (eventAdmin == null) {
      return;
    }
    Map<String, Object> data = new HashMap();
    data.put("themeEngine", this);
    data.put("theme", currentTheme);
    data.put("device", display);
    data.put("restore", Boolean.valueOf(restore));
    Event event = new Event("org/eclipse/e4/ui/css/swt/theme/ThemeManager/themeChanged", data);
    eventAdmin.sendEvent(event);
  }
  
  public List<IResourceLocator> getCurrentResourceLocators()
  {
    if (currentTheme == null) {
      return Collections.emptyList();
    }
    return getResourceLocators(currentTheme.getId());
  }
  
  private EventAdmin getEventAdmin()
  {
    Bundle bundle = FrameworkUtil.getBundle(getClass());
    if (bundle == null) {
      return null;
    }
    BundleContext context = bundle.getBundleContext();
    ServiceReference<EventAdmin> eventAdminRef = context
      .getServiceReference(EventAdmin.class);
    return (EventAdmin)context.getService(eventAdminRef);
  }
  
  public synchronized List<ITheme> getThemes()
  {
    return Collections.unmodifiableList(new ArrayList(themes));
  }
  
  public void applyStyles(Object widget, boolean applyStylesToChildNodes)
  {
    for (CSSEngine engine : cssEngines)
    {
      Object element = engine.getElement(widget);
      if (element != null) {
        engine.applyStyles(element, applyStylesToChildNodes);
      }
    }
  }
  
  private String getPreferenceThemeId()
  {
    return getPreferences().get("themeid", null);
  }
  
  private IEclipsePreferences getPreferences()
  {
    return new InstanceScope().getNode(FrameworkUtil.getBundle(
      ThemeEngine.class).getSymbolicName());
  }
  
  /* Error */
  void copyFile(String from, String to)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aconst_null
    //   3: astore 4
    //   5: new 314	java/io/FileInputStream
    //   8: dup
    //   9: aload_1
    //   10: invokespecial 631	java/io/FileInputStream:<init>	(Ljava/lang/String;)V
    //   13: astore_3
    //   14: new 312	java/io/BufferedOutputStream
    //   17: dup
    //   18: new 315	java/io/FileOutputStream
    //   21: dup
    //   22: aload_2
    //   23: invokespecial 632	java/io/FileOutputStream:<init>	(Ljava/lang/String;)V
    //   26: invokespecial 618	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   29: astore 4
    //   31: sipush 4096
    //   34: newarray <illegal type>
    //   36: astore 5
    //   38: goto +13 -> 51
    //   41: aload 4
    //   43: aload 5
    //   45: iconst_0
    //   46: iload 6
    //   48: invokevirtual 617	java/io/BufferedOutputStream:write	([BII)V
    //   51: aload_3
    //   52: aload 5
    //   54: invokevirtual 630	java/io/FileInputStream:read	([B)I
    //   57: dup
    //   58: istore 6
    //   60: iconst_m1
    //   61: if_icmpne -20 -> 41
    //   64: goto +26 -> 90
    //   67: astore 7
    //   69: aload_3
    //   70: ifnull +7 -> 77
    //   73: aload_3
    //   74: invokevirtual 629	java/io/FileInputStream:close	()V
    //   77: aload 4
    //   79: ifnull +8 -> 87
    //   82: aload 4
    //   84: invokevirtual 616	java/io/BufferedOutputStream:close	()V
    //   87: aload 7
    //   89: athrow
    //   90: aload_3
    //   91: ifnull +7 -> 98
    //   94: aload_3
    //   95: invokevirtual 629	java/io/FileInputStream:close	()V
    //   98: aload 4
    //   100: ifnull +8 -> 108
    //   103: aload 4
    //   105: invokevirtual 616	java/io/BufferedOutputStream:close	()V
    //   108: return
    // Line number table:
    //   Java source line #513	-> byte code offset #0
    //   Java source line #514	-> byte code offset #2
    //   Java source line #516	-> byte code offset #5
    //   Java source line #517	-> byte code offset #14
    //   Java source line #518	-> byte code offset #31
    //   Java source line #520	-> byte code offset #38
    //   Java source line #521	-> byte code offset #41
    //   Java source line #520	-> byte code offset #51
    //   Java source line #524	-> byte code offset #64
    //   Java source line #525	-> byte code offset #69
    //   Java source line #526	-> byte code offset #73
    //   Java source line #527	-> byte code offset #77
    //   Java source line #528	-> byte code offset #82
    //   Java source line #529	-> byte code offset #87
    //   Java source line #525	-> byte code offset #90
    //   Java source line #526	-> byte code offset #94
    //   Java source line #527	-> byte code offset #98
    //   Java source line #528	-> byte code offset #103
    //   Java source line #530	-> byte code offset #108
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	109	0	this	ThemeEngine
    //   0	109	1	from	String
    //   0	109	2	to	String
    //   1	94	3	fStream	java.io.FileInputStream
    //   3	101	4	outputStream	java.io.BufferedOutputStream
    //   36	17	5	buffer	byte[]
    //   41	6	6	c	int
    //   58	3	6	c	int
    //   67	21	7	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   5	67	67	finally
  }
  
  public void restore(String alternateTheme)
  {
    String prefThemeId = getPreferenceThemeId();
    boolean flag = true;
    if (prefThemeId != null) {
      for (ITheme t : getThemes()) {
        if (prefThemeId.equals(t.getId()))
        {
          setTheme(t, false);
          flag = false;
          break;
        }
      }
    }
    if ((alternateTheme != null) && (flag)) {
      setTheme(alternateTheme, false);
    }
  }
  
  public ITheme getActiveTheme()
  {
    return currentTheme;
  }
  
  public CSSStyleDeclaration getStyle(Object widget)
  {
    for (CSSEngine engine : cssEngines)
    {
      CSSElementContext context = engine.getCSSElementContext(widget);
      if (context != null)
      {
        Element e = context.getElement();
        if (e != null) {
          return engine.getViewCSS().getComputedStyle(e, null);
        }
      }
    }
    return null;
  }
  
  public List<String> getStylesheets(ITheme selection)
  {
    List<String> ss = (List)stylesheets.get(selection.getId());
    return ss == null ? new ArrayList() : ss;
  }
  
  public void themeModified(ITheme theme, List<String> paths)
  {
    modifiedStylesheets.put(theme.getId(), paths);
    setTheme(theme, false, true);
  }
  
  public void resetCurrentTheme()
  {
    if (currentTheme != null) {
      setTheme(currentTheme, false, true);
    }
  }
  
  public List<String> getModifiedStylesheets(ITheme selection)
  {
    List<String> ss = (List)modifiedStylesheets.get(selection.getId());
    return ss == null ? new ArrayList() : ss;
  }
  
  public void resetModifiedStylesheets(ITheme selection)
  {
    ((List)modifiedStylesheets.remove(selection.getId()));
  }
  
  public void addCSSEngine(CSSEngine cssEngine)
  {
    cssEngines.add(cssEngine);
    resetCurrentTheme();
  }
  
  public void removeCSSEngine(CSSEngine cssEngine)
  {
    cssEngines.remove(cssEngine);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.internal.theme;

import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;

class ThemeEngineManager$1
  implements CSSErrorHandler
{
  ThemeEngineManager$1(ThemeEngineManager paramThemeEngineManager) {}
  
  public void error(Exception e)
  {
    e.printStackTrace();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.internal.theme;

import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
import org.eclipse.swt.widgets.Display;

public class ThemeEngineManager
  implements IThemeManager
{
  private static final String KEY = "org.eclipse.e4.ui.css.swt.theme";
  
  public IThemeEngine getEngineForDisplay(Display display)
  {
    IThemeEngine engine = (IThemeEngine)display.getData("org.eclipse.e4.ui.css.swt.theme");
    if (engine == null)
    {
      engine = new ThemeEngine(display);
      engine.addCSSEngine(getCSSSWTEngine(display));
      display.setData("org.eclipse.e4.ui.css.swt.theme", engine);
    }
    return engine;
  }
  
  private CSSEngine getCSSSWTEngine(Display display)
  {
    CSSEngine cssEngine = WidgetElement.getEngine(display);
    if (cssEngine != null) {
      return cssEngine;
    }
    cssEngine = new CSSSWTEngineImpl(display, true);
    cssEngine.setErrorHandler(new CSSErrorHandler()
    {
      public void error(Exception e)
      {
        e.printStackTrace();
      }
    });
    WidgetElement.setEngine(display, cssEngine);
    return cssEngine;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.theme;

public abstract interface ITheme
{
  public abstract String getId();
  
  public abstract String getLabel();
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.theme.ITheme
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.theme;

public abstract interface IThemeEngine$Events
{
  public static final String TOPIC = "org/eclipse/e4/ui/css/swt/theme/ThemeManager";
  public static final String THEME_CHANGED = "org/eclipse/e4/ui/css/swt/theme/ThemeManager/themeChanged";
  public static final String THEME = "theme";
  public static final String DEVICE = "device";
  public static final String THEME_ENGINE = "themeEngine";
  public static final String RESTORE = "restore";
}

/* Location:
 * Qualified Name:     org.eclipse.e4.ui.css.swt.theme.IThemeEngine.Events
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.e4.ui.css.swt.theme;

import java.util.List;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
i
1 2

Further reading...

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

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd