Eclipse launch existing launch-configuration - java

So i am writing an eclipse plugin, which adds a custom-launch action to the toolbar. It extends AbstractLaunchToolbarAction , thus it also has that dropdown menu with launch history and so on. This menue is filled up with actions, containing the lauch-configurations.
At this point, when i open dropdown menu and select one launch configuration from the history, it works fine and runs the configuration.
However, my aim would be to alter this behaivor, to do something more.
My problem is that i cannot find the place where the launch configuration from the menu is processed, thus i cannot do anything with it...
So far i just create the menue by calling the fillMenu(Menu m)
So my question is, how (in code) does eclipse proccess the exceution of the history launch-configuration? Where does the actual launching take place.

Figured it out... The menu consists of Action elements, which have method 'run' ... This method gets called when the Action is clicked.

Related

How To Access Invocation Count in Netbeans?

I have a project I'm working on and I need to do some profiling now that the bulk of the coding is finished. However one of the stipulations for completion is that I need to find out Total Time taken for the methods to execute and also how many times a particular method is executed. However it's driving me nuts trying to find Invocation Count on Netbeans. One of the help pages online said click the Drop Down Arrow in the window but all I can see as a selection column called "Hits"; I googled that and no explanations crop up. Anyone here have experience with NetBeans profiling? Thanks in advance.
I think the solution may be as simple as changing the list selection labeled Profile in the OP screen shot from All classes to Selected methods. However, if that is not the case, here is a walk through of the setup to get the invocation count for selected methods in a results snapshot when profiling in NetBeans:
Select Profile -> Profile Project for your project.
If no profiling has been set up the screen should look similar to this:
Click the Configure Session button (or link) shown in the screen shot above.
From the drop down list check User Defined Profiling Points, and select Methods.
This will cause a Settings cog wheel icon on the far right to be displayed. Click that to display another drop list labeled Profile with a default selection of All classes.
Click that Profile drop list, and select Selected methods which will allow Invocations to be shown in the profiling results. (The screen shot in the OP shows All Classes is selected instead.)
Having chosen the profile Selected methods, click the Add button shown in the screen shot below, and select the methods to profile in the Select Method dialog:
Finally run your app with the selected profiling options by clicking the Profile button with the green triangle to its left.
The Invocations column (n.b. not Invocation Count) should be displayed in the results. If not then click the black inverted triangle on the far right of the column headers row, which allows toggling the display of each column in the results snapshot.
These instruction specifically apply to the most recent stable release of NetBeans (8.2) but the general principles should be valid for earlier releases as well, though possibly with some differences in the details.

java popup menu has no focus with VK_CONTEXTMENU

I am incorporating a popup menu in my java application.
I have added a mouse listener to show it up and I have also registed a keyboard action with the key event KeyEvent.VK_CONTEXT_MENU, that brings it up as well.
Problem is that the popup has no focus when it gets to be shown. I can't use the up and down arrows in order to walk it through. In fact, it can be operated only with the mouse (which takes the stinger from my wish to operate my system using the keyboard only...).
I could not find any useful information on that issue over the net, and have already read the java tutorials entry on menu. I also tried the following (each on its own, and cooperated), and none of them worked:
Calling popupmenu.requestFocusInWindow() before and after the show is invoked.
Calling popupmenu.setSelected(firstMenuItemObjectInstance) before and after the show is invoked.
Calling firstMenuItemObjectInstance.requestFocusInWindow() before and after the show is invoked.
any ideas ?

Eclipse Plugin: Creating a dynamic menu and corresponding handler?

I am trying to write what I think is a very simple Eclipse plugin, but I am really struggling to find my way around as I have never worked with the PDE before.
Basically what I am trying to do is add a sub-menu to the Java Project context menu that will list a bunch of available files in the project's root directory. Then upon selecting one of these sub-menu items I want the handler to be called and passed the name of the file that was selected.
So far I have managed to get the menu to appear correctly by adding a dynamic menuContribution to the org.eclipse.ui.menus extension point. I have defined my own CompoundContributionItem which finds all of the files in the appropriate directory and populates the menu. Each of these menu items is hooked up to my handler (extends AbstractHandler) and the handler does get called each time a menu item is selected. What I don't know how to do is to get my handler to actually do something based on which of the menu items was selected. It would be enough if it was somehow passed the string of the menu item label, but I'm guessing there is probably a much better way of doing this.
I tried looking through the code of the org.eclipse.debug.ui to see how they do it with the run/debug configurations, because that is pretty much exactly what I want. They pick up the .launch files from the .launches directory of the project and display them in a list. The code for that is very complicated though and has a lot of other behaviour that is unassociated with it, so as a beginner I am struggling to get my head around it. Also, they seem to have done it a different way than I did, so it might be that I am totally wrong in my approach. Any help or pointers would be appreciated.
I finally found the answer to this myself. Within plugin.xml it is possible to specify parameters for each command, e.g.
<commandParameter
id="commandParameterID"
name="Name of the Parameter"
optional="false">
</commandParameter>
Now, when I am dynamically creating each menu item I can just add my parameter to the parameters Map of the CommandContributionItemParameter object.
CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "CommandID", CommandContributionItem.STYLE_PUSH);
param.parameters = new HashMap<String, String>();
param.parameters.put("commandParameterID", "TheValue");
The parameters that are added this way are accessible in the handler class as follows:
public Object execute(ExecutionEvent event) throws ExecutionException {
System.out.println(event.getParameter("commandParameterID"));
return null;
}
Possibly this simple menu creator helps you a step further (or the surrounding classes within the project underlying the link)
or maybe the plugin.xml of the popup menu within the same project

How to quickly navigate between Java class method definitions in a large class without the 'Find' dialog in Eclipse?

I use what I think is a typical layout in Eclipse: my workspace contains the Project Explorer on the left and the Java editor window taking up most of the screen, with the small console window at the foot of this editor pane.
When I open a very long Java class, containing a large number of method definitions, in the editor pane, it can take a long time to move between methods. I use CTRL-F to open the Find dialog and then type in the name of the method if I can remember it.
Is there a better way to navigate between method definitions in a large class in Eclipse?
Ctrl+O will open a dialog with the methods (and variables) list. It supports "advanced" :-) searching so you can just type a few letters of the method's name
Use the Outline View.
I use a layout much like yours but I keep the Outline panel open in it beneath the project/package explorer. This makes it easy to see the project's outline as well as the current editor's outline at a glance.
In addition to the Ctrl+O option for a quick outline, one can type (on a Mac) Cmd-Alt-Q then O to focus the Outline view. Once focus is in the Outline view, you can use the arrow keys or letter keys to navigate through the list of methods.
Cmd-Alt-Q is useful for opening many of the views. In my Eclipse Helios right now, a momentary delay after playing the chord presents a quick list of many different views, many of which have their own hot key.
Finally, you can use the "Next/Previous member" chord to jump to the previous or next method definition in the file. Again in my Helios build, the Next member key is Ctrl-Alt-down . Yours may be different.
To find out what the keystrokes are in your Eclipse build, open the eclipse preferences. Use the searcher to search for 'keys'. Open the configuration for Keys . Then in the keys search bar look for "member". There should be an item for "Next member" with a bound shortcut key/chord. Browsing the list of hotkeys is a great way to improve Eclipse productivity in the long run ;)

Embedding JTextArea into a JMenuItem

We are building our own Web Browser in Java. It doesn't have to be anything too complicated, we just want several things to do so we could distinguish our project from others.
What we want to know is this:
Is it possible to somehow embed a JTextField object into a JMenuItem?
To be more precise, we want our address bar (text field) to show when we click on a certain item within our menu.
Well, menu items are used for invoking an Action which causes the menu to close.
So you would just have your menu item Action display a popup dialog or something like that.
Or, if you really want to keep the popup open, the you could probably create a sub menu and then just add the JTextField to the sub menu. Remember, you can add any Component to JMenu.
Or, if you just want the text field to display on the main menu, then you just add the text field to the main menu. Of course you would lose functionality like being able to use the keyboard to navigate up and down the menu list.
All the suggestions are a hack at best, so I agree with the original comment to your question.
It's done in the standard OS X "help" menu, so I wouldn't call it an interface "quirk".
A quick google turned up this old link from 2004:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2004-12/0149.html

Categories