netbeans rcp adding to topcomponent at runtime - netbeans-7

I am working on a netbeans RCP desktop application and have a need to add components dynamically. For example, I have a button which if I click on the menu should add components to the window at runtime. I have an actionlistener for the button and I added the following code in the action performed, but am not seeing the new component added. Any help is appreciated.
TopComponent editorTopComponent = WindowManager.getDefault().findTopComponent("componentId");
editorTopComponent.add(new JButton("TEST"));
editorTopComponent.validate();
editorTopComponent.repaint();
editorTopComponent.updateUI();
Thanks

If you want create now instance (more then one), then you can use :
MyTopComponent my = new MyTopComponent();
my.open();
my.requestActive();
if you want open TC in one instance (only), then you can use:
TopComponent editor= WindowManager.getDefault().findTopComponent("componentId");
if(editor!=null){
JPanel x =editor.getMyPanel();
x.setVisible(false);
//some changes
x.setVisible(true);
if(!editor.isOpened())editor.open();
}
Jirka

Related

Why does NavigationView.ContainerFromMenuItem() return null except when executed from an event handler?

I am developing a WinUI3 app containing a NavigationView. The NV uses an observable collection to populate the NavigationViewItems.
The app must support expanding and collapsing NavigationViewItems programmatically. The only way I know of to do that is to set NavigationViewItem.IsExpanded = true. And the only way I know of to get the NavigationViewItem is through NavigationView.ContainerFromMenuItem().
The trouble is, ContainerFromMenuItem always returns null except when it is executed from a button event handler (such as a Click handler). The app must perform expand/collapse without user input.
For example, I have a button that launches a Click event with this code, which works just fine to toggle an NVItem:
Category selectedItem = (Category)navview.SelectedItem;
int idx1 = Categories.IndexOf(selectedItem);
var container = (NavigationViewItem)NavView.ContainerFromMenuItem(Categories[idx1]);
if (container != null)
{
container.IsExpanded = !container.IsExpanded;
}
However, that same code, when executed during app startup, such as in the MainWindow constructor after some test items are created, or in Attach(), always results in container being null.
So what am I doing wrong?
This question is somewhat similar to UWP: NavigationView.MenuItems results empty if populated programmatically but the answer to that one only deals with in-event use of ContainerFromMenuItem().
Thanks very much for any assistance on this.

RFT click on second named node

I have a JTree that has two same-named nodes.
I am writing an RFT script that needs to click the second-named node but it will only click the first entry it finds.
enter image description here
By utilising ITestDataTree, I have managed to retrieve the ITestDataTreeNode I need but can't figure out how to click it.
Is there any way to convert an ITestDataTreeNode object into a GuiTestObject?
Thanks in advance,
Steven.
Finally found a solution.
simple as:
List list = new List();
list.append(new Index(0)); // root
list.append(new Index(0)); // suite
list.append(new Index(0)); // scenario
list.append(new Index(0)); // testcase
list.append(new Index(1)); // action
jTree().click(list); // expands second action node

Call Pop-Up for WebDynpro from a Business AddIn?

We got a Web Dynpro Application which was created with the Floorplan Manager.
By clicking a specific button I start a Business AddIn which check some conditions and then it should show a popup on the screen with a message for the user.
Is there a way I can accomplish that?
One way to get a PopUp (eg confirmation) window in Floorplan applications is to overwrite the NEEDS_CONFIRMATION method of the Interface IF_FPM_GUIBB_*_EXT inside your feeder-class.
Create a reference to cl_fpm_confirmation_request and put this one in the export-parameter EO_CONFIRMATION_REQUEST of the Method.
By Example:
METHOD if_fpm_guibb_list_ext~needs_confirmation.
DATA li_req TYPE REF TO cl_fpm_confirmation_request.
CASE io_event->mv_event_id.
WHEN 'YOUR_EVENT_ID'.
CREATE OBJECT li_req
EXPORTING
it_confirmation_text = 'Plaintext in Content of Popup'
iv_window_title = 'Title of the Popup'
iv_button_text_approve = 'Text Approve-Button'
iv_button_text_reject = 'Text Reject-Button'
.
eo_confirmation_request = li_confrequ.
ENDCASE.
ENDMETHOD.
The method will be called before the PROCESS_EVENT-Method an will override it when you cancel the popup.
Please be aware that every GUIBB-Implementation has it´s own extension interface, e.g. List, Tree, ...
For a deeper look inside popups in FPM or custom-popups have a look into https://blogs.sap.com/2013/11/26/popups-in-floorplan-manager/

How to automate a splitButton using Rautomation ( adapter msuia)

I am trying to automate IE11 notification bar ( while downloading file) using Rautomation. Using MSUIA adapter I am able to catch the the save button. But I want to use Save As to supply the file location and name. But I cannot do that.
When seeing with UIspy I see that there is a splitbutton with name "Save". This splitbutton has another child splitbutton with name "" ( which is basically the down arrow) - I am not able to get to this control.
iemainwindow_local = RAutomation::Window.new(:class=>"IEFrame" , :adapter => :ms_uia )
ienotificationbar_frame = iemainwindow_local.child(:class=>"Frame Notification Bar")
ienotificationbar = ienotificationbar_frame.child(:class=>"DirectUIHWND")
if ienotificationbar.exists?
ienotificationbar.activate
sleep 1
mycontrol = ienotificationbar.control(:value =>"Save")
mycontrol2= mycontrol.control(:children_only => true)
mycontrol2.exist?
mycontrol.click
end
Getting error at this line mycontrol2= mycontrol.control(:children_only => true)
undefined method `control' for #<RAutomation::Adapter::MsUia::Control:0x4108e60>
Any idea how to get over this block?
I understand that there should be a menu and menuitems associated with the splitButton and when I click on down arrow besides Save, at UISpy I see that menu/ menu item is getting created directly under Desktop window ( though the processID is same ) - how to catch the menuitem Save as?
The Problem
Unfortunately, the :ms_uia adapter for RAutomation is not able to do this in its current form. I know this because I have written a lot of the UIA adapter for it :) The problem is that the current API doesn't allow you to really walk the tree like that (as you found out) because the Control class doesn't have a #control method. If the "Save" button had a native window handle, you'd be able to do this:
ieframe = RAutomation::Window.new(class: 'IEFrame')
save = RAutomation::Window.new(hwnd: ieframe.control(value: 'Save').hwnd)
save.control(index: 0)
Since it does not, unfortunately there isn't a reliable way to get down to it that I am aware of since it doesn't have any identifying properties about it (other than being a child of the "Save" button).
Alternative
I've written another gem called uia, which acts as a low-level wrapper around UI Automation and allows you to work more closely with UI Automation and interact with it how you see it within tools like UI Spy. Eventually, I will use this gem in RAutomation but have not had the time yet. To get down to the "Save As..." split button control in your circumstance, you can do this:
ieframe = UIA.find_element(title: /Thanks for downloading/)
save_as = ieframe.find(name: 'Save').find(control_type: :split_button)
save_as.as(:invoke).invoke
The save_as.as(:invoke) will treat the found "Save As" Element as something that implements the Invoke pattern, and then you can call the #invoke method to get the menu to pop.
Hope this helps!

Eclipse plug-in/product - force top-level coolbar layout?

I have an Eclipse product defined in a plugin - it does not define its own Application class (i.e. no custom implementation of IApplication). I am using some dynamic drop-down items in the main toolbar, defined in plugin.xml. I am building the Product using the Eclipse 4.3 (Kepler) platform.
At runtime, I would like the toolbar items to show which of the drop-down items are currently selected. For generic items, I use an icon, but for non-generic items I would like to show some identifying text. The identifying text is not always of the same length.
I am using an IElementUpdater to update the drop-down items and also the toolbar item. Everything works fine, except that the coolbar/toolbar/trimbar does not re-layout. If the new text is longer than the text it is replacing, or if I switch from icon to text or vice-versa, the toolbar appears empty - not even the drop-down arrow is showing. My test team reports that the Drop-down tool item "disappears", which is a pretty good description of the experience.
Is there any way to force the main toolbar/coolbar/trimbar complex re-layout?
I have done some research and it seems that I might be able to do this by defining my own IApplication implementation and capturing the Coolbar/Toolbar manager using an ActionBarAdvisor subclass for later calls to layout(). This is a pretty heavyweight solution - is there any other?
You can always retrieve toolbar manager from PartSite. There are also subclasses EditorSite and ViewSite:
IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite();
ToolBarManager mgr = null;
if (site instanceof IEditorSite) {
IEditorSite editorSite = (IEditorSite) site;
mgr = (ToolBarManager) editorSite.getActionBars().getToolBarManager();
} else if (site instanceof IViewSite) {
IViewSite viewSite = (IViewSite) site;
mgr = (ToolBarManager) viewSite.getActionBars().getToolBarManager();
}
Or if you know there is an active editor available:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars().getToolBarManager();
Or inside of a view:
ToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
Then you will get a possibity to layout it:
mgr.getControl().layout(true);