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 165695 Details for
Bug 16552
[Dialogs] Title Area dialog should support > 2 lines text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch v02
TitleAreaDialogScroll 02.txt (text/plain), 7.43 KB, created by
Prakash Rangaraj
on 2010-04-22 02:47:17 EDT
(
hide
)
Description:
Patch v02
Filename:
MIME Type:
Creator:
Prakash Rangaraj
Created:
2010-04-22 02:47:17 EDT
Size:
7.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/dialogs/TitleAreaDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/dialogs/TitleAreaDialog.java,v >retrieving revision 1.47 >diff -u -r1.47 TitleAreaDialog.java >--- src/org/eclipse/jface/dialogs/TitleAreaDialog.java 3 Mar 2010 22:39:32 -0000 1.47 >+++ src/org/eclipse/jface/dialogs/TitleAreaDialog.java 22 Apr 2010 06:44:10 -0000 >@@ -17,9 +17,13 @@ > import org.eclipse.jface.resource.JFaceColors; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.PaintEvent; >+import org.eclipse.swt.events.PaintListener; > 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.RGB; >@@ -31,9 +35,10 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.Text; > > /** > * A dialog that has a title area for displaying a title and an image as well as >@@ -94,7 +99,7 @@ > > private String errorMessage; > >- private Text messageLabel; >+ private StyledText messageLabel; > > private Composite workArea; > >@@ -109,6 +114,10 @@ > private int messageLabelHeight; > > private Image titleAreaImage; >+ >+ private Label upArrow; >+ >+ private Label downArrow; > > /** > * Instantiate a new title area dialog. >@@ -146,6 +155,14 @@ > // create the dialog area and button bar > dialogArea = createDialogArea(workArea); > buttonBar = createButtonBar(workArea); >+ >+ // need to know whether to draw the up & down arrows >+ getShell().addListener(SWT.Resize, new Listener() { >+ >+ public void handleEvent(Event event) { >+ layoutForNewMessage(); >+ } >+ }); > return contents; > } > >@@ -245,11 +262,61 @@ > messageImageLabel = new Label(parent, SWT.CENTER); > messageImageLabel.setBackground(background); > // Message label @ bottom, center >- messageLabel = new Text(parent, SWT.WRAP | SWT.READ_ONLY); >+ messageLabel = new StyledText(parent, SWT.WRAP | SWT.READ_ONLY); > JFaceColors.setColors(messageLabel, foreground, background); > messageLabel.setText(" \n "); // two lines//$NON-NLS-1$ > messageLabel.setFont(JFaceResources.getDialogFont()); > messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ >+ // arrows >+ upArrow = new Label(parent, SWT.NONE); >+ upArrow.setForeground(titleAreaColor); >+ upArrow.setBackground(titleAreaColor); >+ FormData upArrowData = new FormData(); >+ upArrowData.top = new FormAttachment(titleLabel, verticalSpacing); >+ upArrowData.right = new FormAttachment(titleImageLabel); >+ upArrowData.width = 10; >+ upArrow.setLayoutData(upArrowData); >+ upArrow.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); >+ JFaceColors.setColors(upArrow, foreground, background); >+ upArrow.addListener(SWT.MouseDown, new Listener() { >+ >+ public void handleEvent(Event event) { >+ messageLabel.setTopPixel(messageLabel.getTopPixel()-messageLabel.getLineHeight()); >+ } >+ >+ }); >+ upArrow.addPaintListener(new PaintListener(){ >+ >+ public void paintControl(PaintEvent e) { >+ paintArrow(e, upArrow); >+ } >+ }); >+ >+ downArrow = new Label(parent, SWT.NONE); >+ FormData downArrowData = new FormData(); >+ Control bottomControl = titleImageLabel; >+ downArrowData.bottom = new FormAttachment(bottomControl, 0, SWT.BOTTOM); >+ downArrowData.right = new FormAttachment(titleImageLabel); >+ downArrowData.width = 10; >+ downArrow.setLayoutData(downArrowData); >+ downArrow.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); >+ downArrow.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); >+ JFaceColors.setColors(downArrow, foreground, background); >+ downArrow.addListener(SWT.MouseDown, new Listener() { >+ >+ public void handleEvent(Event event) { >+ messageLabel.setTopPixel(messageLabel.getTopPixel()+messageLabel.getLineHeight()); >+ } >+ >+ }); >+ downArrow.addPaintListener(new PaintListener(){ >+ >+ public void paintControl(PaintEvent e) { >+ paintArrow(e, downArrow); >+ } >+ }); >+ > // Filler labels > leftFillerLabel = new Label(parent, SWT.CENTER); > leftFillerLabel.setBackground(background); >@@ -259,9 +326,40 @@ > determineTitleImageLargest(); > if (titleImageLargest) > return titleImageLabel; >+ > return messageLabel; > } > >+ private void paintArrow(PaintEvent e, Label arrow) { >+ int[] downPoints = { 0, 2, 8, 2, 4, 6 }; >+ >+ int[] upPoints = { 4, 2, 8, 6, 0, 6 }; >+ >+ int[] data; >+ Point size = arrow.getSize(); >+ int x = (size.x - 9) / 2; >+ int y = (size.y - 9) / 2; >+ >+ int[] points = arrow==downArrow?downPoints:upPoints; >+ data = translate (points, x, y); >+ >+ Color bg = arrow.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); >+ GC gc = e.gc; >+ gc.setBackground(bg); >+ gc.fillPolygon(data); >+ } >+ >+ private int[] translate(int[] data, int x, int y) { >+ int[] target = new int[data.length]; >+ for (int i = 0; i < data.length; i += 2) { >+ target[i] = data[i] + x; >+ } >+ for (int i = 1; i < data.length; i += 2) { >+ target[i] = data[i] + y; >+ } >+ return target; >+ } >+ > /** > * Determine if the title image is larger than the title message and message > * area. This is used for layout decisions. >@@ -293,7 +391,11 @@ > messageImageLabel.setLayoutData(messageImageData); > FormData messageLabelData = new FormData(); > messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing); >- messageLabelData.right = new FormAttachment(titleImageLabel); >+ // if scrolling needed, then attach it with the arrow >+ if(arrowsVisible()) >+ messageLabelData.right = new FormAttachment(upArrow); >+ else >+ messageLabelData.right = new FormAttachment(titleImageLabel); > messageLabelData.left = new FormAttachment(messageImageLabel, > horizontalSpacing); > messageLabelData.height = messageLabelHeight; >@@ -437,7 +539,11 @@ > FormData messageLabelData = new FormData(); > messageLabelData.top = new FormAttachment(titleLabel, > verticalSpacing); >- messageLabelData.right = new FormAttachment(titleImageLabel); >+ // if scrolling needed, then attach it with the arrow >+ if(arrowsVisible()) >+ messageLabelData.right = new FormAttachment(upArrow); >+ else >+ messageLabelData.right = new FormAttachment(titleImageLabel); > messageLabelData.left = new FormAttachment(messageImageLabel, 0); > messageLabelData.height = messageLabelHeight; > if (titleImageLargest) >@@ -445,11 +551,20 @@ > 0, SWT.BOTTOM); > messageLabel.setLayoutData(messageLabelData); > } >+ > // Do not layout before the dialog area has been created > // to avoid incomplete calculations. > if (dialogArea != null) > workArea.getParent().layout(true); > } >+ >+ private boolean arrowsVisible() { >+ if(dialogArea == null) >+ return false; >+ Point newSize = messageLabel.computeSize(messageLabel.getSize().x, SWT.DEFAULT, true); >+ return newSize.y > messageLabelHeight; >+ >+ } > > /** > * Set the message text. If the message line currently displays an error, >@@ -660,4 +775,6 @@ > public String getErrorMessage() { > return errorMessage; > } >+ >+ > }
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 16552
:
164664
|
164665
| 165695 |
165979
|
165980
|
166041
|
167724
|
168074
|
168154
|
168272