jxBrowser not resetting focus - eclipse

I am running into a focus issue for the jxBrowser. I integrated the jxBrowser into eclipse as a view and editor, using JavaFX FXCanvas as a container of the jxBrowser. When switching between views within Eclipse, the browser no longer receive focus. It is not possible to use the keyboard, and it is not possible to scroll around the view. Any one know any workaround?
Here is an example of the code:
container = new javafx.embed.swt.FXCanvas(parent, SWT.NONE);
container.setLayout(gridLayout);
container.setLayoutData(gridData);
browser = new Browser();
browserView = new BrowserView(browser);
container.setScene(new javafx.scene.Scene(browserView));
Thanks!

Related

Showing TinyMCE code plugin into the editor, not in popup

I am designing an HTML editor for Windows Forms. I use Geckofx 60.64 and TinyMCE 5.2.0 for this. When everything runs smoothly, this will be a usercontrol.
Here is the screenshot:
And I don't want anything that pops up as a popup in this usercontrol. However, TinyMCE's code plugin opens as a popup.
As in the TinyMCE editor in Wordpress, I want the contents of the HTML code to be displayed in the editor when you click on the code icon and return it when you click the code icon again. But I have no idea how I can do it.
In order to better explain what I want, I also designed a simple image in Photoshop.
The code view in WordPress is not actually using the TinyMCE code view plugin. Rather it extracts the editor contents, loads it into a textarea, allows you to edit, and then it re-invokes TinyMCE and reloads the updated HTML.
If you want a similar experience to WordPress you will have to create the code view behavior yourself.
If you want to use the code viewer that TinyMCE provides it works as a dialog.
I had a similar request (displaying html source in editor) and achieved a pretty simple and (for me) sufficient solution by modifying the initial (open source) code plugin:
var e = tinymce.util.Tools.resolve("tinymce.PluginManager"),
p = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),
o = function (o) {
var e = o.getContent({source_view: !0});
var b = o.getBody();
if (b.getAttribute("code") === "true") {
b.setAttribute("code", "false");
b.style.backgroundColor = "white";
b.style.color = "black";
b.style.fontFamily = "Helvetica";
o.setContent(p.DOM.decode(e));
} else {
b.setAttribute("code", "true");
b.style.backgroundColor = "black";
b.style.color = "white";
b.style.fontFamily = "Monaco";
o.setContent(p.DOM.encode(e));
}
};
Instead of opening a new window, it just changes the css of the editor (background, color, font) and sets a data-attribute (enables toggling between the initial view and the code view). The p.DOM.encode(e) then allows to display the html tags.
I'm not very experienced in javascript, but it works good so far. Anyway, feel free to correct / improve things.

Adding menu to In E4 MWindow

In our Eclipse E4 (pure e4) application I have to open a new window and show some views in a new window (which is completely different from the main window). In the new window I am trying to add menu (File->Import) pro-grammatically. I have written the below code but the new window is not showing the menus. Anything I am missing?
`
MTrimmedWindow window = MBasicFactory.INSTANCE.createTrimmedWindow();
....
MMenu menuBar = MenuFactoryImpl.eINSTANCE.createMenu();
menuBar.setLabel("Test");
window.setMainMenu(menuBar);
MMenu fileMenu = MenuFactoryImpl.eINSTANCE.createMenu();
fileMenu.setElementId("file");
fileMenu.setLabel("File");
menuBar.getChildren().add(fileMenu);
MMenuItem item1 = MenuFactoryImpl.eINSTANCE.createDirectMenuItem();
item1.setElementId("item1");
item1.setLabel("item1");
fileMenu.getChildren().add(item1);`
Don't add the window to the application children until after you have created and setup the main menu (and anything else you want to have in the window).
When you add the window to the application child list it is rendered immediately. So if you have not set the main menu at that point it will not be shown.
If your window design is fixed you can avoid all this code by designing the window in the Application.e4xmi. Just turn off the 'to be rendered' flag so it is not show initially and then do:
MTrimmedWindow window = (MTrimmedWindow)modelService.find("window id", app);
window.setToBeRendered(true);
to show the window.

Change menus and menu items programmatically in Eclipse E4

I am having trouble removing existing menus from the model, in a running app.
For example:
MMenu menu = modelService.findElements(app, "idMenuFoo", MMenu.class,
Collections.<String>emptyList(), EModelService.IN_MAIN_MENU).get(0);
menu.setLabel("X");
menu.setVisible(false);
menu.setToBeRendered(false);
After this code gets executed:
The label has been changed to 'X'
But the menu entry is still visible/rendered
If I start the app without clearPersistedState, then restart it, the menu has disappeared. This leads me to be believe the the visibility and rendering attributes were set in the first place, but not applied to the model (unlike the label attribute).
How can I programmatically trigger a main menu bar "refresh" after such changes?
As a Greg in the comment above posted, there is an open bug filed to address this issue. An easy to implement a workaround involves manually refreshing the underlying SWT menu. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=365724#c9 for details. In a gist:
// retrieve the main menu, containing the top-level menu element that needs to be refreshed
MMenu mainMenu = ...
// org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer
MenuManagerRender renderer = (MenuManagerRenderer)mainMenu.getRenderer();
renderer.getManager(mainMenu).update(true);

Open new browser windows in background using CoffeeScript

How can I open a new browser in the background?
I trying to use window.open, but the new windows always open with focus.
I tried to do:
popup = window.open(#pop_url, '', 'width=,height=,resizable=YES')
You would have to remove the focus from the new window using blur() and set the new focus to your parent window using focus():
popup = window.open(#pop_url, '', 'width=,height=,resizable=YES');
popup.blur();
window.focus();
But be aware since this method has been used in the past mainly for user unfriendly behavior or content this will be blocked my most popup blockers - even though this method is actually called popunder.

AutoCompleteExtender positioning menu incorrectly when scrolled

We have an AutoCompleteExtender linked to a TextBox. Both controls are placed inside an UpdatePanel, and the UpdatePanel is displayed as a pop-up dialog using a Javascript library (Ext.BasicDialog).
The pop-up is a div on the page, not a separate window.
The problem is that when the user scrolls inside the pop-up, the AutoCompleteExtender shows its menu in the wrong place. It looks like it is taking the visible distance from the top of the popup and positioning the menu from the top of the inner html of the popup (which is not visible)
We are using Version 1.0.20229.20821 of the AjaxControlToolkit, and we are targetting ASP.NET Framework vewrsion 2.0.
I have tried to fix the menu by attaching the following Javascript to the OnClientShown event, but it pretty much does the same thing:
function resetPosition(object, args) {
var tb = object._element; // tb is the associated textbox.
var offset = $('#' + tb.id).offset();
var ex = object._completionListElement;
if (ex) {
$('#' + ex.id).offset(offset);
}
}
I fixed this by setting position:relative on a div containing the TextBox and the auto-complete extender. The extender must have been using the wrong element to position on when inside the popup panel.
Add an empty <div id="AutoCompleteContainer"></div> element right after the AutoCompleteExtender. In AutoCompleteExtender, add an attribute pointing to this container, CompletionListElementID="AutoCompleteContainer". The list items should be contained in that div then.
I know this is an old post, but thought this information may help someone else. There is a newer version 15.x of the Ajaxtoolkit now (April 2015) and it fixes this issue. From my reading the CompletionListElementID property was deprecated some time ago, and at the least seems to behave differently in different versions. I upgraded my references to the 15.x version and it just started working as needed.