Home » Eclipse Projects » Nebula » collapsible buttons layout issue 
| collapsible buttons layout issue [message #47270] | 
Thu, 24 January 2008 07:23   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
This is a multi-part message in MIME format. 
--------------060804060409090805000502 
Content-Type: text/plain; charset=ISO-8859-15; format=flowed 
Content-Transfer-Encoding: 7bit 
 
I have an issue concerning the collapsible buttons widget: the  
ButtonsTester example works fine. I then try to use the widget in my RCP  
ViewPart class and the added CustomButtons do not show, no matter how  
often I call redraw, update, layout and so on. 
 
I tracked down the error to the CollapsibleButtons.VerticalLayout class  
which lays out the button only when button.isVisible is true. In the  
ButtonsTester example this method returns true, in my RCP view it  
returns false. The result is that the button does not receive a layout.  
If I uncomment the visibility check the buttons are correctly displayed  
and the collapse works too, but there is an issue with the toolbar at  
the bottom of the composite. 
 
Attached is my ViewPart class. 
 
Regards, 
Stefan Reger 
 
--------------060804060409090805000502 
Content-Type: text/plain; 
 name="ModuleBarView.java" 
Content-Transfer-Encoding: 8bit 
Content-Disposition: inline; 
 filename="ModuleBarView.java" 
 
package de.itscope.mv.ui.views; 
 
import  org.eclipse.nebula.widgets.collapsiblebuttons.CollapsibleBut tons; 
import org.eclipse.nebula.widgets.collapsiblebuttons.CustomButton; 
import  org.eclipse.nebula.widgets.collapsiblebuttons.IButtonListene r; 
import org.eclipse.nebula.widgets.collapsiblebuttons.ImageCache; 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.events.MouseEvent; 
import org.eclipse.swt.layout.GridData; 
import org.eclipse.swt.layout.GridLayout; 
import org.eclipse.swt.widgets.Composite; 
import org.eclipse.swt.widgets.ToolBar; 
import org.eclipse.swt.widgets.ToolItem; 
import org.eclipse.ui.part.ViewPart; 
 
 
import de.itscope.mv.ui.MvGuiPlugin; 
 
public class ModuleBarView extends ViewPart { 
 
	public static final String ID = "de.itscope.mv.ui.views.ModuleBarView"; //$NON-NLS-1$ 
	private CollapsibleButtons bc; 
 
	/** 
	 * Create contents of the view part 
	 * @param parent 
	 */ 
	@Override 
	public void createPartControl(Composite parent) { 
		 
		 
 
		final GridLayout gridLayout = new GridLayout(); 
		gridLayout.verticalSpacing = 0; 
		gridLayout.marginWidth = 0; 
		gridLayout.marginHeight = 0; 
		gridLayout.horizontalSpacing = 0; 
		parent.setLayout(gridLayout); 
		final Composite composite = new Composite(parent, SWT.NONE); 
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 
		composite.setBackground(SWTResourceManager.getColor(214, 223, 247)); 
		composite.setLayout(new GridLayout()); 
 
		final ToolBar toolBar = new ToolBar(composite, SWT.VERTICAL); 
		toolBar.setBackground(SWTResourceManager.getColor(214, 223, 247)); 
		final GridData gd_toolBar = new GridData(SWT.CENTER, SWT.TOP, false, false); 
		gd_toolBar.verticalIndent = 5; 
		gd_toolBar.horizontalIndent = 5; 
		toolBar.setLayoutData(gd_toolBar); 
 
		final ToolItem newItemToolItem = new ToolItem(toolBar, SWT.RADIO); 
		 newItemToolItem.setImage(ResourceManager.getPluginImage(MvGu iPlugin.getDefault(), "oxicons/24x24/devices/gba.png")); 
		newItemToolItem.setText("ITscope-Katalog"); 
 
		final ToolItem newItemToolItem_1 = new ToolItem(toolBar, SWT.RADIO); 
		 newItemToolItem_1.setImage(ResourceManager.getPluginImage(Mv GuiPlugin.getDefault(), "oxicons/24x24/devices/cdrom_unmount.png")); 
		newItemToolItem_1.setText("Produktlisten"); 
 
		final ToolItem newItemToolItem_2 = new ToolItem(toolBar, SWT.RADIO); 
		 newItemToolItem_2.setImage(ResourceManager.getPluginImage(Mv GuiPlugin.getDefault(), "oxicons/24x24/devices/gnome-dev-harddisk-1394.png")); 
		newItemToolItem_2.setText("Produktvergleich"); 
 
		final ToolItem newItemToolItem_3 = new ToolItem(toolBar, SWT.PUSH); 
		 newItemToolItem_3.setImage(ResourceManager.getPluginImage(Mv GuiPlugin.getDefault(), "oxicons/24x24/devices/multimedia-player.png")); 
		newItemToolItem_3.setText("Kalkulation"); 
 
		final ToolItem newItemToolItem_4 = new ToolItem(toolBar, SWT.PUSH); 
		 newItemToolItem_4.setImage(ResourceManager.getPluginImage(Mv GuiPlugin.getDefault(), "oxicons/24x24/devices/video-display.png")); 
		newItemToolItem_4.setText("Statistik"); 
		bc = new CollapsibleButtons(parent, SWT.BORDER); 
		bc.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false)); 
		bc.addButton("Produkte", null, ResourceManager.getPluginImage(MvGuiPlugin.getDefault(), "oxicons/24x24/devices/cdrom_unmount.png"), ResourceManager.getPluginImage(MvGuiPlugin.getDefault(), "oxicons/16x16/devices/cdrom_unmount.png")); 
		bc.addButton("Vorg
 |  
 |  
  |   |  
| Re: collapsible buttons layout issue [message #62918 is a reply to message #47732] | 
Tue, 10 March 2009 15:38   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I ran into the same issue.  I figured I'd my two cents and the work  
around I found. 
 
 From what I can tell, the problem with CollapsibleButtons now showing  
up initially in a view has something to do with the view being laid out  
before the Eclipse Workbench is open.   Basically, calls to the parent  
isVisible() return false until the workbench/view actually open causing  
the buttons to not be displayed. 
 
I briefly looked at creating a patch for CollapsibleButtons, but the  
algorithms heavily depend on isVisible, so I couldn't figure out a  
solution that didn't create more bugs (such as toolbar errors - similar  
to what Stefan wrote below). 
 
Thus, the solution (read: hack) is to add a listener for the Workbench  
opening and use that to invalidate/relayout the CollapsibleButtons on  
workbench open. 
 
Ex: 
PlatformUI.getWorkbench().addWindowListener(new IWindowListener(){ 
 
             @Override 
             public void windowActivated(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowClosed(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowDeactivated(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowOpened(IWorkbenchWindow window) { 
                 //Invalidate the size and relayout 
                 bc.setSize(-1,-1); 
                 bc.forceLayoutUpdate(); 
                 //Cleanup listener as it's only needed once 
                 PlatformUI.getWorkbench().removeWindowListener(this); 
             }}); 
 
-Matt 
 
Sjoerd Kessels wrote: 
> I have the same issue. Actually the buttons are shown when you drag the  
> handle down a bit once. In my case I tried to use the ButtonTester code  
> exactly with the same result. 
>  
> Sjoerd Kessels 
>  
> Stefan Reger schreef: 
>> I have an issue concerning the collapsible buttons widget: the  
>> ButtonsTester example works fine. I then try to use the widget in my  
>> RCP ViewPart class and the added CustomButtons do not show, no matter  
>> how often I call redraw, update, layout and so on. 
>> 
>> I tracked down the error to the CollapsibleButtons.VerticalLayout  
>> class which lays out the button only when button.isVisible is true. In  
>> the ButtonsTester example this method returns true, in my RCP view it  
>> returns false. The result is that the button does not receive a  
>> layout. If I uncomment the visibility check the buttons are correctly  
>> displayed and the collapse works too, but there is an issue with the  
>> toolbar at the bottom of the composite. 
>> 
>> Attached is my ViewPart class. 
>> 
>> Regards, 
>> Stefan Reger 
>>
 |  
 |  
  |  
| Re: collapsible buttons layout issue [message #588051 is a reply to message #47270] | 
Sun, 27 January 2008 11:05   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I have the same issue. Actually the buttons are shown when you drag the  
handle down a bit once. In my case I tried to use the ButtonTester code  
exactly with the same result. 
 
Sjoerd Kessels 
 
Stefan Reger schreef: 
> I have an issue concerning the collapsible buttons widget: the  
> ButtonsTester example works fine. I then try to use the widget in my RCP  
> ViewPart class and the added CustomButtons do not show, no matter how  
> often I call redraw, update, layout and so on. 
>  
> I tracked down the error to the CollapsibleButtons.VerticalLayout class  
> which lays out the button only when button.isVisible is true. In the  
> ButtonsTester example this method returns true, in my RCP view it  
> returns false. The result is that the button does not receive a layout.  
> If I uncomment the visibility check the buttons are correctly displayed  
> and the collapse works too, but there is an issue with the toolbar at  
> the bottom of the composite. 
>  
> Attached is my ViewPart class. 
>  
> Regards, 
> Stefan Reger 
>
 |  
 |  
  |  
| Re: collapsible buttons layout issue [message #593944 is a reply to message #47732] | 
Tue, 10 March 2009 15:38   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I ran into the same issue.  I figured I'd my two cents and the work  
around I found. 
 
 From what I can tell, the problem with CollapsibleButtons now showing  
up initially in a view has something to do with the view being laid out  
before the Eclipse Workbench is open.   Basically, calls to the parent  
isVisible() return false until the workbench/view actually open causing  
the buttons to not be displayed. 
 
I briefly looked at creating a patch for CollapsibleButtons, but the  
algorithms heavily depend on isVisible, so I couldn't figure out a  
solution that didn't create more bugs (such as toolbar errors - similar  
to what Stefan wrote below). 
 
Thus, the solution (read: hack) is to add a listener for the Workbench  
opening and use that to invalidate/relayout the CollapsibleButtons on  
workbench open. 
 
Ex: 
PlatformUI.getWorkbench().addWindowListener(new IWindowListener(){ 
 
             @Override 
             public void windowActivated(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowClosed(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowDeactivated(IWorkbenchWindow window) {} 
 
             @Override 
             public void windowOpened(IWorkbenchWindow window) { 
                 //Invalidate the size and relayout 
                 bc.setSize(-1,-1); 
                 bc.forceLayoutUpdate(); 
                 //Cleanup listener as it's only needed once 
                 PlatformUI.getWorkbench().removeWindowListener(this); 
             }}); 
 
-Matt 
 
Sjoerd Kessels wrote: 
> I have the same issue. Actually the buttons are shown when you drag the  
> handle down a bit once. In my case I tried to use the ButtonTester code  
> exactly with the same result. 
>  
> Sjoerd Kessels 
>  
> Stefan Reger schreef: 
>> I have an issue concerning the collapsible buttons widget: the  
>> ButtonsTester example works fine. I then try to use the widget in my  
>> RCP ViewPart class and the added CustomButtons do not show, no matter  
>> how often I call redraw, update, layout and so on. 
>> 
>> I tracked down the error to the CollapsibleButtons.VerticalLayout  
>> class which lays out the button only when button.isVisible is true. In  
>> the ButtonsTester example this method returns true, in my RCP view it  
>> returns false. The result is that the button does not receive a  
>> layout. If I uncomment the visibility check the buttons are correctly  
>> displayed and the collapse works too, but there is an issue with the  
>> toolbar at the bottom of the composite. 
>> 
>> Attached is my ViewPart class. 
>> 
>> Regards, 
>> Stefan Reger 
>>
 |  
 |  
  |   
Goto Forum:
 
 Current Time: Tue Nov 04 05:29:35 EST 2025 
 Powered by  FUDForum. Page generated in 0.26771 seconds  
 |