diff options
author | Dani Megert | 2006-09-22 15:17:39 +0000 |
---|---|---|
committer | Dani Megert | 2006-09-22 15:17:39 +0000 |
commit | b3b4d7bbb5e53949ead3ed5da6bdf902a9d4ebbb (patch) | |
tree | 86645f6b1bf72a921e686db1a84b5a7ea9cf69bb /org.eclipse.jface.text/src/org/eclipse/jface | |
parent | 1932e846bc3e2eaa301b5ec4094d14c42103a281 (diff) | |
download | eclipse.platform.text-b3b4d7bbb5e53949ead3ed5da6bdf902a9d4ebbb.tar.gz eclipse.platform.text-b3b4d7bbb5e53949ead3ed5da6bdf902a9d4ebbb.tar.xz eclipse.platform.text-b3b4d7bbb5e53949ead3ed5da6bdf902a9d4ebbb.zip |
Fixed bug: 157461: [implementation] Put all html rendering related classes into one package and declare others as x-friends
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface')
10 files changed, 149 insertions, 40 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java index 34767ae6e9e..bafa4810c1e 100755..100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/BrowserInformationControl.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java @@ -8,8 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - -package org.eclipse.jface.internal.text.revisions; +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.StringReader; @@ -46,30 +45,30 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.core.runtime.ListenerList; -import org.eclipse.jface.internal.text.link.contentassist.HTML2TextReader; - import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlExtension; import org.eclipse.jface.text.IInformationControlExtension3; import org.eclipse.jface.text.TextPresentation; + /** * Displays textual information in a {@link org.eclipse.swt.browser.Browser} widget. - * </p> * <p> - * XXX copy of org.eclipse.jdt.internal.ui.text.java.hover.BrowserInformationControl. - * </p> + * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> * <p> - * This class may be instantiated; it is not intended to be subclassed. - * </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) + * Current problems: + * <ul> + * <li>the size computation is too small</li> + * <li>focusLost event is not sent - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=84532</li> + * <li>we need to call <code>content.replaceAll("overflow: auto;", "")<code> which is a problem if <code>"overflow: auto;"</code> appears in the content</li> + * </ul> * </p> * * @since 3.2 */ -class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener { +public class BrowserInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, DisposeListener { /** @@ -307,6 +306,7 @@ class BrowserInformationControl implements IInformationControl, IInformationCont else if (fHideScrollBars && true) styles= new String[] { "overflow:hidden;", "word-wrap: break-word;" }; //$NON-NLS-1$ //$NON-NLS-2$ + // XXX: this is a hack but needed to ensure our overflow directive is honored content= content.replaceAll("overflow: auto;", ""); //$NON-NLS-1$ //$NON-NLS-2$ if (styles != null) { diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java index 6357ffb875d..3c32cbc907c 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTML2TextReader.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java @@ -8,8 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.jface.internal.text.link.contentassist; - +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.PushbackReader; @@ -28,6 +27,8 @@ import org.eclipse.jface.text.TextPresentation; /** * Reads the text contents from a reader of HTML contents and translates * the tags or cut them out. + * <p> + * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> */ public class HTML2TextReader extends SubstitutionTextReader { @@ -182,7 +183,7 @@ public class HTML2TextReader extends SubstitutionTextReader { 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 + ContentAssistMessages.getString("HTML2TextReader.listItemPrefix"); //$NON-NLS-1$ + return LINE_DELIM + HTMLMessages.getString("HTML2TextReader.listItemPrefix"); //$NON-NLS-1$ if ("/b".equals(html)) { //$NON-NLS-1$ stopBold(); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.java new file mode 100644 index 00000000000..69679ccf543 --- /dev/null +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2006 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.jface.internal.text.html; + +import com.ibm.icu.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + + +/** + * Helper class to get NLSed messages. + * + * @since 3.3 + */ +class HTMLMessages { + + private static final String RESOURCE_BUNDLE= HTMLMessages.class.getName(); + + private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); + + private HTMLMessages() { + } + + /** + * Gets a string from the resource bundle. + * + * @param key the string used to get the bundle value, must not be null + * @return the string from the resource bundle + */ + public static String getString(String key) { + try { + return fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ + } + } + + /** + * Gets a string from the resource bundle and formats it with the given arguments. + * + * @param key the string used to get the bundle value, must not be null + * @param args the arguments used to format the string + * @return the formatted string + */ + public static String getFormattedString(String key, Object[] args) { + String format= null; + try { + format= fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ + } + return MessageFormat.format(format, args); + } + + /** + * Gets a string from the resource bundle and formats it with the given argument. + * + * @param key the string used to get the bundle value, must not be null + * @param arg the argument used to format the string + * @return the formatted string + */ + public static String getFormattedString(String key, Object arg) { + String format= null; + try { + format= fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ + } + if (arg == null) + arg= ""; //$NON-NLS-1$ + return MessageFormat.format(format, new Object[] { arg }); + } +} diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.properties b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.properties new file mode 100644 index 00000000000..da851b14949 --- /dev/null +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLMessages.properties @@ -0,0 +1,16 @@ +############################################################################### +# Copyright (c) 2006 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 +############################################################################### + + +HTMLTextPresenter.ellipse= ... + +# The following property value must end with a space +HTML2TextReader.listItemPrefix=\t-\ diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HTMLPrinter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java index 5f7a7e28c09..e6e891b66a9 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HTMLPrinter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java @@ -8,8 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.jface.internal.text.revisions; - +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.Reader; @@ -24,6 +23,8 @@ 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 { diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java index b7bfe4ae30c..8dc0009c3a1 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/HTMLTextPresenter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java @@ -8,9 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.jface.internal.text.link.contentassist; - - +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.Reader; @@ -22,12 +20,17 @@ import org.eclipse.swt.graphics.Drawable; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Display; +import org.eclipse.jface.internal.text.link.contentassist.LineBreakingReader; + import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextPresentation; - +/** + * <p> + * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> + */ public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter, DefaultInformationControl.IInformationPresenterExtension { private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -99,7 +102,7 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) { return updatePresentation((Drawable)display, hoverInfo, presentation, maxWidth, maxHeight); } - + /* * @see IHoverInformationPresenterExtension#updatePresentation(Drawable drawable, String, TextPresentation, int, int) * @since 3.2 @@ -157,7 +160,7 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation if (line != null) { append(buffer, LINE_DELIM, lineFormatted ? presentation : null); - append(buffer, ContentAssistMessages.getString("HTMLTextPresenter.ellipse"), presentation); //$NON-NLS-1$ + append(buffer, HTMLMessages.getString("HTMLTextPresenter.ellipse"), presentation); //$NON-NLS-1$ } return trim(buffer, presentation); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SingleCharReader.java index db3424bbb98..fd8e33d576e 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SingleCharReader.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SingleCharReader.java @@ -8,13 +8,17 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.jface.internal.text.link.contentassist; - +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.Reader; -abstract class SingleCharReader extends Reader { + +/** + * <p> + * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> + */ +public abstract class SingleCharReader extends Reader { /** * @see Reader#read() diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java index 682e27e6205..23d3309db39 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/SubstitutionTextReader.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java @@ -8,9 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - -package org.eclipse.jface.internal.text.link.contentassist; - +package org.eclipse.jface.internal.text.html; import java.io.IOException; import java.io.Reader; @@ -20,13 +18,15 @@ 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. + * <p> + * Moved into this package from <code>org.eclipse.jface.internal.text.revisions</code>.</p> */ -abstract class SubstitutionTextReader extends SingleCharReader { +public 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; + protected boolean fWasWhiteSpace; private int fCharAfterWhiteSpace; /** diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java index da4c7684b99..2093cfa9bd0 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2006 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 @@ -8,10 +8,8 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.jface.internal.text.link.contentassist; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -43,6 +41,8 @@ import org.eclipse.swt.widgets.Widget; import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.internal.text.html.HTMLTextPresenter; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.IEventConsumer; diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java index 9705860cad7..6a11f6438fb 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java @@ -20,10 +20,6 @@ import java.util.ListIterator; import java.util.Map; import java.util.Map.Entry; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Platform; - import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.DisposeEvent; @@ -45,6 +41,15 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.core.runtime.Platform; + +import org.eclipse.jface.internal.text.JFaceTextUtil; +import org.eclipse.jface.internal.text.html.BrowserInformationControl; +import org.eclipse.jface.internal.text.html.HTMLPrinter; +import org.eclipse.jface.internal.text.html.HTMLTextPresenter; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.IDocument; @@ -79,8 +84,6 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRulerColumn; import org.eclipse.jface.text.source.LineRange; -import org.eclipse.jface.internal.text.JFaceTextUtil; -import org.eclipse.jface.internal.text.link.contentassist.HTMLTextPresenter; /** * A strategy for painting the live annotate colors onto the vertical ruler column. It also manages |