MPart toolbar too small for text ToolControl - eclipse-rcp

I added a search text ToolControl to a MPart toolbar as described here:
Eclipse e4 tool Control in trimbars
http://www.vogella.com/tutorials/EclipseRCP/article.html#toolbar_advanced_toolcontrols
My problem is:
When I have another item (e.g. handled tool item with icon) in the toolbar, I can see most of the text, but not all. When there is no other item, I see just the upper line of the text.
The toolbar height seems not to be adapted to my control,
Whould be great if anyone can help me.
Christin

The basic problem is that although the ToolBar control allows controls as children it doesn't take their depth in to account when calculating the tool bar depth.
The Vogella example (which is intended for the window trim bar rather than a part tool bar) is using a default GridLayout which adds a margin above the search text. You could try using:
Composite comp = new Composite(parent, SWT.NONE);
// GridLayout with no margins
comp.setLayout(GridLayoutFactory.fillDefaults().create());
Text text = new Text(comp, SWT.SEARCH | SWT.ICON_SEARCH | SWT.CANCEL | SWT.BORDER);
text.setMessage("Search");
GridDataFactory.fillDefaults().hint(130, SWT.DEFAULT).applyTo(text);
That is using a GridLayout with no margins.

Related

How to Change the cursor in JavaFX Accordion title bar

I'm using custom cursors and it need to be differ in some components in my screen.
When I set the cursor for Accordion, it doesn't effects title headers but effects the body of each TitledPanes. I even tried to set the cursor for each TitledPane but it doesn't effect the title header. I'm using following way to change the cursor.
ImageCursor cursor_title = new ImageCursor(cursorImg_title,cursorImg_title.getWidth() / 2,cursorImg_title.getHeight() / 2);
accordionBody.setCursor(cursor_title);
Is there a way to change the cursor in title bar of a JavaFX Accordian?
More....
I have changed the padding of title bars using css as follows. Hope it doesn't have any relation to the problem.
.titled-pane > .title {
-fx-padding: 30;
}
A TitledPane is divided into two parts :
Title
Content
When you are setting the Cursor on the Accordion, it delegates it to the content of each TitledPane, but leaves the Title. This is by design.
To force your application to change the cursor on the title as well, we need to set it on each of these nodes. We can fetch all the nodes by using the lookupAll() on the accordion and passing the styleclass they use i.e. .title. Make sure you use this after the scene graph is visible.
accordion.lookupAll(".title").forEach(node -> node.setCursor(Cursor.CLOSED_HAND));
You can use your custom cursor in place of CLOSED_HAND.

GXT ScrollBar overlapping content

I'm using setScrollMode(ScrollMode.AUTOY) to enable vertical scrolling when necessary on a VerticalLayoutContainer. However, the scrollbar overlaps the content of the container. The only way around this that I've seen is to call setAdjustForScroll(true). The problem with this is that The panel will then always reserve space for a scrollbar even when one is not present.
Is there a way to tell GXT to only adjust for a scrollbar when one is present? Or perhaps use an event handler (eg ResizeHandler) and check if the scrollbar is currently visible?
Instead of trying to check in a handler if the scrollbar is visible, isn't it just easier to not have the content in the VerticalLayoutContainer?
For example I have:
VerticalLayoutContainer vp = new VerticalLayoutContainer();
vp.setScrollMode(ScrollMode.AUTO);
vp.add(layer1, new VerticalLayoutData(1, -1));
vp.add(layer2, new VerticalLayoutData(1, -1));
vp.add(layer3, new VerticalLayoutData(1, -1));
the layers(1-3) contain the actual content and are different types Ex. VBoxLayoutContainer, Container, VerticalLayoutContainer.
It works for me. I don't think it is relevant but I am adding the vp to a CenterLayoutContainer that is added to the root panel.

Eclipse layout for table and two buttons

I am trying to lay out a form for an Eclipse editor and running into a few problems.
The idea is to have a page which contains 2 sections - the left hand section contains a table and two buttons. The table should line up with the top of the section and expand right to the bottom. I want the buttons to sit to the right of the table in the section with each button under the other and for them to align with the top of the table.
Does anyone know what settings for GridLayouts I need to make this work? I've tried every combination I can think of with no luck.
The closest I can get ends up with the second button at the bottom of the page.
Here is an excerpt of my code so far:-
Section section = toolkit.createSection(sashForm, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | ExpandableComposite.NO_TITLE_FOCUS_BOX);
section.setText("All Items");
Composite client = toolkit.createComposite(section);
section.setClient(client);
client.setLayout(new GridLayout(2, false));
Table table = toolkit.createTable(client, SWT.NULL);
table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
TableViewer viewer = new TableViewer(table);
Button addButton = toolkit.createButton(client, "Add", SWT.PUSH);
addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
Button removeButton = toolkit.createButton(client, "Remove", SWT.PUSH);
removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
Have a look at SWT Layout Tutorials it has a good section on GridLayout.
You will want to use the GridData.verticalSpan for the table to get it to cover two rows. That should put the two buttons on the right. But then the buttons will take the same space as the table which is probably not what you want, so you may need to give vertical size hint to the table.

Widget used in GWT showcase left menu

I would like to develop in GWT a vertical menu similar to the one found on http://gwt.google.com/samples/Showcase/Showcase.html (the left blue menu which first section is "Widgets").
Since it's a GWT showcase, one can assume that left menu is a GWT widget, but which one ?
I have browsed every example and none of them looks like that menu. Any guess ?
Did you know the Showcase sample is open-source? It's even bundled with the GWT SDK.
The code tells use it's a CellTree within a ScrollPanel (within a DockLayoutPanel within a DockLayoutPanel):
The UiBinder template
The code initializing the CellTree
The code initializing the TreeViewModel (including prefetching the split-points for the samples when you expand a category node; and updating the center panel when you select a sample node)
the TreeViewModel itself
It's the CellTree widget!
A demo is actually inside the showcase: CellTree, but in the example, it has a different style applied:
CellTree.Resources res = GWT.create(CellTree.BasicResources.class);
CellTree.Resources res = GWT.create(CellTree.BasicResources.class);
cellTree = new CellTree(
new ContactTreeViewModel(selectionModel), null, res);
(this stlyes makes the +/- buttons and lets it look like a regular tree)
If you don't apply this style the Cell Tree looks like the left menu.
Looks just like a vertical arrangement of DisclosurePanel. Here are the docs.

Eclipse RCP: Right aligned search field in toolbar

I would like to have a right aligned search field in the toolbar of an Eclipse RCP application. I already created the text field as ControlContribution and the respective search action in the ActionBarAdvisor class:
protected void fillCoolBar(ICoolBarManager coolBar) {
IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
//...
toolbar.add(new ControlContribution("searchText") {
//...
This works and I have the search field in the toolbar. But how can I align the search text (or the toolbar with the search text) on the right side?
Thanks,
Michael
If you mean positioning search toolbar on the right hand site of the main toolbar, then consider using these areas instead (when using org.eclipse.ui.menus extension point):
toolbar:org.eclipse.ui.main.toolbar - the top-level tool bar
toolbar:org.eclipse.ui.trim.command1 - the top left trim
toolbar:org.eclipse.ui.trim.command2 - the top right trim
toolbar:org.eclipse.ui.trim.vertical1 - the left vertical trim
toolbar:org.eclipse.ui.trim.vertical2 - the right vertical trim
toolbar:org.eclipse.ui.trim.status - the status line trim