How to use main class selection dialog? - scala

I want my sbt plugin to have the same behavior as sbt run task - use a main class if there's only one and ask a user to choose one if there're multiple. How do I do it?

Turns out selectMainClass setting either shows a dialog or uses the value from mainClass

Related

Intellij Main Class Always Changing

my question today is if there is a way for IntelliJ to build with the current class file I have Instead of always going into the configurations setting and changing the Main class from there.
Picture :
Ok I now understand want you want :)
I hope this image helps.
You can create a run configuration for each class with a main method. In this example we have three classes Main1, Main2 and Main3 which you can see on the left in the image. So I created three run configurations called Main1, Main2 and Main3 which have the corresponding classes set as Main class.
You can add multiple run configurations by clicking on the green plus.
In the toolbar you then can choose the run configuration which you want to run.
EDIT:
You can just make a right click on the main method and choose the option run. I guess that is what you want :)
You can probably go in and change the default to default to that class

Cannot run the selected program/Script in selenium webdriver

I am unable to run some of the classes in my project.After opening the class if i mouse over on Run button its showing different class that i executed previously.I am unable to run the class I opened and one thing i observed is the class which i am unable to run is used as extended class for other classes.Please help me out with this issue and suggest me if i need to change any Run configuration settings?.enter image description here
There is no test or main method to run which is why you are not seeing any option to run..either mark that f method with #Test or any other annotation from testng or create a main method

Change display name of unit tests in JUnit Eclipse plugin

Is it possible for an Eclipse plugin to change the display name of unit tests run by the default Eclipse JUnit plugin?
Some background: I'm trying to create a plugin which will display unit test names (in the JUnit view in Eclipse) a bit different from the actual method name. If the actual test method name is "anEmptyCollectionHasSizeZero" I want it to be displayed in the Eclipse JUnit view as "An empty collection has size zero".
I've managed to display the test method names in the way described above as a separate view in a plugin, but would as I said like to get this feature integrated in the normal JUnit view. I tried to see if I could find a related extension point, but could not find anything. Is it possible to do this?
Also, is there a plugin which already does this, or similar?
I don't know the exact answer, but the best place to start is likely by looking at the code for org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart (in the plug-in org.eclipse.jdt.junit). That ViewPart is the JUnit view that you see in Eclipse.
It looks like org.eclipse.jdt.internal.junit.model.TestCaseElement.getTestMethodName() might be the place where the name is obtained from. Maybe you can trace how/when those elements are created and inject some other name. It looks like the implementation class is internal though (org.eclipse.jdt.internal.junit.model.TestElement), so you might be out of luck.
I'd suggest asking on the JDT forums about the possibility of doing this.
There don't seem to be any plugable way to change the label or the colors used.
(I had hoped the label provider used for the TestViewer was based on a PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator() so the image, label and color could be decorated, but that does not seem to be the case...)
You may want to look at the jnario sources. They have implemented something like that, where the JUnit window displays something that is surely not a stack frame.
You may use the setName() method of the class junit.framework.TestCase (or the constructor with the name parameter).
public MyTestCase() {
super("This is my JUnit test");
By default a TestCase defines the methods to be executed by it's name, which we have just overwritten. To make it runnable we have to overwrite the run method like this.
#Override
protected void runTest() throws Throwable {
testMyTest();
}

Toolbar items dynamically

I need to create dynamically buttons in main toolbar. I found a solution, but I can create just one button (dynamic contribution item - class extending ContributionItem). But I need to create more than one button, but I cannot find the solution.
I'm fighting with task to create plugin, which parses a XML file containing structure of menu and toolbars. We've already done this plugin for Visual Studio. Its quite easy in principle, but I found swiftly, that not for Eclipse. There is one small but critical otherness. Plugins are implemented declaratively in Eclipse. The file plugin.xml is the gist of plugin's infrastructure, Java code is just ancillary.
The customer wants to refresh the menu and toolbar whenever the selected project is changed. Eclipse lacks several features needed to get the task done. Main menu and main toolbar are cteated at Eclipse's start-up and then they can be hardly rebuilt.
In the most cases the conditions defined at enabledWhen/visibleWhen elements are sufficient to filter contributions according to the context (active part, selected object, whatever else).
If you need to have more freedom, please try E4 ToolControl that allows you to implement your own UI elements:
#PostConstruct
public void createControls(Composite parent) {
//your custom code here
}
More details here https://www.vogella.com/tutorials/EclipseRCP/article.html#toolcontrols
From my understanding you want to have different buttons on the main toolbar depending on the selection of the project explorer (eg. 1 project is java project, the other is javascript etc.). First you will have to contribute to the main toolbar. I think there are some tutorial available so google will help.
The main steps are:
1. create a command (org.eclipse.ui.commmands)
2. create a handler (org.eclipse.ui.handlers) with the previously declared command id
3. contribute to the main toolbar (org.eclipse.ui.menus) with menucontribution and commandId with the following locationURI: toolbar:org.eclipse.ui.main.toolbar?after=misc
showing/hiding, enabling/disabling a menu item/button also can be done declaratively or "mixed". Declaratively means eg. using enabledWhen/visibleWhen...
Mixed means using property tester (org.eclipse.core.expressions.propertyTester). With this you can define your "enablement logic" in Java code.
In Eclipse e4 the UI is generated from a, EMF based, model. The Application.e4xmi serves as a base for that model. Contributions to the model can be done via fragments, which are again XML, or via processors. Processors are written in Java and use e4 services, like the part service, to modify the model at runtime.
I think you want to write a processor that parses your custom XML and modifies the eclipse e4 model accordingly.

Opening IProject properties when another (adaptable to IProject) object is selected

I have a custom view displaying a hierarchy model of the current project. The root element is of class MyProject which is my own class, but it represents one Eclipse IProject, and it's adaptable to IProject.
I have a "properties" menu option in the popup menu for that view, and I'd like to open up IProject's properties when a MyProject object is selected. PropertyDialogAction only looks for property pages registered for MyProject and doesn't give me a chance to offer an adapter -- or, at least, I don't know how to offer one.
What's the proper solution for this?
In the meantime, I've overridden PropertyDialogAction to handle my class in the special way I require, but that seems like quite a kludge to get this done.
How did you add the Properties in the Popup menu? Ideally its functionality is to show up the property pages of the current selection - not to show up the properties of the project in which the current selection resides. If you want that, you need to use the menu item Project->Properties - which uses the ProjectPropertyDialogAction instead of the PropertyDialogAction