org.eclipse.ui.intro_3.4.100.v20110425

16:48:18.997 INFO  jd.cli.Main - Decompiling org.eclipse.ui.intro_3.4.100.v20110425.jar
package org.eclipse.ui.internal.intro.impl;

import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.osgi.service.prefs.BackingStoreException;

public class FontSelection
{
  public static final String VAR_FONT_STYLE = "fontStyle";
  public static final String FONT_ABSOLUTE = "absolute";
  public static final String FONT_RELATIVE = "relative";
  private static final String SCALE_FACTOR = "scaleFactor";
  public static final String ATT_SCALABLE = "scalable";
  private static final int MIN_HEIGHT = 10;
  private static final int MAX_HEIGHT = 16;
  
  private static int getDefaultFontHeight()
  {
    Font defaultFont = JFaceResources.getDefaultFont();
    FontData[] fontData = defaultFont.getFontData();
    int height = 10;
    for (int i = 0; i < fontData.length; i++)
    {
      FontData data = fontData[i];
      height = Math.max(height, data.getHeight());
    }
    return Math.min(height, 16);
  }
  
  public static String generatePageFontStyle()
  {
    int defaultFontHeight = getDefaultFontHeight();
    int scale = getScalePercentage();
    String result = getFontSizeDeclaration("", defaultFontHeight, 100, scale);
    result = result + getFontSizeDeclaration("h1", defaultFontHeight, 200, scale);
    result = result + getFontSizeDeclaration("h2", defaultFontHeight, 150, scale);
    result = result + getFontSizeDeclaration("h3", defaultFontHeight, 120, scale);
    result = result + getFontSizeDeclaration("h4", defaultFontHeight, 100, scale);
    result = result + getFontSizeDeclaration("h5", defaultFontHeight, 80, scale);
    result = result + getFontSizeDeclaration("h6", defaultFontHeight, 70, scale);
    return result;
  }
  
  public static final int getScalePercentage()
  {
    int scale = Platform.getPreferencesService().getInt("org.eclipse.ui.intro", "scaleFactor", 0, null);
    return scale;
  }
  
  private static String getFontSizeDeclaration(String element, int baseSize, int percentage, int scale)
  {
    if (scale > 75) {
      scale = 75;
    }
    int newSize = (int)(baseSize * percentage * 1.25D / (100 - scale));
    return " body " + element + "{  font-size : " + newSize + "px; } ";
  }
  
  public static void setScalePercentage(int i)
  {
    InstanceScope instanceScope = new InstanceScope();
    IEclipsePreferences prefs = instanceScope.getNode("org.eclipse.ui.intro");
    prefs.putInt("scaleFactor", i);
    try
    {
      prefs.flush();
    }
    catch (BackingStoreException localBackingStoreException) {}
  }
  
  public static void resetScalePercentage()
  {
    InstanceScope instanceScope = new InstanceScope();
    IEclipsePreferences iprefs = instanceScope.getNode("org.eclipse.ui.intro");
    DefaultScope defaultScope = new DefaultScope();
    IEclipsePreferences dprefs = defaultScope.getNode("org.eclipse.ui.intro");
    String defaultScale = dprefs.get("scaleFactor", "0");
    iprefs.put("scaleFactor", defaultScale);
  }
  
  public static String getFontStyle()
  {
    IProduct product = Platform.getProduct();
    if (product != null)
    {
      String pid = product.getId();
      String style = Platform.getPreferencesService().getString(
        "org.eclipse.ui.intro", pid + "_" + "fontStyle", "", null);
      if (style.length() > 0) {
        return style;
      }
      style = Platform.getPreferencesService().getString(
        "org.eclipse.ui.intro", "fontStyle", "", null);
      if (style.length() > 0) {
        return style;
      }
    }
    return "relative";
  }
}

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

public abstract interface IIntroConstants
{
  public static final String PLUGIN_ID = "org.eclipse.ui.intro";
  public static final String PREFIX = "org.eclipse.ui.intro.";
  public static final String EMPTY_STANDBY_CONTENT_PART = "org.eclipse.ui.intro.config.emptyStandby";
  public static final String MEMENTO_PRESENTATION_TAG = "presentation";
  public static final String MEMENTO_CURRENT_PAGE_ATT = "currentPage";
  public static final String MEMENTO_STANDBY_PART_TAG = "standbyPart";
  public static final String MEMENTO_STANDBY_CONTENT_PART_ID_ATT = "contentPartID";
  public static final String MEMENTO_STANDBY_CONTENT_PART_TAG = "standbyContentPart";
  public static final String MEMENTO_RESTORE_ATT = "restore";
  public static final String SHOW_STANDBY_PART = "showStandbyPart";
  public static final String INTRO_LINK = "IntroLink";
  public static final String PAGE_SUBTITLE = "PageSubtitle";
  public static final String INTRO = "intro";
  public static final String PERF_VIEW_CREATION_TIME = "org.eclipse.ui.intro/perf/createView";
  public static final String PERF_SET_STANDBY_STATE = "org.eclipse.ui.intro/perf/setStandbyState";
  public static final String PERF_UI_ZOOM = "org.eclipse.ui.intro/perf/uiZoom";
}

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

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.internal.intro.impl.model.loader.ExtensionPointManager;
import org.eclipse.ui.internal.intro.impl.presentations.IntroLaunchBar;
import org.eclipse.ui.internal.intro.impl.util.Log;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class IntroPlugin
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.ui.intro";
  public static boolean LOG_WARN = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.intro/debug/warn"));
  public static boolean LOG_INFO = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.intro/debug/info"));
  private static IntroPlugin inst;
  private IntroLaunchBar launchBar;
  private long uiCreationStartTime;
  private ImageRegistry volatileImageRegistry;
  public static boolean DEBUG = false;
  public static boolean DEBUG_NO_BROWSER = false;
  public static boolean DEBUG_TOOLBAR = false;
  
  public static IntroPlugin getDefault()
  {
    return inst;
  }
  
  public ImageRegistry getVolatileImageRegistry()
  {
    if (volatileImageRegistry == null)
    {
      volatileImageRegistry = createImageRegistry();
      initializeImageRegistry(volatileImageRegistry);
    }
    return volatileImageRegistry;
  }
  
  public void resetVolatileImageRegistry()
  {
    if (volatileImageRegistry != null)
    {
      volatileImageRegistry.dispose();
      volatileImageRegistry = null;
    }
  }
  
  public void closeLaunchBar()
  {
    if (launchBar != null)
    {
      launchBar.close();
      launchBar = null;
    }
  }
  
  public void setLaunchBar(IntroLaunchBar launchBar)
  {
    this.launchBar = launchBar;
  }
  
  public ExtensionPointManager getExtensionPointManager()
  {
    return ExtensionPointManager.getInst();
  }
  
  public IntroModelRoot getIntroModelRoot()
  {
    return getExtensionPointManager().getCurrentModel();
  }
  
  public static IIntroPart getIntro()
  {
    IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
      .getIntro();
    return introPart;
  }
  
  public static IIntroPart showIntro(boolean standby)
  {
    IIntroPart introPart = PlatformUI.getWorkbench().getIntroManager()
      .showIntro(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), 
      standby);
    return introPart;
  }
  
  public static boolean isIntroStandby()
  {
    return PlatformUI.getWorkbench().getIntroManager().isIntroStandby(
      getIntro());
  }
  
  public static void setIntroStandby(boolean standby)
  {
    PlatformUI.getWorkbench().getIntroManager().setIntroStandby(getIntro(), 
      standby);
  }
  
  public static boolean closeIntro()
  {
    return PlatformUI.getWorkbench().getIntroManager().closeIntro(
      getIntro());
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    inst = this;
    if (Log.logInfo) {
      Log.info("IntroPlugin - calling start on Intro bundle");
    }
    DEBUG = isDebugging();
    if (DEBUG) {
      DEBUG_NO_BROWSER = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.intro/flags/noBrowser"));
    }
    if (DEBUG) {
      DEBUG_TOOLBAR = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.intro/debug/toolbar"));
    }
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    resetVolatileImageRegistry();
    super.stop(context);
  }
  
  public long gettUICreationStartTime()
  {
    return uiCreationStartTime;
  }
  
  public void setUICreationStartTime(long uiCreationStartTime)
  {
    this.uiCreationStartTime = uiCreationStartTime;
  }
  
  public static synchronized void logError(String message)
  {
    logError(message, null);
  }
  
  public static synchronized void logError(String message, Throwable ex)
  {
    if (message == null) {
      message = "";
    }
    Status errorStatus = new Status(4, "org.eclipse.ui.intro", message, ex);
    getDefault().getLog().log(errorStatus);
  }
  
  public static synchronized void logWarning(String message)
  {
    logWarning(message, null);
  }
  
  public static synchronized void logWarning(String message, Throwable ex)
  {
    if ((getDefault().isDebugging()) && (LOG_WARN))
    {
      if (message == null) {
        message = "";
      }
      Status warningStatus = new Status(2, "org.eclipse.ui.intro", 
        0, message, ex);
      getDefault().getLog().log(warningStatus);
    }
  }
  
  public static synchronized void logDebug(String message)
  {
    if ((getDefault().isDebugging()) && (LOG_INFO))
    {
      if (message == null) {
        message = "";
      }
      Status status = new Status(1, "org.eclipse.ui.intro", message);
      getDefault().getLog().log(status);
    }
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String INTRO_RESOURCE_BUNDLE = "org.eclipse.ui.internal.intro.impl.Messages";
  public static String Browser_homeButton_tooltip;
  public static String Browser_forwardButton_tooltip;
  public static String Browser_backwardButton_tooltip;
  public static String Browser_invalidConfig;
  public static String Browser_magnify_tooltip;
  public static String Browser_reduce_tooltip;
  public static String MessageDialog_errorTitle;
  public static String MessageDialog_warningTitle;
  public static String MessageDialog_infoTitle;
  public static String CustomizableIntroPart_configNotFound;
  public static String StandbyPart_returnToIntro;
  public static String StandbyPart_returnTo;
  public static String EmptyStandbyContentPart_text;
  public static String StandbyPart_failedToCreate;
  public static String StandbyPart_nonDefined;
  public static String StandbyPart_canNotRestore;
  public static String IntroURL_failedToDecode;
  public static String IntroURL_badCommand;
  public static String HyperlinkAdapter_urlIs;
  public static String HTML_embeddedLink;
  public static String StaticHTML_welcome;
  public static String IntroLaunchBar_close_label;
  public static String IntroLaunchBar_close_tooltip;
  public static String IntroLaunchBar_restore_tooltip;
  public static String IntroPart_openExternal_tooltip;
  public static String IntroPart_showContentButton_tooltip;
  public static String AlwaysWelcomeCheckbox_Text;
  public static String RSS_Subscribe;
  public static String RSS_Loading;
  public static String RSS_No_news_please_visit;
  public static String RSS_Reading;
  public static String RSS_No_news;
  public static String RSS_Malformed_feed;
  
  static
  {
    initializeMessages("org.eclipse.ui.internal.intro.impl.Messages", Messages.class);
  }
}

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

import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

public class FormattedHTMLElement
  extends HTMLElement
{
  private int indentLevel;
  private boolean spanMultipleLines;
  private boolean endTagRequired = true;
  
  public FormattedHTMLElement(String name, int indentLevel, boolean spanMultipleLines)
  {
    super(name);
    this.indentLevel = indentLevel;
    this.spanMultipleLines = spanMultipleLines;
    
    endTagRequired = true;
  }
  
  public FormattedHTMLElement(String name, int indentLevel, boolean spanMultipleLines, boolean endTagRequired)
  {
    super(name);
    this.indentLevel = indentLevel;
    this.spanMultipleLines = spanMultipleLines;
    this.endTagRequired = endTagRequired;
  }
  
  public FormattedHTMLElement(String name, Map attributes, Vector content, int indentLevel, boolean spanMultipleLines)
  {
    super(name, attributes, content);
    this.indentLevel = indentLevel;
    this.spanMultipleLines = spanMultipleLines;
    endTagRequired = true;
  }
  
  public void setEndTagRequired(boolean required)
  {
    endTagRequired = required;
  }
  
  public void setIndentLevel(int indentLevel)
  {
    this.indentLevel = indentLevel;
  }
  
  public void setSpanMultipleLines(boolean spanMultipleLines)
  {
    this.spanMultipleLines = spanMultipleLines;
  }
  
  private StringBuffer getIndent(int indentLevel)
  {
    StringBuffer indent = new StringBuffer();
    for (int i = 0; i < indentLevel; i++) {
      indent.append("    ");
    }
    return indent;
  }
  
  public String toString()
  {
    StringBuffer element = new StringBuffer();
    
    element.append(getIndent(indentLevel));
    
    element.append(HTMLUtil.createHTMLStartTag(getElementName(), 
      getElementAttributes(), spanMultipleLines));
    if ((getElementContent().isEmpty()) && (!endTagRequired)) {
      return element.toString();
    }
    for (Iterator it = getElementContent().iterator(); it.hasNext();)
    {
      Object content = it.next();
      element.append(content);
    }
    if ((indentLevel > 0) && (spanMultipleLines)) {
      element.append(getIndent(indentLevel));
    }
    element.append(HTMLUtil.createHTMLEndTag(getElementName(), true));
    return element.toString();
  }
}

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

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;

public class HTMLElement
{
  private String elementName;
  private Map elementAttributes;
  private Vector elementContent;
  
  public HTMLElement(String name)
  {
    elementName = name;
    elementAttributes = new Hashtable();
    elementContent = new Vector();
  }
  
  public HTMLElement(String name, Map attributes, Vector content)
  {
    elementName = name;
    elementAttributes = attributes;
    elementContent = content;
  }
  
  public void addAttribute(String attributeName, String attributeValue)
  {
    if ((attributeName != null) && (attributeValue != null)) {
      getElementAttributes().put(attributeName, attributeValue);
    }
  }
  
  public void addContent(Object content)
  {
    getElementContent().add(content);
  }
  
  public Map getElementAttributes()
  {
    if (elementAttributes == null) {
      elementAttributes = new Hashtable();
    }
    return elementAttributes;
  }
  
  public void setElementAttributes(Map elementAttributes)
  {
    this.elementAttributes = elementAttributes;
  }
  
  public Vector getElementContent()
  {
    if (elementContent == null) {
      elementContent = new Vector();
    }
    return elementContent;
  }
  
  public void setElementContent(Vector elementContent)
  {
    this.elementContent = elementContent;
  }
  
  public String getElementName()
  {
    return elementName;
  }
  
  public void setElementName(String elementName)
  {
    this.elementName = elementName;
  }
  
  public String toString()
  {
    StringBuffer element = new StringBuffer();
    
    element.append(
      HTMLUtil.createHTMLStartTag(
      getElementName(), 
      getElementAttributes(), 
      false));
    for (Iterator it = getElementContent().iterator(); it.hasNext();)
    {
      Object content = it.next();
      element.append(content);
    }
    element.append(HTMLUtil.createHTMLEndTag(getElementName(), false));
    return element.toString();
  }
}

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

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public final class HTMLUtil
{
  public static StringBuffer createHTMLStartTag(String elementName, Map elementAttributes, boolean insertLineBreak)
  {
    StringBuffer element = new StringBuffer();
    if (elementName != null)
    {
      element.append(openHTMLStartTag(elementName));
      if ((elementAttributes != null) && (!elementAttributes.isEmpty())) {
        element.append(" ").append(
          createAttributeList(elementAttributes));
      }
      element.append(closeHTMLTag(insertLineBreak));
    }
    return element;
  }
  
  public static StringBuffer createHTMLStartTag(String elementName, boolean insertLineBreak)
  {
    return createHTMLStartTag(elementName, null, insertLineBreak);
  }
  
  public static StringBuffer createHTMLStartTag(String elementName)
  {
    return createHTMLStartTag(elementName, null, true);
  }
  
  public static StringBuffer createHTMLEndTag(String elementName, boolean addNewLine)
  {
    StringBuffer closingElement = new StringBuffer();
    if (elementName != null) {
      closingElement.append("<").append("/").append(elementName).append(closeHTMLTag(addNewLine));
    }
    return closingElement;
  }
  
  public static String createAttributeList(Map attributes)
  {
    if (attributes == null) {
      return null;
    }
    StringBuffer attributeList = new StringBuffer();
    Set attrNames = attributes.keySet();
    for (Iterator it = attrNames.iterator(); it.hasNext();)
    {
      Object name = it.next();
      Object value = attributes.get(name);
      if (((name instanceof String)) && ((value instanceof String)))
      {
        attributeList.append(createAttribute((String)name, 
          (String)value));
        if (it.hasNext()) {
          attributeList.append(" ");
        }
      }
    }
    return attributeList.toString();
  }
  
  public static StringBuffer createAttribute(String attrName, String attrValue)
  {
    StringBuffer attribute = new StringBuffer();
    if ((attrName != null) && (attrValue != null)) {
      attribute.append(attrName).append("=").append("\"").append(attrValue).append("\"");
    }
    return attribute;
  }
  
  public static StringBuffer openHTMLStartTag(String elementName)
  {
    return new StringBuffer().append("<").append(
      elementName);
  }
  
  public static StringBuffer closeHTMLTag()
  {
    return closeHTMLTag(true);
  }
  
  public static StringBuffer closeHTMLTag(boolean newLine)
  {
    StringBuffer closing = new StringBuffer()
      .append(">");
    if (newLine) {
      closing.append("\n");
    }
    return closing;
  }
  
  public static boolean equalCharArrayContent(char[] a, char[] b)
  {
    if (a.length != b.length) {
      return false;
    }
    for (int i = 0; i < a.length; i++) {
      if (a[i] != b[i]) {
        return false;
      }
    }
    return true;
  }
}

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

public abstract interface IIntroHTMLConstants
{
  public static final String LT = "<";
  public static final String GT = ">";
  public static final String FORWARD_SLASH = "/";
  public static final String QUOTE = "\"";
  public static final String EQUALS = "=";
  public static final String HYPHEN = "-";
  public static final String SPACE = " ";
  public static final String NEW_LINE = "\n";
  public static final String TAB = "\t";
  public static final String SMALL_TAB = "    ";
  public static final String ELEMENT_HTML = "HTML";
  public static final String ELEMENT_HEAD = "HEAD";
  public static final String ELEMENT_BASE = "BASE";
  public static final String ELEMENT_BODY = "BODY";
  public static final String ELEMENT_TITLE = "TITLE";
  public static final String ELEMENT_LINK = "LINK";
  public static final String ELEMENT_DIV = "DIV";
  public static final String ELEMENT_SPAN = "SPAN";
  public static final String ELEMENT_ANCHOR = "A";
  public static final String ELEMENT_OBJECT = "OBJECT";
  public static final String ELEMENT_IMG = "IMG";
  public static final String ELEMENT_H1 = "H1";
  public static final String ELEMENT_H2 = "H2";
  public static final String ELEMENT_H3 = "H3";
  public static final String ELEMENT_H4 = "H4";
  public static final String ELEMENT_HR = "HR";
  public static final String ELEMENT_PARAGRAPH = "P";
  public static final String ELEMENT_STYLE = "STYLE";
  public static final String ELEMENT_TABLE = "TABLE";
  public static final String ELEMENT_TR = "TR";
  public static final String ELEMENT_TD = "TD";
  public static final String ELEMENT_IFrame = "iFrame";
  public static final String ATTRIBUTE_ID = "id";
  public static final String ATTRIBUTE_CLASS = "class";
  public static final String ATTRIBUTE_STYLE = "style";
  public static final String ATTRIBUTE_HREF = "href";
  public static final String ATTRIBUTE_RELATIONSHIP = "rel";
  public static final String ATTRIBUTE_SRC = "src";
  public static final String ATTRIBUTE_TYPE = "type";
  public static final String ATTRIBUTE_DATA = "data";
  public static final String ATTRIBUTE_ALT = "alt";
  public static final String ATTRIBUTE_TITLE = "title";
  public static final String ATTRIBUTE_FRAMEBORDER = "frameborder";
  public static final String ATTRIBUTE_SCROLLING = "scrolling";
  public static final String LINK_REL = "stylesheet";
  public static final String LINK_STYLE = "text/css";
  public static final String OBJECT_TYPE = "text/html";
  public static final String DIV_ID_PAGE = "page";
  public static final String DIV_CLASS_INLINE_HTML = "inline-html";
  public static final String DIV_CLASS_PROVIDED_CONTENT = "provided-content";
  public static final String ANCHOR_CLASS_LINK = "link";
  public static final String IMAGE_SRC_BLANK = "icons/blank.gif";
  public static final String IMAGE_CLASS_BG = "background-image";
  public static final String LINK_EXTRA_DIV = "link-extra-div";
  public static final String SPAN_CLASS_DIV_LABEL = "div-label";
  public static final String SPAN_CLASS_LINK_LABEL = "link-label";
  public static final String SPAN_CLASS_TEXT = "text";
  public static final String STYLE_HTML = "HTML, BODY, IMG { border: 0px; }";
}

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

import java.io.BufferedReader;
import java.io.IOException;
import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
import org.eclipse.ui.internal.intro.impl.util.Log;

class IntroHTMLGenerator$PluginIdParser
{
  private BufferedReader reader;
  private static final char SUBSTITUTION_BEGIN = '$';
  private static final char SUBSTITUTION_END = '$';
  private StringBuffer tokenContent;
  private StringBuffer pluginId;
  
  protected IntroHTMLGenerator$PluginIdParser(int tokenBegin, BufferedReader bufferedreader)
  {
    reader = bufferedreader;
    tokenContent = new StringBuffer();
    pluginId = new StringBuffer();
    if ((tokenBegin > 0) && (tokenBegin < 65535)) {
      tokenContent.append((char)tokenBegin);
    }
  }
  
  protected String parsePluginId()
  {
    if ((reader == null) || (tokenContent == null) || (pluginId == null)) {
      return null;
    }
    try
    {
      reader.mark(1024);
      if (findValidPluginSegment())
      {
        String pluginPath = getPluginPath();
        if (pluginPath == null) {
          return tokenContent.toString();
        }
        return pluginPath;
      }
      reader.reset();
      return tokenContent.toString();
    }
    catch (IOException exception)
    {
      Log.error("Error reading from file", exception);
    }
    return tokenContent.toString();
  }
  
  private boolean findValidPluginSegment()
  {
    char[] PLUGIN_SEGMENT = { 'p', 'l', 'u', 'g', 'i', 'n', ':' };
    char[] streamContent = new char[PLUGIN_SEGMENT.length];
    try
    {
      int peek = reader.read(streamContent, 0, PLUGIN_SEGMENT.length);
      if ((peek == PLUGIN_SEGMENT.length) && 
        (HTMLUtil.equalCharArrayContent(streamContent, PLUGIN_SEGMENT)))
      {
        tokenContent.append(streamContent);
        return true;
      }
      return false;
    }
    catch (IOException exception)
    {
      Log.error("Error reading from file", exception);
    }
    return false;
  }
  
  private String getPluginPath()
  {
    try
    {
      for (;;)
      {
        int nextChar = reader.read();
        if (nextChar == -1) {
          return null;
        }
        if (nextChar == 36)
        {
          String path = BundleUtil.getResolvedBundleLocation(pluginId.toString());
          if (path == null) {
            reader.reset();
          }
          return path;
        }
        reader.mark(1024);
        if ((nextChar > 0) && (nextChar < 65535))
        {
          tokenContent.append((char)nextChar);
          if (!Character.isWhitespace((char)nextChar)) {
            pluginId.append((char)nextChar);
          }
        }
        else
        {
          tokenContent.append(nextChar);
          pluginId.append(nextChar);
        }
      }
      return null;
    }
    catch (IOException exception)
    {
      Log.error("Error reading from file", exception);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ui.internal.intro.impl.html.IntroHTMLGenerator.PluginIdParser
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ui.internal.intro.impl.html;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.util.ProductPreferences;
import org.eclipse.ui.internal.intro.impl.FontSelection;
import org.eclipse.ui.internal.intro.impl.IntroPlugin;
import org.eclipse.ui.internal.intro.impl.model.AbstractBaseIntroElement;
import org.eclipse.ui.internal.intro.impl.model.AbstractIntroElement;
import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage;
import org.eclipse.ui.internal.intro.impl.model.IntroContentProvider;
import org.eclipse.ui.internal.intro.impl.model.IntroGroup;
import org.eclipse.ui.internal.intro.impl.model.IntroHTML;
import org.eclipse.ui.internal.intro.impl.model.IntroHead;
import org.eclipse.ui.internal.intro.impl.model.IntroImage;
import org.eclipse.ui.internal.intro.impl.model.IntroInjectedIFrame;
import org.eclipse.ui.internal.intro.impl.model.IntroLink;
import org.eclipse.ui.internal.intro.impl.model.IntroModelRoot;
import org.eclipse.ui.internal.intro.impl.model.IntroPageTitle;
import org.eclipse.ui.internal.intro.impl.model.IntroPartPresentation;
import org.eclipse.ui.internal.intro.impl.model.IntroSeparator;
import org.eclipse.ui.internal.intro.impl.model.IntroText;
import org.eclipse.ui.internal.intro.impl.model.IntroTheme;
import org.eclipse.ui.internal.intro.impl.model.loader.ContentProviderManager;
import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
import org.eclipse.ui.internal.intro.impl.util.Log;
import org.eclipse.ui.intro.config.IIntroContentProvider;
import org.eclipse.ui.intro.config.IIntroContentProviderSite;

public class IntroHTMLGenerator
{
  private AbstractIntroPage introPage;
  private IIntroContentProviderSite providerSite;
  
  public HTMLElement generateHTMLforPage(AbstractIntroPage page, IIntroContentProviderSite providerSite)
  {
    if (page == null) {
      return null;
    }
    introPage = page;
    this.providerSite = providerSite;
    
    return generateHTMLElement();
  }
  
  private HTMLElement generateHTMLElement()
  {
    int indentLevel = 0;
    HTMLElement html = new FormattedHTMLElement("HTML", indentLevel, true);
    HTMLElement head = generateHeadElement(indentLevel + 1);
    HTMLElement body = generateBodyElement(indentLevel + 1, head);
    html.addContent(head);
    html.addContent(body);
    return html;
  }
  
  private HTMLElement generateHeadElement(int indentLevel)
  {
    HTMLElement head = new FormattedHTMLElement("HEAD", indentLevel, true);
    
    head.addContent(generateTitleElement(introPage.getTitle(), indentLevel + 1));
    
    String basePath = BundleUtil.getResolvedResourceLocation(introPage.getBase(), introPage.getBundle());
    HTMLElement base = generateBaseElement(indentLevel + 1, basePath);
    if (base != null) {
      head.addContent(base);
    }
    head.addContent(generateStyleElement(indentLevel + 1));
    
    String[] presentationStyles = IntroPlugin.getDefault().getIntroModelRoot().getPresentation()
      .getImplementationStyles();
    if ((presentationStyles != null) && (introPage.injectSharedStyle())) {
      for (int i = 0; i < presentationStyles.length; i++) {
        head.addContent(generateLinkElement(presentationStyles[i], indentLevel + 1));
      }
    }
    String pageStyle = introPage.getStyle();
    if (pageStyle != null) {
      head.addContent(generateLinkElement(pageStyle, indentLevel + 1));
    }
    head.addContent(generateJavascriptElement(indentLevel + 1));
    
    String[] pageStyles = introPage.getStyles();
    for (int i = 0; i < pageStyles.length; i++)
    {
      pageStyle = pageStyles[i];
      if (pageStyle != null) {
        head.addContent(generateLinkElement(pageStyle, indentLevel + 1));
      }
    }
    StringBuffer content = null;
    IntroHead introHead = IntroPlugin.getDefault().getIntroModelRoot().getPresentation().getHead();
    if (introHead != null)
    {
      content = readFromFile(introHead.getSrc(), introHead.getInlineEncoding());
      if (content != null) {
        head.addContent(content);
      }
    }
    IntroHead[] htmlHeads = introPage.getHTMLHeads();
    for (int i = 0; i < htmlHeads.length; i++)
    {
      introHead = htmlHeads[i];
      if (introHead != null)
      {
        content = readFromFile(introHead.getSrc(), introHead.getInlineEncoding());
        if (content != null) {
          head.addContent(content);
        }
      }
    }
    return head;
  }
  
  private HTMLElement generateJavascriptElement(int indentLevel)
  {
    String rel = "javascript/common.js";
    String abs = BundleUtil.getResolvedResourceLocation(rel, IntroPlugin.getDefault().getBundle());
    HTMLElement jselement = new FormattedHTMLElement("script", indentLevel, false);
    jselement.addAttribute("type", "text/javascript");
    jselement.addAttribute("src", abs);
    return jselement;
  }
  
  private HTMLElement generateBodyElement(int indentLevel, HTMLElement head)
  {
    HTMLElement body = new FormattedHTMLElement("BODY", indentLevel, true);
    
    String pageId = introPage.getId() != null ? introPage.getId() : "page";
    HTMLElement pageContentDiv = generateDivElement(pageId, indentLevel + 1);
    if (introPage.getStyleId() != null) {
      pageContentDiv.addAttribute("class", introPage.getStyleId());
    }
    if (introPage.getBackgroundImage() != null) {
      pageContentDiv.addAttribute("style", 
        "background-image : url(" + introPage.getBackgroundImage() + ")");
    }
    AbstractIntroElement[] children = introPage.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      AbstractIntroElement child = children[i];
      
      HTMLElement childElement = generateIntroElement(child, indentLevel + 2);
      if (childElement != null)
      {
        addMixinStyle(childElement, child.getMixinStyle());
        pageContentDiv.addContent(childElement);
      }
    }
    body.addContent(pageContentDiv);
    return body;
  }
  
  private HTMLElement generateIntroElement(AbstractIntroElement element, int indentLevel)
  {
    if (element == null) {
      return null;
    }
    if (filteredFromPresentation(element)) {
      return null;
    }
    switch (element.getType())
    {
    case 16: 
      return generateIntroDiv((IntroGroup)element, indentLevel);
    case 64: 
      return generateIntroLink((IntroLink)element, indentLevel);
    case 32: 
      return generateIntroHTML((IntroHTML)element, indentLevel);
    case 16384: 
      return generateIntroContent((IntroContentProvider)element, indentLevel);
    case 128: 
      return generateIntroImage((IntroImage)element, indentLevel);
    case 524288: 
      return generateIntroSeparator((IntroSeparator)element, indentLevel);
    case 512: 
      return generateIntroText((IntroText)element, indentLevel);
    case 4096: 
      return generateIntroTitle((IntroPageTitle)element, indentLevel);
    case 131072: 
      return generateIntroInjectedIFrame((IntroInjectedIFrame)element, indentLevel);
    }
    return null;
  }
  
  private HTMLElement generateIntroDiv(IntroGroup element, int indentLevel)
  {
    HTMLElement divElement = generateDivElement(element.getId(), indentLevel);
    HTMLElement childContainer = divElement;
    if (element.getStyleId() != null) {
      divElement.addAttribute("class", element.getStyleId());
    }
    if (element.getLabel() != null) {
      if (element.isExpandable())
      {
        HTMLElement divLabel = new FormattedHTMLElement("SPAN", 
          indentLevel + 2, false);
        divLabel.addContent(element.getLabel());
        divLabel.addAttribute("class", 
          "section-title");
        String clientId = element.getId() + "-content";
        String toggleClosedId = element.getId() + "-toggle-closed";
        String toggleOpenId = element.getId() + "-toggle-open";
        String href = "#";
        HTMLElement link = new FormattedHTMLElement("A", 
          indentLevel + 1, true);
        link.addAttribute("href", href);
        link.addAttribute("class", "section-title-link");
        StringBuffer call = new StringBuffer();
        call.append("return (toggleSection('");
        call.append(clientId);
        call.append("','");
        call.append(toggleClosedId);
        call.append("','");
        call.append(toggleOpenId);
        call.append("'))");
        link.addAttribute("onClick", call.toString());
        link.addContent(divLabel);
        divElement.addContent(link);
        
        HTMLElement toggleImageClosed = new FormattedHTMLElement("IMG", 
          indentLevel + 2, false, false);
        toggleImageClosed.addAttribute("id", toggleClosedId);
        toggleImageClosed.addAttribute("src", 
          BundleUtil.getResolvedResourceLocation("icons/blank.gif", 
          "org.eclipse.ui.intro"));
        toggleImageClosed.addAttribute("class", "section-toggle-image-closed");
        if (element.isExpanded()) {
          toggleImageClosed.addAttribute("style", "display: none");
        }
        link.addContent(toggleImageClosed);
        HTMLElement toggleImageOpen = new FormattedHTMLElement("IMG", 
          indentLevel + 2, false, false);
        toggleImageOpen.addAttribute("id", toggleOpenId);
        toggleImageOpen.addAttribute("src", 
          BundleUtil.getResolvedResourceLocation("icons/blank.gif", 
          "org.eclipse.ui.intro"));
        toggleImageOpen.addAttribute("class", "section-toggle-image-open");
        if (element.isExpanded()) {
          toggleImageOpen.addAttribute("style", "display: inline");
        }
        link.addContent(toggleImageOpen);
        childContainer = generateDivElement(clientId, indentLevel + 1);
        childContainer.addAttribute("class", "section-body");
        if (element.isExpanded()) {
          childContainer.addAttribute("style", "display: block");
        }
        divElement.addContent(childContainer);
      }
      else
      {
        HTMLElement divLabel = generateTextElement("H4", null, 
          "div-label", element.getLabel(), indentLevel + 1);
        divElement.addContent(divLabel);
      }
    }
    if (element.getBackgroundImage() != null)
    {
      String imageUrl = element.getBackgroundImage();
      imageUrl = BundleUtil.getResolvedResourceLocation(element.getBase(), imageUrl, element
        .getBundle());
      String style;
      String style;
      if ((Platform.getWS().equals("win32")) && (imageUrl.toLowerCase().endsWith(".png"))) {
        style = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imageUrl + "', sizingMethod='crop');";
      } else {
        style = "background-image : url(" + imageUrl + ")";
      }
      divElement.addAttribute("style", style);
    }
    AbstractIntroElement[] children = element.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      AbstractIntroElement child = children[i];
      HTMLElement childElement = generateIntroElement(child, indentLevel + 1);
      if (childElement != null)
      {
        addMixinStyle(childElement, child.getMixinStyle());
        childContainer.addContent(childElement);
      }
    }
    return divElement;
  }
  
  private void addMixinStyle(HTMLElement element, String mixinStyle)
  {
    if (mixinStyle == null) {
      return;
    }
    String key = "class";
    String original = (String)element.getElementAttributes().get(key);
    if (original == null) {
      original = mixinStyle;
    } else {
      original = original + " " + mixinStyle;
    }
    element.addAttribute(key, original);
  }
  
  private HTMLElement generateIntroLink(IntroLink element, int indentLevel)
  {
    String styleId = element.getStyleId();
    boolean useTable = (ProductPreferences.isRTL()) && ("content-link".equals(styleId));
    HTMLElement anchor1 = generateAnchorElement(element, indentLevel);
    HTMLElement anchor2 = null;
    HTMLElement labelAnchor = anchor1;
    int indentBase = indentLevel;
    if (useTable)
    {
      indentBase = indentLevel + 1;
      anchor2 = generateAnchorElement(element, indentLevel + 1);
      labelAnchor = anchor2;
    }
    String blankImageURL = BundleUtil.getResolvedResourceLocation("icons/blank.gif", 
      "org.eclipse.ui.intro");
    if (blankImageURL != null) {
      anchor1.addContent(generateImageElement(blankImageURL, null, null, "background-image", 
        indentBase + 1));
    }
    if (element.getImg() != null)
    {
      HTMLElement img = generateIntroElement(element.getImg(), indentBase + 1);
      if (img != null) {
        anchor1.addContent(img);
      }
    }
    if (!useTable)
    {
      HTMLElement imageDiv = new FormattedHTMLElement("DIV", indentBase + 1, false);
      imageDiv.addAttribute("class", 
        "link-extra-div");
      anchor1.addContent(imageDiv);
    }
    if (elemen
1 2 3 4 5 6 7 8 9 10 11 12 13 14

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