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 154797 Details for
Bug 297901
Scrollbar needs to be fixed
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]
ListScrollBar Fix
297901ScrollBarFix.txt (text/plain), 27.48 KB, created by
Lidija Grahek
on 2009-12-18 12:31:30 EST
(
hide
)
Description:
ListScrollBar Fix
Filename:
MIME Type:
Creator:
Lidija Grahek
Created:
2009-12-18 12:31:30 EST
Size:
27.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.draw2d.ui >Index: src/org/eclipse/gmf/runtime/draw2d/ui/figures/ListScrollBar.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.draw2d.ui/src/org/eclipse/gmf/runtime/draw2d/ui/figures/ListScrollBar.java,v >retrieving revision 1.9 >diff -u -r1.9 ListScrollBar.java >--- src/org/eclipse/gmf/runtime/draw2d/ui/figures/ListScrollBar.java 9 Feb 2007 20:53:14 -0000 1.9 >+++ src/org/eclipse/gmf/runtime/draw2d/ui/figures/ListScrollBar.java 18 Dec 2009 17:33:33 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2002, 2007 IBM Corporation and others. >+ * Copyright (c) 2002, 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 >@@ -11,47 +11,50 @@ > > package org.eclipse.gmf.runtime.draw2d.ui.figures; > >-import java.beans.PropertyChangeEvent; >-import java.beans.PropertyChangeListener; >- > import org.eclipse.draw2d.Border; > import org.eclipse.draw2d.ChangeEvent; > import org.eclipse.draw2d.ChangeListener; > import org.eclipse.draw2d.Clickable; > import org.eclipse.draw2d.ColorConstants; >+import org.eclipse.draw2d.Figure; > import org.eclipse.draw2d.Graphics; > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.MarginBorder; >+import org.eclipse.draw2d.MouseEvent; > import org.eclipse.draw2d.Panel; >-import org.eclipse.draw2d.SchemeBorder; > import org.eclipse.draw2d.ScrollBar; > import org.eclipse.draw2d.geometry.Dimension; > import org.eclipse.draw2d.geometry.Insets; >-import org.eclipse.gmf.runtime.draw2d.ui.graphics.GCUtilities; >-import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.DropShadowButtonBorder; >-import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.ImageFigureEx; >-import org.eclipse.gmf.runtime.draw2d.ui.internal.l10n.Draw2dUIPluginImages; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.draw2d.geometry.Point; >+import org.eclipse.draw2d.geometry.PointList; >+import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; >+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; >+import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.RGB; >-import org.eclipse.swt.widgets.Display; > > > /** >+ * Customizes the look of GEF's ScrollBar > * > * @author sshaw >+ * @author lgrahek > * > */ > public class ListScrollBar extends ScrollBar { > >- static private ImageConstants icons = new ImageConstants(); >- private Image upIcon, upPressedIcon, upGrayedIcon, downIcon, downPressedIcon, downGrayedIcon; >- >- private ImageFigureEx upLabel; >- private ImageFigureEx downLabel; >- >- private static Border dropshadow = new DropShadowButtonBorder(); >+ protected ArrowButton downButtonFigure; >+ protected ArrowButton upButtonFigure; >+ ThumbFigure thumb; >+ >+ protected static Color fillLightGrey = new Color(null, new RGB(240, 240, 240)); >+ protected static Color outlineLightGrey = new Color(null, new RGB(185, 185, 185)); >+ protected static Color fillDarkGrey = new Color(null, new RGB(84, 84, 84)); >+ protected static Color outlineDarkGrey = new Color(null, new RGB(109, 109, 109)); >+ protected static Color arrowFill = new Color(null, new RGB(187, 187, 187)); >+ >+ protected int mm_1; >+ protected int mm_2; > > /** > * Constructor >@@ -69,19 +72,22 @@ > public ListScrollBar(int orientation, Insets insets, Dimension size, int stepInc, int pageInc) { > setOrientation(orientation); > >- Border margin = new MarginBorder(insets.top, insets.left, insets.bottom, insets.right); >- >+ Border margin = new MarginBorder(insets.top, insets.left, insets.bottom, insets.right); > setBorder(margin); > setPreferredSize(size.width, size.height); > setStepIncrement(stepInc); > setPageIncrement(pageInc); >- >- upIcon = isHorizontal()? icons.left : icons.up; >- upPressedIcon = isHorizontal()? icons.leftPressed : icons.upPressed; >- upGrayedIcon = isHorizontal()? icons.leftGrayed : icons.upGrayed; >- downIcon = isHorizontal()? icons.right : icons.down; >- downPressedIcon = isHorizontal()? icons.rightPressed : icons.downPressed; >- downGrayedIcon = isHorizontal()? icons.rightGrayed : icons.downGrayed; >+ if (isHorizontal()) { >+ downButtonFigure.setDirection(EAST); >+ upButtonFigure.setDirection(WEST); >+ } else { >+ downButtonFigure.setDirection(SOUTH); >+ upButtonFigure.setDirection(NORTH); >+ } >+ >+ IMapMode mm= MapModeUtil.getMapMode(this); >+ mm_1 = mm.DPtoLP(1); >+ mm_2 = mm.DPtoLP(2); > } > > >@@ -89,24 +95,22 @@ > * @see org.eclipse.draw2d.ScrollBar#createDefaultDownButton() > */ > protected Clickable createDefaultDownButton() { >- downLabel = new ImageFigureEx(downIcon); >- downLabel.setOpaque(true); >- addPropertyChangeListener(new PropertyChangeListener() { >- public void propertyChange(PropertyChangeEvent event) { >- updateDownLabel(); >- } >- }); >- Clickable button = new Clickable(downLabel); >+ downButtonFigure = new ArrowButton(); >+ downButtonFigure.setBorder(new MarginBorder(new Insets(mm_1))); >+ Clickable button = new Clickable(downButtonFigure) { >+ @Override >+ public boolean hasFocus() { >+ return false; >+ } >+ }; > button.getModel().addChangeListener(new ChangeListener() { > public void handleStateChanged(ChangeEvent event) { >- updateDownLabel(); >+ updateDownColors(); > } > }); > > button.setFiringMethod(Clickable.REPEAT_FIRING); > button.setRolloverEnabled(true); >- button.setBorder(dropshadow); >- button.setOpaque(false); > return button; > } > >@@ -114,25 +118,23 @@ > * @see org.eclipse.draw2d.ScrollBar#createDefaultUpButton() > */ > protected Clickable createDefaultUpButton() { >- upLabel = new ImageFigureEx(upIcon); >- upLabel.setOpaque(true); >- addPropertyChangeListener(new PropertyChangeListener() { >- public void propertyChange(PropertyChangeEvent event) { >- updateUpLabel(); >- } >- }); >- Clickable button = new Clickable(upLabel); >+ upButtonFigure = new ArrowButton(); >+ upButtonFigure.setBorder(new MarginBorder(new Insets(mm_1))); >+ Clickable button = new Clickable(upButtonFigure) { >+ @Override >+ public boolean hasFocus() { >+ return false; >+ } >+ }; > button.getModel().addChangeListener(new ChangeListener() { > public void handleStateChanged(ChangeEvent event) { >- updateUpLabel(); >+ updateUpColors(); > } > }); > > button.setFiringMethod(Clickable.REPEAT_FIRING); > button.setRolloverEnabled(true); >- button.setBorder(dropshadow); >- button.setOpaque(false); >- return button; >+ return button; > } > > /* (non-Javadoc) >@@ -142,136 +144,362 @@ > super.initialize(); > setPageUp(null); > setPageDown(null); >- setOpaque(false); >+ setOpaque(true); > } > > /* (non-Javadoc) > * @see org.eclipse.draw2d.ScrollBar#createDefaultThumb() > */ > protected IFigure createDefaultThumb() { >- Panel thumb = new Panel() { >- >- public void paint(Graphics graphics) { >- if (GCUtilities.supportsAdvancedGraphics()){ >- graphics.setAlpha(128); >- } >- super.paint(graphics); >- } >- >- }; >+ thumbDragger = new ThumbDraggerColors(); >+ >+ thumb = new ThumbFigure(); > thumb.setMinimumSize(new Dimension(6, 6)); >- thumb.setBackgroundColor(ColorConstants.button); >- >- thumb.setBorder(new SchemeBorder(SchemeBorder.SCHEMES.RIDGED)); > return thumb; > } > >- >- private void updateDownLabel() { >- Image icon = null; >- if (((Clickable) getButtonDown()).getModel().isPressed() >- || !((Clickable) getButtonDown()).getModel().isMouseOver()) >- icon = downPressedIcon; >- if (getValue() >= (getMaximum() - getExtent())) { >- icon = downGrayedIcon; >- getButtonDown().setEnabled(false); >- } else { >- getButtonDown().setEnabled(true); >- if (icon == null) >- icon = downIcon; >+ /** >+ * Updates colors of down button depending on its state (highlighted, >+ * pressed, or neither) >+ */ >+ protected void updateDownColors() { >+ boolean pressed = false; >+ boolean highlighted = false; >+ if (getValue() < (getMaximum() - getExtent())) { >+ // Arrow is scrollable >+ if (((Clickable) getButtonDown()).getModel().isPressed()) { >+ pressed = true; >+ } else if (((Clickable) getButtonDown()).getModel().isMouseOver()) { >+ highlighted = true; >+ } >+ } >+ boolean doRepaint = false; >+ if (downButtonFigure.isHighlighted() != highlighted) { >+ downButtonFigure.setHighlighted(highlighted); >+ doRepaint = true; >+ } >+ if (downButtonFigure.isPressed() != pressed) { >+ doRepaint = true; >+ downButtonFigure.setPressed(pressed); >+ } >+ if (doRepaint) { >+ // Just changing color, no recalculation of arrow position needed >+ downButtonFigure.setRecalculate(false); >+ downButtonFigure.repaint(); > } >- downLabel.setImage(icon); > } > >- private void updateUpLabel() { >- Image icon = null; >- if (((Clickable) getButtonUp()).getModel().isPressed() >- || !((Clickable) getButtonUp()).getModel().isMouseOver()) >- icon = upPressedIcon; >- if (getValue() <= getMinimum()) { >- icon = upGrayedIcon; >- getButtonUp().setEnabled(false); >- } else { >- getButtonUp().setEnabled(true); >- if (icon == null) >- icon = upIcon; >+ /** >+ * Updates colors of up button depending on its state (highlighted, >+ * pressed, or neither) >+ */ >+ protected void updateUpColors() { >+ boolean pressed = false; >+ boolean highlighted = false; >+ if (getValue() > getMinimum()) { >+ // Arrow is scrollable >+ if (((Clickable) getButtonUp()).getModel().isPressed()) { >+ pressed = true; >+ } else if (((Clickable) getButtonUp()).getModel().isMouseOver()) { >+ highlighted = true; >+ } >+ } >+ boolean doRepaint = false; >+ if (upButtonFigure.isHighlighted() != highlighted) { >+ upButtonFigure.setHighlighted(highlighted); >+ doRepaint = true; >+ } >+ if (upButtonFigure.isPressed() != pressed) { >+ doRepaint = true; >+ upButtonFigure.setPressed(pressed); >+ } >+ if (doRepaint) { >+ // Just changing color, no recalculation of arrow position needed >+ upButtonFigure.setRecalculate(false); >+ upButtonFigure.repaint(); > } >- upLabel.setImage(icon); > } > > /** >- * @author sshaw >+ * Figure that defines the content for up and down buttons >+ * >+ * @author lgrahek >+ * >+ * @since 1.2 > * > */ >- static private class ImageConstants { >+ protected class ArrowButton extends Figure >+ { >+ private PointList arrow = new PointList(); >+ private boolean recalculate; >+ private int direction; >+ private boolean highlighted; >+ private boolean pressed; >+ >+ @Override >+ protected void paintFigure(Graphics g) { >+ Rectangle r = getBounds(); >+ // If not pressed, fill with white, so later there will be 1px of >+ // white left around outline. >+ g.setAlpha(130); >+ if (!pressed) { >+ g.setBackgroundColor(ColorConstants.white); >+ g.fillRectangle(r); >+ } >+ // Draw the outline (none when button is pressed) >+ if (!pressed) { >+ g.setLineWidth(mm_1); >+ if (highlighted) { >+ g.setForegroundColor(outlineDarkGrey); >+ } else { >+ g.setForegroundColor(outlineLightGrey); >+ } >+ g.drawRectangle(r); >+ } >+ >+ // Fill the interior. If not pressed, leave 1px white between outline and filled area. >+ if (pressed) { >+ g.setBackgroundColor(fillDarkGrey); >+ } else { >+ g.setBackgroundColor(fillLightGrey); >+ r = r.getCopy().shrink(mm_2, mm_2); >+ } >+ g.fillRectangle(r); >+ >+ // Draw the arrow >+ if (pressed) { >+ r = r.getCopy().shrink(mm_2, mm_2); >+ } >+ if (recalculate || arrow.size() == 0) { >+ int size; >+ switch (direction) { >+ case EAST: >+ case WEST: >+ size = Math.min(r.height / 2, r.width); >+ r.x += (r.width - size) / 2; >+ break; >+ default: //North or south >+ size = Math.min(r.height, r.width / 2); >+ r.y += (r.height - size) / 2; >+ break; >+ } >+ size = Math.max(size, 1); //Size cannot be negative >+ Point head, p2, p3; >+ switch (direction) { >+ case NORTH: >+ head = new Point(r.x + r.width / 2, r.y); >+ p2 = new Point (head.x - size, head.y + size); >+ p3 = new Point (head.x + size, head.y + size); >+ break; >+ case SOUTH: >+ head = new Point (r.x + r.width / 2, r.y + size); >+ p2 = new Point (head.x - size, head.y - size); >+ p3 = new Point (head.x + size, head.y - size); >+ break; >+ case WEST: >+ head = new Point (r.x, r.y + r.height / 2); >+ p2 = new Point (head.x + size, head.y - size); >+ p3 = new Point (head.x + size, head.y + size); >+ break; >+ default: >+ head = new Point(r.x + size, r.y + r.height / 2); >+ p2 = new Point(head.x - size, head.y - size); >+ p3 = new Point(head.x - size, head.y + size); >+ >+ } >+ arrow.removeAllPoints(); >+ arrow.addPoint(p2); >+ arrow.addPoint(head); >+ arrow.addPoint(p3); >+ } else { >+ // Recalculating with every paint unless explicitly told not too >+ recalculate = true; >+ } >+ if (highlighted) { >+ g.setForegroundColor(fillDarkGrey); >+ } else if (pressed) { >+ g.setAlpha(255); >+ g.setForegroundColor(ColorConstants.white); >+ } else { >+ g.setForegroundColor(arrowFill); >+ } >+ g.setLineWidth(mm_2); >+ g.drawPolyline(arrow); >+ } > >- private final Image up, upPressed, upGrayed, >- down, downPressed, downGrayed, >- left, leftPressed, leftGrayed, >- right, rightPressed, rightGrayed; > /** >- * >+ * @param value >+ * one of PositionConstants: EAST, WEST, NORTH, SOUTH that >+ * determine the arrow direction > */ >- public ImageConstants() { >- RGB[] palette2 = new RGB[] { FigureUtilities.integerToColor(new Integer(SWT.COLOR_LIST_BACKGROUND)).getRGB(), new RGB(0, 0, 0), new RGB(0, 0, 0), new RGB(0, 0, 0) }; >- RGB[] palette1 = new RGB[] { FigureUtilities.integerToColor(new Integer(SWT.COLOR_LIST_FOREGROUND)).getRGB(), new RGB(0, 0, 0)}; >- >- ImageData image; >- >- // normal images >- image = >- Draw2dUIPluginImages.DESC_DOWN_ARROW.getImageData(); >- down = convert(image, palette2); >- >- image = >- Draw2dUIPluginImages.DESC_UP_ARROW.getImageData(); >- up = convert(image, palette2); >- >- image = >- Draw2dUIPluginImages.DESC_LEFT_ARROW.getImageData(); >- left = convert(image, palette2); >- >- image = >- Draw2dUIPluginImages.DESC_RIGHT_ARROW.getImageData(); >- right = convert(image, palette2); >- >- // pressed images >- upPressed = Draw2dUIPluginImages >- .get(Draw2dUIPluginImages.IMG_UP_PRESSED_ARROW); >- >- downPressed = Draw2dUIPluginImages >- .get(Draw2dUIPluginImages.IMG_DOWN_PRESSED_ARROW); >- >- leftPressed = Draw2dUIPluginImages >- .get(Draw2dUIPluginImages.IMG_LEFT_PRESSED_ARROW); >- >- rightPressed = Draw2dUIPluginImages >- .get(Draw2dUIPluginImages.IMG_RIGHT_PRESSED_ARROW); >+ public void setDirection(int value) { >+ direction = value; >+ } > >- // grayed images >- image = >- Draw2dUIPluginImages.DESC_UP_GRAY_ARROW.getImageData(); >- upGrayed = convert(image, palette1); >+ /** >+ * @param value >+ * false if arrow points do no have to be recalculated (e.g. >+ * when just changing color) >+ */ >+ public void setRecalculate(boolean value) { >+ recalculate = value; >+ } >+ >+ /** >+ * @param value true if highlighted, false if not >+ */ >+ public void setHighlighted(boolean value) { >+ highlighted = value; >+ } >+ >+ /** >+ * @return true if highlighted, false if not >+ */ >+ public boolean isHighlighted() { >+ return highlighted; >+ } >+ >+ /** >+ * @param value true if pressed, false if not >+ */ >+ public void setPressed(boolean value) { >+ pressed = value; >+ } > >- image = >- Draw2dUIPluginImages.DESC_DOWN_GRAY_ARROW.getImageData(); >- downGrayed = convert(image, palette1); >+ /** >+ * @return true if pressed >+ */ >+ public boolean isPressed() { >+ return pressed; >+ } >+ } >+ >+ /** >+ * Figure that defines scroll bar thumb. >+ * >+ * @author lgrahek >+ * >+ * @since 1.2 >+ * >+ */ >+ protected class ThumbFigure extends Panel { >+ boolean highlighted; >+ boolean pressed; >+ >+ @Override >+ protected void paintFigure(Graphics g) { >+ g.setAlpha(130); >+ >+ Rectangle r = getBounds().getCopy(); >+ // Fill with white, so later there will be 1px of >+ // white left around outline. >+ g.setBackgroundColor(ColorConstants.white); >+ g.fillRectangle(getBounds()); >+ // Draw the outline (none when button is pressed) >+ g.setLineWidth(mm_1); >+ if (highlighted || pressed) { >+ g.setForegroundColor(outlineDarkGrey); >+ } else { >+ g.setForegroundColor(outlineLightGrey); >+ } >+ g.drawRectangle(r); >+ >+ // Fill the interior, while leaving 1px white between outline and filled area. >+ r = r.getCopy().shrink(mm_2, mm_2); >+ if (pressed) { >+ g.setBackgroundColor(fillDarkGrey); >+ } else { >+ g.setBackgroundColor(fillLightGrey); >+ } >+ g.fillRectangle(r); >+ } > >- image = >- Draw2dUIPluginImages.DESC_LEFT_GRAY_ARROW.getImageData(); >- leftGrayed = convert(image, palette1); >+ /** >+ * @param value true if highlighted, false if not >+ */ >+ public void setHighlighted(boolean value) { >+ highlighted = value; >+ } >+ >+ /** >+ * @return true if highlighted, false if not >+ */ >+ public boolean isHighlighted() { >+ return highlighted; >+ } >+ >+ /** >+ * @param value true if pressed, false if not >+ */ >+ public void setPressed(boolean value) { >+ pressed = value; >+ } > >- image = >- Draw2dUIPluginImages.DESC_RIGHT_GRAY_ARROW.getImageData(); >- rightGrayed = convert(image, palette1); >- >- palette1 = null; >- palette2 = null; >+ /** >+ * @return true if pressed >+ */ >+ public boolean isPressed() { >+ return pressed; >+ } >+ } >+ >+ /** >+ * Customizes ThumbDragger to set different colors to thumb depending on its >+ * state. >+ * >+ * @author lgrahek >+ * >+ * @since 1.2 >+ * >+ */ >+ protected class ThumbDraggerColors extends ThumbDragger { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.draw2d.MouseMotionListener.Stub#mouseEntered(org.eclipse.draw2d.MouseEvent) >+ */ >+ @Override >+ public void mouseEntered(MouseEvent me) { >+ // Set up highlight colors >+ thumb.setHighlighted(true); >+ thumb.setPressed(false); >+ thumb.repaint(); >+ super.mouseEntered(me); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.draw2d.MouseMotionListener.Stub#mouseExited(org.eclipse.draw2d.MouseEvent) >+ */ >+ @Override >+ public void mouseExited(MouseEvent me) { >+ // Set up colors: back to no-hover, no-drag colors >+ thumb.setHighlighted(false); >+ thumb.setPressed(false); >+ thumb.repaint(); >+ super.mouseExited(me); > } > >- private Image convert(ImageData theData, RGB[] colors) { >- //theData.palette = new PaletteData(colors); >- return new Image(Display.getCurrent(), theData); >+ /* (non-Javadoc) >+ * @see org.eclipse.draw2d.ScrollBar.ThumbDragger#mousePressed(org.eclipse.draw2d.MouseEvent) >+ */ >+ @Override >+ public void mousePressed(MouseEvent me) { >+ // Set up pressed colors >+ thumb.setHighlighted(false); >+ thumb.setPressed(true); >+ thumb.repaint(); >+ super.mousePressed(me); > } >- } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.draw2d.ScrollBar.ThumbDragger#mouseReleased(org.eclipse.draw2d.MouseEvent) >+ */ >+ @Override >+ public void mouseReleased(MouseEvent me) { >+ // Set up colors: back to hover >+ thumb.setHighlighted(true); >+ thumb.setPressed(false); >+ thumb.repaint(); >+ super.mouseReleased(me); >+ } >+ } > } >Index: src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/AnimatableScrollPane.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.draw2d.ui/src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/AnimatableScrollPane.java,v >retrieving revision 1.4 >diff -u -r1.4 AnimatableScrollPane.java >--- src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/AnimatableScrollPane.java 3 Oct 2006 15:04:52 -0000 1.4 >+++ src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/AnimatableScrollPane.java 18 Dec 2009 17:33:33 -0000 >@@ -1,5 +1,5 @@ > /****************************************************************************** >- * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * 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 >@@ -134,11 +134,11 @@ > > protected void createVerticalScrollBar() { > IMapMode mm= MapModeUtil.getMapMode(this); >- int mm_1 = mm.DPtoLP(1); >- Insets insets = new Insets(mm_1, mm.DPtoLP(2), >- mm_1, mm.DPtoLP(0)); >- int mm_15 = mm.DPtoLP(15); >- Dimension size = new Dimension(mm_15, mm_15); >+ int mm_0 = mm.DPtoLP(0); >+ Insets insets = new Insets(mm_0, mm.DPtoLP(2), >+ mm_0, mm_0); >+ int mm_14 = mm.DPtoLP(14); >+ Dimension size = new Dimension(mm_14, mm_14); > setVerticalScrollBar( new ListScrollBar(Orientable.VERTICAL, insets, size, > mm.DPtoLP(10), mm.DPtoLP(50))); > } >@@ -146,11 +146,12 @@ > > protected void createHorizontalScrollBar() { > IMapMode mm= MapModeUtil.getMapMode(this); >+ int mm_0 = mm.DPtoLP(0); > int mm_1 = mm.DPtoLP(1); >- Insets insets = new Insets(mm_1, mm.DPtoLP(2), >- mm_1, mm.DPtoLP(0)); >- int mm_15 = mm.DPtoLP(15); >- Dimension size = new Dimension(mm_15, mm_15); >+ Insets insets = new Insets(mm_0, mm_0, >+ mm_1, mm_1); >+ int mm_13 = mm.DPtoLP(13); >+ Dimension size = new Dimension(mm_13, mm_13); > setHorizontalScrollBar( new ListScrollBar(Orientable.HORIZONTAL, insets, size, > mm.DPtoLP(10), mm.DPtoLP(50))); > } >@@ -163,7 +164,4 @@ > public ScrollBar basicGetHorizontalScrollBar() { > return hBar; > } >- >- >- > } >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/editparts/ShapeNodeEditPart.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editparts/ShapeNodeEditPart.java,v >retrieving revision 1.12 >diff -u -r1.12 ShapeNodeEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editparts/ShapeNodeEditPart.java 30 Jan 2009 19:37:11 -0000 1.12 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editparts/ShapeNodeEditPart.java 18 Dec 2009 17:33:33 -0000 >@@ -17,7 +17,6 @@ > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.geometry.Point; > import org.eclipse.emf.common.notify.Notification; >-import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.transaction.RunnableWithResult; > import org.eclipse.gef.ConnectionEditPart; > import org.eclipse.gef.EditPolicy; >@@ -35,9 +34,7 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; > import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.NoteAttachmentReorientEditPolicy; >-import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >-import org.eclipse.gmf.runtime.emf.core.util.PackageUtil; > import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; > import org.eclipse.gmf.runtime.notation.Anchor; > import org.eclipse.gmf.runtime.notation.FillStyle; >Index: src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java,v >retrieving revision 1.17 >diff -u -r1.17 ResizableCompartmentEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java 5 Mar 2009 01:30:17 -0000 1.17 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java 18 Dec 2009 17:33:33 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.draw2d.Border; > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.LineBorder; >+import org.eclipse.draw2d.ScrollPane; > import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.gef.ExposeHelper; >@@ -22,7 +23,9 @@ > import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; > import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >+import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.AnimatableScrollPane; > import org.eclipse.gmf.runtime.notation.DrawerStyle; >+import org.eclipse.gmf.runtime.notation.FillStyle; > import org.eclipse.gmf.runtime.notation.NotationPackage; > import org.eclipse.gmf.runtime.notation.Ratio; > import org.eclipse.gmf.runtime.notation.TitleStyle; >@@ -73,7 +76,8 @@ > refreshCollapsed(); > refreshRatio(); > refreshLineWidth(); >- refreshLineType(); >+ refreshLineType(); >+ refreshBackgroundColor(); > } > > /** >@@ -146,6 +150,9 @@ > refreshLineWidth(); > } else if (NotationPackage.eINSTANCE.getLineTypeStyle_LineType().equals(feature)) { > refreshLineType(); >+ } else if (NotationPackage.eINSTANCE.getFillStyle_Gradient().equals(feature) || >+ NotationPackage.eINSTANCE.getFillStyle_FillColor().equals(feature)) { >+ refreshBackgroundColor(); > } else > super.handleNotificationEvent(event); > } >@@ -291,4 +298,36 @@ > } > return false; > } >+ >+ /** >+ * This method refreshes background color of scroll bars (when they are >+ * present). Actually, scroll bars inherit background color from their parent shape, >+ * but in case of gradient we want to set the background to the second color >+ * of gradient. >+ * >+ * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refreshBackgroundColor() >+ */ >+ protected void refreshBackgroundColor() { >+ FillStyle style = (FillStyle)getPrimaryView().getStyle(NotationPackage.Literals.FILL_STYLE); >+ ScrollPane scrollPane = getCompartmentFigure().getScrollPane(); >+ if (style != null && >+ scrollPane instanceof AnimatableScrollPane) { >+ IFigure vBar = ((AnimatableScrollPane)scrollPane).basicGetVerticalScrollBar(); >+ IFigure hBar = ((AnimatableScrollPane)scrollPane).basicGetHorizontalScrollBar(); >+ Color color = null; >+ if (style.getGradient() == null) { >+ color = DiagramColorRegistry.getInstance().getColor(new Integer(style.getFillColor())); >+ } else { >+ color = DiagramColorRegistry.getInstance().getColor(new Integer(style.getGradient().getGradientColor2())); >+ } >+ if (color != null) { >+ if (vBar != null) { >+ vBar.setBackgroundColor(color); >+ } >+ if (hBar != null) { >+ hBar.setBackgroundColor(color); >+ } >+ } >+ } >+ } > }
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 297901
:
154526
|
154531
|
154797
|
154827