Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 160474 Details for
Bug 158331
Get rid of copied HTML rendering classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix
patch.txt (text/plain), 52.78 KB, created by
Dani Megert
on 2010-03-01 07:28:47 EST
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
Dani Megert
Created:
2010-03-01 07:28:47 EST
Size:
52.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/TypeCompletionProposal.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/contentassist/TypeCompletionProposal.java,v >retrieving revision 1.12 >diff -u -r1.12 TypeCompletionProposal.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/TypeCompletionProposal.java 21 Sep 2009 14:34:22 -0000 1.12 >+++ src/org/eclipse/pde/internal/ui/editor/contentassist/TypeCompletionProposal.java 1 Mar 2010 12:25:47 -0000 >@@ -13,10 +13,10 @@ > > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.internal.text.html.BrowserInformationControl; >+import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.text.*; > import org.eclipse.jface.text.contentassist.*; >-import org.eclipse.pde.internal.ui.editor.contentassist.display.BrowserInformationControl; >-import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Shell; >@@ -112,9 +112,6 @@ > } > > public IInformationControlCreator getInformationControlCreator() { >- if (!BrowserInformationControl.isAvailable(null)) >- return null; >- > if (fCreator == null) { > fCreator = new AbstractReusableInformationControlCreator() { > >@@ -122,7 +119,9 @@ > * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell) > */ > public IInformationControl doCreateInformationControl(Shell parent) { >- return new BrowserInformationControl(parent, SWT.NO_TRIM | SWT.TOOL, SWT.NONE, null); >+ if (BrowserInformationControl.isAvailable(parent)) >+ return new BrowserInformationControl(parent, JFaceResources.DIALOG_FONT, false); >+ return new DefaultInformationControl(parent, false); > } > }; > } >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/XMLCompletionProposal.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/contentassist/XMLCompletionProposal.java,v >retrieving revision 1.28 >diff -u -r1.28 XMLCompletionProposal.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/XMLCompletionProposal.java 21 Sep 2009 14:34:22 -0000 1.28 >+++ src/org/eclipse/pde/internal/ui/editor/contentassist/XMLCompletionProposal.java 1 Mar 2010 12:25:47 -0000 >@@ -16,6 +16,9 @@ > import java.util.Stack; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.internal.text.html.BrowserInformationControl; >+import org.eclipse.jface.internal.text.html.HTMLPrinter; >+import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.text.*; > import org.eclipse.jface.text.contentassist.*; > import org.eclipse.pde.core.IBaseModel; >@@ -26,11 +29,8 @@ > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.pde.internal.ui.editor.PDESourcePage; >-import org.eclipse.pde.internal.ui.editor.contentassist.display.BrowserInformationControl; >-import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter; > import org.eclipse.pde.internal.ui.editor.text.XMLUtil; > import org.eclipse.pde.internal.ui.util.TextUtil; >-import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Shell; >@@ -518,13 +518,12 @@ > } > > public IInformationControlCreator getInformationControlCreator() { >- if (!BrowserInformationControl.isAvailable(null)) >- return null; >- > if (fCreator == null) { > fCreator = new AbstractReusableInformationControlCreator() { > public IInformationControl doCreateInformationControl(Shell parent) { >- return new BrowserInformationControl(parent, SWT.NO_TRIM | SWT.TOOL, SWT.NONE); >+ if (BrowserInformationControl.isAvailable(parent)) >+ return new BrowserInformationControl(parent, JFaceResources.DIALOG_FONT, false); >+ return new DefaultInformationControl(parent, false); > } > }; > } >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java >diff -N src/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java 26 Feb 2010 14:37:55 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,560 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2010 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.contentassist.display; >- >-import java.io.IOException; >-import java.io.StringReader; >-import java.util.Iterator; >-import org.eclipse.core.runtime.ListenerList; >-import org.eclipse.jface.text.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.SWTError; >-import org.eclipse.swt.browser.*; >-import org.eclipse.swt.custom.StyleRange; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.graphics.*; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.*; >- >-/** >- * Displays textual information in a {@link org.eclipse.swt.browser.Browser} >- * widget. >- * >- * <p> >- * This class may be instantiated; it is not intended to be subclassed. >- * </p> >- * <p> >- * Current problems: >- * - the size computation is too small >- * - focusLost event is not sent (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532) >- * </p> >- * >- * @since 3.1 >- */ >-public class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener { >- >- /** >- * Tells whether the SWT Browser widget and hence this information >- * control is available. >- * >- * @param parent the parent component used for checking or <code>null</code> if none >- * @return <code>true</code> if this control is available >- */ >- public static boolean isAvailable(Composite parent) { >- if (!fgAvailabilityChecked) { >- try { >- if (parent == null) >- parent = PDEPlugin.getActiveWorkbenchShell(); >- if (parent == null) >- return false; // don't store this value - try again later >- >- Browser browser = new Browser(parent, SWT.NONE); >- browser.dispose(); >- fgIsAvailable = true; >- } catch (SWTError er) { >- fgIsAvailable = false; >- } finally { >- fgAvailabilityChecked = true; >- } >- } >- >- return fgIsAvailable; >- } >- >- /** Border thickness in pixels. */ >- private static final int BORDER = 1; >- >- /** >- * Minimal size constraints. >- * @since 3.2 >- */ >- private static final int MIN_WIDTH = 80; >- private static final int MIN_HEIGHT = 80; >- >- /** >- * Availability checking cache. >- */ >- private static boolean fgIsAvailable = false; >- private static boolean fgAvailabilityChecked = false; >- >- /** The control's shell */ >- private Shell fShell; >- /** The control's browser widget */ >- private Browser fBrowser; >- /** Tells whether the browser has content */ >- private boolean fBrowserHasContent; >- /** The control width constraint */ >- private int fMaxWidth = -1; >- /** The control height constraint */ >- private int fMaxHeight = -1; >- private Font fStatusTextFont; >- private Label fStatusTextField; >- private String fStatusFieldText; >- private boolean fHideScrollBars; >- private Listener fDeactivateListener; >- private ListenerList fFocusListeners = new ListenerList(); >- private Label fSeparator; >- private String fInputText; >- private TextLayout fTextLayout; >- >- private TextStyle fBoldStyle; >- >- /** >- * Creates a default information control with the given shell as parent. The given >- * information presenter is used to process the information to be displayed. The given >- * styles are applied to the created styled text widget. >- * >- * @param parent the parent shell >- * @param shellStyle the additional styles for the shell >- * @param style the additional styles for the styled text widget >- */ >- public BrowserInformationControl(Shell parent, int shellStyle, int style) { >- this(parent, shellStyle, style, null); >- } >- >- /** >- * Creates a default information control with the given shell as parent. The given >- * information presenter is used to process the information to be displayed. The given >- * styles are applied to the created styled text widget. >- * >- * @param parent the parent shell >- * @param shellStyle the additional styles for the shell >- * @param style the additional styles for the styled text widget >- * @param statusFieldText the text to be used in the optional status field >- * or <code>null</code> if the status field should be hidden >- */ >- public BrowserInformationControl(Shell parent, int shellStyle, int style, String statusFieldText) { >- fStatusFieldText = statusFieldText; >- >- fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle); >- Display display = fShell.getDisplay(); >- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); >- >- Composite composite = fShell; >- GridLayout layout = new GridLayout(1, false); >- int border = ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER; >- layout.marginHeight = border; >- layout.marginWidth = border; >- composite.setLayout(layout); >- >- if (statusFieldText != null) { >- composite = new Composite(composite, SWT.NONE); >- layout = new GridLayout(1, false); >- layout.marginHeight = 0; >- layout.marginWidth = 0; >- layout.verticalSpacing = 1; >- layout.horizontalSpacing = 1; >- composite.setLayout(layout); >- >- GridData gd = new GridData(GridData.FILL_BOTH); >- composite.setLayoutData(gd); >- >- composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >- composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- } >- >- // Browser field >- fBrowser = new Browser(composite, SWT.NONE); >- >- // Disable javascript for security reasons, see bug 265808 >- fBrowser.setJavascriptEnabled(false); >- >- fHideScrollBars = (style & SWT.V_SCROLL) == 0 && (style & SWT.H_SCROLL) == 0; >- >- GridData gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH); >- fBrowser.setLayoutData(gd); >- >- fBrowser.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); >- fBrowser.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- >- /* >- * XXX revisit when the Browser support is better >- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=107629. Choosing a link to a >- * non-available target will show an error dialog behind the ON_TOP shell that seemingly >- * blocks the workbench. Disable links completely for now. >- */ >- fBrowser.addLocationListener(new LocationAdapter() { >- /* >- * @see org.eclipse.swt.browser.LocationAdapter#changing(org.eclipse.swt.browser.LocationEvent) >- */ >- public void changing(LocationEvent event) { >- String location = event.location; >- if (!"about:blank".equals(location)) //$NON-NLS-1$ >- event.doit = false; >- } >- }); >- >- // Replace browser's built-in context menu with none >- fBrowser.setMenu(new Menu(fShell, SWT.NONE)); >- >- // Status field >- if (statusFieldText != null) { >- >- fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT); >- fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- >- // Status field label >- fStatusTextField = new Label(composite, SWT.RIGHT); >- fStatusTextField.setText(statusFieldText); >- Font font = fStatusTextField.getFont(); >- FontData[] fontDatas = font.getFontData(); >- for (int i = 0; i < fontDatas.length; i++) >- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); >- fStatusTextFont = new Font(fStatusTextField.getDisplay(), fontDatas); >- fStatusTextField.setFont(fStatusTextFont); >- gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); >- fStatusTextField.setLayoutData(gd); >- >- fStatusTextField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); >- >- fStatusTextField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >- } >- >- addDisposeListener(this); >- createTextLayout(); >- } >- >- /** >- * Creates a default information control with the given shell as parent. The given >- * information presenter is used to process the information to be displayed. The given >- * styles are applied to the created styled text widget. >- * >- * @param parent the parent shell >- * @param style the additional styles for the browser widget >- */ >- public BrowserInformationControl(Shell parent, int style) { >- this(parent, SWT.TOOL | SWT.NO_TRIM, style); >- } >- >- /** >- * Creates a default information control with the given shell as parent. >- * No information presenter is used to process the information >- * to be displayed. No additional styles are applied to the styled text widget. >- * >- * @param parent the parent shell >- */ >- public BrowserInformationControl(Shell parent) { >- this(parent, SWT.NONE); >- } >- >- /* >- * @see IInformationControl#setInformation(String) >- */ >- public void setInformation(String content) { >- fBrowserHasContent = content != null && content.length() > 0; >- >- if (!fBrowserHasContent) >- content = "<html><body ></html>"; //$NON-NLS-1$ >- >- fInputText = content; >- >- int shellStyle = fShell.getStyle(); >- boolean RTL = (shellStyle & SWT.RIGHT_TO_LEFT) != 0; >- >- String[] styles = null; >- if (RTL && !fHideScrollBars) >- styles = new String[] {"direction:rtl;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$ >- else if (RTL && fHideScrollBars) >- styles = new String[] {"direction:rtl;", "overflow:hidden;", "word-wrap:break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- else if (fHideScrollBars && true) >- styles = new String[] {"overflow:hidden;", "word-wrap: break-word;"}; //$NON-NLS-1$ //$NON-NLS-2$ >- >- if (styles != null) { >- StringBuffer buffer = new StringBuffer(content); >- HTMLPrinter.insertStyles(buffer, styles); >- content = buffer.toString(); >- } >- >- fBrowser.setText(content); >- >- } >- >- /* >- * @see org.eclipse.jdt.internal.ui.text.IInformationControlExtension4#setStatusText(java.lang.String) >- * @since 3.2 >- */ >- public void setStatusText(String statusFieldText) { >- fStatusFieldText = statusFieldText; >- } >- >- /* >- * @see IInformationControl#setVisible(boolean) >- */ >- public void setVisible(boolean visible) { >- if (fShell.isVisible() == visible) >- return; >- >- if (visible) { >- if (fStatusTextField != null) { >- boolean state = fStatusFieldText != null; >- if (state) >- fStatusTextField.setText(fStatusFieldText); >- fStatusTextField.setVisible(state); >- fSeparator.setVisible(state); >- } >- } >- >- fShell.setVisible(visible); >- if (!visible) >- setInformation(""); //$NON-NLS-1$ >- } >- >- /** >- * Creates and initializes the text layout used >- * to compute the size hint. >- * >- * @since 3.2 >- */ >- private void createTextLayout() { >- fTextLayout = new TextLayout(fBrowser.getDisplay()); >- >- // Initialize fonts >- Font font = fBrowser.getFont(); >- fTextLayout.setFont(font); >- fTextLayout.setWidth(-1); >- FontData[] fontData = font.getFontData(); >- for (int i = 0; i < fontData.length; i++) >- fontData[i].setStyle(SWT.BOLD); >- font = new Font(fShell.getDisplay(), fontData); >- fBoldStyle = new TextStyle(font, null, null); >- >- // Compute and set tab width >- fTextLayout.setText(" "); //$NON-NLS-1$ >- int tabWidth = fTextLayout.getBounds().width; >- fTextLayout.setTabs(new int[] {tabWidth}); >- >- fTextLayout.setText(""); //$NON-NLS-1$ >- } >- >- /* >- * @see IInformationControl#dispose() >- */ >- public void dispose() { >- if (fTextLayout != null) { >- fTextLayout.dispose(); >- fTextLayout = null; >- } >- fBoldStyle.font.dispose(); >- fBoldStyle = null; >- if (fShell != null && !fShell.isDisposed()) >- fShell.dispose(); >- else >- widgetDisposed(null); >- } >- >- /* >- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) >- */ >- public void widgetDisposed(DisposeEvent event) { >- if (fTextLayout != null) { >- fTextLayout.dispose(); >- fTextLayout = null; >- } >- >- if (fStatusTextFont != null && !fStatusTextFont.isDisposed()) >- fStatusTextFont.dispose(); >- >- fShell = null; >- fBrowser = null; >- fStatusTextFont = null; >- } >- >- /* >- * @see IInformationControl#setSize(int, int) >- */ >- public void setSize(int width, int height) { >- fShell.setSize(Math.min(width, fMaxWidth), Math.min(height, fMaxHeight)); >- } >- >- /* >- * @see IInformationControl#setLocation(Point) >- */ >- public void setLocation(Point location) { >- fShell.setLocation(location); >- } >- >- /* >- * @see IInformationControl#setSizeConstraints(int, int) >- */ >- public void setSizeConstraints(int maxWidth, int maxHeight) { >- fMaxWidth = maxWidth; >- fMaxHeight = maxHeight; >- } >- >- /* >- * @see IInformationControl#computeSizeHint() >- */ >- public Point computeSizeHint() { >- TextPresentation presentation = new TextPresentation(); >- HTML2TextReader reader = new HTML2TextReader(new StringReader(fInputText), presentation); >- String text; >- try { >- text = reader.getString(); >- } catch (IOException e) { >- text = ""; //$NON-NLS-1$ >- } >- >- fTextLayout.setText(text); >- Iterator iter = presentation.getAllStyleRangeIterator(); >- while (iter.hasNext()) { >- StyleRange sr = (StyleRange) iter.next(); >- if (sr.fontStyle == SWT.BOLD) >- fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1); >- } >- Rectangle bounds = fTextLayout.getBounds(); >- int width = bounds.width; >- int height = bounds.height; >- >- width += 15; >- height += 25; >- >- if (fStatusFieldText != null && fSeparator != null) { >- fTextLayout.setText(fStatusFieldText); >- Rectangle statusBounds = fTextLayout.getBounds(); >- Rectangle separatorBounds = fSeparator.getBounds(); >- width = Math.max(width, statusBounds.width); >- height = height + statusBounds.height + separatorBounds.height; >- } >- >- // Apply size constraints >- if (fMaxWidth != SWT.DEFAULT) >- width = Math.min(fMaxWidth, width); >- if (fMaxHeight != SWT.DEFAULT) >- height = Math.min(fMaxHeight, height); >- >- // Ensure minimal size >- width = Math.max(MIN_WIDTH, width); >- height = Math.max(MIN_HEIGHT, height); >- >- return new Point(width, height); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim() >- */ >- public Rectangle computeTrim() { >- return fShell.computeTrim(0, 0, 0, 0); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds() >- */ >- public Rectangle getBounds() { >- return fShell.getBounds(); >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation() >- */ >- public boolean restoresLocation() { >- return false; >- } >- >- /* >- * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize() >- */ >- public boolean restoresSize() { >- return false; >- } >- >- /* >- * @see IInformationControl#addDisposeListener(DisposeListener) >- */ >- public void addDisposeListener(DisposeListener listener) { >- fShell.addDisposeListener(listener); >- } >- >- /* >- * @see IInformationControl#removeDisposeListener(DisposeListener) >- */ >- public void removeDisposeListener(DisposeListener listener) { >- fShell.removeDisposeListener(listener); >- } >- >- /* >- * @see IInformationControl#setForegroundColor(Color) >- */ >- public void setForegroundColor(Color foreground) { >- fBrowser.setForeground(foreground); >- } >- >- /* >- * @see IInformationControl#setBackgroundColor(Color) >- */ >- public void setBackgroundColor(Color background) { >- fBrowser.setBackground(background); >- } >- >- /* >- * @see IInformationControl#isFocusControl() >- */ >- public boolean isFocusControl() { >- return fBrowser.isFocusControl(); >- } >- >- /* >- * @see IInformationControl#setFocus() >- */ >- public void setFocus() { >- fShell.forceFocus(); >- fBrowser.setFocus(); >- } >- >- /* >- * @see IInformationControl#addFocusListener(FocusListener) >- */ >- public void addFocusListener(final FocusListener listener) { >- fBrowser.addFocusListener(listener); >- >- /* >- * FIXME: This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532 >- * (Browser widget does not send focusLost event) >- */ >- if (fFocusListeners.isEmpty()) { >- fDeactivateListener = new Listener() { >- public void handleEvent(Event event) { >- Object[] listeners = fFocusListeners.getListeners(); >- for (int i = 0; i < listeners.length; i++) >- ((FocusListener) listeners[i]).focusLost(new FocusEvent(event)); >- } >- }; >- fBrowser.getShell().addListener(SWT.Deactivate, fDeactivateListener); >- } >- fFocusListeners.add(listener); >- } >- >- /* >- * @see IInformationControl#removeFocusListener(FocusListener) >- */ >- public void removeFocusListener(FocusListener listener) { >- fBrowser.removeFocusListener(listener); >- >- /* >- * FIXME: This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532 >- * (Browser widget does not send focusLost event) >- */ >- fFocusListeners.remove(listener); >- if (fFocusListeners.isEmpty()) { >- fBrowser.getShell().removeListener(SWT.Deactivate, fDeactivateListener); >- fDeactivateListener = null; >- } >- } >- >- /* >- * @see IInformationControlExtension#hasContents() >- */ >- public boolean hasContents() { >- return fBrowserHasContent; >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/display/HTML2TextReader.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/contentassist/display/HTML2TextReader.java >diff -N src/org/eclipse/pde/internal/ui/editor/contentassist/display/HTML2TextReader.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/display/HTML2TextReader.java 27 May 2009 20:38:23 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,312 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.contentassist.display; >- >-import java.io.*; >-import java.util.*; >-import org.eclipse.jface.text.TextPresentation; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.StyleRange; >- >-/** >- * Reads the text contents from a reader of HTML contents and translates >- * the tags or cut them out. >- */ >-public class HTML2TextReader extends SubstitutionTextReader { >- >- private static final String EMPTY_STRING = ""; //$NON-NLS-1$ >- private static final Map fgEntityLookup; >- private static final Set fgTags; >- >- static { >- >- fgTags = new HashSet(); >- fgTags.add("b"); //$NON-NLS-1$ >- fgTags.add("br"); //$NON-NLS-1$ >- fgTags.add("br/"); //$NON-NLS-1$ >- fgTags.add("div"); //$NON-NLS-1$ >- fgTags.add("h1"); //$NON-NLS-1$ >- fgTags.add("h2"); //$NON-NLS-1$ >- fgTags.add("h3"); //$NON-NLS-1$ >- fgTags.add("h4"); //$NON-NLS-1$ >- fgTags.add("h5"); //$NON-NLS-1$ >- fgTags.add("p"); //$NON-NLS-1$ >- fgTags.add("dl"); //$NON-NLS-1$ >- fgTags.add("dt"); //$NON-NLS-1$ >- fgTags.add("dd"); //$NON-NLS-1$ >- fgTags.add("li"); //$NON-NLS-1$ >- fgTags.add("ul"); //$NON-NLS-1$ >- fgTags.add("pre"); //$NON-NLS-1$ >- fgTags.add("head"); //$NON-NLS-1$ >- >- fgEntityLookup = new HashMap(7); >- fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$ >- fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$ >- fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$ >- fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$ >- fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$ >- fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$ >- fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- >- private int fCounter = 0; >- private TextPresentation fTextPresentation; >- private int fBold = 0; >- private int fStartOffset = -1; >- private boolean fInParagraph = false; >- private boolean fIsPreformattedText = false; >- private boolean fIgnore = false; >- >- /** >- * Transforms the HTML text from the reader to formatted text. >- * >- * @param reader the reader >- * @param presentation If not <code>null</code>, formattings will be applied to >- * the presentation. >- */ >- public HTML2TextReader(Reader reader, TextPresentation presentation) { >- super(new PushbackReader(reader)); >- fTextPresentation = presentation; >- } >- >- public int read() throws IOException { >- int c = super.read(); >- if (c != -1) >- ++fCounter; >- return c; >- } >- >- protected void startBold() { >- if (fBold == 0) >- fStartOffset = fCounter; >- ++fBold; >- } >- >- protected void startPreformattedText() { >- fIsPreformattedText = true; >- setSkipWhitespace(false); >- } >- >- protected void stopPreformattedText() { >- fIsPreformattedText = false; >- setSkipWhitespace(true); >- } >- >- protected void stopBold() { >- --fBold; >- if (fBold == 0) { >- if (fTextPresentation != null) { >- fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD)); >- } >- fStartOffset = -1; >- } >- } >- >- /* >- * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) >- */ >- protected String computeSubstitution(int c) throws IOException { >- >- if (c == '<') >- return processHTMLTag(); >- else if (fIgnore) >- return EMPTY_STRING; >- else if (c == '&') >- return processEntity(); >- else if (fIsPreformattedText) >- return processPreformattedText(c); >- >- return null; >- } >- >- private String html2Text(String html) { >- >- if (html == null || html.length() == 0) >- return EMPTY_STRING; >- >- html = html.toLowerCase(); >- >- String tag = html; >- if ('/' == tag.charAt(0)) >- tag = tag.substring(1); >- >- if (!fgTags.contains(tag)) >- return EMPTY_STRING; >- >- if ("pre".equals(html)) { //$NON-NLS-1$ >- startPreformattedText(); >- return EMPTY_STRING; >- } >- >- if ("/pre".equals(html)) { //$NON-NLS-1$ >- stopPreformattedText(); >- return EMPTY_STRING; >- } >- >- if (fIsPreformattedText) >- return EMPTY_STRING; >- >- if ("b".equals(html)) { //$NON-NLS-1$ >- startBold(); >- return EMPTY_STRING; >- } >- >- if ((html.length() > 1 && html.charAt(0) == 'h' && Character.isDigit(html.charAt(1))) || "dt".equals(html)) { //$NON-NLS-1$ >- startBold(); >- return EMPTY_STRING; >- } >- >- if ("dl".equals(html)) //$NON-NLS-1$ >- return LINE_DELIM; >- >- if ("dd".equals(html)) //$NON-NLS-1$ >- return "\t"; //$NON-NLS-1$ >- >- if ("li".equals(html)) //$NON-NLS-1$ >- // FIXME: this hard-coded prefix does not work for RTL languages, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=91682 >- return LINE_DELIM + "\t- "; //$NON-NLS-1$ >- >- if ("/b".equals(html)) { //$NON-NLS-1$ >- stopBold(); >- return EMPTY_STRING; >- } >- >- if ("p".equals(html)) { //$NON-NLS-1$ >- fInParagraph = true; >- return LINE_DELIM; >- } >- >- if ("br".equals(html) || "br/".equals(html) || "div".equals(html)) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- return LINE_DELIM; >- >- if ("/p".equals(html)) { //$NON-NLS-1$ >- boolean inParagraph = fInParagraph; >- fInParagraph = false; >- return inParagraph ? EMPTY_STRING : LINE_DELIM; >- } >- >- if ((html.startsWith("/h") && html.length() > 2 && Character.isDigit(html.charAt(2))) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$ >- stopBold(); >- return LINE_DELIM; >- } >- >- if ("/dd".equals(html)) //$NON-NLS-1$ >- return LINE_DELIM; >- >- if ("head".equals(html)) { //$NON-NLS-1$ >- fIgnore = true; >- return EMPTY_STRING; >- } >- >- if ("/head".equals(html)) { //$NON-NLS-1$ >- fIgnore = false; >- return EMPTY_STRING; >- } >- >- return EMPTY_STRING; >- } >- >- /* >- * A '<' has been read. Process a html tag >- */ >- private String processHTMLTag() throws IOException { >- >- StringBuffer buf = new StringBuffer(); >- int ch; >- do { >- >- ch = nextChar(); >- >- while (ch != -1 && ch != '>') { >- buf.append(Character.toLowerCase((char) ch)); >- ch = nextChar(); >- if (ch == '"') { >- buf.append(Character.toLowerCase((char) ch)); >- ch = nextChar(); >- while (ch != -1 && ch != '"') { >- buf.append(Character.toLowerCase((char) ch)); >- ch = nextChar(); >- } >- } >- if (ch == '<') { >- unread(ch); >- return '<' + buf.toString(); >- } >- } >- >- if (ch == -1) >- return null; >- >- int tagLen = buf.length(); >- // needs special treatment for comments >- if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$ >- && !(tagLen >= 5 && "--".equals(buf.substring(tagLen - 2)))) { //$NON-NLS-1$ >- // unfinished comment >- buf.append(ch); >- } else { >- break; >- } >- } while (true); >- >- return html2Text(buf.toString()); >- } >- >- private String processPreformattedText(int c) { >- if (c == '\r' || c == '\n') >- fCounter++; >- return null; >- } >- >- private void unread(int ch) throws IOException { >- ((PushbackReader) getReader()).unread(ch); >- } >- >- protected String entity2Text(String symbol) { >- if (symbol.length() > 1 && symbol.charAt(0) == '#') { >- int ch; >- try { >- if (symbol.charAt(1) == 'x') { >- ch = Integer.parseInt(symbol.substring(2), 16); >- } else { >- ch = Integer.parseInt(symbol.substring(1), 10); >- } >- return EMPTY_STRING + (char) ch; >- } catch (NumberFormatException e) { >- } >- } else { >- String str = (String) fgEntityLookup.get(symbol); >- if (str != null) { >- return str; >- } >- } >- return "&" + symbol; // not found //$NON-NLS-1$ >- } >- >- /* >- * A '&' has been read. Process a entity >- */ >- private String processEntity() throws IOException { >- StringBuffer buf = new StringBuffer(); >- int ch = nextChar(); >- while (Character.isLetterOrDigit((char) ch) || ch == '#') { >- buf.append((char) ch); >- ch = nextChar(); >- } >- >- if (ch == ';') >- return entity2Text(buf.toString()); >- >- buf.insert(0, '&'); >- if (ch != -1) >- buf.append((char) ch); >- return buf.toString(); >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/display/JavaDocCommentReader.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/contentassist/display/JavaDocCommentReader.java,v >retrieving revision 1.4 >diff -u -r1.4 JavaDocCommentReader.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/display/JavaDocCommentReader.java 27 May 2009 20:38:23 -0000 1.4 >+++ src/org/eclipse/pde/internal/ui/editor/contentassist/display/JavaDocCommentReader.java 1 Mar 2010 12:25:47 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,17 +12,23 @@ > > import org.eclipse.jdt.core.IBuffer; > import org.eclipse.jdt.core.formatter.IndentManipulation; >+import org.eclipse.jface.internal.text.html.SingleCharReader; > > /** > * Reads a java doc comment from a java doc comment. Skips star-character >- * on begin of line >+ * on begin of line. >+ * <p> >+ * XXX: copied from <code>org.eclipse.jdt.ui</code>. >+ * </p> > */ > public class JavaDocCommentReader extends SingleCharReader { > > private IBuffer fBuffer; > > private int fCurrPos; >+ > private int fStartPos; >+ > private int fEndPos; > > private boolean fWasNewLine; >@@ -81,6 +87,8 @@ > > /** > * Returns the offset of the last read character in the passed buffer. >+ * >+ * @return the offset > */ > public int getOffset() { > return fCurrPos; >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/display/SingleCharReader.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/contentassist/display/SingleCharReader.java >diff -N src/org/eclipse/pde/internal/ui/editor/contentassist/display/SingleCharReader.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/display/SingleCharReader.java 27 May 2009 20:38:23 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,60 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.contentassist.display; >- >-import java.io.IOException; >-import java.io.Reader; >- >-abstract class SingleCharReader extends Reader { >- >- /** >- * @see Reader#read() >- */ >- public abstract int read() throws IOException; >- >- /** >- * @see Reader#read(char[],int,int) >- */ >- public int read(char cbuf[], int off, int len) throws IOException { >- int end = off + len; >- for (int i = off; i < end; i++) { >- int ch = read(); >- if (ch == -1) { >- if (i == off) >- return -1; >- return i - off; >- } >- cbuf[i] = (char) ch; >- } >- return len; >- } >- >- /** >- * @see Reader#ready() >- */ >- public boolean ready() throws IOException { >- return true; >- } >- >- /** >- * Returns the readable content as string. >- * @return the readable content as string >- * @exception IOException in case reading fails >- */ >- public String getString() throws IOException { >- StringBuffer buf = new StringBuffer(); >- int ch; >- while ((ch = read()) != -1) { >- buf.append((char) ch); >- } >- return buf.toString(); >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/contentassist/display/SubstitutionTextReader.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/contentassist/display/SubstitutionTextReader.java >diff -N src/org/eclipse/pde/internal/ui/editor/contentassist/display/SubstitutionTextReader.java >--- src/org/eclipse/pde/internal/ui/editor/contentassist/display/SubstitutionTextReader.java 27 May 2009 20:38:23 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,156 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.pde.internal.ui.editor.contentassist.display; >- >-import java.io.IOException; >-import java.io.Reader; >- >-/** >- * Reads the text contents from a reader and computes for each character >- * a potential substitution. The substitution may eat more characters than >- * only the one passed into the computation routine. >- */ >-abstract class SubstitutionTextReader extends SingleCharReader { >- >- protected static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ >- >- private Reader fReader; >- private boolean fWasWhiteSpace; >- private int fCharAfterWhiteSpace; >- >- /** >- * Tells whether white space characters are skipped. >- */ >- private boolean fSkipWhiteSpace = true; >- >- private boolean fReadFromBuffer; >- private StringBuffer fBuffer; >- private int fIndex; >- >- protected SubstitutionTextReader(Reader reader) { >- fReader = reader; >- fBuffer = new StringBuffer(); >- fIndex = 0; >- fReadFromBuffer = false; >- fCharAfterWhiteSpace = -1; >- fWasWhiteSpace = true; >- } >- >- /** >- * Computes the substitution for the given character and if necessary >- * subsequent characters. Implementation should use <code>nextChar</code> >- * to read subsequent characters. >- * >- * @param c the character to be substituted >- * @return the substitution for <code>c</code> >- * @throws IOException in case computing the substitution fails >- */ >- protected abstract String computeSubstitution(int c) throws IOException; >- >- /** >- * Returns the internal reader. >- * >- * @return the internal reader >- */ >- protected Reader getReader() { >- return fReader; >- } >- >- /** >- * Returns the next character. >- * @return the next character >- * @throws IOException in case reading the character fails >- */ >- protected int nextChar() throws IOException { >- fReadFromBuffer = (fBuffer.length() > 0); >- if (fReadFromBuffer) { >- char ch = fBuffer.charAt(fIndex++); >- if (fIndex >= fBuffer.length()) { >- fBuffer.setLength(0); >- fIndex = 0; >- } >- return ch; >- } >- >- int ch = fCharAfterWhiteSpace; >- if (ch == -1) { >- ch = fReader.read(); >- } >- if (fSkipWhiteSpace && Character.isWhitespace((char) ch)) { >- do { >- ch = fReader.read(); >- } while (Character.isWhitespace((char) ch)); >- if (ch != -1) { >- fCharAfterWhiteSpace = ch; >- return ' '; >- } >- } else { >- fCharAfterWhiteSpace = -1; >- } >- return ch; >- } >- >- /** >- * @see Reader#read() >- */ >- public int read() throws IOException { >- int c; >- do { >- >- c = nextChar(); >- while (!fReadFromBuffer) { >- String s = computeSubstitution(c); >- if (s == null) >- break; >- if (s.length() > 0) >- fBuffer.insert(0, s); >- c = nextChar(); >- } >- >- } while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' ')); >- fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n'); >- return c; >- } >- >- /** >- * @see Reader#ready() >- */ >- public boolean ready() throws IOException { >- return fReader.ready(); >- } >- >- /** >- * @see Reader#close() >- */ >- public void close() throws IOException { >- fReader.close(); >- } >- >- /** >- * @see Reader#reset() >- */ >- public void reset() throws IOException { >- fReader.reset(); >- fWasWhiteSpace = true; >- fCharAfterWhiteSpace = -1; >- fBuffer.setLength(0); >- fIndex = 0; >- } >- >- protected final void setSkipWhitespace(boolean state) { >- fSkipWhiteSpace = state; >- } >- >- protected final boolean isSkippingWhitespace() { >- return fSkipWhiteSpace; >- } >-} >Index: src/org/eclipse/pde/internal/ui/editor/text/HTMLPrinter.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/editor/text/HTMLPrinter.java >diff -N src/org/eclipse/pde/internal/ui/editor/text/HTMLPrinter.java >--- src/org/eclipse/pde/internal/ui/editor/text/HTMLPrinter.java 14 Jan 2009 22:31:10 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,291 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.editor.text; >- >-import java.io.IOException; >-import java.io.Reader; >-import java.net.URL; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.SWTError; >-import org.eclipse.swt.graphics.FontData; >-import org.eclipse.swt.graphics.RGB; >-import org.eclipse.swt.widgets.Display; >- >-/** >- * Provides a set of convenience methods for creating HTML pages. >- * <p> >- * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> >- */ >-public class HTMLPrinter { >- >- private static RGB BG_COLOR_RGB = new RGB(255, 255, 225); // RGB value of info bg color on WindowsXP >- private static RGB FG_COLOR_RGB = new RGB(0, 0, 0); // RGB value of info fg color on WindowsXP >- >- private static final String UNIT; // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=155993 >- static { >- String platform = SWT.getPlatform(); >- UNIT = "carbon".equals(platform) || "cocoa".equals(platform) ? "px" : "pt"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ >- } >- >- static { >- final Display display = Display.getDefault(); >- if (display != null && !display.isDisposed()) { >- try { >- display.asyncExec(new Runnable() { >- /* >- * @see java.lang.Runnable#run() >- */ >- public void run() { >- BG_COLOR_RGB = display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); >- FG_COLOR_RGB = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(); >- } >- }); >- } catch (SWTError err) { >- // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=45294 >- if (err.code != SWT.ERROR_DEVICE_DISPOSED) >- throw err; >- } >- } >- } >- >- private HTMLPrinter() { >- } >- >- private static String replace(String text, char c, String s) { >- >- int previous = 0; >- int current = text.indexOf(c, previous); >- >- if (current == -1) >- return text; >- >- StringBuffer buffer = new StringBuffer(); >- while (current > -1) { >- buffer.append(text.substring(previous, current)); >- buffer.append(s); >- previous = current + 1; >- current = text.indexOf(c, previous); >- } >- buffer.append(text.substring(previous)); >- >- return buffer.toString(); >- } >- >- public static String convertToHTMLContent(String content) { >- content = replace(content, '&', "&"); //$NON-NLS-1$ >- content = replace(content, '"', """); //$NON-NLS-1$ >- content = replace(content, '<', "<"); //$NON-NLS-1$ >- return replace(content, '>', ">"); //$NON-NLS-1$ >- } >- >- public static String read(Reader rd) { >- >- StringBuffer buffer = new StringBuffer(); >- char[] readBuffer = new char[2048]; >- >- try { >- int n = rd.read(readBuffer); >- while (n > 0) { >- buffer.append(readBuffer, 0, n); >- n = rd.read(readBuffer); >- } >- return buffer.toString(); >- } catch (IOException x) { >- } >- >- return null; >- } >- >- public static void insertPageProlog(StringBuffer buffer, int position, RGB fgRGB, RGB bgRGB, String styleSheet) { >- if (fgRGB == null) >- fgRGB = FG_COLOR_RGB; >- if (bgRGB == null) >- bgRGB = BG_COLOR_RGB; >- >- StringBuffer pageProlog = new StringBuffer(300); >- >- pageProlog.append("<html>"); //$NON-NLS-1$ >- >- appendStyleSheetURL(pageProlog, styleSheet); >- >- appendColors(pageProlog, fgRGB, bgRGB); >- >- buffer.insert(position, pageProlog.toString()); >- } >- >- private static void appendColors(StringBuffer pageProlog, RGB fgRGB, RGB bgRGB) { >- pageProlog.append("<body text=\""); //$NON-NLS-1$ >- appendColor(pageProlog, fgRGB); >- pageProlog.append("\" bgcolor=\""); //$NON-NLS-1$ >- appendColor(pageProlog, bgRGB); >- pageProlog.append("\">"); //$NON-NLS-1$ >- } >- >- private static void appendColor(StringBuffer buffer, RGB rgb) { >- buffer.append('#'); >- appendAsHexString(buffer, rgb.red); >- appendAsHexString(buffer, rgb.green); >- appendAsHexString(buffer, rgb.blue); >- } >- >- private static void appendAsHexString(StringBuffer buffer, int intValue) { >- String hexValue = Integer.toHexString(intValue); >- if (hexValue.length() == 1) >- buffer.append('0'); >- buffer.append(hexValue); >- } >- >- public static void insertStyles(StringBuffer buffer, String[] styles) { >- if (styles == null || styles.length == 0) >- return; >- >- StringBuffer styleBuf = new StringBuffer(10 * styles.length); >- for (int i = 0; i < styles.length; i++) { >- styleBuf.append(" style=\""); //$NON-NLS-1$ >- styleBuf.append(styles[i]); >- styleBuf.append('"'); >- } >- >- // Find insertion index >- // a) within existing body tag with trailing space >- int index = buffer.indexOf("<body "); //$NON-NLS-1$ >- if (index != -1) { >- buffer.insert(index + 5, styleBuf.toString()); >- return; >- } >- >- // b) within existing body tag without attributes >- index = buffer.indexOf("<body>"); //$NON-NLS-1$ >- if (index != -1) { >- buffer.insert(index + 5, ' '); >- buffer.insert(index + 6, styleBuf.toString()); >- return; >- } >- } >- >- private static void appendStyleSheetURL(StringBuffer buffer, String styleSheet) { >- if (styleSheet == null) >- return; >- >- buffer.append("<head><style CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">"); //$NON-NLS-1$ >- buffer.append(styleSheet); >- buffer.append("</style></head>"); //$NON-NLS-1$ >- } >- >- private static void appendStyleSheetURL(StringBuffer buffer, URL styleSheetURL) { >- if (styleSheetURL == null) >- return; >- >- buffer.append("<head>"); //$NON-NLS-1$ >- >- buffer.append("<LINK REL=\"stylesheet\" HREF= \""); //$NON-NLS-1$ >- buffer.append(styleSheetURL); >- buffer.append("\" CHARSET=\"ISO-8859-1\" TYPE=\"text/css\">"); //$NON-NLS-1$ >- >- buffer.append("</head>"); //$NON-NLS-1$ >- } >- >- public static void insertPageProlog(StringBuffer buffer, int position) { >- StringBuffer pageProlog = new StringBuffer(60); >- pageProlog.append("<html>"); //$NON-NLS-1$ >- appendColors(pageProlog, FG_COLOR_RGB, BG_COLOR_RGB); >- buffer.insert(position, pageProlog.toString()); >- } >- >- public static void insertPageProlog(StringBuffer buffer, int position, URL styleSheetURL) { >- StringBuffer pageProlog = new StringBuffer(300); >- pageProlog.append("<html>"); //$NON-NLS-1$ >- appendStyleSheetURL(pageProlog, styleSheetURL); >- appendColors(pageProlog, FG_COLOR_RGB, BG_COLOR_RGB); >- buffer.insert(position, pageProlog.toString()); >- } >- >- public static void insertPageProlog(StringBuffer buffer, int position, String styleSheet) { >- insertPageProlog(buffer, position, null, null, styleSheet); >- } >- >- public static void addPageProlog(StringBuffer buffer) { >- insertPageProlog(buffer, buffer.length()); >- } >- >- public static void addPageEpilog(StringBuffer buffer) { >- buffer.append("</font></body></html>"); //$NON-NLS-1$ >- } >- >- public static void startBulletList(StringBuffer buffer) { >- buffer.append("<ul>"); //$NON-NLS-1$ >- } >- >- public static void endBulletList(StringBuffer buffer) { >- buffer.append("</ul>"); //$NON-NLS-1$ >- } >- >- public static void addBullet(StringBuffer buffer, String bullet) { >- if (bullet != null) { >- buffer.append("<li>"); //$NON-NLS-1$ >- buffer.append(bullet); >- buffer.append("</li>"); //$NON-NLS-1$ >- } >- } >- >- public static void addSmallHeader(StringBuffer buffer, String header) { >- if (header != null) { >- buffer.append("<h5>"); //$NON-NLS-1$ >- buffer.append(header); >- buffer.append("</h5>"); //$NON-NLS-1$ >- } >- } >- >- public static void addParagraph(StringBuffer buffer, String paragraph) { >- if (paragraph != null) { >- buffer.append("<p>"); //$NON-NLS-1$ >- buffer.append(paragraph); >- } >- } >- >- public static void addParagraph(StringBuffer buffer, Reader paragraphReader) { >- if (paragraphReader != null) >- addParagraph(buffer, read(paragraphReader)); >- } >- >- /** >- * Replaces the following style attributes of the font definition of the <code>html</code> >- * element: >- * <ul> >- * <li>font-size</li> >- * <li>font-weight</li> >- * <li>font-style</li> >- * <li>font-family</li> >- * </ul> >- * The font's name is used as font family, a <code>sans-serif</code> default font family is >- * appended for the case that the given font name is not available. >- * <p> >- * If the listed font attributes are not contained in the passed style list, nothing happens. >- * </p> >- * >- * @param styles CSS style definitions >- * @param fontData the font information to use >- * @return the modified style definitions >- * @since 3.3 >- */ >- public static String convertTopLevelFont(String styles, FontData fontData) { >- boolean bold = (fontData.getStyle() & SWT.BOLD) != 0; >- boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0; >- String size = Integer.toString(fontData.getHeight()) + UNIT; >- String family = "'" + fontData.getName() + "',sans-serif"; //$NON-NLS-1$ //$NON-NLS-2$ >- >- styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})", "$1" + size + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})", "$1" + (bold ? "bold" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ >- styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})", "$1" + (italic ? "italic" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ >- styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})", "$1" + family + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- return styles; >- } >-} >Index: src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java,v >retrieving revision 1.8 >diff -u -r1.8 PDEJavaHelperUI.java >--- src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java 15 Oct 2009 01:19:10 -0000 1.8 >+++ src/org/eclipse/pde/internal/ui/util/PDEJavaHelperUI.java 1 Mar 2010 12:25:47 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.jdt.core.search.SearchEngine; > import org.eclipse.jdt.ui.JavaUI; > import org.eclipse.jface.fieldassist.*; >+import org.eclipse.jface.internal.text.html.HTMLPrinter; > import org.eclipse.jface.viewers.ILabelProvider; > import org.eclipse.jface.window.Window; > import org.eclipse.jface.wizard.WizardDialog; >@@ -32,7 +33,6 @@ > import org.eclipse.pde.internal.ui.editor.contentassist.display.JavaDocCommentReader; > import org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeValue; > import org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeWizard; >-import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Text; >Index: src/org/eclipse/pde/internal/ui/wizards/extension/PointSelectionPage.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/extension/PointSelectionPage.java,v >retrieving revision 1.87 >diff -u -r1.87 PointSelectionPage.java >--- src/org/eclipse/pde/internal/ui/wizards/extension/PointSelectionPage.java 13 Oct 2009 15:07:02 -0000 1.87 >+++ src/org/eclipse/pde/internal/ui/wizards/extension/PointSelectionPage.java 1 Mar 2010 12:25:47 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.core.runtime.*; > import org.eclipse.jface.dialogs.*; > import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.internal.text.html.HTMLPrinter; > import org.eclipse.jface.viewers.*; > import org.eclipse.jface.wizard.IWizard; > import org.eclipse.jface.wizard.IWizardNode; >@@ -33,7 +34,6 @@ > import org.eclipse.pde.internal.ui.*; > import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog; > import org.eclipse.pde.internal.ui.editor.contentassist.XMLInsertionComputer; >-import org.eclipse.pde.internal.ui.editor.text.HTMLPrinter; > import org.eclipse.pde.internal.ui.elements.DefaultContentProvider; > import org.eclipse.pde.internal.ui.elements.ElementLabelProvider; > import org.eclipse.pde.internal.ui.search.ShowDescriptionAction;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 158331
: 160474