[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] How to resize a coolBar to add larger Icons

Hi I have a coolBar filled with OpenPerspectiveActions. All of this actions have an icon. The user can change the size of the icons in the preferences

dialog.

When I start the application with the large icons and the user changes the preferred icon size to small, it works fine and the small icons are

displayed. Although the coolBar hight still is as tal as the large icons were.

When I start the application with the small icons and the user changes the preferred icon size to large, the coolBar doesn't display the icons.
I assume the coolBar is too small to display the large icons. But how can i resize the coolBar?


Thats my code to update the icons in the coolBar:
I first remove all contribution items and then update the coolBar.
I set a larger icon (or a smaller one) to the actions and then add the action again to the coolBar. At the end i call update on the coolBar.




preferenceStore.addPropertyChangeListener(new IPropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent event)
{
String iconSize = (String) event.getNewValue();
if (PreferencePageIconSize.LARGE_ICON_SIZE.equals(iconSize) || PreferencePageIconSize.NORMAL_ICON_SIZE.equals(iconSize))
{
coolBar.removeAll();
coolBar.update(true);

int count = 0;
for (IConfigurationElement perspective : extensions)
{
ImageDescriptor image = null;
if (PreferencePageIconSize.LARGE_ICON_SIZE.equals(iconSize))
{
if (perspective.getAttribute("iconLarge") != null)
{
image = Images.get(perspective.getAttribute("iconLarge"));
}
}
else
{
if (perspective.getAttribute("icon") != null)
{
image = Images.get(perspective.getAttribute("icon"));
}
}
OpenPerspectiveAction perspectiveAction = perspectiveActions[count];
perspectiveAction.setImageDescriptor(image);
coolBar.add(perspectiveAction);
count++;
}
coolBar.update(true);
}
}
});


Thanks for your help.