Is it possible to set tool tip to title of JFace dialog - swt

I have created a custom Dialog which extends org.eclipse.jface.dialogs.Dialog. I'm Setting the title of the Dialog by overriding the configureShell method.
#Override
protected void configureShell(Shell shell)
{
super.configureShell(shell);
shell.setText("Parent \ Child \ Sub Child \ Sub Sub Child\ Sub Sub Sub child");
}
I have set the Initial size of the Dialog , so the text if exceeds the width of the Dialog , it displays the text till there and then followed by ...
Is it possible to increase the size of the tile bar?
Is it possible to add a tool tip to the text?

No, you can't set a tooltip or change the size.
The title bar is managed by the operating system window manager. The only things that can be specified in SWT are the title and the style bits when the shell is created.
You could also look at TitleAreaDialog which gives you an area at the top of the dialog for a more expansive title.

Related

Codename One LeftBarCommand Text Size not Changing

In my application I am using a command added to the top left bar and I am trying to change the font size.
What is generally a simple task is causing quite a bit of labor and I still couldn't figure it out.
In the theme builder, I have tried to change the font size in the default settings (changes the color, but not the size) and accessing several component UIIDs, including Command, SideCommand, ToolBar and others, all to no avail.
Command also does not give give direct access to the styles.
How can I change the font size of the command? Is there a special UIID?
Command left = new Command("Done") {
#Override
public void actionPerformed(ActionEvent evt) {
confirmationDialog();
}
};
tb.addCommandToLeftBar(left);
You can customize the command UIID by:
left.putClientProperty("uiid", "MyUIID");
In the case of title commands they have the UIID TitleCommand.

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.

How can I switch between two menu bars occupying the same space below the window title in GTK3?

I like to switch menu bars depending on a button or internal state (COM port used). How can I do that in GTK3+ (preferably using Glade and GtkBuilder)? GtkOverlay does not seem to be the correct approach.
Put both menubars in a gtk(v)box and just declare one of the menubars as invisible in Glade (Leave the one you want by default visible). Then you can later switch menubars by hiding/showing them.
Mind, if you are on Ubuntu, you might run into problems. Ubuntu's Unity moves the menu bar to the top of the workspace, and it might not be happy with two menu bars just existing. In a program I made a couple of years ago Ubuntu refused to show the second menu (but I wasn't hiding either of them, so you might be in luck).
Thanks jcoppens for your answer, but I am not sure how the solution would look over all with one of the positions in the vertical box invisible but still occupying space / the height of one menu bar. Wouldn't that create a gap between either the title and the menu bar (first menu bar visible) or the menu bar and the container below (second menu bar visible)?
I solved it by (before I saw your answer):
Using Glade, create a new file and put the two menu bars in there.
In the Glade file for the main window, create a vertical box with one
item right below the title. (In my case, my main frame contains a
vertical box with three items, the first position is kept empty and
will contain one of the two menu bars, the second one contains all
other items inside another container, and the third item contains a
status bar.)
In the C module using GtkBuilder, I switch the menu bars as shown
below:
/**
* This function adds or replaces the menu bar.
* #param id id string for menu bar
*/
void amci_tester_set_menubar(const gchar *id) {
GtkWidget *menu_bar = GTK_WIDGET(gtk_builder_get_object(builder, id));
GtkBox *box_menu = GTK_BOX(gtk_builder_get_object(builder, "boxMainMenu"));
GList *children = gtk_container_get_children(GTK_CONTAINER(box_menu));
if (children != NULL)
gtk_container_remove(GTK_CONTAINER(box_menu), (GtkWidget *) g_list_first(children)->data);
gtk_box_pack_start(box_menu, menu_bar, false, false, 0);
// Although the visible property is shown as being set in the Glade GUI, in
// the Glade file it is not set.
gtk_widget_set_visible(menu_bar, true);
g_list_free(children);
}
In the beginning of main, I put the usual GtkBuilder stuff, instantiating a GtkBuilder object and then adding the default / first to be shown menu bar object:
// Init GTK+.
gtk_init(&argc, &argv);
// Create new GtkBuilder object from file.
builder = gtk_builder_new_from_file(glade_filename_app);
if (builder == NULL) {
g_warning("Could not create builder from %s", glade_filename_app);
return 1;
}
// Add menu bar for PC menu bar (default) from file.
if (!gtk_builder_add_from_file(builder, glade_filename_menu_pc, &error)) {
g_warning("%s", error->message);
g_free(error);
return 1;
}

Freezing the tool tip after clicking on it

I am trying use org.eclipse.jface.window.DefaultToolTip to display some UI components like checkbox,radio buttons placed on composite. When user clicks on a text, the tooltip with pops up to and displays the UI components.
Issue: I want to freeze tool tip once user clicks inside this tooltip. Using toolTip.setHideOnMouseDown(false); I am able to check/un-check the check boxes/radio buttons as long as I am inside the tool tip area. Once mouse pointer exits the tool tip area, the tooltip disappears. How can this be avoided. I am looking for similar behaviour which is available for eclipse tooltips( javadoc, method definition). In Eclipse tooltip, if we click/press f2, tooltip will remain active until we click outside of the tooltip area.
Edit: I also tried to use Eclipse Plugin Spy on tooltip, but no success.
Any thoughts.
What Eclipse does when F2 is pressed is to create a new Shell with exactly the same size and contents as the tooltip and closes the original tooltip.
I use code like the following in an extended tooltip class:
/**
* Switch from tool tip to a normal window.
*/
private void showWindow()
{
if (_control.isDisposed())
return;
final Shell shell = new Shell(_control.getShell(), SWT.CLOSE | SWT.ON_TOP | SWT.RESIZE);
shell.setLayout(new FillLayout());
createBody(shell);
final Point currLoc = _parent.getShell().getLocation();
final Rectangle client = _parent.getClientArea();
final Rectangle bounds = shell.computeTrim(currLoc.x, currLoc.y, client.width, client.height);
shell.setBounds(bounds);
shell.open();
// Hide the tool tip window
hide();
}
_control is the control passed to the constructor.

Eclipse ui: retrieving the first visible line of an editor

In the Eclipse UI, I'd like to set the visible area in an editor. In other words, if the number of lines of my file is larger than the number of lines my editor can show then I want to specify the first shown line. My first approach was to calculate the first visible line via the selection value of its vertical scroll bar. The following link points to my initial question. Its answer explains how to set the first visible line in an editor.
eclipse ui: setting scrollbar but editor does not follow
The problem now is that my initial way of retrieving the first visible line in an editor fails in some cases: Although I verify that the active page is indeed an editor, the focus might be assigned to another page. In such a case, the following code yields the ScrollBar of a different page:
public static void update(final IWorkbenchWindow w)
final Scrollable scrollable =
(Scrollable) w.getWorkbench().getDisplay().getFocusControl();
final ScrollBar vScrollBar = scrollable.getVerticalBar();
So, my question: If editor is the reference of an active editor (ITextEditor and IReusableEditor), how to I get its first visible line?
If you can access the editor ITextViewer or its extension ISourceViewer (usually implemented by the SourceViewer or TextViewer class) you can call the ITextViewer.getTopIndex() method to get the top line index.
If your editor is derived from AbstractTextEditor (or one of its subclasses such as TextEditor) there is a protected method getSourceViewer() that returns this. You may have to add a public method if you want to access this from outside of the editor.