org.eclipse.ui.forms_3.5.101.v20111011-1919

ocusSelectableSegments();
    if (selectables == null) {
      return false;
    }
    int size = selectables.length;
    if (next) {
      selectedSegmentIndex += 1;
    } else {
      selectedSegmentIndex -= 1;
    }
    if ((selectedSegmentIndex < 0) || (selectedSegmentIndex > size - 1)) {
      selectedSegmentIndex = -1;
    }
    return selectedSegmentIndex != -1;
  }
  
  public IFocusSelectable getNextFocusSegment(boolean next)
  {
    IFocusSelectable[] selectables = getFocusSelectableSegments();
    if (selectables == null) {
      return null;
    }
    int nextIndex = next ? selectedSegmentIndex + 1 : selectedSegmentIndex - 1;
    if ((nextIndex < 0) || (nextIndex > selectables.length - 1)) {
      return null;
    }
    return selectables[nextIndex];
  }
  
  public boolean restoreSavedLink()
  {
    if (savedSelectedLinkIndex != -1)
    {
      selectedSegmentIndex = savedSelectedLinkIndex;
      return true;
    }
    return false;
  }
  
  public void selectLink(IHyperlinkSegment link)
  {
    if (link == null)
    {
      savedSelectedLinkIndex = selectedSegmentIndex;
      selectedSegmentIndex = -1;
    }
    else
    {
      select(link);
    }
  }
  
  public void select(IFocusSelectable selectable)
  {
    IFocusSelectable[] selectables = getFocusSelectableSegments();
    selectedSegmentIndex = -1;
    if (selectables == null) {
      return;
    }
    for (int i = 0; i < selectables.length; i++) {
      if (selectables[i].equals(selectable))
      {
        selectedSegmentIndex = i;
        break;
      }
    }
  }
  
  public boolean hasFocusSegments()
  {
    IFocusSelectable[] segments = getFocusSelectableSegments();
    if (segments.length > 0) {
      return true;
    }
    return false;
  }
  
  public void dispose()
  {
    paragraphs = null;
    selectedSegmentIndex = -1;
    savedSelectedLinkIndex = -1;
    selectableSegments = null;
  }
  
  public boolean isWhitespaceNormalized()
  {
    return whitespaceNormalized;
  }
  
  public void setWhitespaceNormalized(boolean whitespaceNormalized)
  {
    this.whitespaceNormalized = whitespaceNormalized;
  }
  
  public class ParseErrorHandler
    implements ErrorHandler
  {
    public ParseErrorHandler() {}
    
    public void error(SAXParseException arg0)
      throws SAXException
    {}
    
    public void fatalError(SAXParseException arg0)
      throws SAXException
    {}
    
    public void warning(SAXParseException arg0)
      throws SAXException
    {}
  }
}

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

import com.ibm.icu.text.BreakIterator;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ColumnLayout;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormText;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ILayoutExtension;

public class FormUtil
{
  public static final String PLUGIN_ID = "org.eclipse.ui.forms";
  static final int H_SCROLL_INCREMENT = 5;
  static final int V_SCROLL_INCREMENT = 64;
  public static final String DEBUG = "org.eclipse.ui.forms/debug";
  public static final String DEBUG_TEXT = "org.eclipse.ui.forms/debug/text";
  public static final String DEBUG_TEXTSIZE = "org.eclipse.ui.forms/debug/textsize";
  public static final String DEBUG_FOCUS = "org.eclipse.ui.forms/debug/focus";
  public static final String FOCUS_SCROLLING = "focusScrolling";
  public static final String IGNORE_BODY = "__ignore_body__";
  
  public static Text createText(Composite parent, String label, FormToolkit factory)
  {
    return createText(parent, label, factory, 1);
  }
  
  public static Text createText(Composite parent, String label, FormToolkit factory, int span)
  {
    factory.createLabel(parent, label);
    Text text = factory.createText(parent, "");
    int hfill = span == 1 ? 768 : 
      256;
    GridData gd = new GridData(hfill | 0x4);
    horizontalSpan = span;
    text.setLayoutData(gd);
    return text;
  }
  
  public static Text createText(Composite parent, String label, FormToolkit factory, int span, int style)
  {
    Label l = factory.createLabel(parent, label);
    if ((style & 0x2) != 0)
    {
      GridData gd = new GridData(2);
      l.setLayoutData(gd);
    }
    Text text = factory.createText(parent, "", style);
    int hfill = span == 1 ? 768 : 
      256;
    GridData gd = new GridData(hfill | 0x4);
    horizontalSpan = span;
    text.setLayoutData(gd);
    return text;
  }
  
  public static Text createText(Composite parent, FormToolkit factory, int span)
  {
    Text text = factory.createText(parent, "");
    int hfill = span == 1 ? 768 : 
      256;
    GridData gd = new GridData(hfill | 0x4);
    horizontalSpan = span;
    text.setLayoutData(gd);
    return text;
  }
  
  public static int computeMinimumWidth(GC gc, String text)
  {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    int last = 0;
    
    int width = 0;
    for (int loc = wb.first(); loc != -1; loc = wb.next())
    {
      String word = text.substring(last, loc);
      Point extent = gc.textExtent(word);
      width = Math.max(width, x);
      last = loc;
    }
    String lastWord = text.substring(last);
    Point extent = gc.textExtent(lastWord);
    width = Math.max(width, x);
    return width;
  }
  
  public static Point computeWrapSize(GC gc, String text, int wHint)
  {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();
    
    int saved = 0;
    int last = 0;
    int height = lineHeight;
    int maxWidth = 0;
    for (int loc = wb.first(); loc != -1; loc = wb.next())
    {
      String word = text.substring(saved, loc);
      Point extent = gc.textExtent(word);
      if (x > wHint)
      {
        saved = last;
        height += y;
        
        word = text.substring(last, loc);
        extent = gc.textExtent(word);
      }
      maxWidth = Math.max(maxWidth, x);
      last = loc;
    }
    if (maxWidth > wHint) {
      return computeWrapSize(gc, text, maxWidth);
    }
    return new Point(maxWidth, height);
  }
  
  public static void paintWrapText(GC gc, String text, Rectangle bounds)
  {
    paintWrapText(gc, text, bounds, false);
  }
  
  public static void paintWrapText(GC gc, String text, Rectangle bounds, boolean underline)
  {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();
    int descent = fm.getDescent();
    
    int saved = 0;
    int last = 0;
    int y = y;
    int width = width;
    for (int loc = wb.first(); loc != -1; loc = wb.next())
    {
      String line = text.substring(saved, loc);
      Point extent = gc.textExtent(line);
      if (x > width)
      {
        String prevLine = text.substring(saved, last);
        gc.drawText(prevLine, x, y, true);
        if (underline)
        {
          Point prevExtent = gc.textExtent(prevLine);
          int lineY = y + lineHeight - descent + 1;
          gc
            .drawLine(x, lineY, x + x, 
            lineY);
        }
        saved = last;
        y += lineHeight;
      }
      last = loc;
    }
    String lastLine = text.substring(saved, last);
    gc.drawText(lastLine, x, y, true);
    if (underline)
    {
      int lineY = y + lineHeight - descent + 1;
      Point lastExtent = gc.textExtent(lastLine);
      gc.drawLine(x, lineY, x + x, lineY);
    }
  }
  
  public static ScrolledComposite getScrolledComposite(Control c)
  {
    Composite parent = c.getParent();
    while (parent != null)
    {
      if ((parent instanceof ScrolledComposite)) {
        return (ScrolledComposite)parent;
      }
      parent = parent.getParent();
    }
    return null;
  }
  
  public static void ensureVisible(Control c)
  {
    ScrolledComposite scomp = getScrolledComposite(c);
    if (scomp != null)
    {
      Object data = scomp.getData("focusScrolling");
      if ((data == null) || (!data.equals(Boolean.FALSE))) {
        ensureVisible(scomp, c);
      }
    }
  }
  
  public static void ensureVisible(ScrolledComposite scomp, Control control)
  {
    if ((control instanceof FormText)) {
      return;
    }
    Point controlSize = control.getSize();
    Point controlOrigin = getControlLocation(scomp, control);
    ensureVisible(scomp, controlOrigin, controlSize);
  }
  
  public static void ensureVisible(ScrolledComposite scomp, Point controlOrigin, Point controlSize)
  {
    Rectangle area = scomp.getClientArea();
    Point scompOrigin = scomp.getOrigin();
    
    int x = x;
    int y = y;
    if (x < width) {
      if (x + x > x + width) {
        x = x + x - width;
      }
    }
    if (x < x) {
      if (x < width) {
        x = x + x - width;
      } else {
        x = x;
      }
    }
    if (y < height) {
      if (y + y > y + height) {
        y = y + y - height;
      }
    }
    if (y < y) {
      if (y < height) {
        y = y + y - height;
      } else {
        y = y;
      }
    }
    if ((x != x) || (y != y)) {
      scomp.setOrigin(x, y);
    }
  }
  
  public static void ensureVisible(ScrolledComposite scomp, Control control, MouseEvent e)
  {
    Point controlOrigin = getControlLocation(scomp, control);
    int rX = x + x;
    int rY = y + y;
    Rectangle area = scomp.getClientArea();
    Point scompOrigin = scomp.getOrigin();
    
    int x = x;
    int y = y;
    if (rX > x + width) {
      x = rX - width;
    } else if (rX < x) {
      x = rX;
    }
    if (rY > y + height) {
      y = rY - height;
    } else if (rY < y) {
      y = rY;
    }
    if ((x != x) || (y != y)) {
      scomp.setOrigin(x, y);
    }
  }
  
  public static Point getControlLocation(ScrolledComposite scomp, Control control)
  {
    int x = 0;
    int y = 0;
    Control content = scomp.getContent();
    Control currentControl = control;
    while (currentControl != content)
    {
      Point location = currentControl.getLocation();
      
      x += x;
      y += y;
      currentControl = currentControl.getParent();
    }
    return new Point(x, y);
  }
  
  static void scrollVertical(ScrolledComposite scomp, boolean up)
  {
    scroll(scomp, 0, up ? -64 : 64);
  }
  
  static void scrollHorizontal(ScrolledComposite scomp, boolean left)
  {
    scroll(scomp, left ? -5 : 5, 0);
  }
  
  static void scrollPage(ScrolledComposite scomp, boolean up)
  {
    Rectangle clientArea = scomp.getClientArea();
    int increment = up ? -height : height;
    scroll(scomp, 0, increment);
  }
  
  static void scroll(ScrolledComposite scomp, int xoffset, int yoffset)
  {
    Point origin = scomp.getOrigin();
    Point contentSize = scomp.getContent().getSize();
    int xorigin = x + xoffset;
    int yorigin = y + yoffset;
    xorigin = Math.max(xorigin, 0);
    xorigin = Math.min(xorigin, x - 1);
    yorigin = Math.max(yorigin, 0);
    yorigin = Math.min(yorigin, y - 1);
    scomp.setOrigin(xorigin, yorigin);
  }
  
  public static void updatePageIncrement(ScrolledComposite scomp)
  {
    ScrollBar vbar = scomp.getVerticalBar();
    if (vbar != null)
    {
      Rectangle clientArea = scomp.getClientArea();
      int increment = height - 5;
      vbar.setPageIncrement(increment);
    }
    ScrollBar hbar = scomp.getHorizontalBar();
    if (hbar != null)
    {
      Rectangle clientArea = scomp.getClientArea();
      int increment = width - 5;
      hbar.setPageIncrement(increment);
    }
  }
  
  public static void processKey(int keyCode, Control c)
  {
    if (c.isDisposed()) {
      return;
    }
    ScrolledComposite scomp = getScrolledComposite(c);
    if (scomp != null)
    {
      if ((c instanceof Combo)) {
        return;
      }
      switch (keyCode)
      {
      case 16777218: 
        if (scomp.getData("novarrows") == null) {
          scrollVertical(scomp, false);
        }
        break;
      case 16777217: 
        if (scomp.getData("novarrows") == null) {
          scrollVertical(scomp, true);
        }
        break;
      case 16777219: 
        scrollHorizontal(scomp, true);
        break;
      case 16777220: 
        scrollHorizontal(scomp, false);
        break;
      case 16777221: 
        scrollPage(scomp, true);
        break;
      case 16777222: 
        scrollPage(scomp, false);
      }
    }
  }
  
  public static boolean isWrapControl(Control c)
  {
    if ((c.getStyle() & 0x40) != 0) {
      return true;
    }
    if ((c instanceof Composite)) {
      return ((Composite)c).getLayout() instanceof ILayoutExtension;
    }
    return false;
  }
  
  public static int getWidthHint(int wHint, Control c)
  {
    boolean wrap = isWrapControl(c);
    return wrap ? wHint : -1;
  }
  
  public static int getHeightHint(int hHint, Control c)
  {
    if ((c instanceof Composite))
    {
      Layout layout = ((Composite)c).getLayout();
      if ((layout instanceof ColumnLayout)) {
        return hHint;
      }
    }
    return -1;
  }
  
  public static int computeMinimumWidth(Control c, boolean changed)
  {
    if ((c instanceof Composite))
    {
      Layout layout = ((Composite)c).getLayout();
      if ((layout instanceof ILayoutExtension)) {
        return ((ILayoutExtension)layout).computeMinimumWidth(
          (Composite)c, changed);
      }
    }
    return computeSizegetWidthHint5-1x;
  }
  
  public static int computeMaximumWidth(Control c, boolean changed)
  {
    if ((c instanceof Composite))
    {
      Layout layout = ((Composite)c).getLayout();
      if ((layout instanceof ILayoutExtension)) {
        return ((ILayoutExtension)layout).computeMaximumWidth(
          (Composite)c, changed);
      }
    }
    return computeSize-1-1x;
  }
  
  public static Form getForm(Control c)
  {
    Composite parent = c.getParent();
    while (parent != null)
    {
      if ((parent instanceof Form)) {
        return (Form)parent;
      }
      parent = parent.getParent();
    }
    return null;
  }
  
  public static Image createAlphaMashImage(Device device, Image srcImage)
  {
    Rectangle bounds = srcImage.getBounds();
    int alpha = 0;
    int calpha = 0;
    ImageData data = srcImage.getImageData();
    for (int i = 0; i < height; i++)
    {
      alpha = calpha;
      for (int j = 0; j < width; j++)
      {
        data.setAlpha(j, i, alpha);
        alpha = alpha == 255 ? 0 : 255;
      }
      calpha = calpha == 255 ? 0 : 255;
    }
    return new Image(device, data);
  }
  
  public static boolean mnemonicMatch(String text, char key)
  {
    char mnemonic = findMnemonic(text);
    if (mnemonic == 0) {
      return false;
    }
    return Character.toUpperCase(key) == Character.toUpperCase(mnemonic);
  }
  
  private static char findMnemonic(String string)
  {
    int index = 0;
    int length = string.length();
    do
    {
      while ((index < length) && (string.charAt(index) != '&')) {
        index++;
      }
      index++;
      if (index >= length) {
        return '\000';
      }
      if (string.charAt(index) != '&') {
        return string.charAt(index);
      }
      index++;
    } while (index < length);
    return '\000';
  }
  
  public static void setFocusScrollingEnabled(Control c, boolean enabled)
  {
    ScrolledComposite scomp = null;
    if ((c instanceof ScrolledComposite)) {
      scomp = (ScrolledComposite)c;
    } else {
      scomp = getScrolledComposite(c);
    }
    if (scomp != null) {
      scomp.setData("focusScrolling", enabled ? null : Boolean.FALSE);
    }
  }
  
  public static void setAntialias(GC gc, int style)
  {
    if (!gc.getAdvanced())
    {
      gc.setAdvanced(true);
      if (!gc.getAdvanced()) {
        return;
      }
    }
    gc.setAntialias(style);
  }
}

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

import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Display;

public class FormsResources
{
  private static Cursor busyCursor;
  private static Cursor handCursor;
  private static Cursor textCursor;
  
  public static Cursor getBusyCursor()
  {
    if (busyCursor == null) {
      busyCursor = new Cursor(Display.getCurrent(), 1);
    }
    return busyCursor;
  }
  
  public static Cursor getHandCursor()
  {
    if (handCursor == null) {
      handCursor = new Cursor(Display.getCurrent(), 21);
    }
    return handCursor;
  }
  
  public static Cursor getTextCursor()
  {
    if (textCursor == null) {
      textCursor = new Cursor(Display.getCurrent(), 19);
    }
    return textCursor;
  }
  
  public static int getProgressDelay(int index)
  {
    return 100;
  }
  
  public static void shutdown()
  {
    if (busyCursor != null) {
      busyCursor.dispose();
    }
    if (handCursor != null) {
      handCursor.dispose();
    }
    if (textCursor != null) {
      textCursor.dispose();
    }
    busyCursor = null;
    handCursor = null;
    textCursor = null;
  }
}

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

import java.util.Hashtable;
import org.eclipse.swt.graphics.Rectangle;

public abstract interface IFocusSelectable
{
  public abstract boolean isFocusSelectable(Hashtable paramHashtable);
  
  public abstract boolean setFocus(Hashtable paramHashtable, boolean paramBoolean);
  
  public abstract Rectangle getBounds();
}

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

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

public abstract interface IHyperlinkSegment
  extends IFocusSelectable
{
  public abstract String getHref();
  
  public abstract String getText();
  
  public abstract void paintFocus(GC paramGC, Color paramColor1, Color paramColor2, boolean paramBoolean, Rectangle paramRectangle);
  
  public abstract boolean contains(int paramInt1, int paramInt2);
  
  public abstract boolean intersects(Rectangle paramRectangle);
}

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

import java.util.Hashtable;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

public class ImageHyperlinkSegment
  extends ImageSegment
  implements IHyperlinkSegment
{
  private String href;
  private String text;
  private String tooltipText;
  
  public void setHref(String href)
  {
    this.href = href;
  }
  
  public String getHref()
  {
    return href;
  }
  
  public void paintFocus(GC gc, Color bg, Color fg, boolean selected, Rectangle repaintRegion)
  {
    Rectangle bounds = getBounds();
    if (bounds == null) {
      return;
    }
    if (selected)
    {
      gc.setBackground(bg);
      gc.setForeground(fg);
      gc.drawFocus(x, y, width, height);
    }
    else
    {
      gc.setForeground(bg);
      gc.drawRectangle(x, y, width - 1, 
        height - 1);
    }
  }
  
  public boolean isWordWrapAllowed()
  {
    return !isNowrap();
  }
  
  public void setWordWrapAllowed(boolean value)
  {
    setNowrap(!value);
  }
  
  public String getText()
  {
    return text != null ? text : "";
  }
  
  public void setText(String text)
  {
    this.text = text;
  }
  
  public String getTooltipText()
  {
    return tooltipText;
  }
  
  public void setTooltipText(String tooltipText)
  {
    this.tooltipText = tooltipText;
  }
  
  public boolean isSelectable()
  {
    return true;
  }
  
  public boolean isFocusSelectable(Hashtable resourceTable)
  {
    return true;
  }
  
  public boolean setFocus(Hashtable resourceTable, boolean direction)
  {
    return true;
  }
}

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

import java.util.Hashtable;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

public class ImageSegment
  extends ObjectSegment
{
  public static final String SEL_IMAGE_PREFIX = "isel.";
  
  public Image getImage(Hashtable objectTable)
  {
    return getImage(getObjectId(), objectTable);
  }
  
  private Image getImage(String key, Hashtable objectTable)
  {
    if (key == null) {
      return null;
    }
    Object obj = objectTable.get(key);
    if (obj == null) {
      return null;
    }
    if ((obj instanceof Image)) {
      return (Image)obj;
    }
    return null;
  }
  
  private Image getSelectedImage(Hashtable objectTable, SelectionData selData)
  {
    String key = "isel." + getObjectId();
    Image image = getImage(key, objectTable);
    if (image == null)
    {
      image = FormUtil.createAlphaMashImage(display, getImage(objectTable));
      if (image != null) {
        objectTable.put(key, image);
      }
    }
    return image;
  }
  
  public void paint(GC gc, boolean hover, Hashtable resourceTable, boolean selected, SelectionData selData, Rectangle repaintRegion)
  {
    Image image = getImage(resourceTable);
    int iwidth = 0;
    int iheight = 0;
    if (image != null)
    {
      Rectangle rect = image.getBounds();
      iwidth = width + (isSelectable() ? 2 : 0);
      iheight = height + (isSelectable() ? 2 : 0);
    }
    else
    {
      return;
    }
    Rectangle bounds = getBounds();
    int ix = x + (isSelectable() ? 1 : 0);
    int iy = y + (isSelectable() ? 1 : 0);
    if (selData != null)
    {
      int leftOffset = selData.getLeftOffset(height);
      int rightOffset = selData.getRightOffset(height);
      boolean firstRow = selData.isFirstSelectionRow(y, 
        height);
      boolean lastRow = selData.isLastSelectionRow(y, 
        height);
      boolean selectedRow = selData
        .isSelectedRow(y, height);
      if (selectedRow)
      {
        if (((firstRow) && (leftOffset > ix)) || (
          (lastRow) && (rightOffset < ix + iwidth / 2)))
        {
          drawClipImage(gc, image, ix, iy, repaintRegion);
        }
        else
        {
          Color savedBg = gc.getBackground();
          gc.setBackground(bg);
          int sx = ix;
          int sy = iy;
          if (repaintRegion != null)
          {
            sx -= x;
            sy -= y;
          }
          gc.fillRectangle(sx, sy, iwidth, iheight);
          Image selImage = getSelectedImage(resourceTable, selData);
          gc.drawImage(selImage, sx, sy);
          gc.setBackground(savedBg);
        }
      }
      else {
        drawClipImage(gc, image, ix, iy, repaintRegion);
      }
    }
    else
    {
      drawClipImage(gc, image, ix, iy, repaintRegion);
    }
    if (selected)
    {
      int fx = x;
      int fy = y;
      if (repaintRegion != null)
      {
        fx -= x;
        fy -= y;
      }
      Color fg = gc.getForeground();
      gc.setForeground(gc.getBackground());
      
      gc.drawRectangle(x, y, width - 1, 
        height - 1);
      gc.setForeground(fg);
      gc.drawFocus(fx, fy, width, height);
    }
  }
  
  private void drawClipImage(GC gc, Image image, int ix, int iy, Rectangle repaintRegion)
  {
    if (repaintRegion != null)
    {
      ix -= x;
      iy -= y;
    }
    gc.drawImage(image, ix, iy);
  }
  
  protected Point getObjectSize(Hashtable resourceTable, int wHint)
  {
    Image image = getImage(resourceTable);
    if (image == null) {
      return new Point(0, 0);
    }
    Rectangle ibounds = image.getBounds();
    return new Point(width, height);
  }
}

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

import java.util.ArrayList;

public class Locator
  implements Cloneable
{
  public int indent;
  public int x;
  public int y;
  public int width;
  public int leading;
  public int rowHeight;
  public int marginWidth;
  public int marginHeight;
  public int rowCounter;
  public ArrayList heights;
  
  public void newLine()
  {
    resetCaret();
    y += rowHeight;
    rowHeight = 0;
  }
  
  public Locator create()
  {
    try
    {
      return (Locator)clone();
    }
    catch (CloneNotSupportedException localCloneNotSupportedException) {}
    return null;
  }
  
  public void collectHeights()
  {
    heights.add(new int[] { rowHeight, leading });
    rowCounter += 1;
  }
  
  public int getBaseline(int segmentHeight)
  {
    return getBaseline(segmentHeight, true);
  }
  
  public int getMiddle(int segmentHeight, boolean text)
  {
    if ((heights != null) && (heights.size() > rowCounter))
    {
      int[] rdata = (int[])heights.get(rowCounter);
      int rheight = rdata[0];
      int rleading = rdata[1];
      if (text) {
        return y + rheight / 2 - segmentHeight / 2 - rleading;
      }
      return y + rheight / 2 - segmentHeight / 2;
    }
    return y;
  }
  
  public int getBaseline(int segmentHeight, boolean text)
  {
    if ((heights != null) && (heights.size() > rowCounter))
    {
      int[] rdata = (int[])heights.get(rowCounter);
      int rheight = rdata[0];
      int rleading = rdata[1];
      if (text) {
        return y + rheight - segmentHeight - rleading;
      }
      return y + rheight - segmentHeight;
    }
    return y;
  }
  
  public void resetCaret()
  {
    x = getStartX();
  }
  
  public int getStartX()
  {
    return marginWidth + indent;
  }
}

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

import java.util.Hashtable;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

public abstract class ObjectSegment
  extends ParagraphSegment
{
  public static final int TOP = 1;
  public static final int MIDDLE = 2;
  public static final int BOTTOM = 3;
  private int alignment = 3;
  private boolean nowrap = false;
  private Rectangle bounds;
  private String objectId;
  
  public int getVerticalAlignment()
  {
    return alignment;
  }
  
  void setVerticalAlignment(int alignment)
  {
    this.alignment = alignment;
  }
  
  public String getObjectId()
  {
    return objectId;
  }
  
  void setObjectId(String objectId)
  {
    this.objectId = objectId;
  }
  
  protected abstract Point getObjectSize(Hashtable paramHashtable, int paramInt);
  
  public boolean advanceLocator(GC gc, int wHint, Locator loc, Hashtable objectTable, boolean computeHeightOnly)
  {
    Point objectSize = getObjectSize(objectTable, wHint);
    int iwidth = 0;
    int iheight = 0;
    boolean newLine = false;
    if (objectSize != null)
    {
      iwidth = x + (isSelectable() ? 2 : 0);
      iheight = y + (isSelectable() ? 2 : 0);
    }
    if ((wHint != -1) && (!nowrap) && (x + iwidth + marginWidth > wHint))
    {
      if (computeHeightOnly) {
        loc.collectHeights();
      }
      loc.resetCaret();
      x += iwidth;
      y += rowHeight;
      width = x;
      rowHeight = iheight;
      leading = 0;
      newLine = true;
    }
    else
    {
      x += iwidth;
      width += iwidth;
      rowHeight = Math.max(rowHeight, iheight);
    }
    return newLine;
  }
  
  public boolean contains(int x, int y)
  {
    if (bounds == null) {
      return false;
    }
    return bounds.contains(x, y);
  }
  
  public boolean intersects(Rectangle rect)
  {
    if (bounds == null) {
      return false;
    }
    return bounds.intersects(rect);
  }
  
  public Rectangle getBounds()
  {
    return bounds;
  }
  
  public boolean isSelectable()
  {
    return false;
  }
  
  public boolean isNowrap()
  {
    return nowrap;
  }
  
  public void setNowrap(boolean nowrap)
  {
    this.nowrap = nowrap;
  }
  
  public void paint(GC gc, boolean hover, Hashtable resourceTable, boolean selected, SelectionData selData, Rectangle repaintRegion) {}
  
  public void layout(GC gc, int width, Locator loc, Hashtable resourceTable, boolean selected)
  {
    Point size = getObjectSize(resourceTable, width);
    
    int objWidth = 0;
    int objHeight = 0;
    if (size != null)
    {
      objWidth = x + (isSelectable() ? 2 : 0);
      objHeight = y + (isSelectable() ? 2 : 0);
    }
    else
    {
      return;
    }
    width = objWidth;
    if ((!nowrap) && (x + objWidth + marginWidth > width))
    {
      loc.newLine();
      rowCounter += 1;
    }
    int ix = x;
    int iy = y;
    if (alignment == 2) {
      iy = loc.getMiddle(objHeight, false);
    } else if (alignment == 3) {
      iy = loc.getBaseline(objHeight, false);
    }
    x += objWidth;
    rowHeight = Math.max(rowHeight, objHeight);
    bounds = new Rectangle(ix, iy, objWidth, objHeight);
  }
  
  public void computeSelection(GC gc, Hashtable resourceTable, SelectionData selData) {}
}

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

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.forms.HyperlinkSettings;

public class Paragraph
{
  public static final String[] PROTOCOLS = { "http://", "https://", "ftp://" };
  private Vector segments;
  private boolean addVerticalSpace = true;
  
  public Paragraph(boolean addVerticalSpace)
  {
    this.addVerticalSpace = addVerticalSpace;
  }
  
  public int getIndent()
  {
    return 0;
  }
  
  public boolean getAddVerticalSpace()
  {
    return addVerticalSpace;
  }
  
  public ParagraphSegment[] getSegments()
  {
    if (segments == null) {
      return new ParagraphSegment[0];
    }
    return (ParagraphSegment[])segments
      .toArray(new ParagraphSegment[segments.size()]);
  }
  
  public void addSegment(ParagraphSegment segment)
  {
    if (segments == null) {
      segments = new Vector();
    }
    segments.add(segment);
  }
  
  public void parseRegularText(String text, boolean expandURLs, boolean wrapAllowed, HyperlinkSettings settings, String fontId)
  {
    parseRegularText(text, expandURLs, wrapAllowed, settings, fontId, null);
  }
  
  public void parseRegularText(String text, boolean expandURLs, boolean wrapAllowed, HyperlinkSettings settings, String fontId, String colorId)
  {
    if (text.length() == 0) {
      return;
    }
    if (expandURLs)
    {
      int loc = findUrl(text, 0);
      if (loc == -1)
      {
        addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
      }
      else
      {
        int textLoc = 0;
        while (loc != -1)
        {
          addSegment(new TextSegment(text.substring(textLoc, loc), 
            fontId, colorId, wrapAllowed));
          boolean added = false;
          for (textLoc = loc; textLoc < text.length(); textLoc++)
          {
            char c = text.charAt(textLoc);
            if (Character.isSpaceChar(c))
            {
              addHyperlinkSegment(text.substring(loc, textLoc), 
                settings, fontId);
              added = true;
              break;
            }
          }
          if (!added)
          {
            addHyperlinkSegment(text.substring(loc), settings, 
              fontId);
            break;
          }
          loc = findUrl(text, textLoc);
        }
        if (textLoc < text.length()) {
          addSegment(new TextSegment(text.substring(textLoc), fontId, 
            colorId, wrapAllowed));
        }
      }
    }
    else
    {
      addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
    }
  }
  
  private int findUrl(String text, int startIndex)
  {
    int[] locs = new int[PROTOCOLS.length];
    for (int i = 0; i < PROTOCOLS.length; i++) {
      locs[i] = text.indexOf(PROTOCOLS[i], startIndex);
    }
    Arrays.sort(locs);
    for (int i = 0; i < PROTOCOLS.length; i++) {
      if (locs[i] != -1) {
        return locs[i];
      }
    }
    return -1;
  }
  
  private void addHyperlinkSegment(String text, HyperlinkSettings settings, String fontId)
  {
    TextHyperlinkSegment hs = new TextHyperlinkSegment(text, settings, 
      fontId);
    hs.setWordWrapAllowed(false);
    hs.setHref(text);
    addSegment(hs);
  }
  
  protected void computeRowHeights(GC gc, int width, Locator loc, int lineHeight, Hashtable resourceTable)
  {
    ParagraphSegment[] segments = getSegments();
    
    Locator hloc = loc.create();
    ArrayList heights = new ArrayList();
    heights = heights;
    rowCounter = 0;
    for (int j = 0; j < segments.length; j++)
    {
      ParagraphSegment segment = segments[j];
      segment.advanceLocator(gc, width, hloc, resourceTable, true);
    }
    if (rowHeight == 0)
    {
      FontMetrics fm = gc.getFontMetrics();
      rowHeight = fm.getHeight();
    }
    hloc.collectHeights();
    heights = heights;
    rowCounter = 0;
  }
  
  public void layout(GC gc, int width, Locator loc, int lineHeight, Hashtable resourceTable, IHyperlinkSegment selectedLink)
  {
    ParagraphSegment[] segments = getSegments();
    if (segments.length > 0)
    {
      if (heights == null) {
        computeRowHeights(gc, width, loc, lineHeight, resourceTable);
      }
      for (int j = 0; j < segments.length; j++)
      {
        ParagraphSegment segment = segments[j];
        boolean doSelect = false;
        if ((selectedLink != null) && (segment.equals(selectedLink))) {
          doSelect = true;
        }
        segment.layout(gc, width, loc, resourceTable, doSelect);
      }
      heights = null;
      y += rowHeight;
    }
    else
    {
      y += lineHeight;
    }
  }
  
  public void paint(GC gc, Rectangle repaintRegion, Hashtable resourceTable, IHyperlinkSegment selectedLink, SelectionData selData)
  {
    ParagraphSegment[] segments = getSegments();
    for (int i = 0; i < segments.length; i++)
    {
      ParagraphSegment segment = segments[i];
      if (segment.intersects(repaintRegion))
      {
        boolean doSelect = false;
        if ((selectedLink != null) && (segment.equals(selectedLink))) {
          doSelect = true;
        }
        segment.paint(gc, false, resourceTable, doSelect, selData, repaintRegion);
      }
    }
  }
  
  public void computeSelection(GC gc, Hashtable resourceTable, IHyperlinkSegment selectedLink, SelectionData selData)
  {
    ParagraphSegment[] segments = getSegments();
    for (int i = 0; i < segments.length; i++)
    {
      ParagraphSegment segment = segments[i];
      
      segment.computeSelection(gc, resourceTable, selData);
    }
  }
  
  public String getAccessibleText()
  {
    ParagraphSegment[] segments = getSegments();
    StringWriter swriter = new StringWriter();
    PrintWriter writer = new PrintWriter(swriter);
    for (int i = 0; i < segments.length; i++)
    {
      ParagraphSegment segment = segments[i];
      if ((segment instanceof TextSegment))
      {
        String text = ((TextSegment)segment).getText();
        writer.print(text);
      }
    }
    writer.println();
    swriter.flush();
    return swriter.toString();
  }
  
  public ParagraphSegment findSegmentAt(int x, int y)
  {
    if (segments != null) {
      for (int i = 0; i < segments.size(); i++)
      {
        ParagraphSegment segment = (ParagraphSegment)segments.get(i);
        if (segment.contains(x, y)) {
          return segment;
        }
      }
    }
    return null;
  }
  
  public void clearCache(String fontId)
  {
    if (segments != null) {
      for (int i = 0; i < segments.size(); i++)
      {
        ParagraphSegment segment = (ParagraphSegment)segments.get(i);
        segment.clearCache(fontId);
      }
    }
  }
}

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

import java.util.Hashtable;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;

public abstract class ParagraphSegment
{
  public abstract boolean advanceLocator(GC paramGC, int paramInt, Locator paramLocator, Hashtable paramHashtable, boolean paramBoolean);
  
  public abstract void layout(GC paramGC, int paramInt, Locator paramLocator, Hashtable paramHashtable, boolean paramBoolean);
  
  public abstract void paint(GC paramGC, boolean paramBoolean1, Hashtable paramHashtable, boolean paramBoolean2, SelectionData paramSelectionData, Rectangle paramRectangle);
  
  public abstract void computeSelection(GC paramGC, Hashtable paramHashtable, SelectionData paramSelectionData);
  
  public abstract boolean contains(int paramInt1, int paramInt2);
  
  public abstract boolean intersects(Rectangle paramRectangle);
  
  public String getTooltipText()
  {
    return null;
  }
  
  public void clearCache(String fontId) {}
}

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

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.swt.widgets.Display;

public class ResourceManagerManger
{
  private HashMap resourceManagers;
  
  public LocalResourceManager getResourceManager(Display display)
  {
    if (resourceManagers == null) {
      resourceManagers = new HashMap();
    }
    LocalResourceManager resources = (LocalResourceManager)resourceManagers.get(display);
    if (resources == null)
    {
      pruneResourceManagers();
      resources = new LocalResourceManager(JFaceResources.getResources(display));
      resourceManagers.put(display, resources);
    }
    return resources;
  }
  
  private void pruneResourceManagers()
  {
    Set displays = resourceManagers.keySet();
    for (Iterator iter = displays.iterator(); iter.hasNext();)
    {
      Display display = (Display)iter.next();
      if (display.isDisposed())
      {
        resourceManagers.remove(display);
        iter = displays.iterator();
      }
    }
  }
}

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

import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Caret;
import org.eclipse.swt.wi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

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