Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi
Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi [message #1744207] Fri, 23 September 2016 11:20 Go to next message
Joerg Specht is currently offline Joerg SpechtFriend
Messages: 2
Registered: September 2016
Junior Member
I have a simple e4 RPC application, based on e4 model. To create a label or a text field in a toolbar, you need a ToolControl model element (see Lars Vogel www.vogella.com/tutorials/EclipseRCP/article.html#toolcontrols). This works fine when the ToolControl is defined in Application.e4xmi, but not when is defined in fragment.e4xmi.

Definition of a label and a text field in Application.e4xmi

    <trimBars xmi:id="_MX9UBV73EeamgZGnnlIVZQ" elementId="toolbar:org.eclipse.ui.main.toolbar">
      <children xsi:type="menu:ToolBar" xmi:id="_MX9UBl73EeamgZGnnlIVZQ" elementId="e4.application.toolcontrol.label.1">
        <children xsi:type="menu:ToolControl" xmi:id="_FjpsAIAIEeaaRZl6bNljkA" elementId="e4.application.toolcontrol.0" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.LabelToolControl"/>
        <children xsi:type="menu:ToolControl" xmi:id="_ECTZgIDCEeabCK5EUzMndQ" elementId="e4.application.toolcontrol.1" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.TextToolControl"/>
      </children>
    </trimBars>


Definition of a label and a text field in fragment.e4xmi

  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_quycAH__EeaaRZl6bNljkA" featurename="trimContributions" parentElementId="org.eclipse.e4.ide.application">
    <elements xsi:type="menu:TrimContribution" xmi:id="_4VGgsH__EeaaRZl6bNljkA" elementId="e4.application.trimcontribution.0" parentId="toolbar:org.eclipse.ui.main.toolbar">
      <children xsi:type="menu:ToolBar" xmi:id="_6-GjQH__EeaaRZl6bNljkA" elementId="e4.application.toolcontrol.label.2">
        <children xsi:type="menu:ToolControl" xmi:id="_9q-ZMH__EeaaRZl6bNljkA" elementId="e4.application.toolcontrol.label" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.LabelToolControl"/>
        <children xsi:type="menu:ToolControl" xmi:id="_JV9EcIDCEeabCK5EUzMndQ" elementId="e4.application.toolcontrol.text" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.TextToolControl"/>
      </children>
    </elements>
  </fragments>


LablelToolControl class

public class LabelToolControl {
	@PostConstruct
	public void createControls(Composite parent) {
		createLabel(parent, "OneLabel");
	}

	private Control createLabel(Composite parent, String labelText) {
        final Label label = new Label(parent, SWT.LEFT);
		label.setText(labelText);
		label.setVisible(true);
		return label;
	}
}


TextToolControl class

public class TextToolControl {
	@PostConstruct
	public void createControls(Composite parent) {
		createTextbox(parent, "OneTooltip");
	}

	private Control createTextbox(Composite parent, String toolTipText) {
		final Text textBox = new Text(parent, SWT.SINGLE | SWT.BORDER);
		textBox.setToolTipText(toolTipText);
		textBox.setVisible(true);
		return textBox;
	}
}


I use in both cases the same classes. Has anyone an idea?
I have appended an sample project.
Re: Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi [message #1771303 is a reply to message #1744207] Wed, 23 August 2017 20:07 Go to previous messageGo to next message
Guido Schnepp is currently offline Guido SchneppFriend
Messages: 9
Registered: March 2013
Junior Member
Jörg,

have you find any solution for this? I'm run into the same problem. Only "solution" I've found (well, not a good solution) is, that rendering of tool controls in a fragment works fine if they are placed outside of a toolbar - or between two of them. As long as it's placed as child of a toolbar, my control is not rendered successfully.

Many thanks in advance
Guido

[Updated on: Wed, 23 August 2017 20:29]

Report message to a moderator

Re: Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi [message #1771383 is a reply to message #1771303] Thu, 24 August 2017 13:22 Go to previous messageGo to next message
Guido Schnepp is currently offline Guido SchneppFriend
Messages: 9
Registered: March 2013
Junior Member
Jörg & all,

I've found another workaround which is a little application specific: My application hide and show toolbars as needed, depending on the active MPart resp. its inner contents. For this I have implemented a loop over all toolbars and first tried:
toolBar.setVisible(true / false)

which did nothing. I found that this works for me:
toolBar.setToBeRendered(true / false)

Well, this doesn't solve the problem with toolcontrols not rendered correctly, but I found that any additional
toolBar.setToBeRendered(false)

does! So unsetting the ToBeRendered-flag before setting the same option to true in code lets the whole toolbar render again immediately, showing also the toolcontrol as desired:
toolBar.setToBeRendered(false)
toolBar.setToBeRendered(true)

I've not found any better function to let the toolbar render again.

Regards
Guido

Re: Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi [message #1774167 is a reply to message #1771383] Wed, 11 October 2017 08:59 Go to previous message
Joerg Specht is currently offline Joerg SpechtFriend
Messages: 2
Registered: September 2016
Junior Member
My fault: The ToolControls are defined at the wrong position in fragment.e4xmi. The ToolControls have to be defined directly under the trimContributions:

<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_HsXHAMMxEeWKF8pEyQXdlA">
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_quycAH__EeaaRZl6bNljkA" featurename="trimContributions" parentElementId="org.eclipse.e4.ide.application">
    <elements xsi:type="menu:TrimContribution" xmi:id="_4VGgsH__EeaaRZl6bNljkA" elementId="e4.application.trimcontribution.0" parentId="toolbar:org.eclipse.ui.main.toolbar">
      <children xsi:type="menu:ToolControl" xmi:id="_9q-ZMH__EeaaRZl6bNljkA" elementId="e4.application.toolcontrol.label" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.LabelToolControl"/>
      <children xsi:type="menu:ToolControl" xmi:id="_JV9EcIDCEeabCK5EUzMndQ" elementId="e4.application.toolcontrol.text" contributionURI="bundleclass://e4.application/e4.simple.dynamic.toolbar.TextToolControl"/>
    </elements>
  </fragments>
</fragment:ModelFragments>
Previous Topic:How to close the workbench from an other bundle
Next Topic:SceneBuilder integration
Goto Forum:
  


Current Time: Fri Nov 24 11:24:08 GMT 2017

Powered by FUDForum. Page generated in 0.02995 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software