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 90386 Details for
Bug 219838
Inconsistent truncation between drawers and tools on palette
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
the patch
GEF_TruncatedSimpleTextLayout.txt (text/plain), 8.48 KB, created by
Cherie Revells
on 2008-02-21 13:43:00 EST
(
hide
)
Description:
the patch
Filename:
MIME Type:
Creator:
Cherie Revells
Created:
2008-02-21 13:43:00 EST
Size:
8.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/text/SimpleTextLayout.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/text/SimpleTextLayout.java,v >retrieving revision 1.11 >diff -u -r1.11 SimpleTextLayout.java >--- src/org/eclipse/draw2d/text/SimpleTextLayout.java 19 Sep 2007 18:08:47 -0000 1.11 >+++ src/org/eclipse/draw2d/text/SimpleTextLayout.java 21 Feb 2008 18:30:08 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -20,13 +20,13 @@ > */ > public class SimpleTextLayout extends TextLayout { > >-private static final String[] DELIMITERS = { >+static final String[] DELIMITERS = { > "\r\n", //$NON-NLS-1$ > "\n", //$NON-NLS-1$ > "\r"};//$NON-NLS-1$ > >-private static int result; >-private static int delimeterLength; >+static int result; >+static int delimeterLength; > > /** > * Creates a new SimpleTextLayout with the given TextFlow >@@ -55,7 +55,7 @@ > fragment.length = result - offset; > fragment.offset = offset; > fragment.setWidth(-1); >- flowUtilities.setupFragment(fragment, font, text); >+ flowUtilities.setupFragment(fragment, font, text.substring(offset, result)); > getContext().addToCurrentLine(fragment); > getContext().endLine(); > offset = result + delimeterLength; >@@ -65,7 +65,7 @@ > fragments.remove(i++); > } > >-private int nextLineBreak(String text, int offset) { >+int nextLineBreak(String text, int offset) { > result = text.length(); > delimeterLength = 0; > int current; >Index: src/org/eclipse/draw2d/text/TruncatedSimpleTextLayout.java >=================================================================== >RCS file: src/org/eclipse/draw2d/text/TruncatedSimpleTextLayout.java >diff -N src/org/eclipse/draw2d/text/TruncatedSimpleTextLayout.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/draw2d/text/TruncatedSimpleTextLayout.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,129 @@ >+/****************************************************************************** >+ * Copyright (c) 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.draw2d.text; >+ >+import java.util.List; >+ >+import org.eclipse.swt.graphics.Font; >+ >+import org.eclipse.draw2d.TextUtilities; >+ >+/** >+ * A single-line text layout (i.e. no word wrapping), that truncates the text if >+ * it does not all fit in the width available. It does respect existing line >+ * breaks in the text. >+ * >+ * @author satif, crevells >+ * @since 3.4 >+ */ >+public class TruncatedSimpleTextLayout >+ extends SimpleTextLayout { >+ >+private String truncationString; >+ >+/** >+ * Creates a new TruncatedSingleLineTextLayout with the given TextFlow and uses >+ * an ellipsis as the truncation string. >+ * >+ * @param textflow >+ * the TextFlow >+ */ >+public TruncatedSimpleTextLayout(TextFlow textflow) { >+ this(textflow, TextFlow.ELLIPSIS); >+} >+ >+/** >+ * Creates a new TruncatedSingleLineTextLayout with the given TextFlow. >+ * >+ * @param textflow >+ * the TextFlow >+ * @param truncationString >+ * The string to be used when calculating the size of the truncation >+ * string to be shown (e.g. an ellipsis). Note in order to actually >+ * modify the truncation string that is shown, changes must be also >+ * be made to the <code>TextFlow</code> class passed in. >+ */ >+public TruncatedSimpleTextLayout(TextFlow textflow, String truncationString) { >+ super(textflow); >+ this.truncationString = truncationString; >+} >+ >+/** >+ * Gets the string to be used to show truncation (e.g. an ellipsis). >+ * >+ * @return the truncation string >+ */ >+protected String getTruncationString() { >+ return truncationString; >+} >+ >+/** >+ * Returns an instance of <code>TextUtilities</code> to be used for text >+ * calculations. >+ * >+ * @return the <code>TextUtilities</code> instance >+ */ >+protected TextUtilities getTextUtilities() { >+ return TextUtilities.INSTANCE; >+} >+ >+protected void layout() { >+ TextFlow textFlow = (TextFlow) getFlowFigure(); >+ String fullText = textFlow.getText(); >+ List fragments = textFlow.getFragments(); >+ Font font = textFlow.getFont(); >+ TextFragmentBox fragment; >+ int i = 0; >+ int offset = 0; >+ FlowUtilities flowUtilities = textFlow.getFlowUtilities(); >+ int ellipsisWidth = getTextUtilities().getTextExtents(truncationString, >+ font).width; >+ >+ do { >+ nextLineBreak(fullText, offset); >+ String substring = fullText.substring(offset, result); >+ fragment = getFragment(i++, fragments); >+ fragment.length = result - offset; >+ fragment.offset = offset; >+ fragment.setWidth(-1); >+ flowUtilities.setupFragment(fragment, font, substring); >+ >+ int remainingLineWidth = getContext().getRemainingLineWidth(); >+ if (remainingLineWidth > 0 && remainingLineWidth < fragment.getWidth()) { >+ // the text needs to be truncated... >+ remainingLineWidth -= ellipsisWidth; >+ if (remainingLineWidth > 0) { >+ int subStringLength = getTextUtilities() >+ .getLargestSubstringConfinedTo(substring, font, >+ remainingLineWidth); >+ fragment.length = subStringLength; >+ } else { >+ fragment.length = 0; >+ } >+ fragment.setTruncated(true); >+ fragment.setWidth(-1); >+ flowUtilities.setupFragment(fragment, font, substring); >+ } else { >+ fragment.setTruncated(false); >+ } >+ >+ getContext().addToCurrentLine(fragment); >+ getContext().endLine(); >+ offset = result + delimeterLength; >+ } while (offset < fullText.length()); >+ >+ // Remove the remaining unused fragments. >+ while (i < fragments.size()) >+ fragments.remove(i++); >+} >+ >+} >#P org.eclipse.gef >Index: src/org/eclipse/gef/internal/ui/palette/editparts/DetailedLabelFigure.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.gef/src/org/eclipse/gef/internal/ui/palette/editparts/DetailedLabelFigure.java,v >retrieving revision 1.26 >diff -u -r1.26 DetailedLabelFigure.java >--- src/org/eclipse/gef/internal/ui/palette/editparts/DetailedLabelFigure.java 30 Oct 2005 23:51:41 -0000 1.26 >+++ src/org/eclipse/gef/internal/ui/palette/editparts/DetailedLabelFigure.java 21 Feb 2008 18:30:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 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 >@@ -37,7 +37,9 @@ > import org.eclipse.draw2d.geometry.Rectangle; > import org.eclipse.draw2d.text.FlowPage; > import org.eclipse.draw2d.text.ParagraphTextLayout; >+import org.eclipse.draw2d.text.SimpleTextLayout; > import org.eclipse.draw2d.text.TextFlow; >+import org.eclipse.draw2d.text.TruncatedSimpleTextLayout; > > import org.eclipse.gef.ui.palette.PaletteMessages; > import org.eclipse.gef.ui.palette.PaletteViewerPreferences; >@@ -72,8 +74,7 @@ > page.setBorder(PAGE_BORDER); > > nameText = new TextFlow(); >- nameText.setLayoutManager( >- new ParagraphTextLayout(nameText, ParagraphTextLayout.WORD_WRAP_TRUNCATE)); >+ nameText.setLayoutManager(new TruncatedSimpleTextLayout(nameText)); > > descText = new TextFlow(); > descText.setLayoutManager(
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
Flags:
ahunter.eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 219838
: 90386 |
90647