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 83362 Details for
Bug 147497
[Properties] Buttons on the appearance tab should be DROP_DOWN style
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Proposed Patch
147497.txt (text/plain), 16.25 KB, created by
Carson Li
on 2007-11-20 16:33:42 EST
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Carson Li
Created:
2007-11-20 16:33:42 EST
Size:
16.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui.properties >Index: src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/grid/RulerGridPropertySection.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.properties/src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/grid/RulerGridPropertySection.java,v >retrieving revision 1.11 >diff -u -r1.11 RulerGridPropertySection.java >--- src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/grid/RulerGridPropertySection.java 6 Nov 2007 13:59:49 -0000 1.11 >+++ src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/grid/RulerGridPropertySection.java 20 Nov 2007 21:33:29 -0000 >@@ -53,6 +53,8 @@ > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; > import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; >@@ -75,7 +77,7 @@ > > private Button rulerVisibilityButton; > >- private Button lineColorButton; >+ private ToolItem lineColorButton; > > // Labels > private static final String GRID_ON_LABEL = DiagramUIPropertiesMessages.Grid_On_Label_Text; >@@ -286,16 +288,11 @@ > > private void createLineColorControl(Composite composite) { > getWidgetFactory().createLabel(composite, LINE_COLOR_LABEL); >- >- lineColorButton = new Button(composite, SWT.PUSH); >+ ToolBar toolBar = new ToolBar(composite, SWT.FLAT); >+ toolBar.setLayout(new GridLayout(1, false)); >+ toolBar.setBackground(composite.getBackground()); >+ lineColorButton = new ToolItem(toolBar, SWT.DROP_DOWN); > lineColorButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_LINE_COLOR)); >- >- lineColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_LineColor; >- } >- }); >- > lineColorButton.addSelectionListener(new SelectionAdapter() { > > public void widgetSelected(SelectionEvent event) { >@@ -316,6 +313,15 @@ > } > }); > lineColorButton.setEnabled(true); >+ >+ //the accessibility listener is applied to the whole tool bar because there is only one item in it, in the event >+ //that additional tool items are added, this should be changed to search for the tool bar's children and their >+ //their respective tool tips. Refer to ColorsAndFontsPropertySection.java. >+ toolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() { >+ public void getName(AccessibleEvent e) { >+ e.result = DiagramUIMessages.PropertyDescriptorFactory_LineColor; >+ } >+ }); > } > > private void createLineStyleControl(Composite composite) { >@@ -341,30 +347,30 @@ > /** > * @param event - > * selection event >- * @param button - >+ * @param toolItem - > * event source > * @param imageDescriptor - > * the image to draw overlay on the button after the new > * color is set > * @return - new RGB color, or null if none selected > */ >- private RGB changeColor(SelectionEvent event, Button button, >+ private RGB changeColor(SelectionEvent event, ToolItem toolItem, > ImageDescriptor imageDescriptor, int previousColor) { > >- ColorPalettePopup popup = new ColorPalettePopup(button.getParent() >+ ColorPalettePopup popup = new ColorPalettePopup(toolItem.getParent() > .getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); > > popup.setPreviousColor(previousColor); >- Rectangle r = button.getBounds(); >- Point location = button.getParent().toDisplay(r.x, r.y); >+ Rectangle r = toolItem.getBounds(); >+ Point location = toolItem.getParent().toDisplay(r.x, r.y); > popup.open(new Point(location.x, location.y + r.height)); > > if (popup.useDefaultColor()) { > Image overlyedImage = new ColorOverlayImageDescriptor( > imageDescriptor.getImageData(), FigureUtilities.integerToRGB(new Integer(LIGHT_GRAY_RGB))) > .createImage(); >- disposeImage(button.getImage()); >- button.setImage(overlyedImage); >+ disposeImage(toolItem.getImage()); >+ toolItem.setImage(overlyedImage); > return FigureUtilities.integerToRGB(new Integer(LIGHT_GRAY_RGB)); > } > >@@ -372,8 +378,8 @@ > Image overlyedImage = new ColorOverlayImageDescriptor( > imageDescriptor.getImageData(), popup.getSelectedColor()) > .createImage(); >- disposeImage(button.getImage()); >- button.setImage(overlyedImage); >+ disposeImage(toolItem.getImage()); >+ toolItem.setImage(overlyedImage); > } > > return popup.getSelectedColor(); >Index: src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/appearance/ColorsAndFontsPropertySection.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.properties/src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/appearance/ColorsAndFontsPropertySection.java,v >retrieving revision 1.21 >diff -u -r1.21 ColorsAndFontsPropertySection.java >--- src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/appearance/ColorsAndFontsPropertySection.java 6 Nov 2007 13:59:49 -0000 1.21 >+++ src/org/eclipse/gmf/runtime/diagram/ui/properties/sections/appearance/ColorsAndFontsPropertySection.java 20 Nov 2007 21:33:29 -0000 >@@ -38,6 +38,7 @@ > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.accessibility.ACC; > import org.eclipse.swt.accessibility.AccessibleAdapter; > import org.eclipse.swt.accessibility.AccessibleEvent; > import org.eclipse.swt.custom.CCombo; >@@ -53,7 +54,8 @@ > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Group; >-import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.ToolBar; >+import org.eclipse.swt.widgets.ToolItem; > import org.eclipse.ui.IWorkbenchPart; > > /** >@@ -87,7 +89,7 @@ > protected static final String FONTS_AND_COLORS_LABEL = DiagramUIPropertiesMessages. > FontAndColor_nameLabel; > >- protected Button fillColorButton; >+ protected ToolItem fillColorButton; > > protected RGB fillColor = null; > >@@ -97,16 +99,18 @@ > // font size drop down > private CCombo fontSizeCombo; > >- private Button fontBoldButton; >+ private ToolBar toolBar; >+ >+ private ToolItem fontBoldButton; > >- private Button fontItalicButton; >+ private ToolItem fontItalicButton; > > /** the default preference color */ > protected static final RGB DEFAULT_PREF_COLOR = new RGB(0, 0, 0); > >- protected Button fontColorButton; >+ protected ToolItem fontColorButton; > >- protected Button lineColorButton; >+ protected ToolItem lineColorButton; > > protected RGB fontColor; > >@@ -227,82 +231,65 @@ > } > }); > >- Composite toolBar = new Composite(parent, SWT.SHADOW_NONE); >+ toolBar = new ToolBar(parent, SWT.FLAT); > toolBar.setLayout(new GridLayout(7, false)); > toolBar.setBackground(parent.getBackground()); > >- fontBoldButton = new Button(toolBar, SWT.TOGGLE); >- fontBoldButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_BOLD)); >- fontBoldButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_FontStyle_Bold; >- } >- }); >- >- >- fontItalicButton = new Button(toolBar, SWT.TOGGLE ); >- fontItalicButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_ITALIC)); >- fontItalicButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_FontStyle_Italic; >- } >- }); >+ fontBoldButton = new ToolItem(toolBar, SWT.CHECK); > >+ fontBoldButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_BOLD)); > fontBoldButton.addSelectionListener(new SelectionAdapter() { >- > public void widgetSelected(SelectionEvent event) { > updateFontBold(); > } >- }); >+ }); >+ fontBoldButton.setToolTipText(DiagramUIMessages.FontStyleAction_bold_tooltip); > >+ fontItalicButton = new ToolItem(toolBar, SWT.CHECK ); >+ fontItalicButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_ITALIC)); >+ fontItalicButton.setToolTipText(DiagramUIMessages.PropertyDescriptorFactory_FontStyle_Italic); > fontItalicButton.addSelectionListener(new SelectionAdapter() { >- > public void widgetSelected(SelectionEvent event) { > updateFontItalic(); > } > }); > >- new Label(toolBar, SWT.LEFT); >- >- fontColorButton = new Button(toolBar, SWT.PUSH); >+ fontColorButton = new ToolItem(toolBar, SWT.DROP_DOWN); > fontColorButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_FONT_COLOR)); >- fontColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_FontColor; >- } >- }); >+ fontColorButton.setToolTipText(DiagramUIMessages.PropertyDescriptorFactory_FontColor); > fontColorButton.addSelectionListener(new SelectionAdapter() { >- > public void widgetSelected(SelectionEvent event) { > changeFontColor(event); > } > }); > >- new Label(toolBar, SWT.LEFT); >- >- lineColorButton = new Button(toolBar, SWT.PUSH); >+ lineColorButton = new ToolItem(toolBar, SWT.DROP_DOWN); > lineColorButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_LINE_COLOR)); >- lineColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_LineColor; >- } >- }); >+ lineColorButton.setToolTipText(DiagramUIMessages.PropertyDescriptorFactory_LineColor); > lineColorButton.addSelectionListener(new SelectionAdapter() { >- > public void widgetSelected(SelectionEvent event) { > changeLineColor(event); > } > }); > >- fillColorButton = new Button(toolBar, SWT.PUSH); >+ fillColorButton = new ToolItem(toolBar, SWT.DROP_DOWN); > fillColorButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_FILL_COLOR)); >- fillColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { >- public void getName(AccessibleEvent e) { >- e.result = DiagramUIMessages.PropertyDescriptorFactory_FillColor; >- } >- }); >+ fillColorButton.setToolTipText(DiagramUIMessages.PropertyDescriptorFactory_FillColor); > fillColorButton.setEnabled(false); >- >+ >+ toolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() { >+ public void getName(AccessibleEvent e) { >+ if (e.childID != ACC.CHILDID_SELF) { >+ ToolItem item = toolBar.getItem(e.childID); >+ if (item != null) { >+ String toolTip = item.getToolTipText(); >+ if (toolTip != null) { >+ e.result = toolTip; >+ } >+ } >+ } >+ } >+ }); > return toolBar; > } > >@@ -372,6 +359,34 @@ > imageDescriptor); > } > >+ /** >+ * @param event - >+ * selection event >+ * @param toolItem - >+ * event source >+ * @param preferenceId - >+ * id of the preference of the default color value for that >+ * property >+ * @param propertyId - >+ * id of the property >+ * @param commandName - >+ * name of the command >+ * @param imageDescriptor - >+ * the image to draw overlay on the button after the new color is >+ * set >+ * @return - new RGB color, or null if none selected >+ * @deprecated The preference is not being retrieved from the correct >+ * preference store so it is not needed, use the other >+ * <code>changeColor</code> method. >+ */ >+ protected RGB changeColor(SelectionEvent event, ToolItem toolItem, >+ String preferenceId, final String propertyId, String commandName, >+ ImageDescriptor imageDescriptor) { >+ >+ return changeColor(event, toolItem, propertyId, commandName, >+ imageDescriptor); >+ } >+ > /** > * @param event - > * selection event >@@ -454,6 +469,88 @@ > return colorToReturn; > } > >+ /** >+ * @param event - >+ * selection event >+ * @param toolItem - >+ * event source >+ * @param propertyId - >+ * id of the property >+ * @param commandName - >+ * name of the command >+ * @param imageDescriptor - >+ * the image to draw overlay on the button after the new color is >+ * set >+ * @return - new RGB color, or null if none selected >+ */ >+ protected RGB changeColor(SelectionEvent event, ToolItem toolItem, >+ final String propertyId, String commandName, >+ ImageDescriptor imageDescriptor) { >+ >+ ColorPalettePopup popup = new ColorPalettePopup(toolItem.getParent() >+ .getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); >+ popup.setPreviousColor(previousColor); >+ Rectangle r = toolItem.getBounds(); >+ Point location = toolItem.getParent().toDisplay(r.x, r.y); >+ popup.open(new Point(location.x, location.y + r.height)); >+ if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { >+ return null; >+ } >+ // selectedColor should be null if we are to use the default color >+ final RGB selectedColor = popup.getSelectedColor(); >+ >+ final EStructuralFeature feature = (EStructuralFeature) PackageUtil >+ .getElement(propertyId); >+ >+ // Update model in response to user >+ >+ List commands = new ArrayList(); >+ Iterator it = getInputIterator(); >+ >+ RGB colorToReturn = selectedColor; >+ RGB color = selectedColor; >+ while (it.hasNext()) { >+ final IGraphicalEditPart ep = (IGraphicalEditPart) it.next(); >+ >+ color = selectedColor; >+ if (popup.useDefaultColor()) { >+ Object preferredValue = ep.getPreferredValue(feature); >+ if (preferredValue instanceof Integer) { >+ color = FigureUtilities >+ .integerToRGB((Integer) preferredValue); >+ } >+ } >+ >+ // If we are using default colors, we want to return the color of the first selected element to be consistent >+ if (colorToReturn == null) { >+ colorToReturn = color; >+ } >+ >+ if (color != null) { >+ final RGB finalColor = color; // need a final variable >+ commands.add(createCommand(commandName, ((View) ep.getModel()) >+ .eResource(), new Runnable() { >+ >+ public void run() { >+ ENamedElement element = PackageUtil >+ .getElement(propertyId); >+ if (element instanceof EStructuralFeature) >+ ep.setStructuralFeatureValue(feature, >+ FigureUtilities.RGBToInteger(finalColor)); >+ } >+ })); >+ } >+ } >+ if (!commands.isEmpty()){ >+ executeAsCompositeCommand(commandName, commands); >+ Image overlyedImage = new ColorOverlayImageDescriptor( >+ imageDescriptor.getImageData(), color).createImage(); >+ disposeImage(toolItem.getImage()); >+ toolItem.setImage(overlyedImage); >+ } >+ return colorToReturn; >+ } >+ > /** > * Update font property > */ >@@ -475,9 +572,7 @@ > } > })); > } >- > executeAsCompositeCommand(FONT_COMMAND_NAME, commands); >- > } > > /**
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 Raw
Actions:
View
Attachments on
bug 147497
: 83362 |
96375
|
96376